x86/emulation: honor failure of in_longmode()
PATCH 1/1 x86/emulation: honor failure of in_longmode()
Failure of in_longmode() shouldn't be treated the same as the function returning 'true'.
Besides that, the function should always return false on 32-bits, eliminating the possibility for it failing there altogether.
Signed-off-by Jan Beulich <[email protected]>
xen/arch/x86/x86_emulate/x86_emulate.c +12 -2
@@ -958,6 +958,7 @@ in_longmode(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) { +#ifdef __x86_64__ uint64_t efer;if (ops->read_msr ==NULL )
@@ -965,6 +966,9 @@ in_longmode( ops->read_msr (MSR_EFER , &efer, ctxt);return !!(efer &EFER_LMA ); +#else +return 0 ; +#endif } static int
@@ -3605,7 +3609,10 @@ x86_emulate( ss.attr.bytes =0xc93 ;/* G+DB+P+S+Data */ #ifdef __x86_64__ -if (in_longmode (ctxt, ops) ) + rc =in_longmode (ctxt, ops); +if ( rc <0 ) + goto cannot_emulate; +if ( rc ) { cs.attr.fields.db =0 ; cs.attr.fields.l =1 ;
@@ -3777,7 +3784,10 @@ x86_emulate( ss.limit = ~0u ;/* 4GB limit */ ss.attr.bytes =0xc93 ;/* G+DB+P+S+Data */ -if (in_longmode (ctxt, ops) ) + rc =in_longmode (ctxt, ops); +if ( rc <0 ) + goto cannot_emulate; +if ( rc ) { cs.attr.fields.db =0 ; cs.attr.fields.l =1 ;