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

Re: [PATCH v2 1/3] x86/svm: Add infrastructure for Bus Lock Threshold


  • To: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 21 Jan 2026 17:33:44 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5mlf0EoKlcLPA4FV/FDAgNfurSltHR/Tz60fc3BYg4Y=; b=mkI41il5Ogw5GwLWJu+FyOg+vOgGkv2oLXaftJm9InCsqe0iF7f9LIAbXB5DjH1PY0/My1KxjMTBCUXRfHsrJvBouGON0lwTLWSjIMIMApccfQ1aw34UZBMVY1giMewp4nNU5vwqujAr7aXlBsZj+oOnl70UVL9LgPudHzUlSQ33x+OJCMNKQzbC2tfn7cY8hi5hOmZ7o9VjZidoIhi9lEqiK4Hezek1BK3+haeqhAecs5AVrlM3J2xItorCgP4nhtfs8wE6h/FqUfFInYQ3P/hirqmxCCao78WULZN4k3vuGx2949F6B66XAkgMqdTo6CBjj17ABYAfUfmfHHca3g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GLM2V7Z+rej+B/ebLn6K/ZJdMhWWqLOaKcjlAsXXwjmqnpVhF0ANl6VlXmr9nHZExqJAybnKKx6k6ZuHxgnCL1MGAFX8TBZIim9XXZAwa+lm2qEJZc3fMfEmFQaBupiLKlHfGyLubkQoN1g2M1cWaJOQ7NijU5faoOK3agY3oyneVaR2iPqmVZcFK1gziQl+RHz8ByBMCOddj6qoUiVdnIDi3eDES4LoSstqVyrS2oNvCoj1pRE+JTvgoyFZ15861S4PeEZPsLUUzpvxl0x8ESieCc46mGEkPVUoBCNp47yoavYxD3T3pdI77Bb6a3Z7FXNARFhB7uml70usCkSDsQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Wed, 21 Jan 2026 17:34:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21/01/2026 2:28 pm, Alejandro Vallejo wrote:
> Add missing scaffolding to enable BusLock Threshold. That is:
>
>   * Add general_intercepts_3.
>   * Add missing VMEXIT
>   * Adjust NPF perf counter base to immediately after the buslock counter
>
> Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
> Reviewed-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
> ---
> v2:
>   * s/general intercepts 2/general intercepts 3/
>   * removed _thresh suffix
>   * added missing _svm_ infix in the SVM feature
> ---
>  xen/arch/x86/hvm/svm/vmcb.h           | 15 +++++++++++++--
>  xen/arch/x86/include/asm/hvm/svm.h    |  2 ++
>  xen/arch/x86/include/asm/perfc_defn.h |  2 +-
>  3 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/vmcb.h b/xen/arch/x86/hvm/svm/vmcb.h
> index ba554a9644..231f9b1b06 100644
> --- a/xen/arch/x86/hvm/svm/vmcb.h
> +++ b/xen/arch/x86/hvm/svm/vmcb.h
> @@ -65,6 +65,11 @@ enum GenericIntercept2bits
>      GENERAL2_INTERCEPT_RDPRU   = 1 << 14,
>  };
>  
> +/* general 3 intercepts */

All these comments are useless.  I'll do a prep patch to delete them, so
they can't be used as a source of patch nitpicking.

> +enum GenericIntercept3bits
> +{
> +    GENERAL3_INTERCEPT_BUS_LOCK_THRESH = 1 << 5,
> +};
>  
>  /* control register intercepts */
>  enum CRInterceptBits
> @@ -289,6 +294,7 @@ enum VMEXIT_EXITCODE
>      VMEXIT_MWAIT_CONDITIONAL= 140, /* 0x8c */
>      VMEXIT_XSETBV           = 141, /* 0x8d */
>      VMEXIT_RDPRU            = 142, /* 0x8e */
> +    VMEXIT_BUS_LOCK         = 165, /* 0xa5 */
>      /* Remember to also update VMEXIT_NPF_PERFC! */
>      VMEXIT_NPF              = 1024, /* 0x400, nested paging fault */
>      /* Remember to also update SVM_PERF_EXIT_REASON_SIZE! */
> @@ -405,7 +411,8 @@ struct vmcb_struct {
>      u32 _exception_intercepts;  /* offset 0x08 - cleanbit 0 */
>      u32 _general1_intercepts;   /* offset 0x0C - cleanbit 0 */
>      u32 _general2_intercepts;   /* offset 0x10 - cleanbit 0 */
> -    u32 res01[10];
> +    u32 _general3_intercepts;   /* offset 0x14 - cleanbit 0 */
> +    u32 res01[9];
>      u16 _pause_filter_thresh;   /* offset 0x3C - cleanbit 0 */
>      u16 _pause_filter_count;    /* offset 0x3E - cleanbit 0 */
>      u64 _iopm_base_pa;          /* offset 0x40 - cleanbit 1 */
> @@ -489,7 +496,10 @@ struct vmcb_struct {
>      u64 nextrip;                /* offset 0xC8 */
>      u8  guest_ins_len;          /* offset 0xD0 */
>      u8  guest_ins[15];          /* offset 0xD1 */
> -    u64 res10a[100];            /* offset 0xE0 pad to save area */
> +    u64 res10a[8];              /* offset 0xE0 */
> +    u16 bus_lock_thresh;        /* offset 0x120 */
> +    u16 res10b[3];              /* offset 0x122 */
> +    u64 res10c[91];             /* offset 0x128 pad to save area */
>  

This wants a matching hunk:

diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c
index cbee10d0463d..8734fd2bca11 100644
--- a/xen/arch/x86/hvm/svm/vmcb.c
+++ b/xen/arch/x86/hvm/svm/vmcb.c
@@ -430,9 +430,14 @@ static void __init __maybe_unused build_assertions(void)
 
     /* Build-time check of the VMCB layout. */
     BUILD_BUG_ON(sizeof(vmcb) != PAGE_SIZE);
+
+    /* Control area */
     BUILD_BUG_ON(offsetof(typeof(vmcb), _pause_filter_thresh) != 0x03c);
     BUILD_BUG_ON(offsetof(typeof(vmcb), _vintr)               != 0x060);
     BUILD_BUG_ON(offsetof(typeof(vmcb), event_inj)            != 0x0a8);
+    BUILD_BUG_ON(offsetof(typeof(vmcb), bus_lock_count)       != 0x120);
+
+    /* State Save area */
     BUILD_BUG_ON(offsetof(typeof(vmcb), es)                   != 0x400);
     BUILD_BUG_ON(offsetof(typeof(vmcb), _cpl)                 != 0x4cb);
     BUILD_BUG_ON(offsetof(typeof(vmcb), _cr4)                 != 0x548);



Despite all the comments, it's very easy to res[] arrays wrong when
splitting them like this.

I can fold on commit.

~Andrew



 


Rackspace

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