Skip to contentSkip to conversation

x86: don't rely on VMWare emulating PAT MSR correctly

PATCH Superseded Juergen Gross 3 participants 5 messages Dec 16, 2014 – Jan 7, 2015

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

PATCH 1/1 x86: don't rely on VMWare emulating PAT MSR correctly

VMWare seems not to emulate the PAT MSR correctly: reaeding MSR_IA32_CR_PAT returns 0 even after writing another value to it.

Detect this bug and don't use the read value if it is 0.

Commit bd809af16e3ab1f8d55b3e2928c47c67e2a865d2 ("x86: Enable PAT to use cache mode translation tables") triggers this VMWare bug when the kernel is booted as a VMWare guest.

---
 arch/x86/mm/pat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/mm/pat.c +6 -1
index edf299c..7ac6869 100644
@@ -234,8 +234,13 @@ void pat_init(void)
 	      PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC);
 
 	/* Boot CPU check */
-	if (!boot_pat_state)
+	if (!boot_pat_state) {
 		rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
+		if (!boot_pat_state) {
+			pat_disable("PAT read returns always zero, disabled.");
+			return;
+		}
+	}
 
 	wrmsrl(MSR_IA32_CR_PAT, pat);
 
Signature · 1 line
2.1.2
#1 lore raw
Quoted 5 lines · Juergen Gross

VMWare seems not to emulate the PAT MSR correctly: reaeding MSR_IA32_CR_PAT returns 0 even after writing another value to it.

Detect this bug and don't use the read value if it is 0.

Quoted 7 lines

Commit bd809af16e3ab1f8d55b3e2928c47c67e2a865d2 ("x86: Enable PAT to use cache mode translation tables") triggers this VMWare bug when the kernel is booted as a VMWare guest.

I presume cachability control is irrelevant for a VMware guest? I'm wondering if it would be better to just plain ignore the failure rather than disabling PAT.

-hpa

#2 lore raw
Quoted 10 lines · H. Peter Anvin
Quoted 9 lines · Juergen Gross

VMWare seems not to emulate the PAT MSR correctly: reaeding MSR_IA32_CR_PAT returns 0 even after writing another value to it.

Detect this bug and don't use the read value if it is 0.

Commit bd809af16e3ab1f8d55b3e2928c47c67e2a865d2 ("x86: Enable PAT to use cache mode translation tables") triggers this VMWare bug when the kernel is booted as a VMWare guest.

Quoted 7 lines
Quoted 3 lines

I presume cachability control is irrelevant for a VMware guest? I'm wondering if it would be better to just plain ignore the failure rather than disabling PAT.

I'd rather disable PAT as this seems to be like a PAT erratum.

In case you want to keep PAT active I can redo the patch to not rely on the read MSR value in the non-Xen case (under Xen reading the MSR is the only way to obtain the correct settings).

Juergen

Acked-by on v1 1/1
#3 lore raw
In reply to Juergen Gross

Hi,

Quoted 8 lines · Juergen Gross

VMWare seems not to emulate the PAT MSR correctly: reaeding MSR_IA32_CR_PAT returns 0 even after writing another value to it.

Detect this bug and don't use the read value if it is 0.

Commit bd809af16e3ab1f8d55b3e2928c47c67e2a865d2 ("x86: Enable PAT to use cache mode translation tables") triggers this VMWare bug when the kernel is booted as a VMWare guest.

Thanks for taking care of this, we are fine with this workaround. On newer version of our product, where PAT is virtualized correctly on our platform we will go back to using PAT, I will give it a spin sometime later to verify it.

Quoted 16 lines
---
 arch/x86/mm/pat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/mm/pat.c +0 -1
index edf299c..7ac6869 100644
@@ -234,8 +234,13 @@ void pat_init(void)
 	      PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC);
 
 	/* Boot CPU check */
-	if (!boot_pat_state)

arch/x86/mm/pat.c void pat_init(void) · line 246

Quoted 10 lines
arch/x86/mm/pat.c +6 -0
+	if (!boot_pat_state) {
 		rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
+		if (!boot_pat_state) {
+			pat_disable("PAT read returns always zero, disabled.");
+			return;
+		}
+	}
 
 	wrmsrl(MSR_IA32_CR_PAT, pat);
 

Alok ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#4 lore raw

x86 maintainers, could you please consider taking my patch?

There have been several reports now regarding this issue, all could be fixed using my patch.

Juergen

Quoted 49 lines · Alok Kataria

Hi,

Quoted 8 lines · Juergen Gross

VMWare seems not to emulate the PAT MSR correctly: reaeding MSR_IA32_CR_PAT returns 0 even after writing another value to it.

Detect this bug and don't use the read value if it is 0.

Commit bd809af16e3ab1f8d55b3e2928c47c67e2a865d2 ("x86: Enable PAT to use cache mode translation tables") triggers this VMWare bug when the kernel is booted as a VMWare guest.

Thanks for taking care of this, we are fine with this workaround. On newer version of our product, where PAT is virtualized correctly on our platform we will go back to using PAT, I will give it a spin sometime later to verify it.

Quoted 16 lines
---
  arch/x86/mm/pat.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/mm/pat.c +0 -1
index edf299c..7ac6869 100644
@@ -234,8 +234,13 @@ void pat_init(void)
  	      PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC);
 
  	/* Boot CPU check */
-	if (!boot_pat_state)

arch/x86/mm/pat.c void pat_init(void) · line 246

Quoted 10 lines
arch/x86/mm/pat.c +6 -0
+	if (!boot_pat_state) {
  		rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
+		if (!boot_pat_state) {
+			pat_disable("PAT read returns always zero, disabled.");
+			return;
+		}
+	}
 
  	wrmsrl(MSR_IA32_CR_PAT, pat);
 

Alok N�����r��y���b�X��ǧv�^�)޺{.n�+����{����zX����ܨ}���Ơz�&j:+v�������zZ+��+zf���h���~����i���z��w���?����&�)ߢf��^jǫy�m��@A�a��� 0��h��i