Skip to content

Commit 4d5cff6

Browse files
Christoph Hellwigsuryasaimadhu
authored andcommitted
x86/mtrr: Remove the mtrr_bp_init() stub
Add an IS_ENABLED() check in setup_arch() and call pat_disable() directly if MTRRs are not supported. This allows to remove the <asm/memtype.h> include in <asm/mtrr.h>, which pull in lowlevel x86 headers that should not be included for UML builds and will cause build warnings with a following patch. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c494eb3 commit 4d5cff6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

arch/x86/include/asm/mtrr.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#define _ASM_X86_MTRR_H
2525

2626
#include <uapi/asm/mtrr.h>
27-
#include <asm/memtype.h>
2827

28+
void mtrr_bp_init(void);
2929

3030
/*
3131
* The following functions are for use by other drivers that cannot use
@@ -43,7 +43,6 @@ extern int mtrr_del(int reg, unsigned long base, unsigned long size);
4343
extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
4444
extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
4545
extern void mtrr_ap_init(void);
46-
extern void mtrr_bp_init(void);
4746
extern void set_mtrr_aps_delayed_init(void);
4847
extern void mtrr_aps_init(void);
4948
extern void mtrr_bp_restore(void);
@@ -84,11 +83,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)
8483
static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
8584
{
8685
}
87-
static inline void mtrr_bp_init(void)
88-
{
89-
pat_disable("PAT support disabled because CONFIG_MTRR is disabled in the kernel.");
90-
}
91-
9286
#define mtrr_ap_init() do {} while (0)
9387
#define set_mtrr_aps_delayed_init() do {} while (0)
9488
#define mtrr_aps_init() do {} while (0)

arch/x86/kernel/setup.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <asm/kasan.h>
4141
#include <asm/kaslr.h>
4242
#include <asm/mce.h>
43+
#include <asm/memtype.h>
4344
#include <asm/mtrr.h>
4445
#include <asm/realmode.h>
4546
#include <asm/olpc_ofw.h>
@@ -979,7 +980,11 @@ void __init setup_arch(char **cmdline_p)
979980
max_pfn = e820__end_of_ram_pfn();
980981

981982
/* update e820 for memory not covered by WB MTRRs */
982-
mtrr_bp_init();
983+
if (IS_ENABLED(CONFIG_MTRR))
984+
mtrr_bp_init();
985+
else
986+
pat_disable("PAT support disabled because CONFIG_MTRR is disabled in the kernel.");
987+
983988
if (mtrr_trim_uncached_memory(max_pfn))
984989
max_pfn = e820__end_of_ram_pfn();
985990

arch/x86/kvm/mmu/spte.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "spte.h"
1717

1818
#include <asm/e820/api.h>
19+
#include <asm/memtype.h>
1920
#include <asm/vmx.h>
2021

2122
static bool __read_mostly enable_mmio_caching = true;

0 commit comments

Comments
 (0)