On 04/03/26, Philippe Mathieu-Daudé wrote:
> On 3/3/26 17:11, Anton Johansson via qemu development wrote:
> > Reviewed-by: Helge Deller <[email protected]>
> > Signed-off-by: Anton Johansson <[email protected]>
> > ---
> > target/hppa/cpu.h | 11 ++++++++---
> > hw/hppa/machine.c | 4 ++--
> > hw/pci-host/astro.c | 2 +-
> > target/hppa/cpu.c | 9 ++++++++-
> > target/hppa/mem_helper.c | 39 +++++++++++----------------------------
> > 5 files changed, 30 insertions(+), 35 deletions(-)
>
>
> > diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> > index 5d0d4de09e..bb6b7dc76c 100644
> > --- a/hw/hppa/machine.c
> > +++ b/hw/hppa/machine.c
> > @@ -181,12 +181,12 @@ static uint64_t linux_kernel_virt_to_phys(void
> > *opaque, uint64_t addr)
> > static uint64_t translate_pa10(void *dummy, uint64_t addr)
> > {
> > - return hppa_abs_to_phys_pa1x(addr);
> > + return hppa_abs_to_phys_pa1x(cpu_env(first_cpu), addr);
>
> I'm not keen of these @first_cpu uses (for heterogeneous emulation
> we want to restrict this variable to accel/, and poison it elsewhere
> like in hw/). Can we resolve earlier or pass CPUState* around?
Right, I had this in the back of my mind somewhere. Both uses in
machine.c can be changed to instead use the first created HPPA cpu
through `&cpu[0]->env`, which is commonly used in machine.c.
As for the use in astro.c, I think the best option is to add a property
for `phys_addr_bits`. However, this requires changing
hppa_abs_to_phys*() to take `uint8_t phys_addr_bits` instead of
`CPUHPPAState *env`, which IMO is preferable as
`hppa_get_physical_address()` becomes a bit simpler
int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
int type, MemOp mop, hwaddr *pphys, int *pprot)
{
hwaddr phys;
int prot, r_prot, w_prot, x_prot, priv;
HPPATLBEntry *ent;
int ret = -1;
/* Virtual translation disabled. Map absolute to physical. */
if (MMU_IDX_MMU_DISABLED(mmu_idx)) {
+ const uint8_t pa_bits = hppa_phys_addr_bits(env);
switch (mmu_idx) {
case MMU_ABS_W_IDX:
- phys = hppa_abs_to_phys_pa2_w1(env, addr);
+ phys = hppa_abs_to_phys_pa2_w1(pa_bits, addr);
break;
case MMU_ABS_IDX:
if (hppa_is_pa20(env)) {
- phys = hppa_abs_to_phys_pa2_w0(env, addr);
+ phys = hppa_abs_to_phys_pa2_w0(pa_bits, addr);
} else {
- phys = hppa_abs_to_phys_pa1x(env, addr);
+ phys = hppa_abs_to_phys_pa1x(pa_bits, addr);
}
break;
default:
g_assert_not_reached();
}
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
goto egress_align;
}
...
}
--
Anton Johansson
rev.ng Labs Srl.