]> git.baikalelectronics.ru Git - kernel.git/commit
x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case
authorJuergen Gross <jgross@suse.com>
Tue, 10 Jan 2023 06:54:27 +0000 (07:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:58:22 +0000 (11:58 +0100)
commit98ffadcfa1629a1ca5d75e16254777a96ddec5eb
tree9c1cb100373d1694843af27746cef9383e6fa9a0
parentf1610a2f4252bb60d91fab0b0e20c4185757e26e
x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case

commit 26ef7fdb74e4c5274952c2089a1788f67a8825b3 upstream.

Since

  c4edf0a9ac55 ("x86/PAT: Have pat_enabled() properly reflect state when running on Xen")

PAT can be enabled without MTRR.

This has resulted in problems e.g. for a SEV-SNP guest running under Hyper-V,
when trying to establish a new mapping via memremap() with WB caching mode, as
pat_x_mtrr_type() will call mtrr_type_lookup(), which in turn is returning
MTRR_TYPE_INVALID due to MTRR being disabled in this configuration.

The result is a mapping with UC- caching, leading to severe performance
degradation.

Fix that by handling MTRR_TYPE_INVALID the same way as MTRR_TYPE_WRBACK
in pat_x_mtrr_type() because MTRR_TYPE_INVALID means MTRRs are disabled.

  [ bp: Massage commit message. ]

Fixes: c4edf0a9ac55 ("x86/PAT: Have pat_enabled() properly reflect state when running on Xen")
Reported-by: Michael Kelley (LINUX) <mikelley@microsoft.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/20230110065427.20767-1-jgross@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/mm/pat/memtype.c