x86 - relocate_kernel cleanup
cover x86 - relocate_kernel cleanup
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 -
PATCH 2/4 x86: relocate_kernel - use PAGE_SIZE instead of numeric constant
---
arch/x86/kernel/relocate_kernel_32.S +1 -1
@@ -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
arch/x86/kernel/relocate_kernel_64.S +1 -1
@@ -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
PATCH 3/4 x86: relocate_kernel - use predefined macroses for processor state
In reply to [email protected]---
arch/x86/kernel/relocate_kernel_32.S +9 -8
@@ -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 */
arch/x86/kernel/relocate_kernel_64.S +11 -21
@@ -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
PATCH 4/4 x86: relocate_kernel - use predefined macroses for page attributes
In reply to [email protected]---
arch/x86/kernel/relocate_kernel_32.S +3 -2
@@ -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
arch/x86/kernel/relocate_kernel_64.S +2 -1
@@ -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
PATCH 1/4 x86: relocate_kernel_32.S - clear register in more elegant way
In reply to [email protected]---
arch/x86/kernel/relocate_kernel_32.S +1 -2
@@ -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
H. Peter Anvin
reviewerQuoted 3 lines · [email protected] 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
H. Peter Anvin
reviewerQuoted 6 lines · H. Peter Anvin
Quoted 3 lines · [email protected] 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_MASKetc macros withX86_EFLAGS_TFetc.
That wasn't meant to be a comment specific to the relocate_kernel stuff, incidentally.
-hpa
Thanks, i'll take a look
[H. Peter Anvin - Sat, Mar 22, 2008 at 02:18:49PM -0700]
Quoted 5 lines
Quoted 4 lines · H. Peter Anvin
Quoted 3 lines · [email protected] 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.
Quoted 8 lines
Quoted 2 lines
Looks good. Since you're doing work in this realm, you may also want to replace the old
TF_MASKetc macros withX86_EFLAGS_TFetc.That wasn't meant to be a comment specific to the
relocate_kernelstuff, 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 -
Quoted 2 lines · Cyrill Gorcunov
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
Quoted 3 lines · * [email protected] <[email protected]> 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
[Ingo Molnar - Tue, Mar 25, 2008 at 04:57:00PM +0100]
| | * Cyrill Gorcunov <[email protected]> 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 -