Skip to contentSkip to conversation

AMD Erratum 383 workaround for KVM

PATCH In review Joerg Roedel 2 participants 5 messages May 17, 2010 – May 19, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover AMD Erratum 383 workaround for KVM

Hi,

these two patches implement the workaround for AMD Erratum 383 into KVM. This is necessary to prevent the host to crash if a guest triggers the erratum.
For details on the erratum please see page 96 of

http://support.amd.com/us/Processor_TechDocs/41322.pdf

The workaround implemented in these patches will be documented in the next update of the revision guide.

Joerg

Diffstat:

 arch/x86/include/asm/msr-index.h |    1 +
 arch/x86/kvm/svm.c               |   98 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 98 insertions(+), 1 deletions(-)

Shortlog:

Joerg Roedel (2):
KVM: SVM: Handle MCEs early in the vmexit process
KVM: SVM: Implement workaround for Erratum 383

#1 lore raw

PATCH 1/2 KVM: SVM: Handle MCEs early in the vmexit process

This patch moves handling of the MC vmexits to an earlier point in the vmexit. The handle_exit function is too late because the vcpu might alreadry have changed its physical cpu.

---
 arch/x86/kvm/svm.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
arch/x86/kvm/svm.c +14 -1
index cea916f..f92d191 100644
@@ -1410,7 +1410,7 @@ static int nm_interception(struct vcpu_svm *svm)
 	return 1;
 }
 
-static int mc_interception(struct vcpu_svm *svm)
+static void svm_handle_mce(struct vcpu_svm *svm)
 {
 	/*
 	 * On an #MC intercept the MCE handler is not called automatically in
@@ -1420,6 +1420,11 @@ static int mc_interception(struct vcpu_svm *svm)
 		"int $0x12\n");
 	/* not sure if we ever come back to this point */
 
+	return;
+}
+
+static int mc_interception(struct vcpu_svm *svm)
+{
 	return 1;
 }
 
@@ -3183,6 +3188,14 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 		vcpu->arch.regs_avail &= ~(1 << VCPU_EXREG_PDPTR);
 		vcpu->arch.regs_dirty &= ~(1 << VCPU_EXREG_PDPTR);
 	}
+
+	/*
+	 * We need to handle MC intercepts here before the vcpu has a chance to
+	 * change the physical cpu
+	 */
+	if (unlikely(svm->vmcb->control.exit_code ==
+		     SVM_EXIT_EXCP_BASE + MC_VECTOR))
+		svm_handle_mce(svm);
 }
 
 #undef R
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 KVM: SVM: Implement workaround for Erratum 383

In reply to Joerg Roedel

This patch implements a workaround for AMD erratum 383 into KVM. Without this erratum fix it is possible for a guest to kill the host machine. This patch implements the suggested workaround for hypervisors which will be published by the next revision guide update.

---
 arch/x86/include/asm/msr-index.h |    1 +
 arch/x86/kvm/svm.c               |   83 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 0 deletions(-)
arch/x86/include/asm/msr-index.h +1 -0
index 4eb2f72..fdb6af2 100644
@@ -112,6 +112,7 @@
 #define MSR_AMD64_PATCH_LOADER		0xc0010020
 #define MSR_AMD64_OSVW_ID_LENGTH	0xc0010140
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
+#define MSR_AMD64_DC_CFG		0xc0011022
 #define MSR_AMD64_IBSFETCHCTL		0xc0011030
 #define MSR_AMD64_IBSFETCHLINAD		0xc0011031
 #define MSR_AMD64_IBSFETCHPHYSAD	0xc0011032
arch/x86/kvm/svm.c +83 -0

115 lines not on this page · raw message

Signature · 1 line
1.7.1
#3 lore raw
In reply to Joerg Roedel
Quoted 9 lines · Joerg Roedel

these two patches implement the workaround for AMD Erratum 383 into KVM. This is necessary to prevent the host to crash if a guest triggers the erratum.
For details on the erratum please see page 96 of

http://support.amd.com/us/Processor_TechDocs/41322.pdf

The workaround implemented in these patches will be documented in the next update of the revision guide.

Hey Marcelo, Avi,

have you had a chance to look at this? Any opinions?

Thanks,

Joerg

#4 lore raw
Quoted 7 lines · Joerg Roedel
Quoted 5 lines · Joerg Roedel

these two patches implement the workaround for AMD Erratum 383 into KVM. This is necessary to prevent the host to crash if a guest triggers the erratum.
For details on the erratum please see page 96 of

Quoted 10 lines
Quoted 5 lines

http://support.amd.com/us/Processor_TechDocs/41322.pdf

The workaround implemented in these patches will be documented in the next update of the revision guide.

Hey Marcelo, Avi,

have you had a chance to look at this? Any opinions?

Sorry, holiday here. Patches applied, thanks.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.