Skip to contentSkip to conversation

x86: head_64.S cleanup - use PMD_SHIFT instead of numeric constant

PATCH In review Cyrill Gorcunov 2 participants 7 messages May 13, 2008 1 message not in the archive x86

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 x86: head_64.S cleanup - use straight move to CR4 register

There is no need for testing the values because we already know what they should be. Just set them in straight way.

---

arch/x86/kernel/head_64.S +1 -3
Index: linux-2.6.git/arch/x86/kernel/head_64.S
===================================================================
@@ -155,9 +155,7 @@ ENTRY(secondary_startup_64)
 	 */
 
 	/* Enable PAE mode and PGE */
-	xorq	%rax, %rax
-	btsq	$5, %rax
-	btsq	$7, %rax
+	movq	$(X86_CR4_PAE | X86_CR4_PGE), %rax
 	movq	%rax, %cr4
 
 	/* Setup early boot stage 4 level pagetables. */
#2 lore raw

Re: [patch 1/2] x86: head_64.S cleanup - use straight move to CR4 register

Quoted 2 lines · Cyrill Gorcunov

There is no need for testing the values because we already know what they should be. Just set them in straight way.

He isn't testing them, he's setting individual bits.

Either of these is pretty silly; the right way to do this is:

	movl	$(X86_CR4_PAE|X86_CR4_PGE), %eax
	movq	%rax, %cr4

A movl in 64-bit mode zero extends.

-hpa

#3 lore raw

Re: [patch 1/2] x86: head_64.S cleanup - use straight move to CR4 register

[H. Peter Anvin - Tue, May 13, 2008 at 10:03:42AM -0700]

Quoted 5 lines
Quoted 2 lines · Cyrill Gorcunov

There is no need for testing the values because we already know what they should be. Just set them in straight way.

He isn't testing them, he's setting individual bits.

not exactly - bts: bit test and set

Quoted 10 lines

Either of these is pretty silly; the right way to do this is:

	movl	$(X86_CR4_PAE|X86_CR4_PGE), %eax
	movq	%rax, %cr4

A movl in 64-bit mode zero extends.

-hpa

ok, thanks Peter, i'll update in minute ;)

- Cyrill -

#4 lore raw

Re: [patch 1/2] x86: head_64.S cleanup - use straight move to CR4 register

In reply to H. Peter Anvin

[H. Peter Anvin - Tue, May 13, 2008 at 10:03:42AM -0700]

Quoted 6 lines
Quoted 2 lines · Cyrill Gorcunov

There is no need for testing the values because we already know what they should be. Just set them in straight way.

He isn't testing them, he's setting individual bits.

Quoted 9 lines

Either of these is pretty silly; the right way to do this is:

	movl	$(X86_CR4_PAE|X86_CR4_PGE), %eax
	movq	%rax, %cr4

A movl in 64-bit mode zero extends.

-hpa

Here is updated version
---
[PATCH] x86: head_64.S cleanup - use straight move to CR4 register

---

arch/x86/kernel/head_64.S +1 -3
Index: linux-2.6.git/arch/x86/kernel/head_64.S
===================================================================
@@ -155,9 +155,7 @@ ENTRY(secondary_startup_64)
 	 */
 
 	/* Enable PAE mode and PGE */
-	xorq	%rax, %rax
-	btsq	$5, %rax
-	btsq	$7, %rax
+	movl	$(X86_CR4_PAE | X86_CR4_PGE), %rax
 	movq	%rax, %cr4
 
 	/* Setup early boot stage 4 level pagetables. */
#5 lore raw

Re: [patch 1/2] x86: head_64.S cleanup - use straight move to CR4 register

Quoted 28 lines · Cyrill Gorcunov

[H. Peter Anvin - Tue, May 13, 2008 at 10:03:42AM -0700]

Quoted 5 lines
Quoted 2 lines · Cyrill Gorcunov

There is no need for testing the values because we already know what they should be. Just set them in straight way.

He isn't testing them, he's setting individual bits.

Quoted 9 lines

Either of these is pretty silly; the right way to do this is:

	movl	$(X86_CR4_PAE|X86_CR4_PGE), %eax
	movq	%rax, %cr4

A movl in 64-bit mode zero extends.

