mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/svm: Add infrastructure for Bus Lock Threshold
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@amd.com> Reviewed-by: Teddy Astie <teddy.astie@vates.tech> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
6382bda1ea
commit
06d2514278
4 files changed
+17
-3
No files matched your search
@@ -435,6 +435,7 @@ static void __init __maybe_unused build_assertions(void)
|
|||||||
BUILD_BUG_ON(offsetof(typeof(vmcb), _pause_filter_thresh) != 0x03c);
|
BUILD_BUG_ON(offsetof(typeof(vmcb), _pause_filter_thresh) != 0x03c);
|
||||||
BUILD_BUG_ON(offsetof(typeof(vmcb), _vintr) != 0x060);
|
BUILD_BUG_ON(offsetof(typeof(vmcb), _vintr) != 0x060);
|
||||||
BUILD_BUG_ON(offsetof(typeof(vmcb), event_inj) != 0x0a8);
|
BUILD_BUG_ON(offsetof(typeof(vmcb), event_inj) != 0x0a8);
|
||||||
|
BUILD_BUG_ON(offsetof(typeof(vmcb), bus_lock_count) != 0x120);
|
||||||
|
|
||||||
/* State Save area */
|
/* State Save area */
|
||||||
BUILD_BUG_ON(offsetof(typeof(vmcb), es) != 0x400);
|
BUILD_BUG_ON(offsetof(typeof(vmcb), es) != 0x400);
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ enum GenericIntercept2bits
|
|||||||
GENERAL2_INTERCEPT_RDPRU = 1 << 14,
|
GENERAL2_INTERCEPT_RDPRU = 1 << 14,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum GenericIntercept3bits
|
||||||
|
{
|
||||||
|
GENERAL3_INTERCEPT_BUS_LOCK = 1 << 5,
|
||||||
|
};
|
||||||
|
|
||||||
enum CRInterceptBits
|
enum CRInterceptBits
|
||||||
{
|
{
|
||||||
CR_INTERCEPT_CR0_READ = 1 << 0,
|
CR_INTERCEPT_CR0_READ = 1 << 0,
|
||||||
@@ -283,6 +288,7 @@ enum VMEXIT_EXITCODE
|
|||||||
VMEXIT_MWAIT_CONDITIONAL= 140, /* 0x8c */
|
VMEXIT_MWAIT_CONDITIONAL= 140, /* 0x8c */
|
||||||
VMEXIT_XSETBV = 141, /* 0x8d */
|
VMEXIT_XSETBV = 141, /* 0x8d */
|
||||||
VMEXIT_RDPRU = 142, /* 0x8e */
|
VMEXIT_RDPRU = 142, /* 0x8e */
|
||||||
|
VMEXIT_BUS_LOCK = 165, /* 0xa5 */
|
||||||
/* Remember to also update VMEXIT_NPF_PERFC! */
|
/* Remember to also update VMEXIT_NPF_PERFC! */
|
||||||
VMEXIT_NPF = 1024, /* 0x400, nested paging fault */
|
VMEXIT_NPF = 1024, /* 0x400, nested paging fault */
|
||||||
/* Remember to also update SVM_PERF_EXIT_REASON_SIZE! */
|
/* Remember to also update SVM_PERF_EXIT_REASON_SIZE! */
|
||||||
@@ -400,7 +406,8 @@ struct vmcb_struct {
|
|||||||
u32 _exception_intercepts; /* offset 0x08 - cleanbit 0 */
|
u32 _exception_intercepts; /* offset 0x08 - cleanbit 0 */
|
||||||
u32 _general1_intercepts; /* offset 0x0C - cleanbit 0 */
|
u32 _general1_intercepts; /* offset 0x0C - cleanbit 0 */
|
||||||
u32 _general2_intercepts; /* offset 0x10 - 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_thresh; /* offset 0x3C - cleanbit 0 */
|
||||||
u16 _pause_filter_count; /* offset 0x3E - cleanbit 0 */
|
u16 _pause_filter_count; /* offset 0x3E - cleanbit 0 */
|
||||||
u64 _iopm_base_pa; /* offset 0x40 - cleanbit 1 */
|
u64 _iopm_base_pa; /* offset 0x40 - cleanbit 1 */
|
||||||
@@ -484,7 +491,10 @@ struct vmcb_struct {
|
|||||||
u64 nextrip; /* offset 0xC8 */
|
u64 nextrip; /* offset 0xC8 */
|
||||||
u8 guest_ins_len; /* offset 0xD0 */
|
u8 guest_ins_len; /* offset 0xD0 */
|
||||||
u8 guest_ins[15]; /* offset 0xD1 */
|
u8 guest_ins[15]; /* offset 0xD1 */
|
||||||
u64 res10a[100]; /* offset 0xE0 pad to save area */
|
u64 res10a[8]; /* offset 0xE0 */
|
||||||
|
u16 bus_lock_count; /* offset 0x120 */
|
||||||
|
u16 res10b[3]; /* offset 0x122 */
|
||||||
|
u64 res10c[91]; /* offset 0x128 pad to save area */
|
||||||
|
|
||||||
/* State Save area */
|
/* State Save area */
|
||||||
union {
|
union {
|
||||||
@@ -579,6 +589,7 @@ VMCB_ACCESSORS(dr_intercepts, intercepts)
|
|||||||
VMCB_ACCESSORS(exception_intercepts, intercepts)
|
VMCB_ACCESSORS(exception_intercepts, intercepts)
|
||||||
VMCB_ACCESSORS(general1_intercepts, intercepts)
|
VMCB_ACCESSORS(general1_intercepts, intercepts)
|
||||||
VMCB_ACCESSORS(general2_intercepts, intercepts)
|
VMCB_ACCESSORS(general2_intercepts, intercepts)
|
||||||
|
VMCB_ACCESSORS(general3_intercepts, intercepts)
|
||||||
VMCB_ACCESSORS(pause_filter_count, intercepts)
|
VMCB_ACCESSORS(pause_filter_count, intercepts)
|
||||||
VMCB_ACCESSORS(pause_filter_thresh, intercepts)
|
VMCB_ACCESSORS(pause_filter_thresh, intercepts)
|
||||||
VMCB_ACCESSORS(tsc_offset, intercepts)
|
VMCB_ACCESSORS(tsc_offset, intercepts)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ extern u32 svm_feature_flags;
|
|||||||
#define SVM_FEATURE_VGIF 16 /* Virtual GIF */
|
#define SVM_FEATURE_VGIF 16 /* Virtual GIF */
|
||||||
#define SVM_FEATURE_SSS 19 /* NPT Supervisor Shadow Stacks */
|
#define SVM_FEATURE_SSS 19 /* NPT Supervisor Shadow Stacks */
|
||||||
#define SVM_FEATURE_SPEC_CTRL 20 /* MSR_SPEC_CTRL virtualisation */
|
#define SVM_FEATURE_SPEC_CTRL 20 /* MSR_SPEC_CTRL virtualisation */
|
||||||
|
#define SVM_FEATURE_BUS_LOCK 29 /* Bus Lock Threshold */
|
||||||
|
|
||||||
static inline bool cpu_has_svm_feature(unsigned int feat)
|
static inline bool cpu_has_svm_feature(unsigned int feat)
|
||||||
{
|
{
|
||||||
@@ -56,6 +57,7 @@ static inline bool cpu_has_svm_feature(unsigned int feat)
|
|||||||
#define cpu_has_svm_vloadsave cpu_has_svm_feature(SVM_FEATURE_VLOADSAVE)
|
#define cpu_has_svm_vloadsave cpu_has_svm_feature(SVM_FEATURE_VLOADSAVE)
|
||||||
#define cpu_has_svm_sss cpu_has_svm_feature(SVM_FEATURE_SSS)
|
#define cpu_has_svm_sss cpu_has_svm_feature(SVM_FEATURE_SSS)
|
||||||
#define cpu_has_svm_spec_ctrl cpu_has_svm_feature(SVM_FEATURE_SPEC_CTRL)
|
#define cpu_has_svm_spec_ctrl cpu_has_svm_feature(SVM_FEATURE_SPEC_CTRL)
|
||||||
|
#define cpu_has_svm_bus_lock cpu_has_svm_feature(SVM_FEATURE_BUS_LOCK)
|
||||||
|
|
||||||
#define MSR_INTERCEPT_NONE 0
|
#define MSR_INTERCEPT_NONE 0
|
||||||
#define MSR_INTERCEPT_READ 1
|
#define MSR_INTERCEPT_READ 1
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ PERFCOUNTER_ARRAY(exceptions, "exceptions", 32)
|
|||||||
#ifdef CONFIG_HVM
|
#ifdef CONFIG_HVM
|
||||||
|
|
||||||
#define VMX_PERF_EXIT_REASON_SIZE 76
|
#define VMX_PERF_EXIT_REASON_SIZE 76
|
||||||
#define VMEXIT_NPF_PERFC 143
|
#define VMEXIT_NPF_PERFC 166
|
||||||
#define SVM_PERF_EXIT_REASON_SIZE (VMEXIT_NPF_PERFC + 1)
|
#define SVM_PERF_EXIT_REASON_SIZE (VMEXIT_NPF_PERFC + 1)
|
||||||
PERFCOUNTER_ARRAY(vmexits, "vmexits",
|
PERFCOUNTER_ARRAY(vmexits, "vmexits",
|
||||||
MAX(VMX_PERF_EXIT_REASON_SIZE, SVM_PERF_EXIT_REASON_SIZE))
|
MAX(VMX_PERF_EXIT_REASON_SIZE, SVM_PERF_EXIT_REASON_SIZE))
|
||||||
|
|||||||