From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Wei Liu <wei.liu2@citrix.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH for-4.8] x86/svm: Fix svm_nextrip_insn_length() when crossing the virtual boundary to 0
Date: Wed, 16 Nov 2016 10:51:51 +0000 [thread overview]
Message-ID: <1479293511-32420-1-git-send-email-andrew.cooper3@citrix.com> (raw)
vmcb->nextrip can legitimately be less than vmcb->rip when execution wraps
back around to 0. Instead, complain if the reported length is greater than 15
and use x86_decode_insn() as a fallback.
While making changes here, fix two whitespace issues with the case labels.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/hvm/svm/emulate.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/emulate.c b/xen/arch/x86/hvm/svm/emulate.c
index 36585b0..ca670bf 100644
--- a/xen/arch/x86/hvm/svm/emulate.c
+++ b/xen/arch/x86/hvm/svm/emulate.c
@@ -30,18 +30,18 @@ static unsigned long svm_nextrip_insn_length(struct vcpu *v)
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
- if ( !cpu_has_svm_nrips || (vmcb->nextrip <= vmcb->rip) )
+ if ( !cpu_has_svm_nrips )
return 0;
#ifndef NDEBUG
switch ( vmcb->exitcode )
{
- case VMEXIT_CR0_READ... VMEXIT_DR15_WRITE:
+ case VMEXIT_CR0_READ ... VMEXIT_DR15_WRITE:
/* faults due to instruction intercepts */
/* (exitcodes 84-95) are reserved */
case VMEXIT_IDTR_READ ... VMEXIT_TR_WRITE:
case VMEXIT_RDTSC ... VMEXIT_MSR:
- case VMEXIT_VMRUN ... VMEXIT_XSETBV:
+ case VMEXIT_VMRUN ... VMEXIT_XSETBV:
/* ...and the rest of the #VMEXITs */
case VMEXIT_CR0_SEL_WRITE:
case VMEXIT_EXCEPTION_BP:
@@ -88,7 +88,8 @@ int __get_instruction_length_from_list(struct vcpu *v,
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
struct hvm_emulate_ctxt ctxt;
struct x86_emulate_state *state;
- unsigned int inst_len, j, modrm_rm, modrm_reg;
+ unsigned long inst_len, j;
+ unsigned int modrm_rm, modrm_reg;
int modrm_mod;
/*
@@ -96,7 +97,9 @@ int __get_instruction_length_from_list(struct vcpu *v,
* hardware.
*/
#ifdef NDEBUG
- if ( (inst_len = svm_nextrip_insn_length(v)) != 0 )
+ if ( (inst_len = svm_nextrip_insn_length(v)) > MAX_INST_LEN )
+ gprintk(XENLOG_WARNING, "NRip reported insn_len %lu\n", insn_len);
+ else if ( insn_len != 0 )
return inst_len;
if ( vmcb->exitcode == VMEXIT_IOIO )
@@ -120,7 +123,7 @@ int __get_instruction_length_from_list(struct vcpu *v,
j = svm_nextrip_insn_length(v);
if ( j && j != inst_len )
{
- gprintk(XENLOG_WARNING, "insn-len[%02x]=%u (exp %u)\n",
+ gprintk(XENLOG_WARNING, "insn-len[%02x]=%lu (exp %lu)\n",
ctxt.ctxt.opcode, inst_len, j);
return j;
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2016-11-16 10:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 10:51 Andrew Cooper [this message]
2016-11-16 10:56 ` [PATCH for-4.8] x86/svm: Fix svm_nextrip_insn_length() when crossing the virtual boundary to 0 Jan Beulich
2016-11-16 14:52 ` Wei Liu
2016-11-21 10:40 ` Andrew Cooper
2016-11-21 13:38 ` Boris Ostrovsky
2016-11-21 13:53 ` Andrew Cooper
2016-11-21 14:00 ` Boris Ostrovsky
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=1479293511-32420-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).