All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Paul Durrant <paul.durrant@citrix.com>
Subject: [PATCH] x86/Viridian: don't depend on undefined register state
Date: Fri, 14 Oct 2016 03:37:35 -0600	[thread overview]
Message-ID: <5800C37F02000078001174F3@prv-mh.provo.novell.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]

The high halves of all GPRs are undefined in 32-bit and compat modes,
and the dependency is being obfuscated by our structure field names not
matching architectural register names (it was actually while putting
together a patch to correct this when I noticed the issue here).

For consistency also use the architecturally correct names on the
output side.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -667,9 +667,9 @@ int viridian_hypercall(struct cpu_user_r
         output_params_gpa = regs->r8;
         break;
     case 4:
-        input.raw = ((uint64_t)regs->edx << 32) | regs->eax;
-        input_params_gpa = ((uint64_t)regs->ebx << 32) | regs->ecx;
-        output_params_gpa = ((uint64_t)regs->edi << 32) | regs->esi;
+        input.raw = (regs->rdx << 32) | regs->_eax;
+        input_params_gpa = (regs->rbx << 32) | regs->_ecx;
+        output_params_gpa = (regs->rdi << 32) | regs->_esi;
         break;
     default:
         goto out;
@@ -770,8 +770,8 @@ out:
         regs->rax = output.raw;
         break;
     default:
-        regs->edx = output.raw >> 32;
-        regs->eax = output.raw;
+        regs->rdx = output.raw >> 32;
+        regs->rax = (uint32_t)output.raw;
         break;
     }
 



[-- Attachment #2: x86-Viridian-regs.patch --]
[-- Type: text/plain, Size: 1387 bytes --]

x86/Viridian: don't depend on undefined register state

The high halves of all GPRs are undefined in 32-bit and compat modes,
and the dependency is being obfuscated by our structure field names not
matching architectural register names (it was actually while putting
together a patch to correct this when I noticed the issue here).

For consistency also use the architecturally correct names on the
output side.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -667,9 +667,9 @@ int viridian_hypercall(struct cpu_user_r
         output_params_gpa = regs->r8;
         break;
     case 4:
-        input.raw = ((uint64_t)regs->edx << 32) | regs->eax;
-        input_params_gpa = ((uint64_t)regs->ebx << 32) | regs->ecx;
-        output_params_gpa = ((uint64_t)regs->edi << 32) | regs->esi;
+        input.raw = (regs->rdx << 32) | regs->_eax;
+        input_params_gpa = (regs->rbx << 32) | regs->_ecx;
+        output_params_gpa = (regs->rdi << 32) | regs->_esi;
         break;
     default:
         goto out;
@@ -770,8 +770,8 @@ out:
         regs->rax = output.raw;
         break;
     default:
-        regs->edx = output.raw >> 32;
-        regs->eax = output.raw;
+        regs->rdx = output.raw >> 32;
+        regs->rax = (uint32_t)output.raw;
         break;
     }
 

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2016-10-14  9:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14  9:37 Jan Beulich [this message]
2016-10-14  9:52 ` [PATCH] x86/Viridian: don't depend on undefined register state Andrew Cooper
2016-10-14 10:53 ` Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5800C37F02000078001174F3@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=paul.durrant@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.