[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86emul: avoid using _PRE_EFLAGS() in a few cases


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 2 Jun 2021 16:37:38 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Op0EG6H/pxKguEBh5YGLdaL85pglCTLCDsjf1WPZfrM=; b=MPQt4hjwkmgPcc/6CZPI+TrpzGB6SZY21pXCKZEDn+sub6J8BhLu3lh6Bd7Q2LCbzVMIv37Y4OeodxhfetbVBux77yNRCd2HlZQ5psoUIAK5Ox4vjG/ZYPpO9GFW7P9yti1m6vrQdg47L8MneSqyDivZJ0ECGQU2/EG4CC+ozc9gScndsyS2ra+FSXo//XmFm5Ev21SE4fPsavOwPP4Tm5+S3FIoLndHO+8e7kmfs+UcZwd26DhVJwgn8LtVtcQiFMSSTohkJ3Qnoz1ZkZAFMoWoAZzhjEE1fda2moHIiB1MRX/rBBNnTfc3ie96gN1oKVmH02VRSR1PK4KxzYNxuQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTBBdDpkZrS2flw96OEK4mFacDj/zLTCvdz+nt9j4x5cQVJHim3Ua8Zz9nQi5RdHzmiGHmglolySjRIH9K4dShB7rCpg+Fg9Etyr/3hiRJkWdDSgQop5xhs3FvEGsUTd0xFwNrOGJMJSeUejV5HXmd1eNkkN84AWiMOdzKMgOLgHVmVGdLxc5agSkffbaTJei0zscli0/HsNdLjk7CkOBsqVo7a4X8z/eWYS1Fyct28rsYy3xH/6tHhq2KYc4bo4rFj01VlP5SGtzxsc2rz/Oaxzij4iDNgPHp7gT4quWHiRtYOqtAkPazdalHevDO5ZYVOh/aeNDwWn6yyfZ0E21A==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 02 Jun 2021 14:37:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The macro expanding to quite a few insns, replace its use by simply
clearing the status flags when the to be executed insn doesn't depend
on their initial state, in cases where this is easily possible. (There
are more cases where the uses are hidden inside macros, and where some
of the users of the macros want guest flags put in place before running
the insn, i.e. the macros can't be updated as easily.)

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6863,7 +6863,8 @@ x86_emulate(
         }
         opc[2] = 0xc3;
 
-        invoke_stub(_PRE_EFLAGS("[eflags]", "[mask]", "[tmp]"),
+        _regs.eflags &= ~EFLAGS_MASK;
+        invoke_stub("",
                     _POST_EFLAGS("[eflags]", "[mask]", "[tmp]"),
                     [eflags] "+g" (_regs.eflags),
                     [tmp] "=&r" (dummy), "+m" (*mmvalp)
@@ -8111,7 +8112,8 @@ x86_emulate(
         opc[2] = 0xc3;
 
         copy_VEX(opc, vex);
-        invoke_stub(_PRE_EFLAGS("[eflags]", "[mask]", "[tmp]"),
+        _regs.eflags &= ~EFLAGS_MASK;
+        invoke_stub("",
                     _POST_EFLAGS("[eflags]", "[mask]", "[tmp]"),
                     [eflags] "+g" (_regs.eflags),
                     "=a" (dst.val), [tmp] "=&r" (dummy)
@@ -11698,13 +11700,14 @@ int x86_emul_rmw(
         break;
 
     case rmw_xadd:
+        *eflags &= ~EFLAGS_MASK;
         switch ( state->op_bytes )
         {
             unsigned long dummy;
 
 #define XADD(sz, cst, mod) \
         case sz: \
-            asm ( _PRE_EFLAGS("[efl]", "[msk]", "[tmp]") \
+            asm ( "" \
                   COND_LOCK(xadd) " %"#mod"[reg], %[mem]; " \
                   _POST_EFLAGS("[efl]", "[msk]", "[tmp]") \
                   : [reg] "+" #cst (state->ea.val), \




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.