On 10/1/2026 8:59 AM, Anton Johansson wrote:
> Makes cpu_helper.c agnostic to compile-time target specifics, allowing
> it to be compiled twice (once for user- and once for system mode).
> target_[u]long is widened to [u]int64_t and runtime target_long_bits()
> is used in place of the equivalent macro.  Most changes are straight
> forward and no behavioural change is intended.
> 
> Note: the following change might be a bit unclear at first glance
> 
>   #define PTE_PPN_MASK 0x3FFFFFFFFFFC00ULL
> 
>   - target_ulong pte;
>   + uint64_t pte;
> 
>   - ppn = (pte & (target_ulong)PTE_PPN_MASK) >> PTE_PPN_SHIFT;
>   + ppn = (pte & PTE_PPN_MASK) >> PTE_PPN_SHIFT;
> 
> but retains expected behaviour as pte is written a uint32_t for
> MXL_RV32, meaning the top bits of PTE_PPN_MASK or chopped of in the &,
> rather than truncated.
> 
> Note: This commit will print all addresses as 64-bit values, even for a
> 32-bit target. If breaking this interface is not an option we can
> instead opt for more runtime branching, as done by Joel Stanley
> in commit 409c7d8682a.
> 
> Signed-off-by: Anton Johansson <[email protected]>
> ---
>  target/riscv/tcg/cpu_helper.c | 79 
> ++++++++++++++++++++++---------------------
>  target/riscv/tcg/meson.build  |  3 +-
>  2 files changed, 43 insertions(+), 39 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <[email protected]>

Reply via email to