From patchwork Thu Oct 10 08:59:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13829807 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 D27FECF07D9 for ; Thu, 10 Oct 2024 09:00:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84D2D6B00A3; Thu, 10 Oct 2024 05:00:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D5F66B00A4; Thu, 10 Oct 2024 05:00:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 629016B00A5; Thu, 10 Oct 2024 05:00:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 36A3B6B00A3 for ; Thu, 10 Oct 2024 05:00:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2870E1C5CD3 for ; Thu, 10 Oct 2024 09:00:00 +0000 (UTC) X-FDA: 82657095486.21.71A3EA6 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf22.hostedemail.com (Postfix) with ESMTP id 01D05C0020 for ; Thu, 10 Oct 2024 09:00:00 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="b0d/gzxF"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3kJcHZwUKCB0M34439HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--tabba.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3kJcHZwUKCB0M34439HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--tabba.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728550700; a=rsa-sha256; cv=none; b=O6fEcEo4oUs1zevU8b/4yZyKDB+OCnu5tU1ajmkOsZzCFUUttRIXVuZj4ZompaXJEiOtGD WvobA2AvmRqnYocszmeA70RAfJrOCy/9/CBgsoWvHVJyt2n8eTJBgdoSlRnTAoH01GSoCs /MIx3PehJ/zka7crPi/hZt0QJFDZ0so= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="b0d/gzxF"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3kJcHZwUKCB0M34439HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--tabba.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3kJcHZwUKCB0M34439HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--tabba.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728550700; 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=vRqRt9/OdUuC94QGlx1b3LLfUnzhlvtZvk9uJQuMY0s=; b=jCZjx73Ut6MTG1IldvdxMl9BkfqObh9iJWXXZ5chovTkSCDTpc0CpRrIY/IutGDjNRYPpC Fs3znMAmJ6zW/8ZEgux/fBjapy3JcwSpV1vuXqRVjefa13BS+uFlAB0PbwZszpzTM3y9tB ctfwdKhZGASydj6TPucBYvt+5sp4qs0= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e165fc5d94fso1001880276.2 for ; Thu, 10 Oct 2024 02:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728550801; x=1729155601; 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=vRqRt9/OdUuC94QGlx1b3LLfUnzhlvtZvk9uJQuMY0s=; b=b0d/gzxFM0AvdNu3c6KG2oAy7mIJechUtXJM6txYDcz73AzdLLciB3x4tJpaDeMC7Z MMsm3jVZhJpuxP6RK4f69VOPN3dZplnVjSh56eDVY3ikNKeoccX3BijlMNuacfK0laO2 K22KWZ4QzjpT7CsJMVGcEuqMQAsNR7OzmRzqb6cQyOohcu4qtsTrxvjmEDtsVyc0qIkU hrqcuPi3InB8ehbEV/fwCGOvqvNOlWqtlvedhs7MRU32LCYva9jlfRLbrmKs3Y+dpyi8 JSByf7wVCiagstSkfDyaKvohDFbdccB0MOJ5Os9RrGYK8Al9bIKC36XHUvhrfHJJannF 7bIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728550801; x=1729155601; 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=vRqRt9/OdUuC94QGlx1b3LLfUnzhlvtZvk9uJQuMY0s=; b=ZjLzaky06VbGB8Neqej0BKxx6xvLafAV1sEC71qJRDITl08hZBvPi3UZOSJwjKnwOP 43WVyvjCsMtxHwnxb8HiBo7lruxwZkEdNtFj4azQEzkZK+cT2EZySkRz4/CkWW+gz1i3 p21LRCjZhASOhmjqfQeGQuxvnNl7mqzLZUh9e8a4DAW0P/0DBEQTFpplI0HwL4t2lv/B KCIIGUS3tR4XEeRv8YIPgFnEdQi0hQQXonhiFcBYQTldJkIBJk+D7DVKZxfz4q1cbu8x tLfQB0QDBiSz6Ov4vvaK2YEt0gAsXGXC4RQ/q2vibvflPLtIe7ABGb0iPZIG7edb95t2 DboQ== X-Forwarded-Encrypted: i=1; AJvYcCWuw9amINFBtR1CqYLS/Exj4JczG7nCmWYsjIngGlJBtW9IssKiw/DCJl06kpBZO1cKGVhXBZbPtg==@kvack.org X-Gm-Message-State: AOJu0YwV0S8ASZj6ohuowp0Yu9Qm3MpQx5U5cc/xolCfB4dHmLYIuWOp zv3g4jdAazy6AKDKSbrIcNMhEgBjerTblqILk9AFPHBgcaKgeBdfr9tnbl9PTZrW8iLlAt/ijw= = X-Google-Smtp-Source: AGHT+IHKOC7WKTbH/ijVUTH38hxdU+Ou0RoKl5cARtWTF5vqoihO6BtV+q30wvio57rQ24Dl8KyceyokuA== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:1812:b0:e24:9f58:dd17 with SMTP id 3f1490d57ef6-e28fe32f042mr55663276.1.1728550800731; Thu, 10 Oct 2024 02:00:00 -0700 (PDT) Date: Thu, 10 Oct 2024 09:59:30 +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-12-tabba@google.com> Subject: [PATCH v3 11/11] KVM: arm64: Enable guest_memfd private memory when pKVM is enabled 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-Queue-Id: 01D05C0020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 78rbf6ak46adc7qjnwb3w3zyhr4zh1ns X-HE-Tag: 1728550800-494499 X-HE-Meta: U2FsdGVkX1+TWi/TVbBKGoc5draELkRT9gZSCk4hdyj6rhy+7whzP7jMcP5bJ4qJjHfKy3VtI8d2aeaCm8gpbqExjo6pPqHvpRhBSOj5RuICgsdYDGOm+3cea/WRlbHeNgVjVvkF+2aYGjK6SCuPcK9zCBGR7foBVSAAWOkHS/071u2Cr0Vm6kFcFO5ZwC/Q2oKvkJFg3meQEMgF+TfBTdydXxJv7jRrgX5Z9zhPZchrK/FEhqu9o1BsQhtSvUwZA0B/KwklnHipVODhu6aMPeUyHzimUfoqngbPdTkwsj5rPoy5GhEwkqZuQTbYllNbrHN56yoKkvZ4Mx4vOIvscVf1WxPkzFWMLQYJzkxe9+8lz4yp0HQ+OcpTFDzcyRnYlETkdbHDS2ctxDwK2gxF1HjB6nxInAcmrYCL2CKdYBGrJzlBGE9RxiNgNIbGgP+tnA88UsBPSEewmJcyZ/2AdyiQdMjM5EVQBM9eKS4g2Gg4qCAbs0xtzBBoy9ofDEBZADhHtWRjvQNs3L5/8OrFJl+AqeTQ+XMyLQQVn/mQH90bv9GFdL/pJlb2SM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CQAyfLLcm+gRw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.021819, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Implement kvm_arch_has_private_mem() in arm64 when pKVM is enabled, and make it dependent on the configuration option. Also, now that the infrastructure is in place for arm64 to support guest private memory, enable it in the arm64 kernel configuration. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_host.h | 3 +++ arch/arm64/kvm/Kconfig | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 94cff508874b..eec32e537097 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1496,4 +1496,7 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val); (system_supports_fpmr() && \ kvm_has_feat((k), ID_AA64PFR2_EL1, FPMR, IMP)) +#define kvm_arch_has_private_mem(kvm) \ + (IS_ENABLED(CONFIG_KVM_PRIVATE_MEM) && is_protected_kvm_enabled()) + #endif /* __ARM64_KVM_HOST_H__ */ diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index ead632ad01b4..fe3451f244b5 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -38,6 +38,7 @@ menuconfig KVM select HAVE_KVM_VCPU_RUN_PID_CHANGE select SCHED_INFO select GUEST_PERF_EVENTS if PERF_EVENTS + select KVM_GMEM_MAPPABLE help Support hosting virtualized guest machines.