x86/mtrr: Don't let mtrr_type_lookup() return MTRR_TYPE_INVALID
authorJuergen Gross <jgross@suse.com>
Tue, 2 May 2023 12:09:29 +0000 (14:09 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Thu, 1 Jun 2023 13:04:33 +0000 (15:04 +0200)
commit973df1942068c0cc72244ce7dce5e5aeca03ad5f
tree3fc6230c4acde5b2c7ede986d865766d2a765b1f
parent8227f40ade2362982505f66f1614b78a3a083ec9
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>
arch/x86/include/asm/mtrr.h
arch/x86/include/uapi/asm/mtrr.h
arch/x86/kernel/cpu/mtrr/generic.c