linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values
@ 2024-11-22 16:46 James Clark
  2024-11-22 19:08 ` Marc Zyngier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Clark @ 2024-11-22 16:46 UTC (permalink / raw)
  To: will, maz, kvmarm, oliver.upton, linux-arm-kernel
  Cc: James Clark, Catalin Marinas, Joey Gouly, Suzuki K Poulose,
	Zenghui Yu, Yicong Yang, Dave Martin, Fuad Tabba, James Morse,
	Mark Rutland, Anshuman Khandual, Vincent Donnefort,
	Quentin Perret, linux-kernel

Since the linked fixes commit, these masks are already shifted so remove
the shifts. One issue that this fixes is SPE and TRBE not being
available anymore:

 arm_spe_pmu arm,spe-v1: profiling buffer owned by higher exception level

Fixes: 641630313e9c ("arm64: sysreg: Migrate MDCR_EL2 definition to table")
Signed-off-by: James Clark <james.clark@linaro.org>
---
 arch/arm64/include/asm/el2_setup.h | 4 ++--
 arch/arm64/kernel/hyp-stub.S       | 4 ++--
 arch/arm64/kvm/hyp/nvhe/pkvm.c     | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
index 4cd41464be3f..f134907d3c08 100644
--- a/arch/arm64/include/asm/el2_setup.h
+++ b/arch/arm64/include/asm/el2_setup.h
@@ -79,7 +79,7 @@
 		      1 << PMSCR_EL2_PA_SHIFT)
 	msr_s	SYS_PMSCR_EL2, x0		// addresses and physical counter
 .Lskip_spe_el2_\@:
-	mov	x0, #(MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT)
+	mov	x0, #MDCR_EL2_E2PB_MASK
 	orr	x2, x2, x0			// If we don't have VHE, then
 						// use EL1&0 translation.
 
@@ -92,7 +92,7 @@
 	and	x0, x0, TRBIDR_EL1_P
 	cbnz	x0, .Lskip_trace_\@		// If TRBE is available at EL2
 
-	mov	x0, #(MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT)
+	mov	x0, #MDCR_EL2_E2TB_MASK
 	orr	x2, x2, x0			// allow the EL1&0 translation
 						// to own it.
 
diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
index 65f76064c86b..ae990da1eae5 100644
--- a/arch/arm64/kernel/hyp-stub.S
+++ b/arch/arm64/kernel/hyp-stub.S
@@ -114,8 +114,8 @@ SYM_CODE_START_LOCAL(__finalise_el2)
 
 	// Use EL2 translations for SPE & TRBE and disable access from EL1
 	mrs	x0, mdcr_el2
-	bic	x0, x0, #(MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT)
-	bic	x0, x0, #(MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT)
+	bic	x0, x0, #MDCR_EL2_E2PB_MASK
+	bic	x0, x0, #MDCR_EL2_E2TB_MASK
 	msr	mdcr_el2, x0
 
 	// Transfer the MM state from EL1 to EL2
diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
index 01616c39a810..071993c16de8 100644
--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
@@ -126,7 +126,7 @@ static void pvm_init_traps_aa64dfr0(struct kvm_vcpu *vcpu)
 	/* Trap SPE */
 	if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_PMSVer), feature_ids)) {
 		mdcr_set |= MDCR_EL2_TPMS;
-		mdcr_clear |= MDCR_EL2_E2PB_MASK << MDCR_EL2_E2PB_SHIFT;
+		mdcr_clear |= MDCR_EL2_E2PB_MASK;
 	}
 
 	/* Trap Trace Filter */
@@ -143,7 +143,7 @@ static void pvm_init_traps_aa64dfr0(struct kvm_vcpu *vcpu)
 
 	/* Trap External Trace */
 	if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_ExtTrcBuff), feature_ids))
-		mdcr_clear |= MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT;
+		mdcr_clear |= MDCR_EL2_E2TB_MASK;
 
 	vcpu->arch.mdcr_el2 |= mdcr_set;
 	vcpu->arch.mdcr_el2 &= ~mdcr_clear;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values
  2024-11-22 16:46 [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values James Clark
@ 2024-11-22 19:08 ` Marc Zyngier
  2024-11-22 22:07 ` Oliver Upton
  2024-11-26 15:59 ` Oliver Upton
  2 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2024-11-22 19:08 UTC (permalink / raw)
  To: James Clark
  Cc: will, kvmarm, oliver.upton, linux-arm-kernel, Catalin Marinas,
	Joey Gouly, Suzuki K Poulose, Zenghui Yu, Yicong Yang,
	Dave Martin, Fuad Tabba, James Morse, Mark Rutland,
	Anshuman Khandual, Vincent Donnefort, Quentin Perret,
	linux-kernel

