From patchwork Thu Aug 1 09:01:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13749995 Return-Path: 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 84C7AC3DA64 for ; Thu, 1 Aug 2024 09:01:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 443206B0098; Thu, 1 Aug 2024 05:01:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D22D6B0099; Thu, 1 Aug 2024 05:01:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 245E66B009A; Thu, 1 Aug 2024 05:01:33 -0400 (EDT) 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 F353D6B0098 for ; Thu, 1 Aug 2024 05:01:32 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9F342409B0 for ; Thu, 1 Aug 2024 09:01:32 +0000 (UTC) X-FDA: 82403083224.27.CCD0C89 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf02.hostedemail.com (Postfix) with ESMTP id DC63880023 for ; Thu, 1 Aug 2024 09:01:30 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=RzUX4vU7; spf=pass (imf02.hostedemail.com: domain of 36U6rZgUKCHAhOPPOUccUZS.QcaZWbil-aaYjOQY.cfU@flex--tabba.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=36U6rZgUKCHAhOPPOUccUZS.QcaZWbil-aaYjOQY.cfU@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=1722502835; 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=LPYjxi2NpHlLCCCycghuduPbRm3K8NiftdQ2Nx+A00o=; b=WkeKwWP+VhHilaHNpEM7E18lBwMU1iCywZE7h3kNCSDgpE+Km/rN96NY1qtNxXVSgQiBDw h4of4fU7MVcCJjV9S0Q3KQLBjyU/cjCeP/lWffTQeQvUIr7b1SjKYL12onWt8+v41MvmPh bNBs8ZprIHX1U7gE3jwOSHSJkmKWtTI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722502835; a=rsa-sha256; cv=none; b=KbLN8urFUNr8QKvD2A365Cdt0QR6C5nkhZFkpUgGtsik+Kmvn+mTVwFWx7GAeBnDsvvzLX TjzVxmiqFe3lxblmd2Y8aeQgBV6WgBA43W2IEyeDrnP3aojadvJhrlMbhrvxXxGGPtfG3t 9pkWWqUljzWyDDiznHmBVN1Qfr+eCIw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=RzUX4vU7; spf=pass (imf02.hostedemail.com: domain of 36U6rZgUKCHAhOPPOUccUZS.QcaZWbil-aaYjOQY.cfU@flex--tabba.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=36U6rZgUKCHAhOPPOUccUZS.QcaZWbil-aaYjOQY.cfU@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-66c0f57549fso152656857b3.0 for ; Thu, 01 Aug 2024 02:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722502890; x=1723107690; 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=LPYjxi2NpHlLCCCycghuduPbRm3K8NiftdQ2Nx+A00o=; b=RzUX4vU7R6umJ7I6QH7jvcRlTOHrEj2iWpdfcMRaf2dUYE/0kD8AgF61oaSrkevxgS juMO0cTcQYedxT7xCJVKbQspTUHGKQ+JyBKnV3///fw0zx3HO6fFGJDuA6vrFc4MnBw6 IEYTvqxN6w7Q0gmKxN8vyWWGp+0V0KA4JX2vMlNoE51mcr719gwoPtUzWsVT+TIs/PD7 DRrLzTlpvzZgTc7YonfbB+sF3ZnsLVTVPQWqraMeKWDFjI+okgBQEZOuCNtxGcfEr8nI gcrFJ3vj35eiiEDEdh6k/C2c6BpUW87Zhd4pg14/Pjw5DEhrQoTva6Uk8WvQCNwj6XaV YQNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722502890; x=1723107690; 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=LPYjxi2NpHlLCCCycghuduPbRm3K8NiftdQ2Nx+A00o=; b=YLoZz2sN14Tn1BPpio9lh2dmBeLdIKrLL67wpZd73CQpI2BDknqg83Xh70QOs1wwsh ybOMLJe13/QwYTDZHh5VsH9pOBEflP5lh052tjz3tOmCBBPatRD7aHMctNBeNV02n5Ij n8GsBMY4/BYM+L2CDt8lBGFu5Wd/MvcsyNDasbekqCaWO2e8MkfUk44HbunKiHtLK4Fq vi6EYhjskijKvVcKyNpc3XGmrUVRl3o1FydACJqrXHA+SLQ0c3ExpO43WeC5iFFfWysY hqwzdzExumkfl0L55ZLUiM884G6jNFCfdj3zz5Omt5nNfmQ0RHCckccDufyR24+/Zlhc zkmg== X-Forwarded-Encrypted: i=1; AJvYcCV5rTfkRdzYNnJ9eYiHlCd/Yw7wWvtfy1kasSAArhD3XT+zu9CxeWBJjFEcc5s5CNoUmF0bLBu95A==@kvack.org X-Gm-Message-State: AOJu0Yynh9zffxptYKy8FIY1mvMx+phhWkZwNt0j2ZZBXPN5oSqXw9ur BPYuse8hrSl21zRZdkwAzZs2zxq2KQUqB/6teg82zYQrQywLuVfJBNHUUuinhf3cMVWNTfNtvw= = X-Google-Smtp-Source: AGHT+IEWXtT3G1kPV2U5ozw0QmNThPZWLC3X0cJFXxT6qwOkPcf9RWWDopByOJxRGSqLytT/Up6QyZXMSQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:690c:9e:b0:673:b39a:92ce with SMTP id 00721157ae682-6874be4e4b8mr30247b3.3.1722502889731; Thu, 01 Aug 2024 02:01:29 -0700 (PDT) Date: Thu, 1 Aug 2024 10:01:11 +0100 In-Reply-To: <20240801090117.3841080-1-tabba@google.com> Mime-Version: 1.0 References: <20240801090117.3841080-1-tabba@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240801090117.3841080-5-tabba@google.com> Subject: [RFC PATCH v2 04/10] KVM: Add KVM capability to check if guest_memfd can be mapped by the host From: Fuad Tabba 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, tabba@google.com X-Rspamd-Queue-Id: DC63880023 X-Stat-Signature: dhe78aowpjsdp1n4jcbizqmybsg6b854 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722502890-750336 X-HE-Meta: U2FsdGVkX1/aUagP1NUxfos37gL+lbZT1QwNmjw+C1+uCZOkHvdcUANzoA/fpciT8caZZheTji+us7UIjp8La1DfIJojO7CF003uqIZMiCtIpUXLUBRsfsghRVLCBGEGdS6E9a5r7WHAxi6KCQTnX5hic7YFLjLuduMTtbjaaDwozEd3Fj9gkKKnyUgf6p0WtKeLeCS3dftnMbmSXX+cjoA6DCoWur6dUCyXUKzgYS9euNfEwz0y6+IQ0iIq96tkl7UiJtei816RP9jEwx2p2NLs8OLtxrBJ6YgkEttloTOLF7pDkDnQzXjAy6hxbp+LWUpH32bE7skCCZ+izYSaPY53LUptC5y7z2AY3jzAa6Y8oX6JsKFq8sfpM/NqKkSbZ72CgIwRoFbUjK+i/SMUnyy/+3l5dXwzCaBCmz8/WLDCSspaD7HMSnTflOsgGadQ/kN5dl0y92Wb/3UTzdbG20ugmzr9RnQNW3R0dYqAiTJCbK4ObIIlcdfB3LyxXZsMsfNuEuqUqUPlWN/PH2liG24yMXkS458GAB/EmMNi7uBjfo9z0R3+ohtcYYwWPdCvIs6Fi22NoWply9Upx9wSpzIleUdt4uMid8HgU3gBHBa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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add the KVM capability KVM_CAP_GUEST_MEMFD_MAPPABLE, which is true if mapping guest memory is supported by the host. Signed-off-by: Fuad Tabba --- include/uapi/linux/kvm.h | 3 ++- virt/kvm/kvm_main.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index d03842abae57..783d0c3f4cb1 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -916,7 +916,8 @@ struct kvm_enable_cap { #define KVM_CAP_MEMORY_FAULT_INFO 232 #define KVM_CAP_MEMORY_ATTRIBUTES 233 #define KVM_CAP_GUEST_MEMFD 234 -#define KVM_CAP_VM_TYPES 235 +#define KVM_CAP_GUEST_MEMFD_MAPPABLE 235 +#define KVM_CAP_VM_TYPES 236 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ec6255c7325e..485c39fc373c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5077,6 +5077,10 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) #ifdef CONFIG_KVM_PRIVATE_MEM case KVM_CAP_GUEST_MEMFD: return !kvm || kvm_arch_has_private_mem(kvm); +#endif +#ifdef CONFIG_KVM_PRIVATE_MEM_MAPPABLE + case KVM_CAP_GUEST_MEMFD_MAPPABLE: + return !kvm || kvm_arch_has_private_mem(kvm); #endif default: break;