[PULL 06/13] machine/memory encryption: Disable mem merge

Eduardo Habkost posted 13 patches 5 years, 8 months ago
Maintainers: Artyom Tarasenko <atar4qemu@gmail.com>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, Cornelia Huck <cohuck@redhat.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Chris Wulff <crwulff@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Laurent Vivier <laurent@vivier.eu>, Anthony Green <green@moxielogic.com>, Max Filippov <jcmvbkbc@gmail.com>, Aurelien Jarno <aurelien@aurel32.net>, Palmer Dabbelt <palmer@dabbelt.com>, Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Alistair Francis <Alistair.Francis@wdc.com>, David Hildenbrand <david@redhat.com>, Richard Henderson <rth@twiddle.net>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Eduardo Habkost <ehabkost@redhat.com>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Michael Walle <michael@walle.cc>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Marek Vasut <marex@denx.de>, Stafford Horne <shorne@gmail.com>
[PULL 06/13] machine/memory encryption: Disable mem merge
Posted by Eduardo Habkost 5 years, 8 months ago
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

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

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20200130175046.85850-1-dgilbert@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 9e8c06036f..4778bc6b08 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -425,6 +425,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)
-- 
2.24.1