Skip to contentSkip to conversation

machine/memory encryption: Disable mem merge

PATCH Applied Dr. David Alan Gilbert (git) 3 participants 3 messages Jan 30, 2020 – Mar 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 machine/memory encryption: Disable mem merge

From: "Dr. David Alan Gilbert" <[email protected]>

When a host is running with memory encryption, the memory isn't visible to the host kernel; attempts to merge that memory are futile because what it's really comparing is encrypted memory, usually encrypted with different keys.

Automatically turn mem-merge off when memory encryption is specified.

https://bugzilla.redhat.com/show_bug.cgi?id=1796356

---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/core/machine.c +8 -0
index 3e288bfceb..029e1f85b8 100644
@@ -419,6 +419,14 @@ static void machine_set_memory_encryption(Object *obj, const char *value,
 
     g_free(ms->memory_encryption);
     ms->memory_encryption = g_strdup(value);
+
+    /*
+     * With memory encryption, the host can't see the real contents of RAM,
+     * so there's no point in it trying to merge areas.
+     */
+    if (value) {
+        machine_set_mem_merge(obj, false, errp);
+    }
 }
 
 static bool machine_get_nvdimm(Object *obj, Error **errp)
Signature · 1 line
2.24.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

When a host is running with memory encryption, the memory isn't visible to the host kernel; attempts to merge that memory are futile because what it's really comparing is encrypted memory, usually encrypted with different keys.

Automatically turn mem-merge off when memory encryption is specified.

https://bugzilla.redhat.com/show_bug.cgi?id=1796356

---
  hw/core/machine.c | 8 ++++++++
  1 file changed, 8 insertions(+)
hw/core/machine.c +0 -0
index 3e288bfceb..029e1f85b8 100644

hw/core/machine.c static void machine_set_memory_encryption(Object *obj, const char *value, · line 428

Quoted 10 lines
hw/core/machine.c +7 -0
@@ -419,6 +419,14 @@ static void machine_set_memory_encryption(Object *obj, const char *value,
 
      g_free(ms->memory_encryption);
      ms->memory_encryption = g_strdup(value);
+
+    /*
+     * With memory encryption, the host can't see the real contents of RAM,
+     * so there's no point in it trying to merge areas.
+     */
+    if (value) {
+        machine_set_mem_merge(obj, false, errp);

Using the helper is cleaner than accessing ms->mem_merge.

Quoted 5 lines
hw/core/machine.c +1 -0
+    }
  }
 
  static bool machine_get_nvdimm(Object *obj, Error **errp)
#2 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

When a host is running with memory encryption, the memory isn't visible to the host kernel; attempts to merge that memory are futile because what it's really comparing is encrypted memory, usually encrypted with different keys.

Quoted 5 lines

Automatically turn mem-merge off when memory encryption is specified.

https://bugzilla.redhat.com/show_bug.cgi?id=1796356

Queued, thanks.

Signature · 1 line
Eduardo