@@ -34,9 +34,11 @@ struct msr_policy __read_mostly raw_msr_policy,
__read_mostly host_msr_policy;
#ifdef CONFIG_PV
struct msr_policy __read_mostly pv_max_msr_policy;
+struct msr_policy __read_mostly pv_def_msr_policy;
#endif
#ifdef CONFIG_HVM
struct msr_policy __read_mostly hvm_max_msr_policy;
+struct msr_policy __read_mostly hvm_def_msr_policy;
#endif
static void __init calculate_raw_policy(void)
@@ -56,6 +58,20 @@ static void __init calculate_host_policy(void)
mp->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
}
+static void __init calculate_pv_max_policy(void)
+{
+ struct msr_policy *mp = &pv_max_msr_policy;
+
+ *mp = host_msr_policy;
+}
+
+static void __init calculate_pv_def_policy(void)
+{
+ struct msr_policy *mp = &pv_def_msr_policy;
+
+ *mp = pv_max_msr_policy;
+}
+
static void __init calculate_hvm_max_policy(void)
{
struct msr_policy *mp = &hvm_max_msr_policy;
@@ -66,11 +82,11 @@ static void __init calculate_hvm_max_policy(void)
mp->platform_info.cpuid_faulting = true;
}
-static void __init calculate_pv_max_policy(void)
+static void __init calculate_hvm_def_policy(void)
{
- struct msr_policy *mp = &pv_max_msr_policy;
+ struct msr_policy *mp = &hvm_def_msr_policy;
- *mp = host_msr_policy;
+ *mp = hvm_max_msr_policy;
}
void __init init_guest_msr_policy(void)
@@ -79,17 +95,23 @@ void __init init_guest_msr_policy(void)
calculate_host_policy();
if ( IS_ENABLED(CONFIG_PV) )
+ {
calculate_pv_max_policy();
+ calculate_pv_def_policy();
+ }
if ( hvm_enabled )
+ {
calculate_hvm_max_policy();
+ calculate_hvm_def_policy();
+ }
}
int init_domain_msr_policy(struct domain *d)
{
struct msr_policy *mp = is_pv_domain(d)
- ? (IS_ENABLED(CONFIG_PV) ? &pv_max_msr_policy : NULL)
- : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_msr_policy : NULL);
+ ? (IS_ENABLED(CONFIG_PV) ? &pv_def_msr_policy : NULL)
+ : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_msr_policy : NULL);
if ( !mp )
{
@@ -49,7 +49,7 @@ const struct cpu_policy system_policies[6] = {
},
[ XEN_SYSCTL_cpu_policy_pv_default ] = {
&pv_max_cpuid_policy,
- &pv_max_msr_policy,
+ &pv_def_msr_policy,
},
#endif
#ifdef CONFIG_HVM
@@ -59,7 +59,7 @@ const struct cpu_policy system_policies[6] = {
},
[ XEN_SYSCTL_cpu_policy_hvm_default ] = {
&hvm_max_cpuid_policy,
- &hvm_max_msr_policy,
+ &hvm_def_msr_policy,
},
#endif
};
@@ -269,8 +269,10 @@ static inline void wrmsr_tsc_aux(uint32_t val)
extern struct msr_policy raw_msr_policy,
host_msr_policy,
+ pv_max_msr_policy,
+ pv_def_msr_policy,
hvm_max_msr_policy,
- pv_max_msr_policy;
+ hvm_def_msr_policy;
/* Container object for per-vCPU MSRs */
struct vcpu_msrs
For now, the default and max policies remain identical, but this will change in the future. Update XEN_SYSCTL_get_cpu_policy and init_domain_msr_policy() to use the default policies. Take the opportunity sort PV ahead of HVM, as is the prevailing style elsewhere. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: Wei Liu <wl@xen.org> CC: Roger Pau Monné <roger.pau@citrix.com> --- xen/arch/x86/msr.c | 32 +++++++++++++++++++++++++++----- xen/arch/x86/sysctl.c | 4 ++-- xen/include/asm-x86/msr.h | 4 +++- 3 files changed, 32 insertions(+), 8 deletions(-)