]> xenbits.xensource.com Git - people/pauldu/xen.git/commitdiff
viridian: don't blindly write to 32-bit registers is 'mode' is invalid
authorPaul Durrant <pdurrant@amazon.com>
Thu, 19 Nov 2020 16:50:24 +0000 (16:50 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Fri, 20 Nov 2020 09:30:03 +0000 (09:30 +0000)
If hvm_guest_x86_mode() returns something other than 8 or 4 then
viridian_hypercall() will return immediately but, on the way out, will write
back status as if 'mode' was 4. This patch simply makes it leave the registers
alone.

NOTE: The formatting of the 'out' label and the switch statement are also
      adjusted as per CODING_STYLE.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
Cc: Wei Liu <wl@xen.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>
v2:
 - New in v2

xen/arch/x86/hvm/viridian/viridian.c

index dc7183a54627dc5dbef9f3a9ba1962a24c1860d9..54035f75cb1adb196bf5696cb32ba4d4d34b2db5 100644 (file)
@@ -692,13 +692,14 @@ int viridian_hypercall(struct cpu_user_regs *regs)
         break;
     }
 
-out:
+ out:
     output.result = status;
     switch (mode) {
     case 8:
         regs->rax = output.raw;
         break;
-    default:
+
+    case 4:
         regs->rdx = output.raw >> 32;
         regs->rax = (uint32_t)output.raw;
         break;