mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/pv: Make cr4_pv32_mask be PV32-only
The user of cr4_pv32_mask (the cr4_pv32_restore() function) only exists in a CONFIG_PV32 build, but right now the variable is unconditionally set up. To start with, move the setup into set_in_cr4() and remove it from it's somewhat ad-hoc position in __start_xen(). This means the variable will be set up in two steps for a CONFIG_PV32=y build, but it's cleaner and more robust logic overall. With that, there's no good reason for the variable to stay in setup.c. Move it to x86/pv/domain.c (beside opt_pv32, for want of any better place to live), and move the declaration to beside set_in_cr4() and mmu_cr4_features which is a better position than setup.h. Guard the reference with CONFIG_PV32, and fix up a recent typo in an adjacent comment while at it. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
This commit is contained in:
1 parent
8d336fcb6e
commit
7ab0f83e60
5 files changed
+12
-9
No files matched your search
@@ -312,11 +312,15 @@ static inline void stts(void)
|
||||
* after us can get the correct flags.
|
||||
*/
|
||||
extern unsigned long mmu_cr4_features;
|
||||
extern unsigned long cr4_pv32_mask;
|
||||
|
||||
static always_inline void set_in_cr4 (unsigned long mask)
|
||||
{
|
||||
mmu_cr4_features |= mask;
|
||||
write_cr4(read_cr4() | mask);
|
||||
|
||||
if ( IS_ENABLED(CONFIG_PV32) && (mask & XEN_CR4_PV32_BITS) )
|
||||
cr4_pv32_mask |= (mask & XEN_CR4_PV32_BITS);
|
||||
}
|
||||
|
||||
static always_inline void __monitor(const void *eax, unsigned long ecx,
|
||||
|
||||
@@ -64,8 +64,6 @@ extern bool opt_dom0_verbose;
|
||||
extern bool opt_dom0_cpuid_faulting;
|
||||
extern bool opt_dom0_msr_relaxed;
|
||||
|
||||
extern unsigned long cr4_pv32_mask;
|
||||
|
||||
#define max_init_domid (0)
|
||||
|
||||
#endif
|
||||
@@ -1061,12 +1061,14 @@ int __init dom0_construct_pv(struct domain *d,
|
||||
|
||||
/*
|
||||
* Clear SMAP in CR4 to allow user-accesses in construct_dom0(). This
|
||||
* prevents us needing to write rewrite construct_dom0() in terms of
|
||||
* prevents us needing to write construct_dom0() in terms of
|
||||
* copy_{to,from}_user().
|
||||
*/
|
||||
if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) )
|
||||
{
|
||||
cr4_pv32_mask &= ~X86_CR4_SMAP;
|
||||
if ( IS_ENABLED(CONFIG_PV32) )
|
||||
cr4_pv32_mask &= ~X86_CR4_SMAP;
|
||||
|
||||
write_cr4(read_cr4() & ~X86_CR4_SMAP);
|
||||
}
|
||||
|
||||
@@ -1075,7 +1077,9 @@ int __init dom0_construct_pv(struct domain *d,
|
||||
if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) )
|
||||
{
|
||||
write_cr4(read_cr4() | X86_CR4_SMAP);
|
||||
cr4_pv32_mask |= X86_CR4_SMAP;
|
||||
|
||||
if ( IS_ENABLED(CONFIG_PV32) )
|
||||
cr4_pv32_mask |= X86_CR4_SMAP;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#ifdef CONFIG_PV32
|
||||
int8_t __read_mostly opt_pv32 = -1;
|
||||
unsigned long __ro_after_init cr4_pv32_mask;
|
||||
#endif
|
||||
|
||||
static int __init cf_check parse_pv(const char *s)
|
||||
|
||||
@@ -79,8 +79,6 @@ bool __read_mostly use_invpcid;
|
||||
int8_t __initdata opt_probe_port_aliases = -1;
|
||||
boolean_param("probe-port-aliases", opt_probe_port_aliases);
|
||||
|
||||
unsigned long __ro_after_init cr4_pv32_mask;
|
||||
|
||||
/* **** Linux config option: propagated to domain0. */
|
||||
/* "acpi=off": Sisables both ACPI table parsing and interpreter. */
|
||||
/* "acpi=force": Override the disable blacklist. */
|
||||
@@ -1898,8 +1896,6 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
|
||||
if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) )
|
||||
set_in_cr4(X86_CR4_SMAP);
|
||||
|
||||
cr4_pv32_mask = mmu_cr4_features & XEN_CR4_PV32_BITS;
|
||||
|
||||
if ( boot_cpu_has(X86_FEATURE_FSGSBASE) )
|
||||
set_in_cr4(X86_CR4_FSGSBASE);
|
||||
|
||||
|
||||