Skip to content

Commit

Permalink
target/hppa: Fix proberi instruction emulation for linux-user
Browse files Browse the repository at this point in the history
The proberi assembler instruction checks the read/write access rights
for the page of a given address and shall return a value of 1 if the
test succeeds and a value of 0 on failure in the target register.

But when run in linux-user mode, qemu currently simply returns the
return code of page_check_range() which returns 0 on success and -1 on
failure, which is the opposite of what proberi should return.

Fix it by checking the return code of page_check_range() and return the
expected return value.

The easiest way to reproduce the issue is by running
"/lib/ld.so.1 --version" in a chroot which fails without this patch.
At startup of ld.so the __canonicalize_funcptr_for_compare() function is
used to resolve the function address out of a function descriptor, which
fails because proberi (due to the wrong return code) seems to indicate
that the given address isn't accessible.

Signed-off-by: Helge Deller <[email protected]>
  • Loading branch information
hdeller committed Aug 19, 2022
1 parent c7208a6 commit 6fab0c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion target/hppa/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr,
uint32_t level, uint32_t want)
{
#ifdef CONFIG_USER_ONLY
return page_check_range(addr, 1, want);
return (page_check_range(addr, 1, want) == 0) ? 1 : 0;
#else
int prot, excp;
hwaddr phys;
Expand Down

0 comments on commit 6fab0c1

Please sign in to comment.