public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip] x86: trampoline_64.S - use predefined constants with simplification
@ 2009-01-28 20:21 Cyrill Gorcunov
  2009-01-28 21:52 ` Alexander van Heukelum
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2009-01-28 20:21 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner; +Cc: Alexander van Heukelum, LKML

Impact: cleanup

We may use macros from processor-flags.h instead
of hardcoding bits. Actually it's not direct mapping
of old instructions with new ones -- BTS does change
CF flag while MOV does not. But i didn't find any
dependency on CF in this code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---

Please review

 arch/x86/kernel/trampoline_64.S |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/trampoline_64.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/trampoline_64.S
+++ linux-2.6.git/arch/x86/kernel/trampoline_64.S
@@ -29,6 +29,7 @@
 #include <asm/page.h>
 #include <asm/msr.h>
 #include <asm/segment.h>
+#include <asm/processor-flags.h>
 
 .section .rodata, "a", @progbits
 
@@ -37,7 +38,7 @@
 ENTRY(trampoline_data)
 r_base = .
 	cli			# We should be safe anyway
-	wbinvd	
+	wbinvd
 	mov	%cs, %ax	# Code and data in the same place
 	mov	%ax, %ds
 	mov	%ax, %es
@@ -73,9 +74,8 @@ r_base = .
 	lidtl	tidt - r_base	# load idt with 0, 0
 	lgdtl	tgdt - r_base	# load gdt with whatever is appropriate
 
-	xor	%ax, %ax
-	inc	%ax		# protected mode (PE) bit
-	lmsw	%ax		# into protected mode
+	mov	$X86_CR0_PE, %ax	# protected mode (PE) bit
+	lmsw	%ax			# into protected mode
 
 	# flush prefetch and jump to startup_32
 	ljmpl	*(startup_32_vector - r_base)
@@ -86,9 +86,8 @@ startup_32:
 	movl	$__KERNEL_DS, %eax	# Initialize the %ds segment register
 	movl	%eax, %ds
 
-	xorl	%eax, %eax
-	btsl	$5, %eax		# Enable PAE mode
-	movl	%eax, %cr4
+	movl	$X86_CR4_PAE, %eax
+	movl	%eax, %cr4		# Enable PAE mode
 
 					# Setup trampoline 4 level pagetables
 	leal	(trampoline_level4_pgt - r_base)(%esi), %eax
@@ -99,9 +98,9 @@ startup_32:
 	xorl	%edx, %edx
 	wrmsr
 
-	xorl	%eax, %eax
-	btsl	$31, %eax		# Enable paging and in turn activate Long Mode
-	btsl	$0, %eax		# Enable protected mode
+	# Enable paging and in turn activate Long Mode
+	# Enable protected mode
+	movl	$(X86_CR0_PG | X86_CR0_PE), %eax
 	movl	%eax, %cr0
 
 	/*

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -tip] x86: trampoline_64.S - use predefined constants with   simplification
  2009-01-28 20:21 [PATCH -tip] x86: trampoline_64.S - use predefined constants with simplification Cyrill Gorcunov
@ 2009-01-28 21:52 ` Alexander van Heukelum
  2009-01-29 13:36   ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander van Heukelum @ 2009-01-28 21:52 UTC (permalink / raw)
  To: Cyrill Gorcunov, Ingo Molnar, H. Peter Anvin, Thomas Gleixner; +Cc: LKML

On Wed, 28 Jan 2009 23:21:25 +0300, "Cyrill Gorcunov"
<gorcunov@gmail.com> said:
> Impact: cleanup
> 
> We may use macros from processor-flags.h instead
> of hardcoding bits. Actually it's not direct mapping
> of old instructions with new ones -- BTS does change
> CF flag while MOV does not. But i didn't find any
> dependency on CF in this code.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>
> Please review

Looks good.

Acked-by: Alexander van Heukelum <heukelum@fastmail.fm>

