All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Quentin Perret <qperret@google.com>,
	Will Deacon <will@kernel.org>, Fuad Tabba <tabba@google.com>
Subject: [PATCH v2 05/17] arm64: Don't enable VHE for the kernel if OVERRIDE_HVHE is set
Date: Fri, 26 May 2023 15:33:36 +0100	[thread overview]
Message-ID: <20230526143348.4072074-6-maz@kernel.org> (raw)
In-Reply-To: <20230526143348.4072074-1-maz@kernel.org>

If the OVERRIDE_HVHE SW override is set (as a precursor of
the KVM_HVHE capability), do not enable VHE for the kernel
and drop to EL1 as if VHE was either disabled or unavailable.

Further changes will enable VHE at EL2 only, with the kernel
still running at EL1.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kernel/hyp-stub.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
index 9439240c3fcf..5c71e1019545 100644
--- a/arch/arm64/kernel/hyp-stub.S
+++ b/arch/arm64/kernel/hyp-stub.S
@@ -82,7 +82,15 @@ SYM_CODE_START_LOCAL(__finalise_el2)
 	tbnz	x1, #0, 1f
 
 	// Needs to be VHE capable, obviously
-	check_override id_aa64mmfr1 ID_AA64MMFR1_EL1_VH_SHIFT 2f 1f x1 x2
+	check_override id_aa64mmfr1 ID_AA64MMFR1_EL1_VH_SHIFT 0f 1f x1 x2
+
+0:	// Check whether we only want the hypervisor to run VHE, not the kernel
+	adr_l	x1, arm64_sw_feature_override
+	ldr	x2, [x1, FTR_OVR_VAL_OFFSET]
+	ldr	x1, [x1, FTR_OVR_MASK_OFFSET]
+	and	x2, x2, x1
+	ubfx	x2, x2, #ARM64_SW_FEATURE_OVERRIDE_HVHE, #4
+	cbz	x2, 2f
 
 1:	mov_q	x0, HVC_STUB_ERR
 	eret
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Quentin Perret <qperret@google.com>,
	Will Deacon <will@kernel.org>, Fuad Tabba <tabba@google.com>
Subject: [PATCH v2 05/17] arm64: Don't enable VHE for the kernel if OVERRIDE_HVHE is set
Date: Fri, 26 May 2023 15:33:36 +0100	[thread overview]
Message-ID: <20230526143348.4072074-6-maz@kernel.org> (raw)
In-Reply-To: <20230526143348.4072074-1-maz@kernel.org>

If the OVERRIDE_HVHE SW override is set (as a precursor of
the KVM_HVHE capability), do not enable VHE for the kernel
and drop to EL1 as if VHE was either disabled or unavailable.

Further changes will enable VHE at EL2 only, with the kernel
still running at EL1.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kernel/hyp-stub.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
index 9439240c3fcf..5c71e1019545 100644
--- a/arch/arm64/kernel/hyp-stub.S
+++ b/arch/arm64/kernel/hyp-stub.S
@@ -82,7 +82,15 @@ SYM_CODE_START_LOCAL(__finalise_el2)
 	tbnz	x1, #0, 1f
 
 	// Needs to be VHE capable, obviously
-	check_override id_aa64mmfr1 ID_AA64MMFR1_EL1_VH_SHIFT 2f 1f x1 x2
+	check_override id_aa64mmfr1 ID_AA64MMFR1_EL1_VH_SHIFT 0f 1f x1 x2
+
+0:	// Check whether we only want the hypervisor to run VHE, not the kernel
+	adr_l	x1, arm64_sw_feature_override
+	ldr	x2, [x1, FTR_OVR_VAL_OFFSET]
+	ldr	x1, [x1, FTR_OVR_MASK_OFFSET]
+	and	x2, x2, x1
+	ubfx	x2, x2, #ARM64_SW_FEATURE_OVERRIDE_HVHE, #4
+	cbz	x2, 2f
 
 1:	mov_q	x0, HVC_STUB_ERR
 	eret
-- 
2.34.1


  parent reply	other threads:[~2023-05-26 14:34 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 14:33 [PATCH v2 00/17] KVM: arm64: Allow using VHE in the nVHE hypervisor Marc Zyngier
2023-05-26 14:33 ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 01/17] KVM: arm64: Drop is_kernel_in_hyp_mode() from __invalidate_icache_guest_page() Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 02/17] arm64: Prevent the use of is_kernel_in_hyp_mode() in hypervisor code Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-30 19:54   ` Oliver Upton
2023-05-30 19:54     ` Oliver Upton
2023-05-31  7:17     ` Marc Zyngier
2023-05-31  7:17       ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 03/17] arm64: Turn kaslr_feature_override into a generic SW feature override Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 04/17] arm64: Add KVM_HVHE capability and has_hvhe() predicate Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-06-01  7:06   ` Oliver Upton
2023-06-01  7:06     ` Oliver Upton
2023-06-01 12:27     ` Marc Zyngier
2023-06-01 12:27       ` Marc Zyngier
2023-05-26 14:33 ` Marc Zyngier [this message]
2023-05-26 14:33   ` [PATCH v2 05/17] arm64: Don't enable VHE for the kernel if OVERRIDE_HVHE is set Marc Zyngier
2023-06-01  7:32   ` Oliver Upton
2023-06-01  7:32     ` Oliver Upton
2023-06-01 12:48     ` Marc Zyngier
2023-06-01 12:48       ` Marc Zyngier
2023-06-01 20:10       ` Oliver Upton
2023-06-01 20:10         ` Oliver Upton
2023-05-26 14:33 ` [PATCH v2 06/17] arm64: Allow EL1 physical timer access when running VHE Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-06-01  6:34   ` Oliver Upton
2023-06-01  6:34     ` Oliver Upton
2023-06-01 11:59     ` Marc Zyngier
2023-06-01 11:59       ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 07/17] arm64: Use CPACR_EL1 format to set CPTR_EL2 when E2H is set Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 08/17] KVM: arm64: Remove alternatives from sysreg accessors in VHE hypervisor context Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 09/17] KVM: arm64: Key use of VHE instructions in nVHE code off ARM64_KVM_HVHE Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 10/17] KVM: arm64: Force HCR_EL2.E2H when ARM64_KVM_HVHE is set Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 11/17] KVM: arm64: Disable TTBR1_EL2 when using ARM64_KVM_HVHE Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 12/17] KVM: arm64: Adjust EL2 stage-1 leaf AP bits when ARM64_KVM_HVHE is set Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 13/17] KVM: arm64: Rework CPTR_EL2 programming for HVHE configuration Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 14/17] KVM: arm64: Program the timer traps with VHE layout in hVHE mode Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 15/17] KVM: arm64: Force HCR_E2H in guest context when ARM64_KVM_HVHE is set Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 16/17] arm64: Allow arm64_sw.hvhe on command line Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier
2023-05-26 14:33 ` [PATCH v2 17/17] KVM: arm64: Terrible timer hack for M1 with hVHE Marc Zyngier
2023-05-26 14:33   ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230526143348.4072074-6-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.