From patchwork Thu Oct 10 08:59:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13829777 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 B23FBCF07D9 for ; Thu, 10 Oct 2024 08:59:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C69E6B009B; Thu, 10 Oct 2024 04:59:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36A3A6B009A; Thu, 10 Oct 2024 04:59:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EDD86B009B; Thu, 10 Oct 2024 04:59:51 -0400 (EDT) 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 EB0256B0099 for ; Thu, 10 Oct 2024 04:59:50 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9F6EF121B7D for ; Thu, 10 Oct 2024 08:59:47 +0000 (UTC) X-FDA: 82657094940.26.C4DA275 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf20.hostedemail.com (Postfix) with ESMTP id DFDA31C000B for ; Thu, 10 Oct 2024 08:59:47 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ZvxhfrkT; spf=pass (imf20.hostedemail.com: domain of 3g5cHZwUKCBA9qrrqw44w1u.s421y3AD-220Bqs0.47w@flex--tabba.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3g5cHZwUKCBA9qrrqw44w1u.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=1728550719; 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=McR6hFD8xu5MydKKfp3q4/vtlv2OyOY0xakrmAL+qLs=; b=jSYlKTDHjhuCedVEZGPsAfyWCQORG3dCQoRteRPp7GrbCq4jBiUlo1tCx3p5NDo7LaIF9t fsR/0T26ydjgqCIe+vXIolnfjNXbMx5RSTnTbO3YRAbrzmf74skKnAEBwBz7V08d3VTijh 4D1BpyGs7j7AwFZPn5sSG5pNYBnIPrk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ZvxhfrkT; spf=pass (imf20.hostedemail.com: domain of 3g5cHZwUKCBA9qrrqw44w1u.s421y3AD-220Bqs0.47w@flex--tabba.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3g5cHZwUKCBA9qrrqw44w1u.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=1728550719; a=rsa-sha256; cv=none; b=oDrrWKYh/Q2jW3HJpmpUr7z1Gw3I9CdkecgRUH2i6KYv7ZZT5h9yqUZKKUXaI4FPUjyB1Z arp/8qGlGC2sDwOZrwr8g89bxeAZSvJ42RkoF1pCvh1CwIn2cUSjIjQXqPUEkpq7PxC3RY WLvYPqW6OxIuELwQQTu2yajCx23zrg8= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e2270a147aso13009107b3.0 for ; Thu, 10 Oct 2024 01:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728550788; x=1729155588; 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=McR6hFD8xu5MydKKfp3q4/vtlv2OyOY0xakrmAL+qLs=; b=ZvxhfrkTJKjwcISO+0JioIFO42C5LWKc9evekJ4h/SCDfcyMIvCvT4cB5EkQO4marP 7hUqZJkT72HocByX1rj1lHgGaa0qjchjJTUpdwvtcxFZt9r00pBoiEaxXSnThbvBm1Zf 5Di6I5k1MV7ThsOAzUCVrmRGM4kbVyOa4+OHgE43it0Zj9JnKpIW90rz4qr+vHLOMqXy kRmGp4X1Y3bNO747HPpMfGKaO69/vEBMq6Sh1OQing4P4iufRVdVYVzKDo/wEWSnIAY3 0DwfiAif9Ym0p+sCxFG41dQSl2p/R5M6yPgSRKmvIvhiMKn4m/EbNwQu9z7euwxr89T2 XGsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728550788; x=1729155588; 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=McR6hFD8xu5MydKKfp3q4/vtlv2OyOY0xakrmAL+qLs=; b=bJBpH/KArMKlrgCLPIuIn/FvXoDmY+lWaZdUpDq6wtacnsZfZYWMiLwwn5DIs0rjgb tVcHhNDEA4M0arEBaqz1tqUGmQW/iyhEHtMNz2di0pff1aaFDBCeF3H22nri5x2KaID/ 0ijYiccQrhBaWnQEZCMVZNeo+MzQ2t1LfpOpX5jYa02vS3w3ze8qzppRrNtCf4Q2ibTL DqhymahVAuAavz3PMpkL1RoVS/S1kNyiba+tiukfc3ZXV00PTc5+OGkIXK+/OHAtGR6Y 4BsRnlTKx44VbxPYzRYkYcz4bFJZ0WX6UUCnhTgPMoVdMhAl3uGpkAH1LoB5g8rTPNow W4qg== X-Forwarded-Encrypted: i=1; AJvYcCVQ+2RXMAl3xd07UA6AYiU091DVJZnZY0Jbn8A9nOSaslsFjV6ecbGAsT0z0ba6pv+n0wo61M34OQ==@kvack.org X-Gm-Message-State: AOJu0YzfLrn81cNNyETexRshfg3yTOhIXVoGTWkpV+67+JdhQn2I1uia /q7WXSmkmWK58kPf0B0D9PTH+RCVA8HgsaPM/dPpVfetD8lvR87LaWpKrDCGoSqoERng+F/iUg= = X-Google-Smtp-Source: AGHT+IFvDP0XuuJHxV5RnbWlC7X4GO/XpvIVrGemFE3icy6MnaUivOOGAIqQ7A9+OzK7/cvpWXHNkIHIjw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5b:e8e:0:b0:e25:e5b9:8114 with SMTP id 3f1490d57ef6-e28fe362769mr134823276.4.1728550787926; Thu, 10 Oct 2024 01:59:47 -0700 (PDT) Date: Thu, 10 Oct 2024 09:59:25 +0100 In-Reply-To: <20241010085930.1546800-1-tabba@google.com> Mime-Version: 1.0 References: <20241010085930.1546800-1-tabba@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Message-ID: <20241010085930.1546800-7-tabba@google.com> Subject: [PATCH v3 06/11] KVM: guest_memfd: Add KVM capability to check if guest_memfd is host mappable 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, jthoughton@google.com, tabba@google.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: DFDA31C000B X-Stat-Signature: 8ybbrb8aspy9q9dfkr9paizoyhu8n71d X-HE-Tag: 1728550787-133838 X-HE-Meta: U2FsdGVkX1/jN71RYq6zhiOWhmd1Q9tGZ33nNnbhefzXQXkknG4HN8oAQSOU4uZTd/T2INAXThVJo6aMXG8s5yEZbC6GRYZbux9mAey+k0zohlAC+WffDD9plYvA90uA5+GgBtSPJUlMWRZuuEmHFPOaHOnBwFKFFYzOcZuXgpPIVoIKjl+blGQse3ccfg3CrKdJPjEmVCIjBNfF2v/w7Vk7a6ZyMZ+T0kwc0sT5yq+X76SR5jeCZr/ETPg+NNlyQU9CH0l3+5QlRHL78KYgMF5pxC/zq+zmj9fEjHp2AkrW1ofL3HhhOPWMhljGtQ8uG5qkfjY61LUhTGybbEPPS+jUVO53Mao935tFwDi3UkGOQkXnRBxgf/jCifMGhT/VE4F4sjT/D2dtWp7OpdsMYt962YsKf02iA04w1Np3CJ9OtBN62YCGp8sHkSVlGwjKiTXLP2Bk+WGBOpylO12oFOVbsCNEutqO7YCwFDkJ5reakxeodzPQnph0xd3KiB0A18ICC896VKgn4SDJKNxYdghWyl4tvFrzx3tJN8t/qRy3kBwH6ySN61MN7OasKRsoYze2uNxQiX6G0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: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 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 | 1 + virt/kvm/kvm_main.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 637efc055145..2c6057bab71c 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -933,6 +933,7 @@ struct kvm_enable_cap { #define KVM_CAP_PRE_FAULT_MEMORY 236 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_GUEST_MEMFD_MAPPABLE 239 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 77e6412034b9..c2ff09197795 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5176,6 +5176,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_GMEM_MAPPABLE + case KVM_CAP_GUEST_MEMFD_MAPPABLE: + return !kvm || kvm_arch_has_private_mem(kvm); #endif default: break;