diff mbox

[2/2] x86emul: in_longmode() should not ignore ->read_msr() errors

Message ID 5834625B0200007800120D64@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich Nov. 22, 2016, 2:20 p.m. UTC
Suggested-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
x86emul: in_longmode() should not ignore ->read_msr() errors

Suggested-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1296,10 +1296,10 @@ in_longmode(
 {
     uint64_t efer;
 
-    if (ops->read_msr == NULL)
+    if ( !ops->read_msr ||
+         unlikely(ops->read_msr(MSR_EFER, &efer, ctxt) != X86EMUL_OKAY) )
         return -1;
 
-    ops->read_msr(MSR_EFER, &efer, ctxt);
     return !!(efer & EFER_LMA);
 }

Comments

Andrew Cooper Nov. 22, 2016, 2:25 p.m. UTC | #1
On 22/11/16 14:20, Jan Beulich wrote:
> Suggested-by: George Dunlap <george.dunlap@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Possibly worth nothing in the commit message that the current
implementation of this hook when present never fails with MSR_EFER?

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

>
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -1296,10 +1296,10 @@ in_longmode(
>  {
>      uint64_t efer;
>  
> -    if (ops->read_msr == NULL)
> +    if ( !ops->read_msr ||
> +         unlikely(ops->read_msr(MSR_EFER, &efer, ctxt) != X86EMUL_OKAY) )
>          return -1;
>  
> -    ops->read_msr(MSR_EFER, &efer, ctxt);
>      return !!(efer & EFER_LMA);
>  }
>  
>
>
>
diff mbox

Patch

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1296,10 +1296,10 @@  in_longmode(
 {
     uint64_t efer;
 
-    if (ops->read_msr == NULL)
+    if ( !ops->read_msr ||
+         unlikely(ops->read_msr(MSR_EFER, &efer, ctxt) != X86EMUL_OKAY) )
         return -1;
 
-    ops->read_msr(MSR_EFER, &efer, ctxt);
     return !!(efer & EFER_LMA);
 }