]> xenbits.xensource.com Git - xen.git/commit
x86/pv: Handle #PF correctly when reading the IO permission bitmap
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 30 Sep 2024 15:20:29 +0000 (16:20 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 1 Oct 2024 13:58:18 +0000 (14:58 +0100)
commit8a6c495d725408d333c1b47bb8af44615a5bfb18
treebecd94ddce18369d3102f66a7596fa29e87016ef
parent7429e1cc071b0e20ea9581da4893fb9b2f6d21d4
x86/pv: Handle #PF correctly when reading the IO permission bitmap

The switch statement in guest_io_okay() is a very expensive way of
pre-initialising x with ~0, and performing a partial read into it.

However, the logic isn't correct either.

In a real TSS, the CPU always reads two bytes (like here), and any TSS limit
violation turns silently into no-access.  But, in-limit accesses trigger #PF
as usual.  AMD document this property explicitly, and while Intel don't (so
far as I can tell), they do behave consistently with AMD.

Switch from __copy_from_guest_offset() to __copy_from_guest_pv(), like
everything else in this file.  This removes code generation setting up
copy_from_user_hvm() (in the likely path even), and safety LFENCEs from
evaluate_nospec().

Change the logic to raise #PF if __copy_from_guest_pv() fails, rather than
disallowing the IO port access.  This brings the behaviour better in line with
normal x86.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/pv/emul-priv-op.c