From 12bc22f79117dfae5e59382cdda6b8b6b70a7554 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 2 Nov 2016 14:43:48 +0000 Subject: [PATCH] x86/emul: Reject LGDT/LIDT attempts with non-canonical base addresses No sane OS would deliberately try this, but make Xen's emulation match real hardware by delivering #GP(0), rather than suffering a VMEntry failure. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Release-acked-by: Wei Liu --- xen/arch/x86/x86_emulate/x86_emulate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 7a707dcda3..58e1ed8e87 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -4443,6 +4443,7 @@ x86_emulate( (rc = read_ulong(ea.mem.seg, ea.mem.off+2, &base, mode_64bit() ? 8 : 4, ctxt, ops)) ) goto done; + generate_exception_if(!is_canonical_address(base), EXC_GP, 0); sreg.base = base; sreg.limit = limit; if ( op_bytes == 2 ) -- 2.30.2