Skip to contentSkip to conversation

x86: Use v8086_mode helper, trivial unification

PATCH In review Harvey Harrison 3 participants 6 messages Jan 18, 2008

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

PATCH v2 1/1 x86: Use v8086_mode helper, trivial unification

Use v8086_mode inline in fault_32.c, no functional change also ifdef the section for 32-bit only and add to fault_64.c

---
HPA noted that v8086_mode is always zero on X86_64, no ifdef needed.

 arch/x86/mm/fault_32.c |    3 ++-
 arch/x86/mm/fault_64.c |   10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)
arch/x86/mm/fault_32.c +2 -1
index 77915ac..53f4fe4 100644
@@ -550,11 +550,12 @@ good_area:
 	/*
 	 * Did it hit the DOS screen memory VA from vm86 mode?
 	 */
-	if (regs->flags & VM_MASK) {
+	if (v8086_mode(regs)) {
 		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
 		if (bit < 32)
 			tsk->thread.screen_bitmap |= 1 << bit;
 	}
+
 	up_read(&mm->mmap_sem);
 	return;
 
arch/x86/mm/fault_64.c +10 -0
index 84531d8..c05211d 100644
@@ -551,6 +551,16 @@ good_area:
 		tsk->maj_flt++;
 	else
 		tsk->min_flt++;
+
+	/*
+	 * Did it hit the DOS screen memory VA from vm86 mode?
+	 */
+	if (v8086_mode(regs)) {
+		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
+		if (bit < 32)
+			tsk->thread.screen_bitmap |= 1 << bit;
+	}
+
 	up_read(&mm->mmap_sem);
 	return;
 
Signature · 1 line
1.5.4.rc2.1164.g6451
#1 lore raw
Quoted 11 lines · Harvey Harrison

Use v8086_mode inline in fault_32.c, no functional change also ifdef the section for 32-bit only and add to fault_64.c

arch/x86/mm/fault_32.c +1 -1
-	if (regs->flags & VM_MASK) {
+	if (v8086_mode(regs)) {
arch/x86/mm/fault_64.c +0 -0
@@ -551,6 +551,16 @@ good_area:
 		tsk->maj_flt++;
 	else

arch/x86/mm/fault_64.c good_area: · line 562

Quoted 10 lines
arch/x86/mm/fault_64.c +9 -0
 		tsk->min_flt++;
+
+	/*
+	 * Did it hit the DOS screen memory VA from vm86 mode?
+	 */
+	if (v8086_mode(regs)) {
+		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
+		if (bit < 32)
+			tsk->thread.screen_bitmap |= 1 << bit;
+	}

hm, is there even vm86 mode in 64-bit? Anyway, gcc will eliminate it i guess. I've applied your patch.

Ingo

#2 lore raw
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Harvey Harrison

Use v8086_mode inline in fault_32.c, no functional change also ifdef the section for 32-bit only and add to fault_64.c

arch/x86/mm/fault_32.c +1 -1
-	if (regs->flags & VM_MASK) {
+	if (v8086_mode(regs)) {
arch/x86/mm/fault_64.c +4 -0
@@ -551,6 +551,16 @@ good_area:
 		tsk->maj_flt++;
 	else
 		tsk->min_flt++;
+
+	/*
+	 * Did it hit the DOS screen memory VA from vm86 mode?
+	 */
Quoted 9 lines

arch/x86/mm/fault_64.c good_area: · line 562

Quoted 5 lines
arch/x86/mm/fault_64.c +5 -0
+	if (v8086_mode(regs)) {
+		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
+		if (bit < 32)
+			tsk->thread.screen_bitmap |= 1 << bit;
+	}

hm, is there even vm86 mode in 64-bit? Anyway, gcc will eliminate it i guess. I've applied your patch.

No, it doesn't mean anything to 64-bit, but helps make the diff a little bit smaller, getting pretty close now.

Still needs a bit of work to introduce oops_begin/end from 64-bit to 32-bit in traps_32.c and introduce a bad_pgtable-like function to 32bit, then we're down to small differences between 32/64 bit do_page_fault and vmalloc_sync_all that should be relatively clean to harmonize.

Got distracted with the ptrace stuff today, but patch coming soon.

Harvey

#3 lore raw
In reply to Ingo Molnar
Quoted 9 lines

arch/x86/mm/fault_64.c good_area: · line 562

Quoted 9 lines
arch/x86/mm/fault_64.c +8 -0
+	/*
+	 * Did it hit the DOS screen memory VA from vm86 mode?
+	 */
+	if (v8086_mode(regs)) {
+		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
+		if (bit < 32)
+			tsk->thread.screen_bitmap |= 1 << bit;
+	}

this does not build on 64-bit, because screen_bitmap is 32-bit only - so i had to pull the patch. I suspect a small #ifdef section would look better here?

Ingo

#4 lore raw
Quoted 4 lines · Ingo Molnar
Quoted 4 lines
Quoted 4 lines
arch/x86/mm/fault_64.c +4 -0
+	/*
+	 * Did it hit the DOS screen memory VA from vm86 mode?
+	 */
+	if (v8086_mode(regs)) {
Quoted 9 lines
Quoted 4 lines

arch/x86/mm/fault_64.c good_area: · line 562

Quoted 4 lines
arch/x86/mm/fault_64.c +4 -0
+		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
+		if (bit < 32)
+			tsk->thread.screen_bitmap |= 1 << bit;
+	}

this does not build on 64-bit, because screen_bitmap is 32-bit only - so i had to pull the patch. I suspect a small #ifdef section would look better here?

My original patch had the ifdef, you can grab that one.

Harvey

#5 lore raw
Quoted 12 lines · Harvey Harrison
Quoted 10 lines · Ingo Molnar
Quoted 8 lines

arch/x86/mm/fault_64.c good_area: · line 562

Quoted 8 lines
arch/x86/mm/fault_64.c +8 -0
+	/*
+	 * Did it hit the DOS screen memory VA from vm86 mode?
+	 */
+	if (v8086_mode(regs)) {
+		unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
+		if (bit < 32)
+			tsk->thread.screen_bitmap |= 1 << bit;
+	}

this does not build on 64-bit, because screen_bitmap is 32-bit only - so i had to pull the patch. I suspect a small #ifdef section would look better here?

Quoted 2 lines

My original patch had the ifdef, you can grab that one.

Me bad, I should have been less definite in my reply.

-hpa