On 12/9/25 07:56, Anton Johansson wrote:
In preparation for dropping TARGET_PHYS_ADDR_SPACE_BITS, add a
a runtime function to correctly represent the size of the physical
address space for EV4-6 based on the current CPU version.
Signed-off-by: Anton Johansson <[email protected]>
---
linux-user/alpha/target_proc.h | 2 +-
target/alpha/cpu.h | 1 +
target/alpha/helper.c | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/linux-user/alpha/target_proc.h b/linux-user/alpha/target_proc.h
index da437ee0e5..bcdd1e343c 100644
--- a/linux-user/alpha/target_proc.h
+++ b/linux-user/alpha/target_proc.h
@@ -57,7 +57,7 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
"L1 Dcache\t\t: n/a\n"
"L2 cache\t\t: n/a\n"
"L3 cache\t\t: n/a\n",
- model, TARGET_PAGE_SIZE, TARGET_PHYS_ADDR_SPACE_BITS,
+ model, TARGET_PAGE_SIZE, alpha_phys_addr_space_bits(cpu_env),
max_cpus, num_cpus, cpu_mask);
return 0;
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 45944e46b5..9ee8d93b72 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -286,6 +286,7 @@ bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
#endif /* !CONFIG_USER_ONLY */
void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
+uint8_t alpha_phys_addr_space_bits(CPUAlphaState *env);
int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
diff --git a/target/alpha/helper.c b/target/alpha/helper.c
index a9af52a928..0f0cf73bf3 100644
--- a/target/alpha/helper.c
+++ b/target/alpha/helper.c
@@ -523,6 +523,24 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags)
qemu_fprintf(f, "\n");
}
+uint8_t alpha_phys_addr_space_bits(CPUAlphaState *env)
+{
+ switch (env->implver) {
+ case IMPLVER_2106x:
+ /* EV4 */
+ return 34;
+ case IMPLVER_21164:
+ /* EV5 */
+ return 40;
+ case IMPLVER_21264:
+ case IMPLVER_21364:
+ /* EV6 and EV7*/
+ return 44;
+ default:
+ g_assert_not_reached();
+ }
+}
+
/* This should only be called from translate, via gen_excp.
We expect that ENV->PC has already been updated. */
G_NORETURN void helper_excp(CPUAlphaState *env, int excp, int error)
This could just as well be a static function within
linux-user/alpha/target_proc.h.
r~