]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commit
x86/PV: simplify (and thus correct) guest accessor functions
authorJan Beulich <jbeulich@suse.com>
Tue, 29 Oct 2024 15:37:12 +0000 (16:37 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 29 Oct 2024 15:37:12 +0000 (16:37 +0100)
commit0902958b51a6135ce43bee2c9eadd43f481e311d
tree4ec5c542a3121086cf3d87eec464f22a0fad63eb
parenta897560155a58b36bec721eb3b994a62a0432996
x86/PV: simplify (and thus correct) guest accessor functions

Taking a fault on a non-byte-granular insn means that the "number of
bytes not handled" return value would need extra care in calculating, if
we want callers to be able to derive e.g. exception context (to be
injected to the guest) - CR2 for #PF in particular - from the value. To
simplify things rather than complicating them, reduce inline assembly to
just byte-granular string insns. On recent CPUs that's also supposed to
be more efficient anyway.

For singular element accessors, however, alignment checks are added,
hence slightly complicating the code. Misaligned (user) buffer accesses
will now be forwarded to copy_{from,to}_guest_ll().

Naturally copy_{from,to}_unsafe_ll() accessors end up being adjusted the
same way, as they're produced by mere re-processing of the same code.
Otoh copy_{from,to}_unsafe() aren't similarly adjusted, but have their
comments made match reality; down the road we may want to change their
return types, e.g. to bool.

Fixes: 76974398a63c ("Added user-memory accessing functionality for x86_64")
Fixes: 7b8c36701d26 ("Introduce clear_user and clear_guest")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 67a8e5721e1ea9c28526883036bf08fb2e8a8c9c
master date: 2024-10-01 09:44:55 +0200
xen/arch/x86/include/asm/uaccess.h
xen/arch/x86/usercopy.c