From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3F0FC433F5 for ; Thu, 13 Jan 2022 14:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KmbyZAedbNStRhj84CZ8DUQ1vn4MDLWF8LrqyHqTv5o=; b=koDOaxGtu6aVub aC19jRrRZ3MnzG4dUsqSIjJO3AU5ufB7grqq4OyphvaWF0Aq4XV38RkdfkcdC9dBBwfrylJRgzow0 ze1RghYceqJDs+vjKC/v7FfXaQHjf0jZGmbE89WMYZJAEupP0HUIr4vSmJuAs5aXDfGJphdrkNER5 NauhWcWmQ2wJPRWYqUWYxP39O1MBj8knpsUIegb02FBpmQNhClzQ3e3/u7T0w6aNlBxnwmwdU52lg sN6GRzomqPTFQjvfkROZzvMXUlxbPkNkk0KhVTplbmjLEfNFE+cORXKF+Q1tW8W5UqD1Hd6pTLei2 SiPxmT44zMdD5EAyRHEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n80oF-006CZo-U2; Thu, 13 Jan 2022 14:10:36 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n80oC-006CZI-F5 for linux-arm-kernel@lists.infradead.org; Thu, 13 Jan 2022 14:10:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB3ABED1; Thu, 13 Jan 2022 06:10:30 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 50EFF3F766; Thu, 13 Jan 2022 06:10:28 -0800 (PST) Date: Thu, 13 Jan 2022 14:10:39 +0000 From: Alexandru Elisei To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Jintack Lim , Haibo Xu , Ganapatrao Kulkarni , James Morse , Suzuki K Poulose , kernel-team@android.com Subject: Re: [PATCH v5 07/69] KVM: arm64: nv: Introduce nested virtualization VCPU feature Message-ID: References: <20211129200150.351436-1-maz@kernel.org> <20211129200150.351436-8-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211129200150.351436-8-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220113_061032_580490_E48A4774 X-CRM114-Status: GOOD ( 21.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marc, On Mon, Nov 29, 2021 at 08:00:48PM +0000, Marc Zyngier wrote: > From: Christoffer Dall > > Introduce the feature bit and a primitive that checks if the feature is > set behind a static key check based on the cpus_have_const_cap check. > > Checking nested_virt_in_use() on systems without nested virt enabled > should have neglgible overhead. > > We don't yet allow userspace to actually set this feature. > > Signed-off-by: Christoffer Dall > Signed-off-by: Marc Zyngier > --- > arch/arm64/include/asm/kvm_nested.h | 14 ++++++++++++++ > arch/arm64/include/uapi/asm/kvm.h | 1 + > 2 files changed, 15 insertions(+) > create mode 100644 arch/arm64/include/asm/kvm_nested.h > > diff --git a/arch/arm64/include/asm/kvm_nested.h b/arch/arm64/include/asm/kvm_nested.h > new file mode 100644 > index 000000000000..1028ac65a897 > --- /dev/null > +++ b/arch/arm64/include/asm/kvm_nested.h > @@ -0,0 +1,14 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __ARM64_KVM_NESTED_H > +#define __ARM64_KVM_NESTED_H > + > +#include > + > +static inline bool nested_virt_in_use(const struct kvm_vcpu *vcpu) > +{ > + return (!__is_defined(__KVM_NVHE_HYPERVISOR__) && > + cpus_have_final_cap(ARM64_HAS_NESTED_VIRT) && > + test_bit(KVM_ARM_VCPU_HAS_EL2, vcpu->arch.features)); kvm_vcpu_init_nested() checks the ARM64_HAS_NESTED_VIRT cap before setting the features bit, so I guess you can drop this check here if you're interested in correctness. But the reason the cap check done is performance, right? Same with the NVHE define. Thanks, Alex > +} > + > +#endif /* __ARM64_KVM_NESTED_H */ > diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h > index b3edde68bc3e..395a4c039bcc 100644 > --- a/arch/arm64/include/uapi/asm/kvm.h > +++ b/arch/arm64/include/uapi/asm/kvm.h > @@ -106,6 +106,7 @@ struct kvm_regs { > #define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ > #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ > #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ > +#define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */ > > struct kvm_vcpu_init { > __u32 target; > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel