Skip to contentSkip to conversation

i386: do a global tlb flush in S4 resume

PATCH In review Shaohua Li 3 participants 11 messages Mar 4, 2010 – Mar 30, 2010

Subsystems (2)
lore
Share & tools
lore

Shaohua Li

author
#0 lore raw

PATCH 1/1 i386: do a global tlb flush in S4 resume

Colin reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

---
 arch/x86/power/hibernate_asm_32.S |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/power/hibernate_asm_32.S +11 -0
index b641388..9e4ef64 100644
@@ -27,10 +27,21 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %edx
+	andl	$~(X86_CR4_PGE), %edx
+	movl	%edx, %cr4;  # turn off PGE
+1:
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %cr4;  # turn PGE back on
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 36 lines · Shaohua Li

Colin reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

---
 arch/x86/power/hibernate_asm_32.S |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/power/hibernate_asm_32.S +4 -0
index b641388..9e4ef64 100644
@@ -27,10 +27,21 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %edx
+	andl	$~(X86_CR4_PGE), %edx

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 47

Quoted 10 lines
arch/x86/power/hibernate_asm_32.S +7 -0
+	movl	%edx, %cr4;  # turn off PGE
+1:
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %cr4;  # turn PGE back on
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 

Since we're about to do another global page flush a bit further down in the same code, why not just leave PGE off until then?

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
author
#2 lore raw
Quoted 34 lines · H. Peter Anvin
Quoted 33 lines · Shaohua Li

Colin reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

---
 arch/x86/power/hibernate_asm_32.S |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..9e4ef64 100644
@@ -27,10 +27,21 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
Quoted 16 lines

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 47

Quoted 13 lines
arch/x86/power/hibernate_asm_32.S +10 -0
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %edx
+	andl	$~(X86_CR4_PGE), %edx
+	movl	%edx, %cr4;  # turn off PGE
+1:
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %cr4;  # turn PGE back on
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 

Since we're about to do another global page flush a bit further down in the same code, why not just leave PGE off until then?

sure, updated patch.

i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +7 -0
index b641388..cd5e878 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
#3 lore raw
Quoted 84 lines · Shaohua Li
Quoted 34 lines · H. Peter Anvin
Quoted 33 lines · Shaohua Li

Colin reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

---
 arch/x86/power/hibernate_asm_32.S |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..9e4ef64 100644
@@ -27,10 +27,21 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
Quoted 16 lines

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 43

Quoted 13 lines
arch/x86/power/hibernate_asm_32.S +10 -0
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %edx
+	andl	$~(X86_CR4_PGE), %edx
+	movl	%edx, %cr4;  # turn off PGE
+1:
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %cr4;  # turn PGE back on
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 

Since we're about to do another global page flush a bit further down in the same code, why not just leave PGE off until then?

sure, updated patch.

i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..cd5e878 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 42

Quoted 10 lines
arch/x86/power/hibernate_asm_32.S +6 -0
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7

In that case please also remove the turning GPE off down the road.

Rafael

#4 lore raw
Quoted 87 lines · Rafael J. Wysocki
Quoted 86 lines · Shaohua Li
Quoted 34 lines · H. Peter Anvin
Quoted 33 lines · Shaohua Li

Colin reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

---
 arch/x86/power/hibernate_asm_32.S |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..9e4ef64 100644
@@ -27,10 +27,21 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
Quoted 16 lines

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 43

Quoted 13 lines
arch/x86/power/hibernate_asm_32.S +10 -0
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %edx
+	andl	$~(X86_CR4_PGE), %edx
+	movl	%edx, %cr4;  # turn off PGE
+1:
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %cr4;  # turn PGE back on
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 

Since we're about to do another global page flush a bit further down in the same code, why not just leave PGE off until then?

sure, updated patch.

i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..cd5e878 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
Quoted 10 lines

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 42

Quoted 8 lines
arch/x86/power/hibernate_asm_32.S +6 -0
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7

In that case please also remove the turning GPE off down the road.

s/GPE/PGE/

doh, too much ACPI programming lately.

Rafael

author
#5 lore raw
In reply to Rafael J. Wysocki
Quoted 87 lines · Rafael J. Wysocki
Quoted 86 lines · Shaohua Li
Quoted 34 lines · H. Peter Anvin
Quoted 33 lines · Shaohua Li

Colin reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

---
 arch/x86/power/hibernate_asm_32.S |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..9e4ef64 100644
@@ -27,10 +27,21 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
Quoted 16 lines

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 47

