From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86emul: tighten CLFLUSH emulation Date: Mon, 12 Jan 2015 11:04:42 +0000 Message-ID: <54B3AA4A.50706@citrix.com> References: <54B3927D020000780005374A@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8076946528473521338==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YAcng-0006Tb-DA for xen-devel@lists.xenproject.org; Mon, 12 Jan 2015 11:04:48 +0000 In-Reply-To: <54B3927D020000780005374A@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============8076946528473521338== Content-Type: multipart/alternative; boundary="------------050604030304000908060201" --------------050604030304000908060201 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable On 12/01/15 08:23, Jan Beulich wrote: > While for us it's not as bad as it was for Linux, their commit > 13e457e0ee ("KVM: x86: Emulator does not decode clflush well", by > Nadav Amit ) nevertheless points out two > shortcomings in our code: opcode 0F AE /7 is clflush only when it uses > a memory mode (otherwise it's SFENCE) and when there's no REP prefix > (an operand size prefix is fine, as that's CLFLUSHOPT). > > Signed-off-by: Jan Beulich Acked-by: Andrew Cooper > > --- a/xen/arch/x86/x86_emulate/x86_emulate.c > +++ b/xen/arch/x86/x86_emulate/x86_emulate.c > @@ -4400,7 +4400,9 @@ x86_emulate( > case 0xae: /* Grp15 */ > switch ( modrm_reg & 7 ) > { > - case 7: /* clflush */ > + case 7: /* clflush{,opt} */ > + fail_if(modrm_mod =3D=3D 3); > + fail_if(rep_prefix()); > fail_if(ops->wbinvd =3D=3D NULL); > if ( (rc =3D ops->wbinvd(ctxt)) !=3D 0 ) > goto done; > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------050604030304000908060201 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: 8bit
On 12/01/15 08:23, Jan Beulich wrote:
While for us it's not as bad as it was for Linux, their commit
13e457e0ee ("KVM: x86: Emulator does not decode clflush well", by
Nadav Amit <namit@cs.technion.ac.il>) nevertheless points out two
shortcomings in our code: opcode 0F AE /7 is clflush only when it uses
a memory mode (otherwise it's SFENCE) and when there's no REP prefix
(an operand size prefix is fine, as that's CLFLUSHOPT).

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

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -4400,7 +4400,9 @@ x86_emulate(
     case 0xae: /* Grp15 */
         switch ( modrm_reg & 7 )
         {
-        case 7: /* clflush */
+        case 7: /* clflush{,opt} */
+            fail_if(modrm_mod == 3);
+            fail_if(rep_prefix());
             fail_if(ops->wbinvd == NULL);
             if ( (rc = ops->wbinvd(ctxt)) != 0 )
                 goto done;





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

--------------050604030304000908060201-- --===============8076946528473521338== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============8076946528473521338==--