On Fri, 22 Nov 2024 16:46:35 +0000,
James Clark <james.clark@linaro.org> wrote:
> 
> Since the linked fixes commit, these masks are already shifted so remove
> the shifts. One issue that this fixes is SPE and TRBE not being
> available anymore:
> 
>  arm_spe_pmu arm,spe-v1: profiling buffer owned by higher exception level
> 
> Fixes: 641630313e9c ("arm64: sysreg: Migrate MDCR_EL2 definition to table")
> Signed-off-by: James Clark <james.clark@linaro.org>

Huh, well spotted. This is doubleplusungood. Thankfully, the KVM/arm64
tree hasn't reached Linus yet, but this needs quick fixing.

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values
  2024-11-22 16:46 [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values James Clark
  2024-11-22 19:08 ` Marc Zyngier
@ 2024-11-22 22:07 ` Oliver Upton
  2024-11-26 15:59 ` Oliver Upton
  2 siblings, 0 replies; 4+ messages in thread
From: Oliver Upton @ 2024-11-22 22:07 UTC (permalink / raw)
  To: James Clark
  Cc: will, maz, kvmarm, linux-arm-kernel, Catalin Marinas, Joey Gouly,
	Suzuki K Poulose, Zenghui Yu, Yicong Yang, Dave Martin,
	Fuad Tabba, James Morse, Mark Rutland, Anshuman Khandual,
	Vincent Donnefort, Quentin Perret, linux-kernel, Paolo Bonzini

+cc Paolo

Ugh, sorry for the mess + thanks for the fix James.

Paolo -- would you be able to apply this patch directly to your tree?
This really should go in ASAP.

Otherwise, I'll grab it + send another pull.

On Fri, Nov 22, 2024 at 04:46:35PM +0000, James Clark wrote:
> Since the linked fixes commit, these masks are already shifted so remove
> the shifts. One issue that this fixes is SPE and TRBE not being
> available anymore:
> 
>  arm_spe_pmu arm,spe-v1: profiling buffer owned by higher exception level
> 
> Fixes: 641630313e9c ("arm64: sysreg: Migrate MDCR_EL2 definition to table")
> Signed-off-by: James Clark <james.clark@linaro.org>

Acked-by: Oliver Upton <oliver.upton@linux.dev>

-- 
Thanks,
Oliver


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values
  2024-11-22 16:46 [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values James Clark
  2024-11-22 19:08 ` Marc Zyngier
  2024-11-22 22:07 ` Oliver Upton
@ 2024-11-26 15:59 ` Oliver Upton
  2 siblings, 0 replies; 4+ messages in thread
From: Oliver Upton @ 2024-11-26 15:59 UTC (permalink / raw)
  To: will, maz, kvmarm, linux-arm-kernel, James Clark
  Cc: Oliver Upton, Catalin Marinas, Joey Gouly, Suzuki K Poulose,
	Zenghui Yu, Yicong Yang, Dave Martin, Fuad Tabba, James Morse,
	Mark Rutland, Anshuman Khandual, Vincent Donnefort,
	Quentin Perret, linux-kernel

On Fri, 22 Nov 2024 16:46:35 +0000, James Clark wrote:
> Since the linked fixes commit, these masks are already shifted so remove
> the shifts. One issue that this fixes is SPE and TRBE not being
> available anymore:
> 
>  arm_spe_pmu arm,spe-v1: profiling buffer owned by higher exception level
> 
> 
> [...]

Applied to fixes, thanks!

[1/1] arm64: Fix usage of new shifted MDCR_EL2 values
      https://git.kernel.org/kvmarm/kvmarm/c/d798bc6f3c17

--
Best,
Oliver


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-26 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-22 16:46 [PATCH] arm64: Fix usage of new shifted MDCR_EL2 values James Clark
2024-11-22 19:08 ` Marc Zyngier
2024-11-22 22:07 ` Oliver Upton
2024-11-26 15:59 ` Oliver Upton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).