Hi all,
we are using the ucontext_t
from a signal handler in a program being run under qemu-user.
We have found that there seems to be a discrepancy between the context structure of the glibc and the one in qemu-user.
My understanding is that the one used by the glibc
The one used by qemu-user under riscv is here
qemu’s structure struct target_sigcontext
should, at least, be aligned to 16 because this is what ends
happening to the glibc’s union __riscv_mc_fp_state
(because of the __f
array in struct __riscv_mc_q_ext_state
).
Also we believe one of the fields is in the wrong order and there should be a padding field, mimicking what the glibc does.
In the time being, the patch below in qemu fixes this issue for us (we can now access the context correctly).
We are not sure, however, whether this is a bug in qemu-user or we’re actually seeing some other problem elsewhere. Can anyone confirm?
Thanks!
-struct target_sigcontext {
+struct __attribute__((aligned(16))) target_sigcontext {
abi_long pc;
abi_long gpr[31]; /* x0 is not present, so all offsets must be -1 */
uint64_t fpr[32];
uint32_t fcsr;
}; /* cf. riscv-linux:arch/riscv/include/uapi/asm/ptrace.h */
struct target_ucontext {
unsigned long uc_flags;
struct target_ucontext *uc_link;
target_stack_t uc_stack;
- struct target_sigcontext uc_mcontext;
target_sigset_t uc_sigmask;
+ uint8_t __unused[1024 / 8 - sizeof(target_sigset_t)];
+ struct target_sigcontext uc_mcontext;
};
-- Roger Ferrer Ibáñez - roger....@bsc.es Barcelona Supercomputing Center - Centro Nacional de Supercomputación
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/df82702e-4f4d-734d-6fc5-3bc5599157d0%40bsc.es.