x86/emul: Prepare to allow use of system segments for memory references
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 30 Jun 2016 22:55:33 +0000 (23:55 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 2 Dec 2016 17:23:02 +0000 (17:23 +0000)
commitc785f759718b0a86a0b1332901d1ee63c9e67c77
treeaa165d7b3e478a92f52c30a607128840e0a76c96
parent28ef9ccaa91cf945c052cdd9364be0c40f7bce4a
x86/emul: Prepare to allow use of system segments for memory references

All system segments (GDT/IDT/LDT and TR) describe a linear address and limit,
and act similarly to user segments.  However all current uses of these tables
in the emulator opencode the address calculations and limit checks.  In
particular, no care is taken for access which wrap around the 4GB or
non-canonical boundaries.

Alter hvm_virtual_to_linear_addr() to cope with performing segmentation checks
on system segments.  This involves restricting access checks in the 32bit case
to user segments only, and adding presence/limit checks in the 64bit case.

When suffering a segmentation fault for a system segments, return
X86EMUL_EXCEPTION but leave the fault injection to the caller.  The fault type
depends on the higher level action being performed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <JBeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/mm/shadow/common.c
xen/arch/x86/x86_emulate/x86_emulate.h