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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D283FC43613 for ; Mon, 24 Jun 2019 11:28:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B48D820674 for ; Mon, 24 Jun 2019 11:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729823AbfFXL24 (ORCPT ); Mon, 24 Jun 2019 07:28:56 -0400 Received: from foss.arm.com ([217.140.110.172]:47644 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729816AbfFXL2z (ORCPT ); Mon, 24 Jun 2019 07:28:55 -0400 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 2CF612B; Mon, 24 Jun 2019 04:28:55 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CCCB13F718; Mon, 24 Jun 2019 04:28:53 -0700 (PDT) Date: Mon, 24 Jun 2019 12:28:51 +0100 From: Dave Martin To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Julien Thierry , Andre Przywara , Suzuki K Poulose , Christoffer Dall , James Morse , Jintack Lim Subject: Re: [PATCH 04/59] KVM: arm64: nv: Introduce nested virtualization VCPU feature Message-ID: <20190624112851.GM2790@e103592.cambridge.arm.com> References: <20190621093843.220980-1-marc.zyngier@arm.com> <20190621093843.220980-5-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190621093843.220980-5-marc.zyngier@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, Jun 21, 2019 at 10:37:48AM +0100, 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/arm/include/asm/kvm_nested.h | 9 +++++++++ > arch/arm64/include/asm/kvm_nested.h | 13 +++++++++++++ > arch/arm64/include/uapi/asm/kvm.h | 1 + > 3 files changed, 23 insertions(+) > create mode 100644 arch/arm/include/asm/kvm_nested.h > create mode 100644 arch/arm64/include/asm/kvm_nested.h > > diff --git a/arch/arm/include/asm/kvm_nested.h b/arch/arm/include/asm/kvm_nested.h > new file mode 100644 > index 000000000000..124ff6445f8f > --- /dev/null > +++ b/arch/arm/include/asm/kvm_nested.h > @@ -0,0 +1,9 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __ARM_KVM_NESTED_H > +#define __ARM_KVM_NESTED_H > + > +#include > + > +static inline bool nested_virt_in_use(const struct kvm_vcpu *vcpu) { return false; } > + > +#endif /* __ARM_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..8a3d121a0b42 > --- /dev/null > +++ b/arch/arm64/include/asm/kvm_nested.h > @@ -0,0 +1,13 @@ > +/* 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 cpus_have_const_cap(ARM64_HAS_NESTED_VIRT) && > + test_bit(KVM_ARM_VCPU_NESTED_VIRT, vcpu->arch.features); > +} > + > +#endif /* __ARM64_KVM_NESTED_H */ > diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h > index d819a3e8b552..563e2a8bae93 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_NESTED_VIRT 7 /* Support nested virtualization */ This seems weirdly named: Isn't the feature we're exposing here really EL2? In that case, the feature the guest gets with this flag enabled is plain virtualisation, possibly with the option to nest further. Does the guest also get nested virt (i.e., recursively nested virt from the host's PoV) as a side effect, or would require an explicit extra flag? Cheers ---Dave