[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 17/23] target/loongarch: Refactoring is_la64/is_va32 for Loong
From: |
Jiaxun Yang |
Subject: |
[PATCH v2 17/23] target/loongarch: Refactoring is_la64/is_va32 for LoongArch32 |
Date: |
Thu, 26 Dec 2024 21:19:48 +0000 |
is_la64 should be wired to false on LA32 build.
VA32 CSR check shouldn't be performed in LA32 mode.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
target/loongarch/cpu.h | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index
4f542a3376831141d012f177dc46a0e928afc85c..a2d416b6634b7f6787c93eac2b777a2f6c71bebf
100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -438,18 +438,26 @@ struct LoongArchCPUClass {
static inline bool is_la64(CPULoongArchState *env)
{
+#ifdef TARGET_LOONGARCH64
return FIELD_EX32(env->cpucfg[1], CPUCFG1, ARCH) == CPUCFG1_ARCH_LA64;
+#endif
+ return false;
}
static inline bool is_va32(CPULoongArchState *env)
{
/* VA32 if !LA64 or VA32L[1-3] */
- bool va32 = !is_la64(env);
- uint64_t plv = FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV);
- if (plv >= 1 && (FIELD_EX64(env->CSR_MISC, CSR_MISC, VA32) & (1 << plv))) {
- va32 = true;
+ if (is_la64(env)) {
+ uint64_t plv = FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV);
+
+ if (plv >= 1 &&
+ extract64(FIELD_EX64(env->CSR_MISC, CSR_MISC, VA32), plv, 1)) {
+ return true;
+ }
+ return false;
}
- return va32;
+
+ return true;
}
static inline void set_pc(CPULoongArchState *env, uint64_t value)
--
2.43.0
- Re: [PATCH v2 12/23] target/loongarch: Scrutinise TCG bitops translation for 32 bit build, (continued)
[PATCH v2 13/23] target/loongarch: Fix rdtimer on 32bit build, Jiaxun Yang, 2024/12/26
[PATCH v2 14/23] target/loongarch: Scrutinise TCG arithmetic translation for 32 bit build, Jiaxun Yang, 2024/12/26
[PATCH v2 15/23] target/loongarch: Fix load type for gen_ll, Jiaxun Yang, 2024/12/26
[PATCH v2 16/23] target/loongarch: Define address space information for LoongArch32, Jiaxun Yang, 2024/12/26
[PATCH v2 17/23] target/loongarch: Refactoring is_la64/is_va32 for LoongArch32,
Jiaxun Yang <=
[PATCH v2 18/23] target/loongarch: ifdef out 64 bit CPUs on 32 bit builds, Jiaxun Yang, 2024/12/26
[PATCH v2 19/23] target/loongarch: Introduce max32 CPU type, Jiaxun Yang, 2024/12/26
[PATCH v2 22/23] target/loongarch: Wire up LoongArch32 Kconfigs, Jiaxun Yang, 2024/12/26
[PATCH v2 20/23] hw/loongarch/virt: Default to max32 CPU for LoongArch 32 build, Jiaxun Yang, 2024/12/26
[PATCH v2 21/23] qapi/machine: Replace TARGET_LOONGARCH64 with TARGET_LOONGARCH, Jiaxun Yang, 2024/12/26