mirror of https://github.com/xemu-project/xemu.git
Fix file offset for preadv/pwritev linux-user syscalls.
-----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEEK2eFS5jlMn3N6xfYUfnMkfg/oEQFAlrMG6gTHGpjbXZia2Jj QGdtYWlsLmNvbQAKCRBR+cyR+D+gRJe7D/9S8cCUW1kDWE9AkFgXgLljaQ/RbnAn wNwFbpe1w/EmrUXTHUZwEuky3IYdjkmhUUR4sRcE0z3RJY2B+4JAz8vB4BpG25dJ 0e8SyC1HDWI8G3qLATs1S4sVN6ZBUdUjm2R9rDGAUc6tqVkJ0exn4dUD6Xdm2K6P vYhdGkI9WuXTPdnq3ZEEaEq1fEfWXff84hNVEr/QOP4vqm/Ycx2CMFWf543Ayog6 5TKB5S3ucF1qt/HXRE1SgklDzTwo+FqUQTSjtdk1uGnIEo/3gydTntFdmRyWQg1+ QKE5CPE0MT3gwgQc3PoEBKj0TmClv9qJHgSYgpM3PxfA52Q5+ccDv31U2kENUBgs PRqoB9Enrg7gvGhnhgbT7BcM/2eXcDOiANO4nniyneJb7Ua0JAGWS5q/B1QuZM/K hqFAiO/r3Fgq/lSX2hXyRq5sE8vBbqTUafA1ZVGcpmJJHfnguuCM19wSsEIA9l85 pIEoZ5xDHSkFuZgY/r0JqilUtJKayUn4tScvMEQ8csXO1sryNO1nNrKprIXPXvgr ZclCHu2nE3L476oAqJfZNXca3e2WBXe51i4nwBsBGPl1CD2kEMXYU/BNfRAi08ae +Cv8UwUWIaCRhFE6ZT/oh46PszW16YpxUyPLJ8bZWhmPFWN0ofI1E6tBJeksav5e WwIeC/ygYG6njg== =rvKH -----END PGP SIGNATURE----- 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>
This commit is contained in:
commit
fb4fe32d5b
|
@ -3386,6 +3386,23 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
|
|||
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,
|
||||
abi_ulong count, int copy)
|
||||
{
|
||||
|
@ -10452,7 +10469,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|||
{
|
||||
struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
|
||||
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);
|
||||
} else {
|
||||
ret = -host_to_target_errno(errno);
|
||||
|
@ -10465,7 +10485,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|||
{
|
||||
struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
|
||||
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);
|
||||
} else {
|
||||
ret = -host_to_target_errno(errno);
|
||||
|
|
Loading…
Reference in New Issue