From nobody Sun May 5 17:07:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563200939; cv=none; d=zoho.com; s=zohoarc; b=fvWhC+X/g+Q2an6RKaH5+h7EiEffzGgdD0cGLtYO7d7wMYJ8guy+BW+W8pm8vCSfHjO83vGGl/iQu73hbwLHYX7AYw/s7oEBQcvd3/kYMlYIhBTvis2SZ8FHM/UVa1cKyLZV1OsFVUzUJNA83cNPPnkqG41lVkI3o9SVnB7Us8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563200939; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=4IvlbKURJ1uxWhac0sGPtYaE/1A2xAP7iRCE5/sd3GM=; b=e0Cd0ef+twIE9tA1HQBs0q5oOAp7sdG8AJ4TFBI7RfV3vpkLflk6SVZKNyA0GpuKDwZDPf7EOPvKqOKm+7jNROqo/6eWc8Xrq5CFRE90kadzVvZaG1yO3khpdFaMISlIrMo4JI2fsj/5lAOUoMu/dhQiCwL6Q8azU6+sq3HBFMo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563200939569383.03751464894594; Mon, 15 Jul 2019 07:28:59 -0700 (PDT) Received: from localhost ([::1]:39396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1yK-0003QN-6c for importer@patchew.org; Mon, 15 Jul 2019 10:28:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34014) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1y9-00031u-1e for qemu-devel@nongnu.org; Mon, 15 Jul 2019 10:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1y8-0005bD-37 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 10:28:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56114) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hn1y7-0005ZT-TZ for qemu-devel@nongnu.org; Mon, 15 Jul 2019 10:28:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F15FE31628E5; Mon, 15 Jul 2019 14:28:41 +0000 (UTC) Received: from gimli.home (ovpn-116-35.phx2.redhat.com [10.3.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CA145D9C8; Mon, 15 Jul 2019 14:28:39 +0000 (UTC) From: Alex Williamson To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 08:28:39 -0600 Message-ID: <156320087103.2556.10983987500488190423.stgit@gimli.home> User-Agent: StGit/0.19-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 15 Jul 2019 14:28:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-4.1] target/i386: sev: Do not unpin ram device memory region 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: pbonzini@redhat.com, brijesh.singh@amd.com, ehabkost@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The commit referenced below skipped pinning ram device memory when ram blocks are added, we need to do the same when they're removed. Cc: Brijesh Singh Cc: Paolo Bonzini Fixes: cedc0ad539af ("target/i386: sev: Do not pin the ram device memory re= gion") Signed-off-by: Alex Williamson Reviewed-by: Brijesh Singh --- target/i386/sev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index 6dbdc3cdf10f..5ba1384ea1f6 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -161,6 +161,17 @@ sev_ram_block_removed(RAMBlockNotifier *n, void *host,= size_t size) { int r; struct kvm_enc_region range; + ram_addr_t offset; + MemoryRegion *mr; + + /* + * The RAM device presents a memory region that should be treated + * as IO region and should not have been pinned. + */ + mr =3D memory_region_from_host(host, &offset); + if (mr && memory_region_is_ram_device(mr)) { + return; + } =20 range.addr =3D (__u64)(unsigned long)host; range.size =3D size;