mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
x86/HVM: fail virt-to-linear conversion for insn fetches from non-code segments
Just like (in protected mode) reads may not go to exec-only segments and writes may not go to non-writable ones, insn fetches may not access data segments. Fixes:623e837167("hvm: Support hardware task switching") Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> master commit:311297f421master date: 2021-12-06 14:15:05 +0100
This commit is contained in:
1 parent
fb91773853
commit
d8cf50574b
1 file changed
+10
@@ -2530,6 +2530,9 @@ bool_t hvm_virtual_to_linear_addr(
|
||||
*/
|
||||
ASSERT(seg < x86_seg_none);
|
||||
|
||||
/* However, check that insn fetches only ever specify CS. */
|
||||
ASSERT(access_type != hvm_access_insn_fetch || seg == x86_seg_cs);
|
||||
|
||||
if ( !(curr->arch.hvm.guest_cr[0] & X86_CR0_PE) )
|
||||
{
|
||||
/*
|
||||
@@ -2594,10 +2597,17 @@ bool_t hvm_virtual_to_linear_addr(
|
||||
if ( (reg->type & 0xa) == 0x8 )
|
||||
goto out; /* execute-only code segment */
|
||||
break;
|
||||
|
||||
case hvm_access_write:
|
||||
if ( (reg->type & 0xa) != 0x2 )
|
||||
goto out; /* not a writable data segment */
|
||||
break;
|
||||
|
||||
case hvm_access_insn_fetch:
|
||||
if ( !(reg->type & 0x8) )
|
||||
goto out; /* not a code segment */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||