xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] hvm/fep: Allow testing of instructions crossing the -1 -> 0 virtual boundary
@ 2016-09-08 14:11 Andrew Cooper
  2016-09-08 14:11 ` [PATCH 2/4] x86/segment: Bounds check accesses to emulation ctxt->seg_reg[] Andrew Cooper
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andrew Cooper @ 2016-09-08 14:11 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper

The Force Emulation Prefix is named to follow its PV counterpart for cpuid or
rdtsc, but isn't really an instruction prefix.  It behaves as a break-out into
Xen, with the purpose of emulating the next instruction in the current state.

It is important to be able to test legal situations which occur in real
hardware, including instruction which cross certain boundaries, and
instructions starting at 0.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 787f055..596a903 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3981,15 +3981,8 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
         unsigned long addr;
         char sig[5]; /* ud2; .ascii "xen" */
 
-        /*
-         * Note that in the call below we pass 1 more than the signature
-         * size, to guard against the overall code sequence wrapping between
-         * "prefix" and actual instruction. There's necessarily at least one
-         * actual instruction byte required, so this won't cause failure on
-         * legitimate uses.
-         */
         if ( hvm_virtual_to_linear_addr(x86_seg_cs, cs, regs->eip,
-                                        sizeof(sig) + 1, hvm_access_insn_fetch,
+                                        sizeof(sig), hvm_access_insn_fetch,
                                         (hvm_long_mode_enabled(cur) &&
                                          cs->attr.fields.l) ? 64 :
                                         cs->attr.fields.db ? 32 : 16, &addr) &&
@@ -3999,6 +3992,11 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
         {
             regs->eip += sizeof(sig);
             regs->eflags &= ~X86_EFLAGS_RF;
+
+            /* Zero the upper 32 bits of %rip if not in long mode. */
+            if ( !(hvm_long_mode_enabled(cur) && cs->attr.fields.l) )
+                regs->eip = regs->_eip;
+
             add_taint(TAINT_HVM_FEP);
         }
     }
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-09-08 14:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-08 14:11 [PATCH 1/4] hvm/fep: Allow testing of instructions crossing the -1 -> 0 virtual boundary Andrew Cooper
2016-09-08 14:11 ` [PATCH 2/4] x86/segment: Bounds check accesses to emulation ctxt->seg_reg[] Andrew Cooper
2016-09-08 14:11 ` [PATCH 3/4] x86/hvm: Optimise segment accesses in hvmemul_write_segment() Andrew Cooper
2016-09-08 14:26   ` Paul Durrant
2016-09-08 14:32   ` Jan Beulich
2016-09-08 14:11 ` [PATCH 4/4] x86/hvm: Perform a user instruction fetch for a FEP in userspace Andrew Cooper
2016-09-08 14:28 ` [PATCH 1/4] hvm/fep: Allow testing of instructions crossing the -1 -> 0 virtual boundary Jan Beulich
2016-09-08 14:40   ` Andrew Cooper

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).