From nobody Mon Feb 9 17:06:49 2026 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553690744274195.79940729045904; Wed, 27 Mar 2019 05:45:44 -0700 (PDT) Received: from localhost ([127.0.0.1]:47190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h97w4-0001RJ-A6 for importer@patchew.org; Wed, 27 Mar 2019 08:45:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h97oo-0003ia-V8 for qemu-devel@nongnu.org; Wed, 27 Mar 2019 08:38:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h97on-0002VU-UB for qemu-devel@nongnu.org; Wed, 27 Mar 2019 08:38:10 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:54924) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h97on-0002U2-KE for qemu-devel@nongnu.org; Wed, 27 Mar 2019 08:38:09 -0400 Received: by mail-wm1-x334.google.com with SMTP id f3so16054966wmj.4 for ; Wed, 27 Mar 2019 05:38:09 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id c20sm27722863wre.28.2019.03.27.05.38.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 05:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vw2dihVNPb/Py984z8eJC0i9M3sxcAsCX62xcFgfpDc=; b=vLhlGwvh5zpvBoCn6kcjtycOj0gJ0EQe64BA4eTHDkeC0C8dTAwio1t9V6vh0c4hwJ srsURa2KRagD7dm0jzjS7WhFJwYfr3wZ1S6TKYxH+CYTFwzHekTe7/qleopu6j8evS6J b88zMrKODxqXGachv2VYhlpTIt/JcKMIQEVT7Vf2uf8+BlpmDdIL3WOZexvh7g5cwibB giYVky5DRTPeMoSCPHXAsEBdZkZ8nSXqCWGRZ8h+ShnIpFg7eH1US17CZcaDDIi2j/bU cFU+oGaV5No7cqNt4YNYz2H4v7F/cDpO+qxyJzd4WJgH1c08ukSV+zDRVrCde2mBPBt1 4w9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Vw2dihVNPb/Py984z8eJC0i9M3sxcAsCX62xcFgfpDc=; b=DO+j316ED8LE+Ss36Wtq0vS+kAdxZHXqMlivLo+PPAc8W8pZG3N6pzSrJZOf5RRCDu eAxi2+dRp0hCoAyUV1rnOHiO8j7CF9GaKaiZs1F1vv7/TklfAsFW45v2OsU3/8kUVm5q Gi5djCM838A3toqyN6ZolMKas1IfMFIAvFfKzpDXrei1n90wTPRJWG/9eqWG2ap0LOlZ tcqa87s/3Kp119+Bn45seXecg21oxkHGRviNl6Wzj0W1zRFwSNBooz95UN6HgR+DXPOR +nlT8nSDE8YkdqVk+gfMUNIeCfJwrj6AU6I4lpESRPz0+a3OPDQMuAZirBhST4EDxDmh BAXQ== X-Gm-Message-State: APjAAAXkyhmBGVmt5DwakT7dqz4TLmB5iSAnyf5EyEZ33+COdadG+LkP uCtEwF8lhMAjpvirqAl4UMxl1D2M X-Google-Smtp-Source: APXvYqz8B6zeeqftJiaS9L4XSIyFxTqVJVlQCEIqtVY88albmzmVOcGMWkTJGPr0FqA8jGwN66YAMA== X-Received: by 2002:a1c:c254:: with SMTP id s81mr12704163wmf.55.1553690288375; Wed, 27 Mar 2019 05:38:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 27 Mar 2019 13:37:43 +0100 Message-Id: <1553690281-81854-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1553690281-81854-1-git-send-email-pbonzini@redhat.com> References: <1553690281-81854-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 Subject: [Qemu-devel] [PULL 05/23] target/i386: sev: Do not pin the ram device memory region X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Williamson , "Singh, Brijesh" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Singh, Brijesh" The RAM device presents a memory region that should be handled as an IO region and should not be pinned. In the case of the vfio-pci, RAM device represents a MMIO BAR and the memory region is not backed by pages hence KVM_MEMORY_ENCRYPT_REG_REGION fails to lock the memory range. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1667249 Cc: Alex Williamson Cc: Paolo Bonzini Signed-off-by: Brijesh Singh Message-Id: <20190204222322.26766-3-brijesh.singh@amd.com> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index 20b2d32..cd77f6b 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -131,6 +131,17 @@ sev_ram_block_added(RAMBlockNotifier *n, void *host, s= ize_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 be 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; --=20 1.8.3.1