Commit 098416e6 authored by Tony Luck's avatar Tony Luck Committed by Borislav Petkov
Browse files

x86/mce: Use "safe" MSR functions when enabling additional error logging



Booting as a guest under KVM results in error messages about
unchecked MSR access:

  unchecked MSR access error: RDMSR from 0x17f at rIP: 0xffffffff84483f16 (mce_intel_feature_init+0x156/0x270)

because KVM doesn't provide emulation for random model specific
registers.

Switch to using rdmsrl_safe()/wrmsrl_safe() to avoid the message.

Fixes: 68299a42 ("x86/mce: Enable additional error logging on certain Intel CPUs")
Reported-by: default avatarQian Cai <cai@redhat.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20201111003954.GA11878@agluck-desk2.amr.corp.intel.com
parent 15af3659
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -521,9 +521,10 @@ static void intel_imc_init(struct cpuinfo_x86 *c)
	case INTEL_FAM6_SANDYBRIDGE_X:
	case INTEL_FAM6_IVYBRIDGE_X:
	case INTEL_FAM6_HASWELL_X:
		rdmsrl(MSR_ERROR_CONTROL, error_control);
		if (rdmsrl_safe(MSR_ERROR_CONTROL, &error_control))
			return;
		error_control |= 2;
		wrmsrl(MSR_ERROR_CONTROL, error_control);
		wrmsrl_safe(MSR_ERROR_CONTROL, error_control);
		break;
	}
}