Skip to contentSkip to conversation

x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs

PATCH In review Borislav Petkov 2 participants 7 messages Feb 13, 2013

Subsystems (3)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/1 x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs

From: Borislav Petkov <[email protected]>

The "x86, AMD: Enable WC+ memory type on family 10 processors" patch currently in -tip added a workaround for AMD F10h CPUs which #GPs my guest when booted in kvm. This is because it accesses MSR_AMD64_BU_CFG2 which is not currently ignored by kvm. Do that because this MSR is only baremetal-relevant anyway. While at it, move the ignored MSRs at the beginning of kvm_set_msr_common so that we exit then and there.

Cc Boris Ostrovsky <[email protected]>
Cc Andre Przywara <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Gleb Natapov <[email protected]>
---
 arch/x86/kvm/x86.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kvm/x86.c +9 -7
index c243b81e3c74..37040079cd6b 100644
@@ -1881,6 +1881,14 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	u64 data = msr_info->data;
 
 	switch (msr) {
+	case MSR_AMD64_NB_CFG:
+	case MSR_IA32_UCODE_REV:
+	case MSR_IA32_UCODE_WRITE:
+	case MSR_VM_HSAVE_PA:
+	case MSR_AMD64_PATCH_LOADER:
+	case MSR_AMD64_BU_CFG2:
+		break;
+
 	case MSR_EFER:
 		return set_efer(vcpu, data);
 	case MSR_K7_HWCR:
@@ -1900,8 +1908,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 			return 1;
 		}
 		break;
-	case MSR_AMD64_NB_CFG:
-		break;
 	case MSR_IA32_DEBUGCTLMSR:
 		if (!data) {
 			/* We support the non-activated case already */
@@ -1914,11 +1920,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
 			    __func__, data);
 		break;
-	case MSR_IA32_UCODE_REV:
-	case MSR_IA32_UCODE_WRITE:
-	case MSR_VM_HSAVE_PA:
-	case MSR_AMD64_PATCH_LOADER:
-		break;
 	case 0x200 ... 0x2ff:
 		return set_msr_mtrr(vcpu, msr, data);
 	case MSR_IA32_APICBASE:
@@ -2253,6 +2254,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case MSR_K8_INT_PENDING_MSG:
 	case MSR_AMD64_NB_CFG:
 	case MSR_FAM10H_MMIO_CONF_BASE:
+	case MSR_AMD64_BU_CFG2:
 		data = 0;
 		break;
 	case MSR_P6_PERFCTR0:
Signature · 1 line
1.8.1.3.535.ga923c31
#1 lore raw
Quoted 9 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

The "x86, AMD: Enable WC+ memory type on family 10 processors" patch currently in -tip added a workaround for AMD F10h CPUs which #GPs my guest when booted in kvm. This is because it accesses MSR_AMD64_BU_CFG2 which is not currently ignored by kvm. Do that because this MSR is only baremetal-relevant anyway. While at it, move the ignored MSRs at the beginning of kvm_set_msr_common so that we exit then and there.

Is your guest compiled without PV support? With PV Linux traps #GP for all MSRs and it saves us in more than one places.

Quoted 59 lines
Cc Boris Ostrovsky <[email protected]>
Cc Andre Przywara <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Gleb Natapov <[email protected]>
---
 arch/x86/kvm/x86.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kvm/x86.c +9 -7
index c243b81e3c74..37040079cd6b 100644
@@ -1881,6 +1881,14 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	u64 data = msr_info->data;
 
 	switch (msr) {
+	case MSR_AMD64_NB_CFG:
+	case MSR_IA32_UCODE_REV:
+	case MSR_IA32_UCODE_WRITE:
+	case MSR_VM_HSAVE_PA:
+	case MSR_AMD64_PATCH_LOADER:
+	case MSR_AMD64_BU_CFG2:
+		break;
+
 	case MSR_EFER:
 		return set_efer(vcpu, data);
 	case MSR_K7_HWCR:
@@ -1900,8 +1908,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 			return 1;
 		}
 		break;
-	case MSR_AMD64_NB_CFG:
-		break;
 	case MSR_IA32_DEBUGCTLMSR:
 		if (!data) {
 			/* We support the non-activated case already */
@@ -1914,11 +1920,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
 			    __func__, data);
 		break;
-	case MSR_IA32_UCODE_REV:
-	case MSR_IA32_UCODE_WRITE:
-	case MSR_VM_HSAVE_PA:
-	case MSR_AMD64_PATCH_LOADER:
-		break;
 	case 0x200 ... 0x2ff:
 		return set_msr_mtrr(vcpu, msr, data);
 	case MSR_IA32_APICBASE:
@@ -2253,6 +2254,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case MSR_K8_INT_PENDING_MSG:
 	case MSR_AMD64_NB_CFG:
 	case MSR_FAM10H_MMIO_CONF_BASE:
+	case MSR_AMD64_BU_CFG2:
 		data = 0;
 		break;
 	case MSR_P6_PERFCTR0:
Signature · 1 line
1.8.1.3.535.ga923c31

--
Gleb.

author maintainer
#2 lore raw
Quoted 10 lines · Gleb Natapov
Quoted 9 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

The "x86, AMD: Enable WC+ memory type on family 10 processors" patch currently in -tip added a workaround for AMD F10h CPUs which #GPs my guest when booted in kvm. This is because it accesses MSR_AMD64_BU_CFG2 which is not currently ignored by kvm. Do that because this MSR is only baremetal-relevant anyway. While at it, move the ignored MSRs at the beginning of kvm_set_msr_common so that we exit then and there.

