linux/arch
Juergen Gross 230ec83d42 x86/pat: Fix x86_has_pat_wp()
x86_has_pat_wp() is using a wrong test, as it relies on the normal
PAT configuration used by the kernel. In case the PAT MSR has been
setup by another entity (e.g. Xen hypervisor) it might return false
even if the PAT configuration is allowing WP mappings. This due to the
fact that when running as Xen PV guest the PAT MSR is setup by the
hypervisor and cannot be changed by the guest. This results in the WP
related entry to be at a different position when running as Xen PV
guest compared to the bare metal or fully virtualized case.

The correct way to test for WP support is:

1. Get the PTE protection bits needed to select WP mode by reading
   __cachemode2pte_tbl[_PAGE_CACHE_MODE_WP] (depending on the PAT MSR
   setting this might return protection bits for a stronger mode, e.g.
   UC-)
2. Translate those bits back into the real cache mode selected by those
   PTE bits by reading __pte2cachemode_tbl[__pte2cm_idx(prot)]
3. Test for the cache mode to be _PAGE_CACHE_MODE_WP

Fixes: f88a68facd ("x86/mm: Extend early_memremap() support with additional attrs")
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org> # 4.14
Link: https://lore.kernel.org/r/20220503132207.17234-1-jgross@suse.com
2022-07-13 12:44:04 +02:00
..
alpha
arc
arm xen: security patches for v5.19 2022-07-05 09:18:32 -07:00
arm64 ARM: SoC fixes for v5.19, part 2 2022-07-04 10:41:59 -07:00
csky
hexagon
ia64
loongarch LoongArch: Fix section mismatch warning 2022-07-07 17:41:01 +08:00
m68k
microblaze
mips
nios2
openrisc openrisc: unwinder: Fix grammar issue in comment 2022-06-28 17:31:24 +09:00
parisc parisc: Fix vDSO signal breakage on 32-bit kernel 2022-07-02 18:36:58 +02:00
powerpc powerpc/powernv: delay rng platform device creation until later in boot 2022-07-04 21:11:47 +10:00
riscv riscv/mm: fix build error while PAGE_TABLE_CHECK enabled without MMU 2022-07-03 15:42:32 -07:00
s390 s390/qdio: Fix spelling mistake 2022-06-30 19:40:36 +02:00
sh sh: convert nommu io{re,un}map() to static inline functions 2022-07-03 15:42:32 -07:00
sparc
um
x86 x86/pat: Fix x86_has_pat_wp() 2022-07-13 12:44:04 +02:00
xtensa
.gitignore
Kconfig