From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 2/2] x86/HVM: re-order operations in hvm_ud_intercept()
Date: Wed, 08 Jun 2016 07:43:39 -0600 [thread overview]
Message-ID: <57583D2B02000078000F31CE@prv-mh.provo.novell.com> (raw)
In-Reply-To: <57583B4E02000078000F3198@prv-mh.provo.novell.com>
[-- Attachment #1: Type: text/plain, Size: 2020 bytes --]
Don't fetch CS explicitly, leverage the fact that hvm_emulate_prepare()
already does (and that hvm_virtual_to_linear_addr() doesn't alter it).
At once increase the length passed to hvm_virtual_to_linear_addr() by
one: There definitely needs to be at least one more opcode byte, and we
can avoid missing a wraparound case this way.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3834,19 +3834,20 @@ void hvm_ud_intercept(struct cpu_user_re
{
struct hvm_emulate_ctxt ctxt;
+ hvm_emulate_prepare(&ctxt, regs);
+
if ( opt_hvm_fep )
{
struct vcpu *cur = current;
- struct segment_register cs;
+ const struct segment_register *cs = &ctxt.seg_reg[x86_seg_cs];
unsigned long addr;
char sig[5]; /* ud2; .ascii "xen" */
- hvm_get_segment_register(cur, x86_seg_cs, &cs);
- if ( hvm_virtual_to_linear_addr(x86_seg_cs, &cs, regs->eip,
- sizeof(sig), hvm_access_insn_fetch,
+ if ( hvm_virtual_to_linear_addr(x86_seg_cs, cs, regs->eip,
+ sizeof(sig) + 1, hvm_access_insn_fetch,
(hvm_long_mode_enabled(cur) &&
- cs.attr.fields.l) ? 64 :
- cs.attr.fields.db ? 32 : 16, &addr) &&
+ cs->attr.fields.l) ? 64 :
+ cs->attr.fields.db ? 32 : 16, &addr) &&
(hvm_fetch_from_guest_virt_nofault(sig, addr, sizeof(sig),
0) == HVMCOPY_okay) &&
(memcmp(sig, "\xf\xbxen", sizeof(sig)) == 0) )
@@ -3856,8 +3857,6 @@ void hvm_ud_intercept(struct cpu_user_re
}
}
- hvm_emulate_prepare(&ctxt, regs);
-
switch ( hvm_emulate_one(&ctxt) )
{
case X86EMUL_UNHANDLEABLE:
[-- Attachment #2: x86-HVM-fep-reorder.patch --]
[-- Type: text/plain, Size: 2068 bytes --]
x86/HVM: re-order operations in hvm_ud_intercept()
Don't fetch CS explicitly, leverage the fact that hvm_emulate_prepare()
already does (and that hvm_virtual_to_linear_addr() doesn't alter it).
At once increase the length passed to hvm_virtual_to_linear_addr() by
one: There definitely needs to be at least one more opcode byte, and we
can avoid missing a wraparound case this way.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3834,19 +3834,20 @@ void hvm_ud_intercept(struct cpu_user_re
{
struct hvm_emulate_ctxt ctxt;
+ hvm_emulate_prepare(&ctxt, regs);
+
if ( opt_hvm_fep )
{
struct vcpu *cur = current;
- struct segment_register cs;
+ const struct segment_register *cs = &ctxt.seg_reg[x86_seg_cs];
unsigned long addr;
char sig[5]; /* ud2; .ascii "xen" */
- hvm_get_segment_register(cur, x86_seg_cs, &cs);
- if ( hvm_virtual_to_linear_addr(x86_seg_cs, &cs, regs->eip,
- sizeof(sig), hvm_access_insn_fetch,
+ if ( hvm_virtual_to_linear_addr(x86_seg_cs, cs, regs->eip,
+ sizeof(sig) + 1, hvm_access_insn_fetch,
(hvm_long_mode_enabled(cur) &&
- cs.attr.fields.l) ? 64 :
- cs.attr.fields.db ? 32 : 16, &addr) &&
+ cs->attr.fields.l) ? 64 :
+ cs->attr.fields.db ? 32 : 16, &addr) &&
(hvm_fetch_from_guest_virt_nofault(sig, addr, sizeof(sig),
0) == HVMCOPY_okay) &&
(memcmp(sig, "\xf\xbxen", sizeof(sig)) == 0) )
@@ -3856,8 +3857,6 @@ void hvm_ud_intercept(struct cpu_user_re
}
}
- hvm_emulate_prepare(&ctxt, regs);
-
switch ( hvm_emulate_one(&ctxt) )
{
case X86EMUL_UNHANDLEABLE:
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-08 13:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 13:35 [PATCH] x86/HVM: mis adjustments Jan Beulich
2016-06-08 13:42 ` [PATCH 1/2] x86/HVM: constify hvm_virtual_to_linear_addr()'s segment register parameter Jan Beulich
2016-06-09 11:25 ` Andrew Cooper
2016-06-08 13:43 ` Jan Beulich [this message]
2016-06-09 11:34 ` [PATCH 2/2] x86/HVM: re-order operations in hvm_ud_intercept() Andrew Cooper
2016-06-09 12:31 ` Jan Beulich
2016-06-09 14:06 ` Andrew Cooper
2016-06-09 14:13 ` Jan Beulich
2016-06-09 14:27 ` Andrew Cooper
2016-06-09 15:05 ` Jan Beulich
2016-06-17 8:19 ` Ping: " Jan Beulich
2016-06-17 9:37 ` Andrew Cooper
2016-06-17 10:01 ` Jan Beulich
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=57583D2B02000078000F31CE@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@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 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).