Quoted 2 lines

Is your guest compiled without PV support? With PV Linux traps #GP for all MSRs and it saves us in more than one places.

Yes, CONFIG_PARAVIRT_GUEST is not set on the guest kernel.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#3 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 10 lines · Gleb Natapov
Quoted 9 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

The "x86, AMD: Enable WC+ memory type on family 10 processors" patch currently in -tip added a workaround for AMD F10h CPUs which #GPs my guest when booted in kvm. This is because it accesses MSR_AMD64_BU_CFG2 which is not currently ignored by kvm. Do that because this MSR is only baremetal-relevant anyway. While at it, move the ignored MSRs at the beginning of kvm_set_msr_common so that we exit then and there.

Quoted 5 lines
Quoted 2 lines

Is your guest compiled without PV support? With PV Linux traps #GP for all MSRs and it saves us in more than one places.

Yes, CONFIG_PARAVIRT_GUEST is not set on the guest kernel.

Thanks. It does not mean that the patch should not be applied though. I cannot seems to find the documentation for the MSR anywhere, do you have a pointer?

--
Gleb.

author maintainer
#4 lore raw
Quoted 6 lines · Gleb Natapov
Quoted 5 lines
Quoted 2 lines

Is your guest compiled without PV support? With PV Linux traps #GP for all MSRs and it saves us in more than one places.

Yes, CONFIG_PARAVIRT_GUEST is not set on the guest kernel.

Thanks. It does not mean that the patch should not be applied though.

Right,

but, come to think of it, adding an MSR each time to those functions could turn out to be a PITA. The PV solution with trapping on the MSR accesses might be better so maybe CONFIG_KVM should do

select KVM_GUEST

?

This is even a good forward-looking solution.

Quoted 2 lines

I cannot seems to find the documentation for the MSR anywhere, do you have a pointer?

http://support.amd.com/us/Processor_TechDocs/31116.pdf, p.438

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#5 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Gleb Natapov
Quoted 5 lines
Quoted 2 lines

Is your guest compiled without PV support? With PV Linux traps #GP for all MSRs and it saves us in more than one places.

Yes, CONFIG_PARAVIRT_GUEST is not set on the guest kernel.

Quoted 8 lines
Quoted 1 line

Thanks. It does not mean that the patch should not be applied though.

Right,

but, come to think of it, adding an MSR each time to those functions could turn out to be a PITA. The PV solution with trapping on the MSR accesses might be better so maybe CONFIG_KVM should do

PV solution does not exists for some other guests.

Quoted 3 lines

select KVM_GUEST

?

I can easily imaging the situation where one whats to build different kernels for host and guest and do not have PV in the host one.

Quoted 8 lines

This is even a good forward-looking solution.

Quoted 2 lines

I cannot seems to find the documentation for the MSR anywhere, do you have a pointer?

http://support.amd.com/us/Processor_TechDocs/31116.pdf, p.438

Thanks,

--
Gleb.

Acked-by on v1 1/1
#6 lore raw
In reply to Borislav Petkov
Quoted 9 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

The "x86, AMD: Enable WC+ memory type on family 10 processors" patch currently in -tip added a workaround for AMD F10h CPUs which #GPs my guest when booted in kvm. This is because it accesses MSR_AMD64_BU_CFG2 which is not currently ignored by kvm. Do that because this MSR is only baremetal-relevant anyway. While at it, move the ignored MSRs at the beginning of kvm_set_msr_common so that we exit then and there.

Quoted 5 lines
Cc Boris Ostrovsky <[email protected]>
Cc Andre Przywara <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Gleb Natapov <[email protected]>

Ingo, MSR_AMD64_BU_CFG2 exists only on tip. Can you get this through the tip too?

Quoted 54 lines
---
 arch/x86/kvm/x86.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kvm/x86.c +9 -7
index c243b81e3c74..37040079cd6b 100644
@@ -1881,6 +1881,14 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	u64 data = msr_info->data;
 
 	switch (msr) {
+	case MSR_AMD64_NB_CFG:
+	case MSR_IA32_UCODE_REV:
+	case MSR_IA32_UCODE_WRITE:
+	case MSR_VM_HSAVE_PA:
+	case MSR_AMD64_PATCH_LOADER:
+	case MSR_AMD64_BU_CFG2:
+		break;
+
 	case MSR_EFER:
 		return set_efer(vcpu, data);
 	case MSR_K7_HWCR:
@@ -1900,8 +1908,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 			return 1;
 		}
 		break;
-	case MSR_AMD64_NB_CFG:
-		break;
 	case MSR_IA32_DEBUGCTLMSR:
 		if (!data) {
 			/* We support the non-activated case already */
@@ -1914,11 +1920,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
 			    __func__, data);
 		break;
-	case MSR_IA32_UCODE_REV:
-	case MSR_IA32_UCODE_WRITE:
-	case MSR_VM_HSAVE_PA:
-	case MSR_AMD64_PATCH_LOADER:
-		break;
 	case 0x200 ... 0x2ff:
 		return set_msr_mtrr(vcpu, msr, data);
 	case MSR_IA32_APICBASE:
@@ -2253,6 +2254,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case MSR_K8_INT_PENDING_MSG:
 	case MSR_AMD64_NB_CFG:
 	case MSR_FAM10H_MMIO_CONF_BASE:
+	case MSR_AMD64_BU_CFG2:
 		data = 0;
 		break;
 	case MSR_P6_PERFCTR0:
Signature · 1 line
1.8.1.3.535.ga923c31

--
Gleb.