x86/mtrr: Rename mtrr_overwrite_state() to guest_force_mtrr_state()

[ Upstream commit 6a5abeea9c ]

Rename the helper to better reflect its function.

Suggested-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Link: https://lore.kernel.org/all/20241202073139.448208-1-kirill.shutemov%40linux.intel.com
Stable-dep-of: 0dccbc75e1 ("x86/kvm: Force legacy PCI hole to UC when overriding MTRRs for TDX/SNP")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Kirill A. Shutemov
2025-10-16 21:13:05 -04:00
committed by Greg Kroah-Hartman
parent 423eba50f8
commit b7b6f95bb3
6 changed files with 13 additions and 13 deletions

View File

@@ -681,7 +681,7 @@ void __init hv_vtom_init(void)
x86_platform.guest.enc_status_change_finish = hv_vtom_set_host_visibility; x86_platform.guest.enc_status_change_finish = hv_vtom_set_host_visibility;
/* Set WB as the default cache mode. */ /* Set WB as the default cache mode. */
mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK); guest_force_mtrr_state(NULL, 0, MTRR_TYPE_WRBACK);
} }
#endif /* defined(CONFIG_AMD_MEM_ENCRYPT) || defined(CONFIG_INTEL_TDX_GUEST) */ #endif /* defined(CONFIG_AMD_MEM_ENCRYPT) || defined(CONFIG_INTEL_TDX_GUEST) */

View File

@@ -58,8 +58,8 @@ struct mtrr_state_type {
*/ */
# ifdef CONFIG_MTRR # ifdef CONFIG_MTRR
void mtrr_bp_init(void); void mtrr_bp_init(void);
void mtrr_overwrite_state(struct mtrr_var_range *var, unsigned int num_var, void guest_force_mtrr_state(struct mtrr_var_range *var, unsigned int num_var,
mtrr_type def_type); mtrr_type def_type);
extern u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform); extern u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform);
extern void mtrr_save_fixed_ranges(void *); extern void mtrr_save_fixed_ranges(void *);
extern void mtrr_save_state(void); extern void mtrr_save_state(void);
@@ -75,9 +75,9 @@ void mtrr_disable(void);
void mtrr_enable(void); void mtrr_enable(void);
void mtrr_generic_set_state(void); void mtrr_generic_set_state(void);
# else # else
static inline void mtrr_overwrite_state(struct mtrr_var_range *var, static inline void guest_force_mtrr_state(struct mtrr_var_range *var,
unsigned int num_var, unsigned int num_var,
mtrr_type def_type) mtrr_type def_type)
{ {
} }

View File

@@ -423,7 +423,7 @@ void __init mtrr_copy_map(void)
} }
/** /**
* mtrr_overwrite_state - set static MTRR state * guest_force_mtrr_state - set static MTRR state for a guest
* *
* Used to set MTRR state via different means (e.g. with data obtained from * Used to set MTRR state via different means (e.g. with data obtained from
* a hypervisor). * a hypervisor).
@@ -436,8 +436,8 @@ void __init mtrr_copy_map(void)
* @num_var: length of the @var array * @num_var: length of the @var array
* @def_type: default caching type * @def_type: default caching type
*/ */
void mtrr_overwrite_state(struct mtrr_var_range *var, unsigned int num_var, void guest_force_mtrr_state(struct mtrr_var_range *var, unsigned int num_var,
mtrr_type def_type) mtrr_type def_type)
{ {
unsigned int i; unsigned int i;

View File

@@ -625,7 +625,7 @@ void mtrr_save_state(void)
static int __init mtrr_init_finalize(void) static int __init mtrr_init_finalize(void)
{ {
/* /*
* Map might exist if mtrr_overwrite_state() has been called or if * Map might exist if guest_force_mtrr_state() has been called or if
* mtrr_enabled() returns true. * mtrr_enabled() returns true.
*/ */
mtrr_copy_map(); mtrr_copy_map();

View File

@@ -983,7 +983,7 @@ static void __init kvm_init_platform(void)
x86_platform.apic_post_init = kvm_apic_init; x86_platform.apic_post_init = kvm_apic_init;
/* Set WB as the default cache mode for SEV-SNP and TDX */ /* Set WB as the default cache mode for SEV-SNP and TDX */
mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK); guest_force_mtrr_state(NULL, 0, MTRR_TYPE_WRBACK);
} }
#if defined(CONFIG_AMD_MEM_ENCRYPT) #if defined(CONFIG_AMD_MEM_ENCRYPT)

View File

@@ -171,7 +171,7 @@ static void __init xen_set_mtrr_data(void)
/* Only overwrite MTRR state if any MTRR could be got from Xen. */ /* Only overwrite MTRR state if any MTRR could be got from Xen. */
if (reg) if (reg)
mtrr_overwrite_state(var, reg, MTRR_TYPE_UNCACHABLE); guest_force_mtrr_state(var, reg, MTRR_TYPE_UNCACHABLE);
#endif #endif
} }
@@ -195,7 +195,7 @@ static void __init xen_pv_init_platform(void)
if (xen_initial_domain()) if (xen_initial_domain())
xen_set_mtrr_data(); xen_set_mtrr_data();
else else
mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK); guest_force_mtrr_state(NULL, 0, MTRR_TYPE_WRBACK);
/* Adjust nr_cpu_ids before "enumeration" happens */ /* Adjust nr_cpu_ids before "enumeration" happens */
xen_smp_count_cpus(); xen_smp_count_cpus();