From: Marc Zyngier <maz@kernel.org>
To: linux-arm-kernel@lists.infradead.org
Cc: Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ard Biesheuvel <ardb@kernel.org>,
broonie@kernel.org, danielmentz@google.com, saravanak@google.com,
kernel-team@android.com
Subject: [PATCH 4/6] arm64: Factor out checking of a feature against the override into a macro
Date: Mon, 27 Jun 2022 16:14:10 +0100 [thread overview]
Message-ID: <20220627151412.1496361-5-maz@kernel.org> (raw)
In-Reply-To: <20220627151412.1496361-1-maz@kernel.org>
Checking for a feature being supported from assembly code is
a bit tedious if we need to factor in the idreg override.
Since we already have such code written for forcing nVHE, move
the whole thing into a macro. This heavily relies on the override
structure being called foo_override for foo_el1.
No functional change.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/kernel/hyp-stub.S | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
index 26206e53e0c9..4a02a73650db 100644
--- a/arch/arm64/kernel/hyp-stub.S
+++ b/arch/arm64/kernel/hyp-stub.S
@@ -16,6 +16,23 @@
#include <asm/ptrace.h>
#include <asm/virt.h>
+.macro check_override idreg, fld, pass, fail
+ mrs x1, \idreg\()_el1
+ ubfx x1, x1, #\fld, #4
+ cbz x1, \fail
+
+ adr_l x1, \idreg\()_override
+ ldr x2, [x1, FTR_OVR_VAL_OFFSET]
+ ldr x1, [x1, FTR_OVR_MASK_OFFSET]
+ ubfx x2, x2, #\fld, #4
+ ubfx x1, x1, #\fld, #4
+ cmp x1, xzr
+ and x2, x2, x1
+ csinv x2, x2, xzr, ne
+ cbnz x2, \pass
+ b \fail
+.endm
+
.text
.pushsection .hyp.text, "ax"
@@ -80,20 +97,7 @@ SYM_CODE_START_LOCAL(__finalise_el2)
tbnz x1, #0, 1f
// Needs to be VHE capable, obviously
- mrs x1, id_aa64mmfr1_el1
- ubfx x1, x1, #ID_AA64MMFR1_VHE_SHIFT, #4
- cbz x1, 1f
-
- // Check whether VHE is disabled from the command line
- adr_l x1, id_aa64mmfr1_override
- ldr x2, [x1, FTR_OVR_VAL_OFFSET]
- ldr x1, [x1, FTR_OVR_MASK_OFFSET]
- ubfx x2, x2, #ID_AA64MMFR1_VHE_SHIFT, #4
- ubfx x1, x1, #ID_AA64MMFR1_VHE_SHIFT, #4
- cmp x1, xzr
- and x2, x2, x1
- csinv x2, x2, xzr, ne
- cbnz x2, 2f
+ check_override id_aa64mmfr1 ID_AA64MMFR1_VHE_SHIFT 2f 1f
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
next prev parent reply other threads:[~2022-06-27 15:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-27 15:14 [PATCH 0/6] arm64: Disabling SVE/SME from the command-line Marc Zyngier
2022-06-27 15:14 ` [PATCH 1/6] arm64: Rename the VHE switch to "finalise_el2" Marc Zyngier
2022-06-27 15:14 ` [PATCH 2/6] arm64: Save state of HCR_EL2.E2H before switch to EL1 Marc Zyngier
2022-06-27 15:14 ` [PATCH 3/6] arm64: Allow sticky E2H when entering EL1 Marc Zyngier
2022-06-27 15:14 ` Marc Zyngier [this message]
2022-06-28 11:28 ` [PATCH 4/6] arm64: Factor out checking of a feature against the override into a macro Mark Brown
2022-06-29 15:46 ` Marc Zyngier
2022-06-29 16:00 ` Mark Brown
2022-06-27 15:14 ` [PATCH 5/6] arm64: Add the arm64.nosme command line option Marc Zyngier
2022-06-27 17:04 ` Mark Brown
2022-06-27 18:08 ` Marc Zyngier
2022-06-27 18:20 ` Mark Brown
2022-06-27 15:14 ` [PATCH 6/6] arm64: Add the arm64.nosve " Marc Zyngier
2022-06-27 17:08 ` Mark Brown
2022-06-27 15:18 ` [PATCH 0/6] arm64: Disabling SVE/SME from the command-line Mark Brown
2022-06-27 15:30 ` Marc Zyngier
2022-06-27 16:49 ` Mark Brown
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=20220627151412.1496361-5-maz@kernel.org \
--to=maz@kernel.org \
--cc=ardb@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=danielmentz@google.com \
--cc=kernel-team@android.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=saravanak@google.com \
--cc=will@kernel.org \
/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.