>  arch/x86/kernel/trampoline_64.S |   19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> Index: linux-2.6.git/arch/x86/kernel/trampoline_64.S
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/kernel/trampoline_64.S
> +++ linux-2.6.git/arch/x86/kernel/trampoline_64.S
> @@ -29,6 +29,7 @@
>  #include <asm/page.h>
>  #include <asm/msr.h>
>  #include <asm/segment.h>
> +#include <asm/processor-flags.h>
>  
>  .section .rodata, "a", @progbits
>  
> @@ -37,7 +38,7 @@
>  ENTRY(trampoline_data)
>  r_base = .
>  	cli			# We should be safe anyway
> -	wbinvd	
> +	wbinvd
>  	mov	%cs, %ax	# Code and data in the same place
>  	mov	%ax, %ds
>  	mov	%ax, %es
> @@ -73,9 +74,8 @@ r_base = .
>  	lidtl	tidt - r_base	# load idt with 0, 0
>  	lgdtl	tgdt - r_base	# load gdt with whatever is appropriate
>  
> -	xor	%ax, %ax
> -	inc	%ax		# protected mode (PE) bit
> -	lmsw	%ax		# into protected mode
> +	mov	$X86_CR0_PE, %ax	# protected mode (PE) bit
> +	lmsw	%ax			# into protected mode
>  
>  	# flush prefetch and jump to startup_32
>  	ljmpl	*(startup_32_vector - r_base)
> @@ -86,9 +86,8 @@ startup_32:
>  	movl	$__KERNEL_DS, %eax	# Initialize the %ds segment register
>  	movl	%eax, %ds
>  
> -	xorl	%eax, %eax
> -	btsl	$5, %eax		# Enable PAE mode
> -	movl	%eax, %cr4
> +	movl	$X86_CR4_PAE, %eax
> +	movl	%eax, %cr4		# Enable PAE mode
>  
>  					# Setup trampoline 4 level pagetables
>  	leal	(trampoline_level4_pgt - r_base)(%esi), %eax
> @@ -99,9 +98,9 @@ startup_32:
>  	xorl	%edx, %edx
>  	wrmsr
>  
> -	xorl	%eax, %eax
> -	btsl	$31, %eax		# Enable paging and in turn activate Long Mode
> -	btsl	$0, %eax		# Enable protected mode
> +	# Enable paging and in turn activate Long Mode
> +	# Enable protected mode
> +	movl	$(X86_CR0_PG | X86_CR0_PE), %eax
>  	movl	%eax, %cr0
>  
>  	/*
-- 
  Alexander van Heukelum
  heukelum@fastmail.fm

-- 
http://www.fastmail.fm - Faster than the air-speed velocity of an
                          unladen european swallow


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -tip] x86: trampoline_64.S - use predefined constants with simplification
  2009-01-28 21:52 ` Alexander van Heukelum
@ 2009-01-29 13:36   ` Ingo Molnar
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2009-01-29 13:36 UTC (permalink / raw)
  To: Alexander van Heukelum
  Cc: Cyrill Gorcunov, H. Peter Anvin, Thomas Gleixner, LKML


* Alexander van Heukelum <heukelum@fastmail.fm> wrote:

> On Wed, 28 Jan 2009 23:21:25 +0300, "Cyrill Gorcunov"
> <gorcunov@gmail.com> said:
> > Impact: cleanup
> > 
> > We may use macros from processor-flags.h instead
> > of hardcoding bits. Actually it's not direct mapping
> > of old instructions with new ones -- BTS does change
> > CF flag while MOV does not. But i didn't find any
> > dependency on CF in this code.
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> > ---
> >
> > Please review
> 
> Looks good.
> 
> Acked-by: Alexander van Heukelum <heukelum@fastmail.fm>

applied to tip/x86/asm, thanks guys!

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-29 13:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 20:21 [PATCH -tip] x86: trampoline_64.S - use predefined constants with simplification Cyrill Gorcunov
2009-01-28 21:52 ` Alexander van Heukelum
2009-01-29 13:36   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox