diff options
author | Andrew Cooper <andrew.cooper3@citrix.com> | 2020-02-26 12:26:14 +0000 |
---|---|---|
committer | Andrew Cooper <andrew.cooper3@citrix.com> | 2020-02-27 18:54:58 +0000 |
commit | fd0ec12c3a41065faab70153b8037c9263571dc0 (patch) | |
tree | b700fc0e23c74a4bef1d59906caa876700138112 /xen/arch/x86/msr.c | |
parent | 78a9ae2399d3f326c824ba3664e9654ff18a0091 (diff) |
x86/msr: Compile out unused logic/objects
Arrange to compile out the PV or HVM logic and objects as applicable. This
involves a bit of complexity in init_domain_msr_policy() as is_pv_domain()
can't be evaulated at compile time.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/msr.c')
-rw-r--r-- | xen/arch/x86/msr.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index e39bb6dce4..738d7123f9 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -31,9 +31,13 @@ DEFINE_PER_CPU(uint32_t, tsc_aux); struct msr_policy __read_mostly raw_msr_policy, - __read_mostly host_msr_policy, - __read_mostly hvm_max_msr_policy, - __read_mostly pv_max_msr_policy; + __read_mostly host_msr_policy; +#ifdef CONFIG_PV +struct msr_policy __read_mostly pv_max_msr_policy; +#endif +#ifdef CONFIG_HVM +struct msr_policy __read_mostly hvm_max_msr_policy; +#endif static void __init calculate_raw_policy(void) { @@ -56,9 +60,6 @@ static void __init calculate_hvm_max_policy(void) { struct msr_policy *mp = &hvm_max_msr_policy; - if ( !hvm_enabled ) - return; - *mp = host_msr_policy; /* It's always possible to emulate CPUID faulting for HVM guests */ @@ -76,16 +77,27 @@ void __init init_guest_msr_policy(void) { calculate_raw_policy(); calculate_host_policy(); - calculate_hvm_max_policy(); - calculate_pv_max_policy(); + + if ( IS_ENABLED(CONFIG_PV) ) + calculate_pv_max_policy(); + + if ( hvm_enabled ) + calculate_hvm_max_policy(); } int init_domain_msr_policy(struct domain *d) { - struct msr_policy *mp = - xmemdup(is_pv_domain(d) ? &pv_max_msr_policy - : &hvm_max_msr_policy); + 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); + + if ( !mp ) + { + ASSERT_UNREACHABLE(); + return -EOPNOTSUPP; + } + mp = xmemdup(mp); if ( !mp ) return -ENOMEM; |