Quoted 13 lines
arch/x86/power/hibernate_asm_32.S +10 -0
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %edx
+	andl	$~(X86_CR4_PGE), %edx
+	movl	%edx, %cr4;  # turn off PGE
+1:
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	movl	%ecx, %cr4;  # turn PGE back on
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 

Since we're about to do another global page flush a bit further down in the same code, why not just leave PGE off until then?

sure, updated patch.

i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +1 -0
index b641388..cd5e878 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
Quoted 10 lines

arch/x86/power/hibernate_asm_32.S ENTRY(swsusp_arch_suspend) · line 42

Quoted 8 lines
arch/x86/power/hibernate_asm_32.S +6 -0
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7

In that case please also remove the turning GPE off down the road.

    i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +7 -8
index b641388..ad47dae 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
@@ -54,16 +61,8 @@ done:
 	movl	$swapper_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
-	/* Flush TLB, including "global" things (vmalloc) */
 	movl	mmu_cr4_features, %ecx
 	jecxz	1f	# cr4 Pentium and higher, skip if zero
-	movl	%ecx, %edx
-	andl	$~(X86_CR4_PGE), %edx
-	movl	%edx, %cr4;  # turn off PGE
-1:
-	movl	%cr3, %eax;  # flush TLB
-	movl	%eax, %cr3
-	jecxz	1f	# cr4 Pentium and higher, skip if zero
 	movl	%ecx, %cr4;  # turn PGE back on
 1:
 
#6 lore raw
Quoted 2 lines · Shaohua Li
Quoted 1 line · Rafael J. Wysocki

On Thursday 04 March 2010, Shaohua Li wrote:

...

Quoted 47 lines
Quoted 2 lines

In that case please also remove the turning GPE off down the road.

    i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +7 -0
index b641388..ad47dae 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
@@ -54,16 +61,8 @@ done:
 	movl	$swapper_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax

arch/x86/power/hibernate_asm_32.S done: · line 65

Quoted 10 lines
arch/x86/power/hibernate_asm_32.S +0 -7
 	movl	%eax, %cr3
-	/* Flush TLB, including "global" things (vmalloc) */
 	movl	mmu_cr4_features, %ecx
 	jecxz	1f	# cr4 Pentium and higher, skip if zero
-	movl	%ecx, %edx
-	andl	$~(X86_CR4_PGE), %edx
-	movl	%edx, %cr4;  # turn off PGE
-1:
-	movl	%cr3, %eax;  # flush TLB
-	movl	%eax, %cr3

Now that's too much removed. We actually _want_ to do the TLB flush here, but not unset PGE, because it's been unset already.

So, the above two lines should not be removed.

Also, I'd remove the first jecxz and keep the second one.

arch/x86/power/hibernate_asm_32.S done: · line 67

Quoted 3 lines
arch/x86/power/hibernate_asm_32.S +0 -1
-	jecxz	1f	# cr4 Pentium and higher, skip if zero
 	movl	%ecx, %cr4;  # turn PGE back on
 1:

Rafael

#7 lore raw
Quoted 65 lines · Rafael J. Wysocki
Quoted 2 lines · Shaohua Li
Quoted 1 line · Rafael J. Wysocki

On Thursday 04 March 2010, Shaohua Li wrote:

...

Quoted 47 lines
Quoted 2 lines

In that case please also remove the turning GPE off down the road.

    i386: do a global tlb flush in S4 resume

    Colin reported a strange oops in S4 resume code path (see below). The test
    system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used.
    The oops always happen a virtual address 0xc03ff000, which is mapped to the
    last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

    EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0
    EIP is at copy_loop+0xe/0x15
    EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
    ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    ...
    ...
    CR2: 00000000c03ff000

    Tested-by: Colin Ian King <[email protected]>
    Signed-off-by: Shaohua Li <[email protected]>
arch/x86/power/hibernate_asm_32.S +7 -0
index b641388..ad47dae 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
@@ -54,16 +61,8 @@ done:
 	movl	$swapper_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax

arch/x86/power/hibernate_asm_32.S done: · line 65

Quoted 10 lines
arch/x86/power/hibernate_asm_32.S +0 -7
 	movl	%eax, %cr3
-	/* Flush TLB, including "global" things (vmalloc) */
 	movl	mmu_cr4_features, %ecx
 	jecxz	1f	# cr4 Pentium and higher, skip if zero
-	movl	%ecx, %edx
-	andl	$~(X86_CR4_PGE), %edx
-	movl	%edx, %cr4;  # turn off PGE
-1:
-	movl	%cr3, %eax;  # flush TLB
-	movl	%eax, %cr3

Now that's too much removed. We actually _want_ to do the TLB flush here, but not unset PGE, because it's been unset already.

