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.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 88A5FC0650E for ; Wed, 3 Jul 2019 16:27:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68F95218BA for ; Wed, 3 Jul 2019 16:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbfGCQ1L (ORCPT ); Wed, 3 Jul 2019 12:27:11 -0400 Received: from foss.arm.com ([217.140.110.172]:52062 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbfGCQ1K (ORCPT ); Wed, 3 Jul 2019 12:27:10 -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 DF292344; Wed, 3 Jul 2019 09:27:09 -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 1E05F3F718; Wed, 3 Jul 2019 09:27:09 -0700 (PDT) Date: Wed, 3 Jul 2019 17:27:07 +0100 From: Dave Martin To: Marc Zyngier Cc: kvm@vger.kernel.org, Andre Przywara , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 04/59] KVM: arm64: nv: Introduce nested virtualization VCPU feature Message-ID: <20190703162706.GV2790@e103592.cambridge.arm.com> References: <20190621093843.220980-1-marc.zyngier@arm.com> <20190621093843.220980-5-marc.zyngier@arm.com> <20190624112851.GM2790@e103592.cambridge.arm.com> <01e61a51-5bf0-8943-6f68-7a5cea59f093@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01e61a51-5bf0-8943-6f68-7a5cea59f093@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 Wed, Jul 03, 2019 at 12:53:58PM +0100, Marc Zyngier wrote: > On 24/06/2019 12:28, Dave Martin wrote: > > 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? > > So far, there is no extra flag to describe further nesting, and it > directly comes from EL2 being emulated. I don't mind renaming this to > KVM_ARM_VCPU_HAS_EL2, or something similar... Whether we want userspace > to control the exposure of the nesting capability (i.e. EL2 with > ARMv8.3-NV) is another question. Agreed. KVM_ARM_VCPU_HAS_EL2 seems a reasonable name to me. If we have have an internal flag in vcpu_arch.flags we could call that something different (i.e., keep the NESTED_VIRT naming) if it's natural to do so. Cheers ---Dave 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.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 50D9BC0650E for ; Wed, 3 Jul 2019 16:27:15 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id D1DFE218A4 for ; Wed, 3 Jul 2019 16:27:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1DFE218A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 68B4D4A4EB; Wed, 3 Jul 2019 12:27:14 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oqBKM33QU6cX; Wed, 3 Jul 2019 12:27:13 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 10C5E4A4FF; Wed, 3 Jul 2019 12:27:13 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A89014A4FF for ; Wed, 3 Jul 2019 12:27:11 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JbP8UnpK+PLi for ; Wed, 3 Jul 2019 12:27:10 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3EDB04A4EB for ; Wed, 3 Jul 2019 12:27:10 -0400 (EDT) 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 DF292344; Wed, 3 Jul 2019 09:27:09 -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 1E05F3F718; Wed, 3 Jul 2019 09:27:09 -0700 (PDT) Date: Wed, 3 Jul 2019 17:27:07 +0100 From: Dave Martin To: Marc Zyngier Subject: Re: [PATCH 04/59] KVM: arm64: nv: Introduce nested virtualization VCPU feature Message-ID: <20190703162706.GV2790@e103592.cambridge.arm.com> References: <20190621093843.220980-1-marc.zyngier@arm.com> <20190621093843.220980-5-marc.zyngier@arm.com> <20190624112851.GM2790@e103592.cambridge.arm.com> <01e61a51-5bf0-8943-6f68-7a5cea59f093@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <01e61a51-5bf0-8943-6f68-7a5cea59f093@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: linux-arm-kernel@lists.infradead.org, Andre Przywara , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Wed, Jul 03, 2019 at 12:53:58PM +0100, Marc Zyngier wrote: > On 24/06/2019 12:28, Dave Martin wrote: > > 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? > > So far, there is no extra flag to describe further nesting, and it > directly comes from EL2 being emulated. I don't mind renaming this to > KVM_ARM_VCPU_HAS_EL2, or something similar... Whether we want userspace > to control the exposure of the nesting capability (i.e. EL2 with > ARMv8.3-NV) is another question. Agreed. KVM_ARM_VCPU_HAS_EL2 seems a reasonable name to me. If we have have an internal flag in vcpu_arch.flags we could call that something different (i.e., keep the NESTED_VIRT naming) if it's natural to do so. Cheers ---Dave _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 9C7CCC06511 for ; Wed, 3 Jul 2019 16:27:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6EADF218A4 for ; Wed, 3 Jul 2019 16:27:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DoROnfft" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EADF218A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject: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=hTboRd5TrMt8kLL6xOBHSkcqi5h/xT7mduSODhNbMAg=; b=DoROnfftiXGY7h dts2MxwVYlCPU9GHffKu2IaOL1kRDmex2Ia2JHVUpKKxrIfopbs2C5/0tg77BkqVaQJnqNMvYzRYb LcmqA0X0kL5z84ygzr2yF8cjUBk0bCR8dr+YLz/ZIAVuFiAyotn7cWP+KHGZJ5zK7avjm/xViCt8b 90f4HIpbKIRbx48e6YOfBayx16W7aiPHYzZvOZd3aa3wq4p2aJyhkdVW/AuCcWKRpMsDlJxMWt2YW FiV2dk41F/YFC2SqU+1WNOw0FApRb5fWUOSxiAKXn05V2wYRYszJhQ15gk18X8NzwkytCNfmp1U9O DwIpEBFG04ac1cRdAAUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hii6E-0006Kj-1Z; Wed, 03 Jul 2019 16:27:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hii6A-0006Jl-Do for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2019 16:27:11 +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 DF292344; Wed, 3 Jul 2019 09:27:09 -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 1E05F3F718; Wed, 3 Jul 2019 09:27:09 -0700 (PDT) Date: Wed, 3 Jul 2019 17:27:07 +0100 From: Dave Martin To: Marc Zyngier Subject: Re: [PATCH 04/59] KVM: arm64: nv: Introduce nested virtualization VCPU feature Message-ID: <20190703162706.GV2790@e103592.cambridge.arm.com> References: <20190621093843.220980-1-marc.zyngier@arm.com> <20190621093843.220980-5-marc.zyngier@arm.com> <20190624112851.GM2790@e103592.cambridge.arm.com> <01e61a51-5bf0-8943-6f68-7a5cea59f093@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <01e61a51-5bf0-8943-6f68-7a5cea59f093@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190703_092710_556610_11182095 X-CRM114-Status: GOOD ( 21.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Andre Przywara , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 03, 2019 at 12:53:58PM +0100, Marc Zyngier wrote: > On 24/06/2019 12:28, Dave Martin wrote: > > 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? > > So far, there is no extra flag to describe further nesting, and it > directly comes from EL2 being emulated. I don't mind renaming this to > KVM_ARM_VCPU_HAS_EL2, or something similar... Whether we want userspace > to control the exposure of the nesting capability (i.e. EL2 with > ARMv8.3-NV) is another question. Agreed. KVM_ARM_VCPU_HAS_EL2 seems a reasonable name to me. If we have have an internal flag in vcpu_arch.flags we could call that something different (i.e., keep the NESTED_VIRT naming) if it's natural to do so. Cheers ---Dave _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel