Skip to contentSkip to conversation

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

PATCH RESEND In review Juergen Gross 3 participants 4 messages Jan 12, 2015 – Jan 20, 2015

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

PATCH RESEND 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

PING!

The patch repairs a bug with VMWARE, which has been reported by several users. All of them have confirmed the patch is working. And VMWARE has acked the patch. What else do you need to take it? It is available for over a month now!

Juergen

Quoted 37 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.

---
  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);
 
#2 lore raw

Juergen, thanks for following up on this.

X86 maintainers - If it helps let me also confirm that without this patch the latest kernels *always* crash on VMware guest running HWv10 and earlier.

Please include the fix at your earliest.

Thanks,
Alok

Quoted 44 lines · Juergen Gross

PING!

The patch repairs a bug with VMWARE, which has been reported by several users. All of them have confirmed the patch is working. And VMWARE has acked the patch. What else do you need to take it? It is available for over a month now!

Juergen

Quoted 34 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.

---
  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;
+		}
+	}
 
Quoted 4 lines

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

Quoted 3 lines
arch/x86/mm/pat.c +0 -0
  	wrmsrl(MSR_IA32_CR_PAT, pat);
 

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

#3 lore raw

[tip:x86/urgent] x86: Don' t rely on VMWare emulating PAT MSR correctly

In reply to Juergen Gross
x86: Don't rely on VMWare emulating PAT MSR correctly
Commit-ID:  9d34cfdf47963905d792ae9c000efa522739abe4
Gitweb:     http://git.kernel.org/tip/9d34cfdf47963905d792ae9c000efa522739abe4
Author:     Juergen Gross <[email protected]>
AuthorDate: Mon, 12 Jan 2015 06:15:45 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 20 Jan 2015 14:33:45 +0100

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.

Commit bd809af16e3ab triggers this VMWare bug when the kernel is booted as a VMWare guest.

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

Fixes bd809af16e3ab "x86: Enable PAT to use cache mode translation tables"
Reported-and-tested-by Jongman Heo <[email protected]>
---
 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);