From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tamas K Lengyel Subject: Re: [PATCH V2] vm_event: Allow subscribing to write events for specific MSR-s Date: Wed, 13 Apr 2016 08:50:51 -0600 Message-ID: References: <1460524280-6902-1-git-send-email-rcojocaru@bitdefender.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1891585083524580290==" Return-path: In-Reply-To: <1460524280-6902-1-git-send-email-rcojocaru@bitdefender.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Razvan Cojocaru Cc: Kevin Tian , "wei.liu2@citrix.com" , Jun Nakajima , Andrew Cooper , Ian Jackson , Xen-devel , Jan Beulich , Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============1891585083524580290== Content-Type: multipart/alternative; boundary=001a11471aee73f83505305ee7e5 --001a11471aee73f83505305ee7e5 Content-Type: text/plain; charset=UTF-8 > diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c > index 1fec412..4c96968 100644 > --- a/xen/arch/x86/monitor.c > +++ b/xen/arch/x86/monitor.c > @@ -22,6 +22,58 @@ > #include > #include > > +static int arch_monitor_enable_msr(struct domain *d, u32 msr) > IMHO there is no need to prepend the function names here with arch_ as these are x86 specific so there never will be ARM equivalent. > +{ > + if ( !d->arch.monitor_msr_bitmap ) > + return -EINVAL; > + > + if ( msr <= 0x1fff ) > + set_bit(msr, d->arch.monitor_msr_bitmap + 0x000/BYTES_PER_LONG); > + else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) ) > + { > + msr &= 0x1fff; > + set_bit(msr, d->arch.monitor_msr_bitmap + 0x400/BYTES_PER_LONG); > + } > + > + hvm_enable_msr_interception(d, msr); > + > + return 0; > +} > + > +static int arch_monitor_disable_msr(struct domain *d, u32 msr) > +{ > + if ( !d->arch.monitor_msr_bitmap ) > + return -EINVAL; > + > + if ( msr <= 0x1fff ) > + clear_bit(msr, d->arch.monitor_msr_bitmap + 0x000/BYTES_PER_LONG); > + else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) ) > + { > + msr &= 0x1fff; > + clear_bit(msr, d->arch.monitor_msr_bitmap + 0x400/BYTES_PER_LONG); > + } > + > + return 0; > +} > + > +bool_t arch_monitor_is_msr_enabled(const struct domain *d, u32 msr) > +{ > + bool_t rc = 0; > + > + if ( !d->arch.monitor_msr_bitmap ) > + return 0; > + > + if ( msr <= 0x1fff ) > + rc = test_bit(msr, d->arch.monitor_msr_bitmap + > 0x000/BYTES_PER_LONG); > + else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) ) > + { > + msr &= 0x1fff; > + rc = test_bit(msr, d->arch.monitor_msr_bitmap + > 0x400/BYTES_PER_LONG); > + } > + > + return rc; > +} > + > int arch_monitor_domctl_event(struct domain *d, > struct xen_domctl_monitor_op *mop) > { --001a11471aee73f83505305ee7e5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

=
diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index 1fec412..4c96968 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -22,6 +22,58 @@
=C2=A0#include <asm/monitor.h>
=C2=A0#include <public/vm_event.h>

+static int arch_monitor_enable_msr(struct domain *d, u32 msr)

IMHO there is no need to prepend the function names= here with arch_ as these are x86 specific so there never will be ARM equiv= alent.
=C2=A0
+{
+=C2=A0 =C2=A0 if ( !d->arch.monitor_msr_bitmap )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EINVAL;
+
+=C2=A0 =C2=A0 if ( msr <=3D 0x1fff )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 set_bit(msr, d->arch.monitor_msr_bitmap + 0= x000/BYTES_PER_LONG);
+=C2=A0 =C2=A0 else if ( (msr >=3D 0xc0000000) && (msr <=3D 0= xc0001fff) )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 msr &=3D 0x1fff;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 set_bit(msr, d->arch.monitor_msr_bitmap + 0= x400/BYTES_PER_LONG);
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 hvm_enable_msr_interception(d, msr);
+
+=C2=A0 =C2=A0 return 0;
+}
+
+static int arch_monitor_disable_msr(struct domain *d, u32 msr)
+{
+=C2=A0 =C2=A0 if ( !d->arch.monitor_msr_bitmap )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EINVAL;
+
+=C2=A0 =C2=A0 if ( msr <=3D 0x1fff )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 clear_bit(msr, d->arch.monitor_msr_bitmap += 0x000/BYTES_PER_LONG);
+=C2=A0 =C2=A0 else if ( (msr >=3D 0xc0000000) && (msr <=3D 0= xc0001fff) )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 msr &=3D 0x1fff;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 clear_bit(msr, d->arch.monitor_msr_bitmap += 0x400/BYTES_PER_LONG);
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 return 0;
+}
+
+bool_t arch_monitor_is_msr_enabled(const struct domain *d, u32 msr)=
+{
+=C2=A0 =C2=A0 bool_t rc =3D 0;
+
+=C2=A0 =C2=A0 if ( !d->arch.monitor_msr_bitmap )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
+
+=C2=A0 =C2=A0 if ( msr <=3D 0x1fff )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 rc =3D test_bit(msr, d->arch.monitor_msr_bi= tmap + 0x000/BYTES_PER_LONG);
+=C2=A0 =C2=A0 else if ( (msr >=3D 0xc0000000) && (msr <=3D 0= xc0001fff) )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 msr &=3D 0x1fff;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 rc =3D test_bit(msr, d->arch.monitor_msr_bi= tmap + 0x400/BYTES_PER_LONG);
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 return rc;
+}
+
=C2=A0int arch_monitor_domctl_event(struct domain *d,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct xen_domctl_monitor_op *mop) =C2=A0{

--001a11471aee73f83505305ee7e5-- --===============1891585083524580290== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --===============1891585083524580290==--