public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/4] x86 - relocate_kernel cleanup
@ 2008-03-22 21:00 gorcunov
  2008-03-22 21:00 ` [patch 1/4] x86: relocate_kernel_32.S - clear register in more elegant way gorcunov
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: gorcunov @ 2008-03-22 21:00 UTC (permalink / raw)
  To: mingo; +Cc: tglx, hpa, gorcunov, linux-kernel

The main purpose of this patches is to eliminate numeric constant and
use predefined macroses. Please review. I've tested 64bit version on
object level - it remains the same. Any comments are welcome.

		- Cyrill -

-- 

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

* [patch 1/4] x86: relocate_kernel_32.S - clear register in more elegant way
  2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
@ 2008-03-22 21:00 ` gorcunov
  2008-03-22 21:00 ` [patch 2/4] x86: relocate_kernel - use PAGE_SIZE instead of numeric constant gorcunov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: gorcunov @ 2008-03-22 21:00 UTC (permalink / raw)
  To: mingo; +Cc: tglx, hpa, gorcunov, linux-kernel

[-- Attachment #1: x86-remove-dead-code --]
[-- Type: text/plain, Size: 574 bytes --]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---

Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 20:58:02.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 21:15:37.000000000 +0300
@@ -185,8 +185,7 @@ identity_mapped:
 	/* Set cr4 to a known state:
 	 * Setting everything to zero seems safe.
 	 */
-	movl	%cr4, %eax
-	andl	$0, %eax
+	xorl	%eax, %eax
 	movl	%eax, %cr4
 
 	jmp 1f

-- 

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

* [patch 2/4] x86: relocate_kernel - use PAGE_SIZE instead of numeric constant
  2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
  2008-03-22 21:00 ` [patch 1/4] x86: relocate_kernel_32.S - clear register in more elegant way gorcunov
@ 2008-03-22 21:00 ` gorcunov
  2008-03-22 21:00 ` [patch 3/4] x86: relocate_kernel - use predefined macroses for processor state gorcunov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: gorcunov @ 2008-03-22 21:00 UTC (permalink / raw)
  To: mingo; +Cc: tglx, hpa, gorcunov, linux-kernel

