From: Andrew Jones <andrew.jones@linux.dev>
To: kvmarm@lists.linux.dev
Cc: alexandru.elisei@arm.com, eric.auger@redhat.com,
nikos.nikoleris@arm.com, shahuang@redhat.com
Subject: [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2
Date: Tue, 2 Apr 2024 15:27:41 +0200 [thread overview]
Message-ID: <20240402132739.201939-6-andrew.jones@linux.dev> (raw)
In-Reply-To: <20240402132739.201939-5-andrew.jones@linux.dev>
When checking for supported granules also check for the values
which indicate support when LPA2 is implemented.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
lib/arm64/asm/processor.h | 49 +++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
index 1c73ba32725a..bab9c26c2c9e 100644
--- a/lib/arm64/asm/processor.h
+++ b/lib/arm64/asm/processor.h
@@ -110,31 +110,36 @@ static inline unsigned long get_id_aa64mmfr0_el1(void)
#define ID_AA64MMFR0_TGRAN64_SHIFT 24
#define ID_AA64MMFR0_TGRAN16_SHIFT 20
-#define ID_AA64MMFR0_TGRAN4_SUPPORTED 0x0
-#define ID_AA64MMFR0_TGRAN64_SUPPORTED 0x0
-#define ID_AA64MMFR0_TGRAN16_SUPPORTED 0x1
+#define ID_AA64MMFR0_TGRAN4_SUPPORTED(r) \
+({ \
+ u64 __v = ((r) >> ID_AA64MMFR0_TGRAN4_SHIFT) & 0xf; \
+ (__v) == 0 || (__v) == 1; \
+})
+
+#define ID_AA64MMFR0_TGRAN64_SUPPORTED(r) \
+({ \
+ u64 __v = ((r) >> ID_AA64MMFR0_TGRAN64_SHIFT) & 0xf; \
+ (__v) == 0; \
+})
+
+#define ID_AA64MMFR0_TGRAN16_SUPPORTED(r) \
+({ \
+ u64 __v = ((r) >> ID_AA64MMFR0_TGRAN16_SHIFT) & 0xf; \
+ (__v) == 1 || (__v) == 2; \
+})
static inline bool system_supports_granule(size_t granule)
{
- u32 shift;
- u32 val;
- u64 mmfr0;
-
- if (granule == SZ_4K) {
- shift = ID_AA64MMFR0_TGRAN4_SHIFT;
- val = ID_AA64MMFR0_TGRAN4_SUPPORTED;
- } else if (granule == SZ_16K) {
- shift = ID_AA64MMFR0_TGRAN16_SHIFT;
- val = ID_AA64MMFR0_TGRAN16_SUPPORTED;
- } else {
- assert(granule == SZ_64K);
- shift = ID_AA64MMFR0_TGRAN64_SHIFT;
- val = ID_AA64MMFR0_TGRAN64_SUPPORTED;
- }
-
- mmfr0 = get_id_aa64mmfr0_el1();
-
- return ((mmfr0 >> shift) & 0xf) == val;
+ u64 mmfr0 = get_id_aa64mmfr0_el1();
+
+ if (granule == SZ_4K)
+ return ID_AA64MMFR0_TGRAN4_SUPPORTED(mmfr0);
+
+ if (granule == SZ_16K)
+ return ID_AA64MMFR0_TGRAN16_SUPPORTED(mmfr0);
+
+ assert(granule == SZ_64K);
+ return ID_AA64MMFR0_TGRAN64_SUPPORTED(mmfr0);
}
#endif /* !__ASSEMBLY__ */
--
2.44.0
next prev parent reply other threads:[~2024-04-02 13:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 13:27 [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
2024-04-02 13:27 ` Andrew Jones [this message]
2024-04-03 8:50 ` [kvm-unit-tests PATCH v2 1/3] arm64: Prepare for LPA2 Nikos Nikoleris
2024-04-09 11:54 ` Eric Auger
2024-05-10 15:06 ` Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 2/3] arm/arm64: Use 'max' gic type Andrew Jones
2024-04-02 13:27 ` [kvm-unit-tests PATCH v2 3/3] arm64: Use 'max' cpu type Andrew Jones
2024-04-02 16:57 ` [kvm-unit-tests PATCH v2 0/2] arm/arm64: Use 'max' cpu and gic types Andrew Jones
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=20240402132739.201939-6-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=alexandru.elisei@arm.com \
--cc=eric.auger@redhat.com \
--cc=kvmarm@lists.linux.dev \
--cc=nikos.nikoleris@arm.com \
--cc=shahuang@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox