x86/mce: Mask out non-address bits from machine check bank
authorTony Luck <tony.luck@intel.com>
Mon, 9 Jan 2023 15:29:36 +0000 (07:29 -0800)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 10 Jan 2023 10:47:07 +0000 (11:47 +0100)
commit8a01ec97dc066009dd89e43bfcf55644f2dd6d19
tree5d1888d7c2c721ef95fb3e551bd2a2732b597b44
parentfcd343a285cb41894a7bd02dbd675042d394758d
x86/mce: Mask out non-address bits from machine check bank

Systems that support various memory encryption schemes (MKTME, TDX, SEV)
use high order physical address bits to indicate which key should be
used for a specific memory location.

When a memory error is reported, some systems may report those key
bits in the IA32_MCi_ADDR machine check MSR.

The Intel SDM has a footnote for the contents of the address register
that says: "Useful bits in this field depend on the address methodology
in use when the register state is saved."

AMD Processor Programming Reference has a more explicit description
of the MCA_ADDR register:

 "For physical addresses, the most significant bit is given by
  Core::X86::Cpuid::LongModeInfo[PhysAddrSize]."

Add a new #define MCI_ADDR_PHYSADDR for the mask of valid physical
address bits within the machine check bank address register. Use this
mask for recoverable machine check handling and in the EDAC driver to
ignore any key bits that may be present.

  [ Tony: Based on independent fixes proposed by Fan Du and Isaku Yamahata ]

Reported-by: Isaku Yamahata <isaku.yamahata@intel.com>
Reported-by: Fan Du <fan.du@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Link: https://lore.kernel.org/r/20230109152936.397862-1-tony.luck@intel.com
arch/x86/include/asm/mce.h
arch/x86/kernel/cpu/mce/core.c
drivers/edac/skx_common.c