From patchwork Thu Jan 30 17:50:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 1231537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZE1g1DWX; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487nwC0Qp5z9sNx for ; Fri, 31 Jan 2020 04:51:22 +1100 (AEDT) Received: from localhost ([::1]:37182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixDyJ-0003lK-KH for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 12:51:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55534) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixDxy-0003l9-Eu for qemu-devel@nongnu.org; Thu, 30 Jan 2020 12:50:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixDxw-00069Q-KP for qemu-devel@nongnu.org; Thu, 30 Jan 2020 12:50:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44290 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixDxw-00069D-H6 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 12:50:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580406655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WI4+JM/uuh1ZBu0K9HeEEa+M4efRHgf+TWM8H30d3KA=; b=ZE1g1DWX/iAdvSWEEGTNVEuItBj/SRr7KqTDr8zwl8MIINJ8th/gM3UhTI9YJhDCazzQUe ey2ITFkC4Bhh7KbwB23lnShdEfYnLntpz99IpO0kIXsgXyYq8MmPnBQSdK8zz3AeDByUoo 8v6K1Gxk72kFgVdSbKQK7KdW/Egy3cg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-HHmVPpo8NR2FOa6bRr9BMQ-1; Thu, 30 Jan 2020 12:50:51 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40D7E107ACC4; Thu, 30 Jan 2020 17:50:50 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.36.118.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 113F519756; Thu, 30 Jan 2020 17:50:48 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, brijesh.singh@amd.com Subject: [PATCH] machine/memory encryption: Disable mem merge Date: Thu, 30 Jan 2020 17:50:46 +0000 Message-Id: <20200130175046.85850-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: HHmVPpo8NR2FOa6bRr9BMQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aarcange@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" 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 Reviewed-by: Philippe Mathieu-Daudé --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 3e288bfceb..029e1f85b8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -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)