Skip to contentSkip to conversation

mm/memremap.c: map FS_DAX device memory as decrypted

PATCH Applied Pankaj Gupta 2 participants 5 messages Nov 2, 2022 – Nov 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/memremap.c: map FS_DAX device memory as decrypted

virtio_pmem use devm_memremap_pages() to map the device memory. By default this memory is mapped as encrypted with SEV. Guest reboot changes the current encryption key and guest no longer properly decrypts the FSDAX device meta data.

Mark the corresponding device memory region for FSDAX devices (mapped with memremap_pages) as decrypted to retain the persistent memory property.

---
 mm/memremap.c | 1 +
 1 file changed, 1 insertion(+)
mm/memremap.c +1 -0
index 421bec3a29ee..08cbf54fe037 100644
@@ -335,6 +335,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
 			WARN(1, "File system DAX not supported\n");
 			return ERR_PTR(-EINVAL);
 		}
+		params.pgprot = pgprot_decrypted(params.pgprot);
 		break;
 	case MEMORY_DEVICE_GENERIC:
 		break;
Signature · 1 line
2.34.1
#1 lore raw

+Cc Andrew [forgot to add earlier]

Quoted 26 lines

virtio_pmem use devm_memremap_pages() to map the device memory. By default this memory is mapped as encrypted with SEV. Guest reboot changes the current encryption key and guest no longer properly decrypts the FSDAX device meta data.

Mark the corresponding device memory region for FSDAX devices (mapped with memremap_pages) as decrypted to retain the persistent memory property.

---
  mm/memremap.c | 1 +
  1 file changed, 1 insertion(+)
mm/memremap.c +1 -0
index 421bec3a29ee..08cbf54fe037 100644
@@ -335,6 +335,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
  			WARN(1, "File system DAX not supported\n");
  			return ERR_PTR(-EINVAL);
  		}
+		params.pgprot = pgprot_decrypted(params.pgprot);
  		break;
  	case MEMORY_DEVICE_GENERIC:
  		break;
maintainer
#2 lore raw
In reply to Pankaj Gupta
Quoted 14 lines · On Wed, 2 Nov 2022 11:07:28 -0500 Pankaj Gupta <[email protected]> wrote:

virtio_pmem use devm_memremap_pages() to map the device memory. By default this memory is mapped as encrypted with SEV. Guest reboot changes the current encryption key and guest no longer properly decrypts the FSDAX device meta data.

Mark the corresponding device memory region for FSDAX devices (mapped with memremap_pages) as decrypted to retain the persistent memory property.

...

mm/memremap.c void *memremap_pages(struct dev_pagemap *pgmap, int nid) · line 341

Quoted 7 lines
mm/memremap.c +1 -0
@@ -335,6 +335,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
 			WARN(1, "File system DAX not supported\n");
 			return ERR_PTR(-EINVAL);
 		}
+		params.pgprot = pgprot_decrypted(params.pgprot);
 		break;
 	case MEMORY_DEVICE_GENERIC:
 		break;

Should this be backported into earlier kernels?

Is b7b3c01b19159 a suitable Fixes: target?

#3 lore raw

Hi Andrew,

Quoted 11 lines
Quoted 11 lines

virtio_pmem use devm_memremap_pages() to map the device memory. By default this memory is mapped as encrypted with SEV. Guest reboot changes the current encryption key and guest no longer properly decrypts the FSDAX device meta data.

Mark the corresponding device memory region for FSDAX devices (mapped with memremap_pages) as decrypted to retain the persistent memory property.

...

Quoted 12 lines

mm/memremap.c void *memremap_pages(struct dev_pagemap *pgmap, int nid) · line 341

Quoted 10 lines
mm/memremap.c +1 -0
@@ -335,6 +335,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
  			WARN(1, "File system DAX not supported\n");
  			return ERR_PTR(-EINVAL);
  		}
+		params.pgprot = pgprot_decrypted(params.pgprot);
  		break;
  	case MEMORY_DEVICE_GENERIC:
  		break;

Should this be backported into earlier kernels?

Yes, kernel >= 5.10 for clean back-port as it contains the below commit.

Quoted 2 lines

Is b7b3c01b19159 a suitable Fixes: target?

Not very sure. But seems like the right commit for fixes tag as the target code is moved in this commit with multiple range support addition.

Should I send a v2 with fixes & stable kernel fixes tag?

Thanks,
Pankaj

maintainer
#4 lore raw
Quoted 11 lines · Pankaj
Quoted 1 line

Should this be backported into earlier kernels?

Yes, kernel >= 5.10 for clean back-port as it contains the below commit.

Quoted 2 lines

Is b7b3c01b19159 a suitable Fixes: target?

Not very sure. But seems like the right commit for fixes tag as the target code is moved in this commit with multiple range support addition.

Should I send a v2 with fixes & stable kernel fixes tag?

That's OK thanks - I made those changes to my copy.