Quoted 3 lines

So, the above two lines should not be removed.

Also, I'd remove the first jecxz and keep the second one.

Scratch that, the patch is fine, because we load cr3 right before that. Sorry for the noise.

Peter, are you going to take it or should I handle it?

Rafael

#8 lore raw
Quoted 3 lines · Rafael J. Wysocki

Peter, are you going to take it or should I handle it?

I'll take it after -rc1.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#9 lore raw

[tip:x86/urgent] x86-32, resume: do a global tlb flush in S4 resume

In reply to Shaohua Li
Commit-ID:  f1ddc38590a400e19ba67963dac5bc3addc6e14b
Gitweb:     http://git.kernel.org/tip/f1ddc38590a400e19ba67963dac5bc3addc6e14b
Author:     Shaohua Li <[email protected]>
AuthorDate: Fri, 5 Mar 2010 08:59:32 +0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 30 Mar 2010 10:50:42 -0700

x86-32, resume: do a global tlb flush in S4 resume

Colin King reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

LKML-Reference: <[email protected]>

---
 arch/x86/power/hibernate_asm_32.S |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
arch/x86/power/hibernate_asm_32.S +7 -8
index b641388..ad47dae 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
@@ -54,16 +61,8 @@ done:
 	movl	$swapper_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
-	/* Flush TLB, including "global" things (vmalloc) */
 	movl	mmu_cr4_features, %ecx
 	jecxz	1f	# cr4 Pentium and higher, skip if zero
-	movl	%ecx, %edx
-	andl	$~(X86_CR4_PGE), %edx
-	movl	%edx, %cr4;  # turn off PGE
-1:
-	movl	%cr3, %eax;  # flush TLB
-	movl	%eax, %cr3
-	jecxz	1f	# cr4 Pentium and higher, skip if zero
 	movl	%ecx, %cr4;  # turn PGE back on
 1:
 
#10 lore raw

[tip:x86/urgent] x86-32, resume: do a global tlb flush in S4 resume

In reply to Shaohua Li
Commit-ID:  8ae06d223f8203c72104e5c0c4ee49a000aedb42
Gitweb:     http://git.kernel.org/tip/8ae06d223f8203c72104e5c0c4ee49a000aedb42
Author:     Shaohua Li <[email protected]>
AuthorDate: Fri, 5 Mar 2010 08:59:32 +0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 30 Mar 2010 11:46:02 -0700

x86-32, resume: do a global tlb flush in S4 resume

Colin King reported a strange oops in S4 resume code path (see below). The test system has i5/i7 CPU. The kernel doesn't open PAE, so 4M page table is used. The oops always happen a virtual address 0xc03ff000, which is mapped to the last 4k of first 4M memory. Doing a global tlb flush fixes the issue.

EIP: 0060:[<c0493a01>] EFLAGS: 00010086 CPU: 0 EIP is at copy_loop+0xe/0x15
EAX: 36aeb000 EBX: 00000000 ECX: 00000400 EDX: f55ad46c
ESI: 0f800000 EDI: c03ff000 EBP: f67fbec4 ESP: f67fbea8
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
...
...
CR2: 00000000c03ff000

LKML-Reference: <[email protected]>

---
 arch/x86/power/hibernate_asm_32.S |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
arch/x86/power/hibernate_asm_32.S +7 -8
index b641388..ad47dae 100644
@@ -27,10 +27,17 @@ ENTRY(swsusp_arch_suspend)
 	ret
 
 ENTRY(restore_image)
+	movl	mmu_cr4_features, %ecx
 	movl	resume_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	jecxz	1f	# cr4 Pentium and higher, skip if zero
+	andl	$~(X86_CR4_PGE), %ecx
+	movl	%ecx, %cr4;  # turn off PGE
+	movl	%cr3, %eax;  # flush TLB
+	movl	%eax, %cr3
+1:
 	movl	restore_pblist, %edx
 	.p2align 4,,7
 
@@ -54,16 +61,8 @@ done:
 	movl	$swapper_pg_dir, %eax
 	subl	$__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
-	/* Flush TLB, including "global" things (vmalloc) */
 	movl	mmu_cr4_features, %ecx
 	jecxz	1f	# cr4 Pentium and higher, skip if zero
-	movl	%ecx, %edx
-	andl	$~(X86_CR4_PGE), %edx
-	movl	%edx, %cr4;  # turn off PGE
-1:
-	movl	%cr3, %eax;  # flush TLB
-	movl	%eax, %cr3
-	jecxz	1f	# cr4 Pentium and higher, skip if zero
 	movl	%ecx, %cr4;  # turn PGE back on
 1: