mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 12:14:06 +00:00
x86/mtrr: Don't let mtrr_type_lookup() return MTRR_TYPE_INVALID
mtrr_type_lookup() should always return a valid memory type. In case there is no information available, it should return the default UC. This will remove the last case where mtrr_type_lookup() can return MTRR_TYPE_INVALID, so adjust the comment in include/uapi/asm/mtrr.h. Note that removing the MTRR_TYPE_INVALID #define from that header could break user code, so it has to stay. At the same time the mtrr_type_lookup() stub for the !CONFIG_MTRR case should set uniform to 1, as if the memory range would be covered by no MTRR at all. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Tested-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20230502120931.20719-15-jgross@suse.com Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
This commit is contained in:
parent
8227f40ade
commit
973df19420
3 changed files with 10 additions and 7 deletions
|
@ -86,9 +86,12 @@ static inline void mtrr_overwrite_state(struct mtrr_var_range *var,
|
|||
static inline u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform)
|
||||
{
|
||||
/*
|
||||
* Return no-MTRRs:
|
||||
* Return the default MTRR type, without any known other types in
|
||||
* that range.
|
||||
*/
|
||||
return MTRR_TYPE_INVALID;
|
||||
*uniform = 1;
|
||||
|
||||
return MTRR_TYPE_UNCACHABLE;
|
||||
}
|
||||
#define mtrr_save_fixed_ranges(arg) do {} while (0)
|
||||
#define mtrr_save_state() do {} while (0)
|
||||
|
|
|
@ -107,9 +107,9 @@ typedef __u8 mtrr_type;
|
|||
#define MTRR_NUM_TYPES 7
|
||||
|
||||
/*
|
||||
* Invalid MTRR memory type. mtrr_type_lookup() returns this value when
|
||||
* MTRRs are disabled. Note, this value is allocated from the reserved
|
||||
* values (0x7-0xff) of the MTRR memory types.
|
||||
* Invalid MTRR memory type. No longer used outside of MTRR code.
|
||||
* Note, this value is allocated from the reserved values (0x7-0xff) of
|
||||
* the MTRR memory types.
|
||||
*/
|
||||
#define MTRR_TYPE_INVALID 0xff
|
||||
|
||||
|
|
|
@ -508,13 +508,13 @@ u8 mtrr_type_lookup(u64 start, u64 end, u8 *uniform)
|
|||
if (!mtrr_state_set) {
|
||||
/* Uniformity is unknown. */
|
||||
*uniform = 0;
|
||||
return MTRR_TYPE_INVALID;
|
||||
return MTRR_TYPE_UNCACHABLE;
|
||||
}
|
||||
|
||||
*uniform = 1;
|
||||
|
||||
if (!(mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED))
|
||||
return MTRR_TYPE_INVALID;
|
||||
return MTRR_TYPE_UNCACHABLE;
|
||||
|
||||
for (i = 0; i < cache_map_n && start < end; i++) {
|
||||
/* Region after current map entry? -> continue with next one. */
|
||||
|
|
Loading…
Add table
Reference in a new issue