[-- Attachment #1: x86-use-PAGE_SIZE --]
[-- Type: text/plain, Size: 1188 bytes --]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 21:15:37.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 21:16:54.000000000 +0300
@@ -154,7 +154,7 @@ relocate_new_kernel:
 	movl	%eax, %cr3
 
 	/* setup a new stack at the end of the physical control page */
-	lea	4096(%edi), %esp
+	lea	PAGE_SIZE(%edi), %esp
 
 	/* jump to identity mapped page */
 	movl    %edi, %eax
Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_64.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_64.S	2008-03-22 20:58:02.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_64.S	2008-03-22 21:17:13.000000000 +0300
@@ -159,7 +159,7 @@ relocate_new_kernel:
 	movq	%r9, %cr3
 
 	/* setup a new stack at the end of the physical control page */
-	lea	4096(%r8), %rsp
+	lea	PAGE_SIZE(%r8), %rsp
 
 	/* jump to identity mapped page */
 	addq	$(identity_mapped - relocate_kernel), %r8

-- 

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

* [patch 3/4] x86: relocate_kernel - use predefined macroses for processor state
  2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
  2008-03-22 21:00 ` [patch 1/4] x86: relocate_kernel_32.S - clear register in more elegant way gorcunov
  2008-03-22 21:00 ` [patch 2/4] x86: relocate_kernel - use PAGE_SIZE instead of numeric constant gorcunov
@ 2008-03-22 21:00 ` gorcunov
  2008-03-22 21:00 ` [patch 4/4] x86: relocate_kernel - use predefined macroses for page attributes gorcunov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: gorcunov @ 2008-03-22 21:00 UTC (permalink / raw)
  To: mingo; +Cc: tglx, hpa, gorcunov, linux-kernel

[-- Attachment #1: x86-cr-states --]
[-- Type: text/plain, Size: 3148 bytes --]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 22:22:06.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 22:53:11.000000000 +0300
@@ -9,6 +9,7 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 #include <asm/kexec.h>
+#include <asm/processor-flags.h>
 
 /*
  * Must be relocatable PIC code callable as a C function
@@ -167,16 +168,16 @@ identity_mapped:
 	pushl   %edx
 
 	/* Set cr0 to a known state:
-	 * 31 0 == Paging disabled
-	 * 18 0 == Alignment check disabled
-	 * 16 0 == Write protect disabled
-	 * 3  0 == No task switch
-	 * 2  0 == Don't do FP software emulation.
-	 * 0  1 == Proctected mode enabled
+	 *  - Paging disabled
+	 *  - Alignment check disabled
+	 *  - Write protect disabled
+	 *  - No task switch
+	 *  - Don't do FP software emulation.
+	 *  - Proctected mode enabled
 	 */
 	movl	%cr0, %eax
-	andl	$~((1<<31)|(1<<18)|(1<<16)|(1<<3)|(1<<2)), %eax
-	orl	$(1<<0), %eax
+	andl	$~(X86_CR0_PG | X86_CR0_AM | X86_CR0_WP | X86_CR0_TS | X86_CR0_EM), %eax
+	orl	$(X86_CR0_PE), %eax
 	movl	%eax, %cr0
 
 	/* clear cr4 if applicable */
Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_64.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_64.S	2008-03-22 22:22:06.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_64.S	2008-03-22 22:53:28.000000000 +0300
@@ -9,6 +9,7 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 #include <asm/kexec.h>
+#include <asm/processor-flags.h>
 
 /*
  * Must be relocatable PIC code callable as a C function
@@ -171,33 +172,22 @@ identity_mapped:
 	pushq   %rdx
 
 	/* Set cr0 to a known state:
-	 * 31 1 == Paging enabled
-	 * 18 0 == Alignment check disabled
-	 * 16 0 == Write protect disabled
-	 * 3  0 == No task switch
-	 * 2  0 == Don't do FP software emulation.
-	 * 0  1 == Proctected mode enabled
+	 *  - Paging enabled
+	 *  - Alignment check disabled
+	 *  - Write protect disabled
+	 *  - No task switch
+	 *  - Don't do FP software emulation.
+	 *  - Proctected mode enabled
 	 */
 	movq	%cr0, %rax
-	andq	$~((1<<18)|(1<<16)|(1<<3)|(1<<2)), %rax
-	orl	$((1<<31)|(1<<0)), %eax
+	andq	$~(X86_CR0_AM | X86_CR0_WP | X86_CR0_TS | X86_CR0_EM), %rax
+	orl	$(X86_CR0_PG | X86_CR0_PE), %eax
 	movq	%rax, %cr0
 
 	/* Set cr4 to a known state:
-	 * 10 0 == xmm exceptions disabled
-	 * 9  0 == xmm registers instructions disabled
-	 * 8  0 == performance monitoring counter disabled
-	 * 7  0 == page global disabled
-	 * 6  0 == machine check exceptions disabled
-	 * 5  1 == physical address extension enabled
-	 * 4  0 == page size extensions	disabled
-	 * 3  0 == Debug extensions disabled
-	 * 2  0 == Time stamp disable (disabled)
-	 * 1  0 == Protected mode virtual interrupts disabled
-	 * 0  0 == VME disabled
+	 *  - physical address extension enabled
 	 */
-
-	movq	$((1<<5)), %rax
+	movq	$X86_CR4_PAE, %rax
 	movq	%rax, %cr4
 
 	jmp 1f

-- 

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

* [patch 4/4] x86: relocate_kernel - use predefined macroses for page attributes
  2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
                   ` (2 preceding siblings ...)
  2008-03-22 21:00 ` [patch 3/4] x86: relocate_kernel - use predefined macroses for processor state gorcunov
@ 2008-03-22 21:00 ` gorcunov
  2008-03-22 21:14 ` [patch 0/4] x86 - relocate_kernel cleanup H. Peter Anvin
  2008-03-25 15:59 ` Ingo Molnar
  5 siblings, 0 replies; 12+ messages in thread
From: gorcunov @ 2008-03-22 21:00 UTC (permalink / raw)
  To: mingo; +Cc: tglx, hpa, gorcunov, linux-kernel

[-- Attachment #1: x86-page-attr --]
[-- Type: text/plain, Size: 1591 bytes --]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---

Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 22:22:16.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_32.S	2008-03-22 22:22:17.000000000 +0300
@@ -10,14 +10,15 @@
 #include <asm/page.h>
 #include <asm/kexec.h>
 #include <asm/processor-flags.h>
+#include <asm/pgtable.h>
 
 /*
  * Must be relocatable PIC code callable as a C function
  */
 
 #define PTR(x) (x << 2)
-#define PAGE_ATTR 0x63 /* _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY */
-#define PAE_PGD_ATTR 0x01 /* _PAGE_PRESENT */
+#define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
+#define PAE_PGD_ATTR (_PAGE_PRESENT)
 
 	.text
 	.align PAGE_SIZE
Index: linux-2.6.git/arch/x86/kernel/relocate_kernel_64.S
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/relocate_kernel_64.S	2008-03-22 22:22:16.000000000 +0300
+++ linux-2.6.git/arch/x86/kernel/relocate_kernel_64.S	2008-03-22 22:22:17.000000000 +0300
@@ -10,13 +10,14 @@
 #include <asm/page.h>
 #include <asm/kexec.h>
 #include <asm/processor-flags.h>
+#include <asm/pgtable.h>
 
 /*
  * Must be relocatable PIC code callable as a C function
  */
 
 #define PTR(x) (x << 3)
-#define PAGE_ATTR 0x63 /* _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY */
+#define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
 
 	.text
 	.align PAGE_SIZE

-- 

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
                   ` (3 preceding siblings ...)
  2008-03-22 21:00 ` [patch 4/4] x86: relocate_kernel - use predefined macroses for page attributes gorcunov
@ 2008-03-22 21:14 ` H. Peter Anvin
  2008-03-22 21:18   ` H. Peter Anvin
  2008-03-25 15:59 ` Ingo Molnar
  5 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2008-03-22 21:14 UTC (permalink / raw)
  To: gorcunov; +Cc: mingo, tglx, linux-kernel

gorcunov@gmail.com wrote:
> The main purpose of this patches is to eliminate numeric constant and
> use predefined macroses. Please review. I've tested 64bit version on
> object level - it remains the same. Any comments are welcome.

Looks good.  Since you're doing work in this realm, you may also want to 
replace the old TF_MASK etc macros with X86_EFLAGS_TF etc.

	-hpa

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-22 21:14 ` [patch 0/4] x86 - relocate_kernel cleanup H. Peter Anvin
@ 2008-03-22 21:18   ` H. Peter Anvin
  2008-03-22 21:38     ` Cyrill Gorcunov
  2008-03-23 11:10     ` Cyrill Gorcunov
  0 siblings, 2 replies; 12+ messages in thread
From: H. Peter Anvin @ 2008-03-22 21:18 UTC (permalink / raw)
  To: gorcunov; +Cc: mingo, tglx, linux-kernel

H. Peter Anvin wrote:
> gorcunov@gmail.com wrote:
>> The main purpose of this patches is to eliminate numeric constant and
>> use predefined macroses. Please review. I've tested 64bit version on
>> object level - it remains the same. Any comments are welcome.
> 
> Looks good.  Since you're doing work in this realm, you may also want to 
> replace the old TF_MASK etc macros with X86_EFLAGS_TF etc.

That wasn't meant to be a comment specific to the relocate_kernel stuff, 
incidentally.

	-hpa

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-22 21:18   ` H. Peter Anvin
@ 2008-03-22 21:38     ` Cyrill Gorcunov
  2008-03-23 11:10     ` Cyrill Gorcunov
  1 sibling, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2008-03-22 21:38 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: mingo, tglx, linux-kernel

Thanks, i'll take a look

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-22 21:18   ` H. Peter Anvin
  2008-03-22 21:38     ` Cyrill Gorcunov
@ 2008-03-23 11:10     ` Cyrill Gorcunov
  2008-03-25 15:57       ` Ingo Molnar
  1 sibling, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2008-03-23 11:10 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: mingo, tglx, linux-kernel

[H. Peter Anvin - Sat, Mar 22, 2008 at 02:18:49PM -0700]
> H. Peter Anvin wrote:
>> gorcunov@gmail.com wrote:
>>> The main purpose of this patches is to eliminate numeric constant and
>>> use predefined macroses. Please review. I've tested 64bit version on
>>> object level - it remains the same. Any comments are welcome.
>> Looks good.  Since you're doing work in this realm, you may also want to 
>> replace the old TF_MASK etc macros with X86_EFLAGS_TF etc.
>
> That wasn't meant to be a comment specific to the relocate_kernel stuff, 
> incidentally.
>
> 	-hpa
>

You know, Peter, I'm a bit scared that these flags are in number
of files and could break others queued patches...

		- Cyrill -

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-23 11:10     ` Cyrill Gorcunov
@ 2008-03-25 15:57       ` Ingo Molnar
  2008-03-25 17:34         ` Cyrill Gorcunov
  0 siblings, 1 reply; 12+ messages in thread
From: Ingo Molnar @ 2008-03-25 15:57 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: H. Peter Anvin, mingo, tglx, linux-kernel


* Cyrill Gorcunov <gorcunov@gmail.com> wrote:

> You know, Peter, I'm a bit scared that these flags are in number of 
> files and could break others queued patches...

as long as your work against x86.git/latest you shouldnt be worried 
about any clashes.

	Ingo

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
                   ` (4 preceding siblings ...)
  2008-03-22 21:14 ` [patch 0/4] x86 - relocate_kernel cleanup H. Peter Anvin
@ 2008-03-25 15:59 ` Ingo Molnar
  5 siblings, 0 replies; 12+ messages in thread
From: Ingo Molnar @ 2008-03-25 15:59 UTC (permalink / raw)
  To: gorcunov; +Cc: mingo, tglx, hpa, linux-kernel


* gorcunov@gmail.com <gorcunov@gmail.com> wrote:

> The main purpose of this patches is to eliminate numeric constant and 
> use predefined macroses. Please review. I've tested 64bit version on 
> object level - it remains the same. Any comments are welcome.

thanks Cyrill, i've applied all four patches of yours.

	Ingo

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

* Re: [patch 0/4] x86 - relocate_kernel cleanup
  2008-03-25 15:57       ` Ingo Molnar
@ 2008-03-25 17:34         ` Cyrill Gorcunov
  0 siblings, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2008-03-25 17:34 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: H. Peter Anvin, mingo, tglx, linux-kernel

[Ingo Molnar - Tue, Mar 25, 2008 at 04:57:00PM +0100]
| 
| * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
| 
| > You know, Peter, I'm a bit scared that these flags are in number of 
| > files and could break others queued patches...
| 
| as long as your work against x86.git/latest you shouldnt be worried 
| about any clashes.
| 
| 	Ingo
| 
oh, thanks Ingo, I continue workin on this realm ;)

		- Cyrill -

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

end of thread, other threads:[~2008-03-25 17:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-22 21:00 [patch 0/4] x86 - relocate_kernel cleanup gorcunov
2008-03-22 21:00 ` [patch 1/4] x86: relocate_kernel_32.S - clear register in more elegant way gorcunov
2008-03-22 21:00 ` [patch 2/4] x86: relocate_kernel - use PAGE_SIZE instead of numeric constant gorcunov
2008-03-22 21:00 ` [patch 3/4] x86: relocate_kernel - use predefined macroses for processor state gorcunov
2008-03-22 21:00 ` [patch 4/4] x86: relocate_kernel - use predefined macroses for page attributes gorcunov
2008-03-22 21:14 ` [patch 0/4] x86 - relocate_kernel cleanup H. Peter Anvin
2008-03-22 21:18   ` H. Peter Anvin
2008-03-22 21:38     ` Cyrill Gorcunov
2008-03-23 11:10     ` Cyrill Gorcunov
2008-03-25 15:57       ` Ingo Molnar
2008-03-25 17:34         ` Cyrill Gorcunov
2008-03-25 15:59 ` Ingo Molnar

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