Message ID | 20250129172320.950523-7-tabba@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55733C0218D for <linux-mm@archiver.kernel.org>; Wed, 29 Jan 2025 17:23:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF93128025A; Wed, 29 Jan 2025 12:23:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B7F2D280067; Wed, 29 Jan 2025 12:23:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AD0628025A; Wed, 29 Jan 2025 12:23:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 73173280067 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 12:23:39 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D6619C0FDD for <linux-mm@kvack.org>; Wed, 29 Jan 2025 17:23:38 +0000 (UTC) X-FDA: 83061161316.06.F3711AA Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf22.hostedemail.com (Postfix) with ESMTP id E1343C0014 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 17:23:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DTyCUiPw; spf=pass (imf22.hostedemail.com: domain of 3F2SaZwUKCIw9qrrqw44w1u.s421y3AD-220Bqs0.47w@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3F2SaZwUKCIw9qrrqw44w1u.s421y3AD-220Bqs0.47w@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738171417; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yt94aUdAvXZMqsG3cEe+u7ei8ysAwqoWnN4dmeRVKOk=; b=nzUnyAelYrX04nMDhBZSxwPOmpzRe+9dwJPBn+Ve2Ntkgp3sHVPgICwlyUEDwl6B/VccQH oK3glDsdf00mogjdodDFFfr+7sl4RJuvN29+gCNcWISg4p5cfZel5J5MFepo/KrYGUIJTh yK/GMtVlw7bGVPOKSGu14z5MKXt58U0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DTyCUiPw; spf=pass (imf22.hostedemail.com: domain of 3F2SaZwUKCIw9qrrqw44w1u.s421y3AD-220Bqs0.47w@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3F2SaZwUKCIw9qrrqw44w1u.s421y3AD-220Bqs0.47w@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738171417; a=rsa-sha256; cv=none; b=nb5IgCfqZiOhknXkEmjDusLZpYkYAAQ7j6bWzeH2Yc4/cnNiXXp3TwMCzV4ad8td+G9PGU 6Y6rwZ23OuRUe3rFt+rxhIPRDpcfgI8XpAUDjT1dqKkHtwu5zl60u02xz5rPnwaPqJqccO 3+6D+yqfhzs9H8gr9m3jWHlDPjNjmhM= Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-436723bf7ffso56536385e9.3 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 09:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738171415; x=1738776215; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yt94aUdAvXZMqsG3cEe+u7ei8ysAwqoWnN4dmeRVKOk=; b=DTyCUiPw5ypjhO4RV0eev9stu3rsfLE9Hw0tJ4H85390jiOj/akw2+gt4KK1eMtU9d nNE11GTZ9XjOhCr0xX4nkPaupykFR2o+u+UiRxDrnB6Pmt0zgQjvBq7N+cDULNgQDwKW y/6t/lxiVdQex42jP+bHQKUGvhxEzJHObk3iB7rXZ7fNzpCsPzXqT2tuG7MNkTaY5BOV 86IZDAuMvIJGVL90nH58NsL4nhA9DiAuewm05Zn+1p86XgtrM0aRXXvzSBqfrHD45QkZ Hg5r/XWxbBZKPp8JbMxVJ3WYL+Bx+aL/ma2C3WFGZE4mwzSZbxWDp2XGK0CBl4js+ZNq pHZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738171415; x=1738776215; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yt94aUdAvXZMqsG3cEe+u7ei8ysAwqoWnN4dmeRVKOk=; b=S/ftoHZKEXhUMU599sibTnFw60A/+TN6qa7KfPPENnSQITWpcCtOgf8hASKe4FqMN0 lJW6vKWoTrS/Yzvg3rARxQB1PRlebGSin44JE+YgiuznradWBFm4A8b/eYdzE+w5I+gb y7Jy25dZCJzyDt4rDs6OYFgrhdQBdfUbtUFJMhs34/nfpHrnoSu6u1FCjpM4mXf8O+Mz uFhXFnqmsnbSZgAsUa78+BnbgIkxwXn6Nz1DAHLJjgMDWflM8saQi8UxaThJjJomUxmy 6QBTIWAbUxYPFoHCnPPPIrlSVoqBwI+XQtxlAgq4tndr7WSPVfxV4RtFZ0XKEucNRWTy vxtw== X-Forwarded-Encrypted: i=1; AJvYcCU4mIZLyAgT8lGHo2kCS9SRuVDe4bdkT8rTZkkbyRRQKtNt/mbJr2DOtVBn5FY6lOD6rHlzzd+0hw==@kvack.org X-Gm-Message-State: AOJu0YyPzh/SJNWwYZUUaDwB/THnuZTtGhcsjEn2AKTmTDEKRMiQg3lq 5pVSo7oOpmQbIJLVpCCigiP1PUzLxIfhReYdTsOw28a1De5CLygEM/6sfQ+He+cFaeXNHbTT1Q= = X-Google-Smtp-Source: AGHT+IEVZD0fIeUKq/vmlbjgjG2X+DT3UCWZpcJ4Ann1EaDXdRvf6zyGqzjMjCufoNNThN4KeHC2zb1K+A== X-Received: from wmbfk10.prod.google.com ([2002:a05:600c:cca:b0:434:feb1:add1]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1d26:b0:436:916b:aaf4 with SMTP id 5b1f17b1804b1-438dc3c31a3mr45515505e9.10.1738171415500; Wed, 29 Jan 2025 09:23:35 -0800 (PST) Date: Wed, 29 Jan 2025 17:23:15 +0000 In-Reply-To: <20250129172320.950523-1-tabba@google.com> Mime-Version: 1.0 References: <20250129172320.950523-1-tabba@google.com> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250129172320.950523-7-tabba@google.com> Subject: [RFC PATCH v2 06/11] KVM: x86: Mark KVM_X86_SW_PROTECTED_VM as supporting guest_memfd shared memory From: Fuad Tabba <tabba@google.com> To: kvm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mm@kvack.org Cc: pbonzini@redhat.com, chenhuacai@kernel.org, mpe@ellerman.id.au, anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org, xiaoyao.li@intel.com, yilun.xu@intel.com, chao.p.peng@linux.intel.com, jarkko@kernel.org, amoorthy@google.com, dmatlack@google.com, yu.c.zhang@linux.intel.com, isaku.yamahata@intel.com, mic@digikod.net, vbabka@suse.cz, vannapurve@google.com, ackerleytng@google.com, mail@maciej.szmigiero.name, david@redhat.com, michael.roth@amd.com, wei.w.wang@intel.com, liam.merwick@oracle.com, isaku.yamahata@gmail.com, kirill.shutemov@linux.intel.com, suzuki.poulose@arm.com, steven.price@arm.com, quic_eberman@quicinc.com, quic_mnalajal@quicinc.com, quic_tsoni@quicinc.com, quic_svaddagi@quicinc.com, quic_cvanscha@quicinc.com, quic_pderrin@quicinc.com, quic_pheragu@quicinc.com, catalin.marinas@arm.com, james.morse@arm.com, yuzenghui@huawei.com, oliver.upton@linux.dev, maz@kernel.org, will@kernel.org, qperret@google.com, keirf@google.com, roypat@amazon.co.uk, shuah@kernel.org, hch@infradead.org, jgg@nvidia.com, rientjes@google.com, jhubbard@nvidia.com, fvdl@google.com, hughd@google.com, jthoughton@google.com, tabba@google.com Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E1343C0014 X-Stat-Signature: c761um3q6t1351f14g59bkqhknrgwhaf X-HE-Tag: 1738171416-854635 X-HE-Meta: U2FsdGVkX18K1fQ8uKVrWx8S+5f+NhUsh+VYD1U36BW2C8Wso0TtsKYVl42rL1P+cRnGxF35i4tPt1fsEf6IqefSgMTl2p4JpQ28AdrkCkvRKnUi/8rOGDIOrrCHkKCMoRI9FYvpC6uhnIfUzjdXtScHkUfXQY/MT1PAhZWshh5Zt51/5QXq+E36s7eY9FdvvdJqq1iQxNR/eXJFyX7eEsp9Cb/9DNcUw646pwDHbmM1/Or8KHA/47VLEv0AD+WK0I9cKHuDzKZfCMq00ZUC9SKAk7c/N3FGbF7o7IkPj8i7b1wLUVIaVDXoIkGUrcoDSGLyDpP1tJ56TkMla2c5XA5TF8OS2V/Y1p2aOr4+oYBmNOqIBSIRroWf/l+kFNaAcdiFo3mcevcNN+FDDsO2JyQcrk8tgca7tmtg4IXxaYGq0skQtjXWmgYJ/Pv1lMWR+RiYqkMkbRUz4ALnHzeOnqWln/jWovreOLHCRVYYhtMyBu+3EiPIZUBCzqY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Bxqpk0d11A0UGiZc/pF14UEa0bc3ejw5H0QVquXcCVZqCCpVLi3JOgKQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
KVM: Mapping guest_memfd backed memory at the host for software protected VMs
|
expand
|
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index e159e44a6a1b..35d5995350da 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -2202,8 +2202,13 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level, #ifdef CONFIG_KVM_PRIVATE_MEM #define kvm_arch_has_private_mem(kvm) ((kvm)->arch.has_private_mem) + +#define kvm_arch_gmem_supports_shared_mem(kvm) \ + (IS_ENABLED(CONFIG_KVM_GMEM_SHARED_MEM) && \ + ((kvm)->arch.vm_type == KVM_X86_SW_PROTECTED_VM)) #else #define kvm_arch_has_private_mem(kvm) false +#define kvm_arch_gmem_supports_shared_mem(kvm) false #endif #define kvm_arch_has_readonly_mem(kvm) (!(kvm)->arch.has_protected_state) diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index ea2c4f21c1ca..22d1bcdaad58 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -45,7 +45,8 @@ config KVM_X86 select HAVE_KVM_PM_NOTIFIER if PM select KVM_GENERIC_HARDWARE_ENABLING select KVM_GENERIC_PRE_FAULT_MEMORY - select KVM_GENERIC_PRIVATE_MEM if KVM_SW_PROTECTED_VM + select KVM_PRIVATE_MEM if KVM_SW_PROTECTED_VM + select KVM_GMEM_SHARED_MEM if KVM_SW_PROTECTED_VM select KVM_WERROR if WERROR config KVM
The KVM_X86_SW_PROTECTED_VM type is meant for experimentation and does not have any underlying support for protected guests. This makes it a good candidate to use for testing this patch series. Therefore, when the kconfig option is enabled, mark KVM_X86_SW_PROTECTED_VM as supporting shared memory. This means that this memory is considered by guest_memfd to be shared with the host, with in-place conversion. This allows the host to map and fault in guest_memfd memory belonging to this VM type. Signed-off-by: Fuad Tabba <tabba@google.com> --- arch/x86/include/asm/kvm_host.h | 5 +++++ arch/x86/kvm/Kconfig | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)