Message ID | 20250129172320.950523-6-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 9EA4AC0218D for <linux-mm@archiver.kernel.org>; Wed, 29 Jan 2025 17:23:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 565F2280258; Wed, 29 Jan 2025 12:23:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53D52280067; Wed, 29 Jan 2025 12:23:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B8EE280258; Wed, 29 Jan 2025 12:23:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1B8ED280067 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 12:23:37 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BEE3F120FD6 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 17:23:36 +0000 (UTC) X-FDA: 83061161232.21.DE7E065 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf05.hostedemail.com (Postfix) with ESMTP id 592FC100010 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 17:23:34 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=r769NHYk; spf=pass (imf05.hostedemail.com: domain of 3FWSaZwUKCIo7oppou22uzs.q20zw18B-00y9oqy.25u@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3FWSaZwUKCIo7oppou22uzs.q20zw18B-00y9oqy.25u@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=1738171415; 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=LUYJLmVCJmslu0EZ70wF3BbY2jfY7y/4QOInoyL0YSs=; b=NZuBpPPo/OFAiRKsqTUbz0R9InQrjTKxUqqBx75ZdCmMxNC/hdlWVpkP1e8ZfDNp6ePeye oXdoYKabcYy33TkiqJREv/4BXM8MvGwXYJRykzRxCgw4AbXo9IRqdwJEEWbKTOnLkSWdiD 4vN8YfbUyHvhHC1nYv16XQEkLBRB+PE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738171415; a=rsa-sha256; cv=none; b=vPYCilSB72Mf29l1j9nwPZTJuAuV9diCf1AtaXawEH4AOWuh52vmiorqhhAr9W7W8nWyQh 6tNJVDQx7nnDO1BS3ozGzKy7CjDXRNZCOwVpxFJm2m5eyLWXpg3u0VyD8IQ6dPzqt8vI7u 4faa3THOkozcEnI71zf4H1XyaimBVRU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=r769NHYk; spf=pass (imf05.hostedemail.com: domain of 3FWSaZwUKCIo7oppou22uzs.q20zw18B-00y9oqy.25u@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3FWSaZwUKCIo7oppou22uzs.q20zw18B-00y9oqy.25u@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4359eb032c9so50903835e9.2 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 09:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738171413; x=1738776213; 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=LUYJLmVCJmslu0EZ70wF3BbY2jfY7y/4QOInoyL0YSs=; b=r769NHYkV0HtrTFK7OTJpalGLX8fnQCVQcqV7tKmwHoatfVJMPQZpl3e3ff+UodOMM 166PKPLi1EZHWuoZzKpRzu4Q8EduAxLNVmXU57PcBj+mDL3Fei7nCGldUqiUKakFGcXi DJHgt2xSP9Jj47P47/5QGSZZ5UgGgSwjABhWzH8bkajhgvyOZ9HzX/in6My9SOG5oMlr +kf6G39KPFhDUvKnSnqei6Dp7itmFYxK2yryBjTy9Bh0gxMAljoj0R2Bllzr1HaiWSed bWTBc0lXy/kjuyw1aCOGuTYkwyx5Imy60EGhIjAZ8wbOnCb+OlCcGlLZyPdWhytjLgML cpyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738171413; x=1738776213; 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=LUYJLmVCJmslu0EZ70wF3BbY2jfY7y/4QOInoyL0YSs=; b=Ueh9bzOFwfsNxgkXTdwCrgtCBWwosCH4DyCYxSsM50b7tRVaqwMrihjSex1UKVYuX/ S+E9cXFSFWpQdm11wOb4yE5xJUtKYS1B6+jdkFGXp20GcYVWyHc3hWhhyq2KeYnh6Eaq AwiOaPOL5fHWqcdBLIDuu3C0SNo1AWLPoBdcQSHo2Ifw6NRW3FKQfCfag8HYk8cZwUcZ mGr0MltoGCrn76rmgwdIOy1hRQatcdvK1eizbHcXc/tJ/0B+DdjxFKiojYWJY7jKMon1 fYwjFV9HC67fnW5XZP1gzmUim7dYHnV/h3EdoepNwPDR/wIo0MFNZ5bNr4iwPIN60Lvl gpUg== X-Forwarded-Encrypted: i=1; AJvYcCVlxQAAeCarUR9PIsgaDe7/wA7Z9U4TM2P8ZJSiZngJQhF6ccaoozq2sUzLtyexh9TwAj9Xmmjy/A==@kvack.org X-Gm-Message-State: AOJu0YyKvRGECxnoeLEctnHmAGWDTOfV7+Cbcv6AYCYbWGCHq7orhKx+ PoIdr9PZxK5C173uFpS/IoeD3b1IVWf94VX3CtsoWC0mUy7BpeGjIiQAHEwJLwKaAH862A0u2A= = X-Google-Smtp-Source: AGHT+IEzz5y+mMN5wvE2N/WLUB8ZD0NYIc/aKjbCfNBDRcZwxKLOkunY2FkpKk8kIiLC8nBZsvQDYPVFww== X-Received: from wmrn34.prod.google.com ([2002:a05:600c:5022:b0:436:3ea:c491]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1863:b0:386:37af:dd9a with SMTP id ffacd0b85a97d-38c5209037cmr4744111f8f.35.1738171413076; Wed, 29 Jan 2025 09:23:33 -0800 (PST) Date: Wed, 29 Jan 2025 17:23:14 +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-6-tabba@google.com> Subject: [RFC PATCH v2 05/11] KVM: guest_memfd: Handle in-place shared memory as guest_memfd backed 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-Stat-Signature: qguz6ei93j8gqy5hezbwtennqstgaukm X-Rspam-User: X-Rspamd-Queue-Id: 592FC100010 X-Rspamd-Server: rspam03 X-HE-Tag: 1738171414-421783 X-HE-Meta: U2FsdGVkX18S02wiEwWAVa7JABRZSL2NN9tdMllQHnFR87FMnho6RvUkT9KMWIifr0VIPQF13bVl4kOTogg65Qeqy1KwpjGjYcxnk34bQ6ftP44PDGqhffLK80GqyfcqURKEnNiD/cX/Kh41w+mDqtOSScM6Ks84tvDkRRo4aIFLE6fQkaMKyHBFXN8V4TiWfQ5C6qqcjXAXLin4uGJ2+z9XVd+XN+42Im2fsnWV6FoMO22bmtloX57S36jLuFDd1+MipdSCl020tqSVACpV9M93HCig3PbZqiLI3o82PTTz2c9i0VZ6+tZPYZejWeHYSY3c6eDTg1lp2YiaMq3HfEjr9iXin0l7OkdG8WkdMYoeYrw2IOBMViaDDXbPgMi09uGMv776ciiG1SjnA3mBg4oqEJI3hfob0l28J+cs9JdqvCrCYNpp1am87aCi3UGVUjXoBikIAkmD766p5y1zqSNGlnjj7Rrki6PQQLIa6m81qhDQxtq1FT754awkz1/t4q3umaV+SPF5/Y7oHrVXtrWAI3ywEEzuTJ9pV6OnwydMk91z7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zWTNCKk0W+g== 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/include/linux/kvm_host.h b/include/linux/kvm_host.h index 408429f13bf4..e57cdf4e3f3f 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -2503,7 +2503,8 @@ static inline bool kvm_mem_is_private(struct kvm *kvm, gfn_t gfn) #else static inline bool kvm_mem_is_private(struct kvm *kvm, gfn_t gfn) { - return false; + return kvm_arch_gmem_supports_shared_mem(kvm) && + kvm_slot_can_be_private(gfn_to_memslot(kvm, gfn)); } #endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
For VMs that allow sharing guest_memfd backed memory in-place, handle that memory the same as "private" guest_memfd memory. This means that faulting that memory in the host or in the guest will go through the guest_memfd subsystem. Note that the word "private" in the name of the function kvm_mem_is_private() doesn't necessarily indicate that the memory isn't shared, but is due to the history and evolution of guest_memfd and the various names it has received. In effect, this function is used to multiplex between the path of a normal page fault and the path of a guest_memfd backed page fault. Signed-off-by: Fuad Tabba <tabba@google.com> --- include/linux/kvm_host.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)