if (strncmp(buf, "pmem\n", n) == 0
                                || strncmp(buf, "pmem", n) == 0) {
-                       /* TODO: allocate from PMEM support */
-                       rc = -ENOTTY;
+                       nd_pfn->mode = PFN_MODE_PMEM;
                } else if (strncmp(buf, "ram\n", n) == 0
                                || strncmp(buf, "ram", n) == 0)
                        nd_pfn->mode = PFN_MODE_RAM;
 
        struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
        struct nd_pfn *nd_pfn = to_nd_pfn(ndns->claim);
        struct device *dev = &nd_pfn->dev;
-       struct vmem_altmap *altmap;
        struct nd_region *nd_region;
+       struct vmem_altmap *altmap;
        struct nd_pfn_sb *pfn_sb;
        struct pmem_device *pmem;
        phys_addr_t offset;
        int rc;
+       struct vmem_altmap __altmap = {
+               .base_pfn = __phys_to_pfn(nsio->res.start),
+               .reserve = __phys_to_pfn(SZ_8K),
+       };
 
        if (!nd_pfn->uuid || !nd_pfn->ndns)
                return -ENODEV;
                        return -EINVAL;
                nd_pfn->npfns = le64_to_cpu(pfn_sb->npfns);
                altmap = NULL;
+       } else if (nd_pfn->mode == PFN_MODE_PMEM) {
+               nd_pfn->npfns = (resource_size(&nsio->res) - offset)
+                       / PAGE_SIZE;
+               if (le64_to_cpu(nd_pfn->pfn_sb->npfns) > nd_pfn->npfns)
+                       dev_info(&nd_pfn->dev,
+                                       "number of pfns truncated from %lld to %ld\n",
+                                       le64_to_cpu(nd_pfn->pfn_sb->npfns),
+                                       nd_pfn->npfns);
+               altmap = & __altmap;
+               altmap->free = __phys_to_pfn(offset - SZ_8K);
+               altmap->alloc = 0;
        } else {
                rc = -ENXIO;
                goto err;
        pmem = dev_get_drvdata(dev);
        devm_memunmap(dev, (void __force *) pmem->virt_addr);
        pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res,
-                       NULL);
+                       altmap);
        pmem->pfn_flags |= PFN_MAP;
        if (IS_ERR(pmem->virt_addr)) {
                rc = PTR_ERR(pmem->virt_addr);