qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/xtensa/tags/20180409-xtensa' into staging

Fix file offset for preadv/pwritev linux-user syscalls.

# gpg: Signature made Tue 10 Apr 2018 03:04:24 BST
# gpg: using RSA key 51F9CC91F83FA044
# gpg: Good signature from "Max Filippov <filippov@cadence.com>"
# gpg: aka "Max Filippov <max.filippov@cogentembedded.com>"
# gpg: aka "Max Filippov <jcmvbkbc@gmail.com>"
# Primary key fingerprint: 2B67 854B 98E5 327D CDEB 17D8 51F9 CC91 F83F A044

* remotes/xtensa/tags/20180409-xtensa:
linux-user: fix preadv/pwritev offsets

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+25 -2
+25 -2
linux-user/syscall.c
··· 3386 3386 return ret; 3387 3387 } 3388 3388 3389 + /* Convert target low/high pair representing file offset into the host 3390 + * low/high pair. This function doesn't handle offsets bigger than 64 bits 3391 + * as the kernel doesn't handle them either. 3392 + */ 3393 + static void target_to_host_low_high(abi_ulong tlow, 3394 + abi_ulong thigh, 3395 + unsigned long *hlow, 3396 + unsigned long *hhigh) 3397 + { 3398 + uint64_t off = tlow | 3399 + ((unsigned long long)thigh << TARGET_LONG_BITS / 2) << 3400 + TARGET_LONG_BITS / 2; 3401 + 3402 + *hlow = off; 3403 + *hhigh = (off >> HOST_LONG_BITS / 2) >> HOST_LONG_BITS / 2; 3404 + } 3405 + 3389 3406 static struct iovec *lock_iovec(int type, abi_ulong target_addr, 3390 3407 abi_ulong count, int copy) 3391 3408 { ··· 10452 10469 { 10453 10470 struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); 10454 10471 if (vec != NULL) { 10455 - ret = get_errno(safe_preadv(arg1, vec, arg3, arg4, arg5)); 10472 + unsigned long low, high; 10473 + 10474 + target_to_host_low_high(arg4, arg5, &low, &high); 10475 + ret = get_errno(safe_preadv(arg1, vec, arg3, low, high)); 10456 10476 unlock_iovec(vec, arg2, arg3, 1); 10457 10477 } else { 10458 10478 ret = -host_to_target_errno(errno); ··· 10465 10485 { 10466 10486 struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); 10467 10487 if (vec != NULL) { 10468 - ret = get_errno(safe_pwritev(arg1, vec, arg3, arg4, arg5)); 10488 + unsigned long low, high; 10489 + 10490 + target_to_host_low_high(arg4, arg5, &low, &high); 10491 + ret = get_errno(safe_pwritev(arg1, vec, arg3, low, high)); 10469 10492 unlock_iovec(vec, arg2, arg3, 0); 10470 10493 } else { 10471 10494 ret = -host_to_target_errno(errno);