mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-28 05:50:37 +00:00
linux-user: fix preadv/pwritev offsets
preadv/pwritev accept low and high parts of file offset in two separate parameters. When host bitness doesn't match guest bitness these parts must be appropriately recombined. Introduce target_to_host_low_high that does this recombination and use it in preadv/pwritev syscalls. This fixes glibc testsuite test misc/tst-preadvwritev64. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
parent
9abfc88af3
commit
9ac225171c
@ -3386,6 +3386,23 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert target low/high pair representing file offset into the host
|
||||||
|
* low/high pair. This function doesn't handle offsets bigger than 64 bits
|
||||||
|
* as the kernel doesn't handle them either.
|
||||||
|
*/
|
||||||
|
static void target_to_host_low_high(abi_ulong tlow,
|
||||||
|
abi_ulong thigh,
|
||||||
|
unsigned long *hlow,
|
||||||
|
unsigned long *hhigh)
|
||||||
|
{
|
||||||
|
uint64_t off = tlow |
|
||||||
|
((unsigned long long)thigh << TARGET_LONG_BITS / 2) <<
|
||||||
|
TARGET_LONG_BITS / 2;
|
||||||
|
|
||||||
|
*hlow = off;
|
||||||
|
*hhigh = (off >> HOST_LONG_BITS / 2) >> HOST_LONG_BITS / 2;
|
||||||
|
}
|
||||||
|
|
||||||
static struct iovec *lock_iovec(int type, abi_ulong target_addr,
|
static struct iovec *lock_iovec(int type, abi_ulong target_addr,
|
||||||
abi_ulong count, int copy)
|
abi_ulong count, int copy)
|
||||||
{
|
{
|
||||||
@ -10449,7 +10466,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
{
|
{
|
||||||
struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
|
struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
|
||||||
if (vec != NULL) {
|
if (vec != NULL) {
|
||||||
ret = get_errno(safe_preadv(arg1, vec, arg3, arg4, arg5));
|
unsigned long low, high;
|
||||||
|
|
||||||
|
target_to_host_low_high(arg4, arg5, &low, &high);
|
||||||
|
ret = get_errno(safe_preadv(arg1, vec, arg3, low, high));
|
||||||
unlock_iovec(vec, arg2, arg3, 1);
|
unlock_iovec(vec, arg2, arg3, 1);
|
||||||
} else {
|
} else {
|
||||||
ret = -host_to_target_errno(errno);
|
ret = -host_to_target_errno(errno);
|
||||||
@ -10462,7 +10482,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
{
|
{
|
||||||
struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
|
struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
|
||||||
if (vec != NULL) {
|
if (vec != NULL) {
|
||||||
ret = get_errno(safe_pwritev(arg1, vec, arg3, arg4, arg5));
|
unsigned long low, high;
|
||||||
|
|
||||||
|
target_to_host_low_high(arg4, arg5, &low, &high);
|
||||||
|
ret = get_errno(safe_pwritev(arg1, vec, arg3, low, high));
|
||||||
unlock_iovec(vec, arg2, arg3, 0);
|
unlock_iovec(vec, arg2, arg3, 0);
|
||||||
} else {
|
} else {
|
||||||
ret = -host_to_target_errno(errno);
|
ret = -host_to_target_errno(errno);
|
||||||
|
Loading…
Reference in New Issue
Block a user