From: "Jan Beulich" Subject: [PATCH 3/4] VMX: allow RTM advanced debugging to be used by guests Date: Tue, 12 Aug 2014 10:17:26 +0100 Message-ID: <53E9F7C6020000780002B740@mail.emea.novell.com> References: <53E9F5A0020000780002B70C@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartBF8D08B6.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XH8D0-0008Na-Co for xen-devel@lists.xenproject.org; Tue, 12 Aug 2014 09:17:34 +0000 In-Reply-To: <53E9F5A0020000780002B70C@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: xen-devel Cc: Keir Fraser , Kevin Tian , Eddie Dong , Jun Nakajima List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartBF8D08B6.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline All that is needed here is allowing the respective DebugCtl MSR bit to be set by the guest. At once - even if PV guests can't currently use it due to missing DebugCtl MSR virtualization - make the respective adjustments to debugreg.h. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2246,6 +2246,8 @@ static int vmx_msr_write_intercept(unsig int i, rc =3D 0; uint64_t supported =3D IA32_DEBUGCTLMSR_LBR | IA32_DEBUGCTLMSR_BTF= ; =20 + if ( boot_cpu_has(X86_FEATURE_RTM) ) + supported |=3D IA32_DEBUGCTLMSR_RTM; if ( msr_content & ~supported ) { /* Perhaps some other bits are supported in vpmu. */ --- a/xen/include/asm-x86/debugreg.h +++ b/xen/include/asm-x86/debugreg.h @@ -20,6 +20,7 @@ #define DR_TRAP3 (0x8) /* db3 */ #define DR_STEP (0x4000) /* single-step */ #define DR_SWITCH (0x8000) /* task switch */ +#define DR_NOT_RTM (0x10000) /* clear: #BP inside RTM region = */ =20 /* Now define a bunch of things for manipulating the control register. The top two bytes of the control register consist of 4 fields of 4 @@ -62,6 +63,7 @@ #define DR_CONTROL_RESERVED_ONE (0x00000400ul) /* Reserved, read as one = */ #define DR_LOCAL_EXACT_ENABLE (0x00000100ul) /* Local exact enable */ #define DR_GLOBAL_EXACT_ENABLE (0x00000200ul) /* Global exact enable */ +#define DR_RTM_ENABLE (0x00000800ul) /* RTM debugging enable = */ #define DR_GENERAL_DETECT (0x00002000ul) /* General detect enable = */ =20 #define write_debugreg(reg, val) do { \ --- a/xen/include/asm-x86/msr-index.h +++ b/xen/include/asm-x86/msr-index.h @@ -79,6 +79,7 @@ #define IA32_DEBUGCTLMSR_BTINT (1<<8) /* Branch Trace Interrupt = */ #define IA32_DEBUGCTLMSR_BTS_OFF_OS (1<<9) /* BTS off if CPL 0 */ #define IA32_DEBUGCTLMSR_BTS_OFF_USR (1<<10) /* BTS off if CPL > 0 */ +#define IA32_DEBUGCTLMSR_RTM (1<<15) /* RTM debugging enable */ =20 #define MSR_IA32_LASTBRANCHFROMIP 0x000001db #define MSR_IA32_LASTBRANCHTOIP 0x000001dc --=__PartBF8D08B6.1__= Content-Type: text/plain; name="VMX-RTM-debugging.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="VMX-RTM-debugging.patch" VMX: allow RTM advanced debugging to be used by guests=0A=0AAll that is = needed here is allowing the respective DebugCtl MSR bit to=0Abe set by the = guest.=0A=0AAt once - even if PV guests can't currently use it due to = missing=0ADebugCtl MSR virtualization - make the respective adjustments = to=0Adebugreg.h.=0A=0ASigned-off-by: Jan Beulich =0A=0A-= -- a/xen/arch/x86/hvm/vmx/vmx.c=0A+++ b/xen/arch/x86/hvm/vmx/vmx.c=0A@@ = -2246,6 +2246,8 @@ static int vmx_msr_write_intercept(unsig=0A int = i, rc =3D 0;=0A uint64_t supported =3D IA32_DEBUGCTLMSR_LBR | = IA32_DEBUGCTLMSR_BTF;=0A =0A+ if ( boot_cpu_has(X86_FEATURE_RTM) = )=0A+ supported |=3D IA32_DEBUGCTLMSR_RTM;=0A if ( = msr_content & ~supported )=0A {=0A /* Perhaps some = other bits are supported in vpmu. */=0A--- a/xen/include/asm-x86/debugreg.h= =0A+++ b/xen/include/asm-x86/debugreg.h=0A@@ -20,6 +20,7 @@=0A #define = DR_TRAP3 (0x8) /* db3 */=0A #define DR_STEP = (0x4000) /* single-step */=0A #define DR_SWITCH (0x8000) = /* task switch */=0A+#define DR_NOT_RTM (0x10000) /* clear: = #BP inside RTM region */=0A =0A /* Now define a bunch of things for = manipulating the control register.=0A The top two bytes of the control = register consist of 4 fields of 4=0A@@ -62,6 +63,7 @@=0A #define DR_CONTROL= _RESERVED_ONE (0x00000400ul) /* Reserved, read as one */=0A #define = DR_LOCAL_EXACT_ENABLE (0x00000100ul) /* Local exact enable */=0A = #define DR_GLOBAL_EXACT_ENABLE (0x00000200ul) /* Global exact enable = */=0A+#define DR_RTM_ENABLE (0x00000800ul) /* RTM debugging = enable */=0A #define DR_GENERAL_DETECT (0x00002000ul) /* General = detect enable */=0A =0A #define write_debugreg(reg, val) do { = \=0A--- a/xen/include/asm-x86/msr-index.h=0A+++ b/xen/include/asm-= x86/msr-index.h=0A@@ -79,6 +79,7 @@=0A #define IA32_DEBUGCTLMSR_BTINT = (1<<8) /* Branch Trace Interrupt */=0A #define IA32_DEBUGCTLMSR_BTS_OFF_OS = (1<<9) /* BTS off if CPL 0 */=0A #define IA32_DEBUGCTLMSR_BTS_OFF_USR = (1<<10) /* BTS off if CPL > 0 */=0A+#define IA32_DEBUGCTLMSR_RTM = (1<<15) /* RTM debugging enable */=0A =0A #define MSR_IA32_LASTBRANCHFROMIP= 0x000001db=0A #define MSR_IA32_LASTBRANCHTOIP 0x000001dc= =0A --=__PartBF8D08B6.1__= 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 --=__PartBF8D08B6.1__=--