]> xenbits.xensource.com Git - xen.git/commit
x86/PV: simplify (and thus correct) guest accessor functions
authorJan Beulich <jbeulich@suse.com>
Tue, 29 Oct 2024 15:26:30 +0000 (16:26 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 29 Oct 2024 15:26:30 +0000 (16:26 +0100)
commit950e57e0ce74f8284b8aa3f34f15f38c70dbc9ae
treecfc3e2a60f1151af0ddd7eba9fb4b9b861744b85
parent84d8fbd883882b6c3ca3e86261bcbd1d3bc2df70
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