-hpa

Here is updated version
---
[PATCH] x86: head_64.S cleanup - use straight move to CR4 register

---

Index: linux-2.6.git/arch/x86/kernel/head_64.S
===================================================================

arch/x86/kernel/head_64.S ENTRY(secondary_startup_64) · line 160

Quoted 9 lines
arch/x86/kernel/head_64.S +1 -3
@@ -155,9 +155,7 @@ ENTRY(secondary_startup_64)
 	 */
 
 	/* Enable PAE mode and PGE */
-	xorq	%rax, %rax
-	btsq	$5, %rax
-	btsq	$7, %rax
+	movl	$(X86_CR4_PAE | X86_CR4_PGE), %rax
 	movq	%rax, %cr4
 

Syntax error. %eax, not %rax.

-hpa

#6 lore raw

Re: [patch 1/2] x86: head_64.S cleanup - use straight move to CR4 register

[H. Peter Anvin - Tue, May 13, 2008 at 10:11:34AM -0700]

Quoted 39 lines
Quoted 27 lines · Cyrill Gorcunov

[H. Peter Anvin - Tue, May 13, 2008 at 10:03:42AM -0700]

Quoted 5 lines
Quoted 2 lines · Cyrill Gorcunov

There is no need for testing the values because we already know what they should be. Just set them in straight way.

He isn't testing them, he's setting individual bits.

Quoted 9 lines

Either of these is pretty silly; the right way to do this is:

	movl	$(X86_CR4_PAE|X86_CR4_PGE), %eax
	movq	%rax, %cr4

A movl in 64-bit mode zero extends.

-hpa

Here is updated version
---
[PATCH] x86: head_64.S cleanup - use straight move to CR4 register

---
Index: linux-2.6.git/arch/x86/kernel/head_64.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/head_64.S 2008-05-13
20:04:23.000000000 +0400
+++ linux-2.6.git/arch/x86/kernel/head_64.S 2008-05-13 21:08:20.000000000
+0400

Review ENTRY(secondary_startup_64) · line 159

Quoted 8 lines
(quoted diff) +1 -3
@@ -155,9 +155,7 @@ ENTRY(secondary_startup_64)
 	 */
  	/* Enable PAE mode and PGE */
-	xorq	%rax, %rax
-	btsq	$5, %rax
-	btsq	$7, %rax
+	movl	$(X86_CR4_PAE | X86_CR4_PGE), %rax
 	movq	%rax, %cr4
 

Syntax error. %eax, not %rax.

Quoted 2 lines

-hpa

Oh my, what I'm doing... sorry
Here we go

---
[PATCH] x86: head_64.S cleanup - use straight move to CR4 register

---

arch/x86/kernel/head_64.S +1 -3
Index: linux-2.6.git/arch/x86/kernel/head_64.S
===================================================================
@@ -155,9 +155,7 @@ ENTRY(secondary_startup_64)
 	 */
 
 	/* Enable PAE mode and PGE */
-	xorq	%rax, %rax
-	btsq	$5, %rax
-	btsq	$7, %rax
+	movl	$(X86_CR4_PAE | X86_CR4_PGE), %eax
 	movq	%rax, %cr4
 
 	/* Setup early boot stage 4 level pagetables. */

- Cyrill -

#7 lore raw

PATCH 2/2 x86: head_64.S cleanup - use PMD_SHIFT instead of numeric constant

In reply to a message not in the archive

---

arch/x86/kernel/head_64.S +5 -5
Index: linux-2.6.git/arch/x86/kernel/head_64.S
===================================================================
@@ -322,11 +322,11 @@ early_idt_ripmsg:
 ENTRY(name)
 
 /* Automate the creation of 1 to 1 mapping pmd entries */
-#define PMDS(START, PERM, COUNT)		\
-	i = 0 ;					\
-	.rept (COUNT) ;				\
-	.quad	(START) + (i << 21) + (PERM) ;	\
-	i = i + 1 ;				\
+#define PMDS(START, PERM, COUNT)			\
+	i = 0 ;						\
+	.rept (COUNT) ;					\
+	.quad	(START) + (i << PMD_SHIFT) + (PERM) ;	\
+	i = i + 1 ;					\
 	.endr
 
 	/*