x86_64: Relocatable bzImage Support (V2)
cover x86_64: Relocatable bzImage Support (V2)
Hi All,
Eric Biederman implemented the relocatable bzImage for x86_64 and posted patches for comments quite some time back.
http://marc.theaimsgroup.com/?l=linux-kernel&m=115443019026302&w=2
We have been testing the patches in RHEL kernels since then and things are looking up. I think this is the time that patches can be included in -mm and get more testing done and get rest of the issues sorted out.
Eric is currently held up with other things, so I have taken his patches and forward ported to 2.6.19-rc5-git2. Did few cleanups and fixed few bugs as faced in our testing. I have also accomodated the review comments received last time.
These changes make a bzImage and vmlinux relocatable hence kernel can be loaded at and run from a non-1MB location. These changes are especially useful for kdump where a single kernel can be used both as production kernel and dump capture kernel hence making the life easier both for distros and developers.
Following is a brief account of changes I have done since patches were posted last time.
- Forward ported the changes to latest kernel.
- Extended bzImage protocol to handle relocatable kernel
- Dropped support for elf bzImage
- Dropped support for the serial debugging in decompressor code.
- Fixed a bug related to memory hotplug.
- Fixed a bug related to setting NX bit (Thanks to larry woodman)
- Fixed a bug regarding jumping to secondary_startup_64 instead of assuming that align fills empty space with "nop".
- Fixed a bug regarding phys_base being put in initdata section.
- Fixed a but where bss was not being zeroed properly
- Reverted the change back to cotinue to compile the kernel for 2MB so that loaders loading vmlinux directly are not broken.
- Aligned data segment to 4K boundary to make kexec using vmlinux work.
- Tested to patch for making sure suspend/resume to/from memory is working. (Required due to ACPI wake up code changes)
Your comments/suggestions are welcome.
Thanks
Vivek
RFC PATCH 1/16 x86_64: Align data segment to page size boundary
o Explicitly align data segment to PAGE_SIZE boundary otherwise depending on config options and tool chain it might be placed on a non PAGE_SIZE aligned boundary and vmlinux loaders like kexec fail when they encounter a PT_LOAD type segment which is not aligned to PAGE_SIZE boundary.
---
arch/x86_64/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/x86_64/kernel/vmlinux.lds.S renamed from arch/x86_64/kernel/vmlinux.lds.S~x86_64-align-data-segment-to-4K-boundary +1 -0
@@ -60,6 +60,7 @@ SECTIONS } #endif + . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */ /* Data */ .data : AT(ADDR(.data) - LOAD_OFFSET) { *(.data)
_
RFC PATCH 2/16 x86_64: Assembly safe page.h and pgtable.h
In reply to Vivek GoyalThis patch makes pgtable.h and page.h safe to include in assembly files like head.S. Allowing us to use symbolic constants instead of hard coded numbers when refering to the page tables.
This patch copies asm-sparc64/const.h to asm-x86_64 to get a definition of _AC() a very convinient macro that allows us to force the type when we are compiling the code in C and to drop all of the type information when we are using the constant in assembly. Previously this was done with multiple definition of the same constant. const.h was modified slightly so that it works when given CONFIG options as arguments.
This patch adds #ifndef __ASSEMBLY__ ... #endif and _AC(1,UL) where appropriate so the assembler won't choke on the header files. Otherwise nothing should have changed.
---
include/asm-x86_64/const.h | 20 ++++++++++++++++++++ include/asm-x86_64/page.h | 34 +++++++++++++--------------------- include/asm-x86_64/pgtable.h | 33 +++++++++++++++++++++------------ 3 files changed, 54 insertions(+), 33 deletions(-)
include/asm-x86_64/const.h new file +20 -0
@@ -0,0 +1,20 @@ +/* const.h: Macros for dealing with constants. */ + +#ifndef _X86_64_CONST_H +#define _X86_64_CONST_H + +/* Some constant macros are used in both assembler and +* C code. Therefore we cannot annotate them always with +* 'UL' and other type specificers unilaterally. We +* use the following macros to deal with this. +*/ + +#ifdef __ASSEMBLY__ +#define _AC (X ,Y ) X +#else +#define __AC (X ,Y ) (X##Y) +#define _AC (X ,Y ) __AC(X,Y) +#endif + + +#endif /* !(_X86_64_CONST_H) */
include/asm-x86_64/page.h renamed from include/asm-x86_64/page.h~x86_64-Assembly-safe-page.h-and-pgtable.h +13 -21
@@ -1,14 +1,11 @@#ifndef _X86_64_PAGE_H#define _X86_64_PAGE_H +#include <asm/const.h> /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12 -#ifdef __ASSEMBLY__ -#define PAGE_SIZE (0x1 << PAGE_SHIFT) -#else -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#endif +#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)#define PAGE_MASK (~(PAGE_SIZE-1))#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK)
@@ -33,10 +30,10 @@#define N_EXCEPTION_STACKS 5/* hw limit: 7 */ #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) -#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT) +#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)#define HPAGE_SHIFT PMD_SHIFT -#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) +#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)#define HPAGE_MASK (~(HPAGE_SIZE - 1))#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
@@ -76,29 +73,24 @@ typedef struct { unsigned long pgprot; }#define __pgd (x) ((pgd_t) { (x) } )#define __pgprot (x) ((pgprot_t) { (x) } ) -#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) -#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START) -#define __START_KERNEL_map 0xffffffff80000000UL -#define __PAGE_OFFSET 0xffff810000000000UL +#endif /* !__ASSEMBLY__ */ -#else -#define __PHYSICAL_START CONFIG_PHYSICAL_START +#define __PHYSICAL_START _AC(CONFIG_PHYSICAL_START,UL)#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START) -#define __START_KERNEL_map 0xffffffff80000000 -#define __PAGE_OFFSET 0xffff810000000000 -#endif /* !__ASSEMBLY__ */ +#define __START_KERNEL_map _AC(0xffffffff80000000,UL) +#define __PAGE_OFFSET _AC(0xffff810000000000,UL)/* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN (addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)/* See Documentation/x86_64/mm.txt for a description of the memory map. */ #define __PHYSICAL_MASK_SHIFT 46 -#define __PHYSICAL_MASK ((1UL << __PHYSICAL_MASK_SHIFT) - 1) +#define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)#define __VIRTUAL_MASK_SHIFT 48 -#define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) +#define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1) -#define KERNEL_TEXT_SIZE (40UL*1024*1024) -#define KERNEL_TEXT_START 0xffffffff80000000UL +#define KERNEL_TEXT_SIZE (_AC(40,UL)*1024*1024) +#define KERNEL_TEXT_START _AC(0xffffffff80000000,UL)#ifndef __ASSEMBLY__
@@ -106,7 +98,7 @@ typedef struct { unsigned long pgprot; }#endif /* __ASSEMBLY__ */ -#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) +#define PAGE_OFFSET __PAGE_OFFSET/* Note: __pa(&symbol_visible_to_c) should be always replaced with __pa_symbol. Otherwise you risk miscompilation. */
include/asm-x86_64/pgtable.h renamed from include/asm-x86_64/pgtable.h~x86_64-Assembly-safe-page.h-and-pgtable.h +21 -12
@@ -1,6 +1,9 @@#ifndef _X86_64_PGTABLE_H#define _X86_64_PGTABLE_H +#include <asm/const.h> +#ifndef __ASSEMBLY__ +/* * This file contains the functions and defines necessary to modify and use * the x86-64 page table tree.
@@ -31,6 +34,8 @@ extern void clear_kernel_mapping(unsigneextern unsigned long empty_zero_page[PAGE_SIZE /sizeof (unsigned long )];#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page)) +#endif /* !__ASSEMBLY__ */ +/* * PGDIR_SHIFT determines what a top-level page table entry can map */
@@ -55,6 +60,8 @@ extern unsigned long empty_zero_page[PAG*/ #define PTRS_PER_PTE 512 +#ifndef __ASSEMBLY__ +#define pte_ERROR (e) \ printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), pte_val(e))#define pmd_ERROR (e) \
@@ -118,22 +125,23 @@ static inline pte_t ptep_get_and_clear_f#define pte_pgprot (a) (__pgprot((a).pte & ~PHYSICAL_PAGE_MASK)) -#define PMD_SIZE (1UL << PMD_SHIFT) +#endif /* !__ASSEMBLY__ */ + +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)#define PMD_MASK (~(PMD_SIZE-1)) -#define PUD_SIZE (1UL << PUD_SHIFT) +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)#define PUD_MASK (~(PUD_SIZE-1)) -#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT)#define PGDIR_MASK (~(PGDIR_SIZE-1))#define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1)#define FIRST_USER_ADDRESS 0 -#ifndef __ASSEMBLY__ -#define MAXMEM 0x3fffffffffffUL -#define VMALLOC_START 0xffffc20000000000UL -#define VMALLOC_END 0xffffe1ffffffffffUL -#define MODULES_VADDR 0xffffffff88000000UL -#define MODULES_END 0xfffffffffff00000UL +#define MAXMEM _AC(0x3fffffffffff,UL) +#define VMALLOC_START _AC(0xffffc20000000000,UL) +#define VMALLOC_END _AC(0xffffe1ffffffffff,UL) +#define MODULES_VADDR _AC(0xffffffff88000000,UL) +#define MODULES_END _AC(0xfffffffffff00000,UL)#define MODULES_LEN (MODULES_END - MODULES_VADDR)#define _PAGE_BIT_PRESENT 0
@@ -159,7 +167,7 @@ static inline pte_t ptep_get_and_clear_f#define _PAGE_GLOBAL 0x100/* Global TLB entry */ #define _PAGE_PROTNONE 0x080/* If not present */ -#define _PAGE_NX (1UL<<_PAGE_BIT_NX) +#define _PAGE_NX (_AC(1,UL)<<_PAGE_BIT_NX)#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
@@ -221,6 +229,8 @@ static inline pte_t ptep_get_and_clear_f#define __S110 PAGE_SHARED_EXEC#define __S111 PAGE_SHARED_EXEC +#ifndef __ASSEMBLY__ +static inline unsigned long pgd_bad (pgd_t pgd) {unsigned long val =pgd_val (pgd);
@@ -417,8 +427,6 @@ extern spinlock_t pgd_lock;extern struct page *pgd_list;void vmalloc_sync_all (void ); -#endif /* !__ASSEMBLY__ */ -extern int kern_addr_valid (unsigned long addr);#define io_remap_pfn_range (vma, vaddr, pfn, size, prot) \
@@ -448,5 +456,6 @@ extern int kern_addr_valid(unsigned long#define __HAVE_ARCH_PTEP_SET_WRPROTECT#define __HAVE_ARCH_PTE_SAME#include <asm-generic/pgtable.h> +#endif /* !__ASSEMBLY__ */ #endif /* _X86_64_PGTABLE_H */
_
Re: [RFC] [PATCH 2/16] x86_64: Assembly safe page.h and pgtable.h
Quoted 5 lines · Vivek Goyal
This patch makes
pgtable.handpage.hsafe to include in assembly files likehead.S. Allowing us to use symbolic constants instead of hard coded numbers when refering to the page tables.
Hmm, I think the ULs are probably not needed anyways. What happens when you just drop them even for C? You shouldn't get any new warnings i hope.
-Andi
Re: [RFC] [PATCH 2/16] x86_64: Assembly safe page.h and pgtable.h
Quoted 10 lines · Andi Kleen
Quoted 5 lines · Vivek Goyal
This patch makes
pgtable.handpage.hsafe to include in assembly files likehead.S. Allowing us to use symbolic constants instead of hard coded numbers when refering to the page tables.Hmm, I think the ULs are probably not needed anyways. What happens when you just drop them even for C? You shouldn't get any new warnings i hope.
I don't remember the details anymore but there were problems when I tried by just removing the suffixes. I think they were no warnings or possibly promotion problems.
Using _AC is just about as simple as dropping the suffix and much more maintainable then maintaining multiple definitions.
Eric
Re: [RFC] [PATCH 2/16] x86_64: Assembly safe page.h and pgtable.h
In reply to Andi KleenQuoted 11 lines · Andi Kleen
Quoted 5 lines · Vivek Goyal
This patch makes
pgtable.handpage.hsafe to include in assembly files likehead.S. Allowing us to use symbolic constants instead of hard coded numbers when refering to the page tables.Hmm, I think the ULs are probably not needed anyways. What happens when you just drop them even for C? You shouldn't get any new warnings i hope.
I think we need these UL suffixes. Otherwise in some cases overflow can take place and compiler emits warning.
For ex. in following definition I got rid of UL.
#define PGDIR_SIZE (1 << PGDIR_SHIFT)
Here constant defaulted to intger and PGDIR_SHIFT is 39. Hence compiler emits following warning wherever PGDIR_SIZE is used.
arch/x86_64/kernel/machine_kexec.c: In function init_level3_page:arch/x86_64/kernel/machine_kexec.c:47: warning: left shift count >= width of typearch/x86_64/kernel/machine_kexec.c: In function init_level4_page:arch/x86_64/kernel/machine_kexec.c:80: warning: left shift count >= width of typearch/x86_64/kernel/machine_kexec.c:96: warning: left shift count >= width of typearch/x86_64/kernel/machine_kexec.c:101: warning: left shift count >= width of type
Thanks
Vivek
Re: [RFC] [PATCH 2/16] x86_64: Assembly safe page.h and pgtable.h
Quoted 8 lines
I think we need these UL suffixes. Otherwise in some cases overflow can take place and compiler emits warning.
For ex. in following definition I got rid of UL.
#define
PGDIR_SIZE(1 <<PGDIR_SHIFT)
Yes for the shifts it is needed, but not for the unshifted constants. I think. At least when they're hex the compiler should chose the right type on its own.
-Andi
Re: [RFC] [PATCH 2/16] x86_64: Assembly safe page.h and pgtable.h
Quoted 11 lines · Andi Kleen
Quoted 7 lines
I think we need these UL suffixes. Otherwise in some cases overflow can take place and compiler emits warning.
For ex. in following definition I got rid of UL.
#define
PGDIR_SIZE(1 <<PGDIR_SHIFT)Yes for the shifts it is needed, but not for the unshifted constants. I think. At least when they're hex the compiler should chose the right type on its own.
Only if the high bit is set. But it should chose a big enough type. However there is no reason to play games and possibly out smart ourselves. That is the point of the _AC() macro. It adds the suffix only for C code, and drops it for assembly.
Eric
RFC PATCH 3/16 x86_64: Kill temp_boot_pmds
In reply to Vivek GoyalEarly in the boot process we need the ability to set up temporary mappings, before our normal mechanisms are initialized. Currently this is used to map pages that are part of the page tables we are building and pages during the dmi scan.
The core problem is that we are using the user portion of the page tables to implement this. Which means that while this mechanism is active we cannot catch NULL pointer dereferences and we deviate from the normal ways of handling things.
In this patch I modify early_ioremap to map pages into the kernel portion of address space, roughly where we will later put modules, and I make the discovery of which addresses we can use dynamic which removes all kinds of static limits and remove the dependencies on implementation details between different parts of the code.
Now alloc_low_page() and unmap_low_page() use early_iomap() and early_iounmap() to allocate/map and unmap a page.
---
arch/x86_64/kernel/head.S | 3 - arch/x86_64/mm/init.c | 100 ++++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-Kill-temp_boot_pmds +0 -3
@@ -280,9 +280,6 @@ NEXT_PAGE(level2_ident_pgt) .quad i << 21 | 0x083 i = i + 1 .endr - /* Temporary mappings for the super early allocator in arch/x86_64/mm/init.c */ - .globl temp_boot_pmds -temp_boot_pmds: .fill 492,8,0 NEXT_PAGE(level2_kernel_pgt)
arch/x86_64/mm/init.c renamed from arch/x86_64/mm/init.c~x86_64-Kill-temp_boot_pmds +45 -55
165 lines not on this page · raw message
_
RFC PATCH 4/16 x86_64: Clean up the early boot page table
In reply to Vivek Goyal- Merge physmem_pgt and ident_pgt, removing physmem_pgt. The merge is broken as soon as mm/init.c:init_memory_mapping is run.
- As physmem_pgt is gone don't export it in pgtable.h.
- Use defines from pgtable.h for page permissions.
- Fix the physical memory identity mapping so it is at the correct address.
- Remove the physical memory mapping from wakeup_level4_pgt it is at the wrong address so we can't possibly be usinging it.
- Simply NEXT_PAGE the work to calculate the phys_ alias of the labels was very cool. Unfortuantely it was a brittle special purpose hack that makes maitenance more difficult. Instead just use label - __START_KERNEL_map like we do everywhere else in assembly.
---
arch/x86_64/kernel/head.S | 61 +++++++++++++++++++------------------------ include/asm-x86_64/pgtable.h | 1 2 files changed, 28 insertions(+), 34 deletions(-)
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-Cleanup-the-early-boot-page-table +28 -33
@@ -13,6 +13,7 @@ #include <linux/init.h> #include <asm/desc.h> #include <asm/segment.h> +#include <asm/pgtable.h> #include <asm/page.h> #include <asm/msr.h> #include <asm/cache.h>
@@ -252,52 +253,48 @@ ljumpvector: ENTRY(stext) ENTRY(_stext) - $page = 0 #define NEXT_PAGE(name) \ - $page = $page + 1; \ - .org $page * 0x1000; \ - phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \ + .balign PAGE_SIZE; \ 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 ; \ + .endr + NEXT_PAGE(init_level4_pgt) /* This gets initialized in x86_64_start_kernel */ .fill 512,8,0 NEXT_PAGE(level3_ident_pgt) - .quad phys_level2_ident_pgt | 0x007 + .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE .fill 511,8,0 NEXT_PAGE(level3_kernel_pgt) .fill 510,8,0 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ - .quad phys_level2_kernel_pgt | 0x007 + .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE .fill 1,8,0 NEXT_PAGE(level2_ident_pgt) - /* 40MB for bootup. */ - i = 0 - .rept 20 - .quad i << 21 | 0x083 - i = i + 1 - .endr - .fill 492,8,0 + /* Since I easily can, map the first 1G. + * Don't set NX because code runs from these pages. + */ + PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD) NEXT_PAGE(level2_kernel_pgt) /* 40MB kernel mapping. The kernel code cannot be bigger than that. When you change this change KERNEL_TEXT_SIZE in page.h too. */ /* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */ - i = 0 - .rept 20 - .quad i << 21 | 0x183 - i = i + 1 - .endr + PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL, + KERNEL_TEXT_SIZE/PMD_SIZE) /* Module mapping starts here */ - .fill 492,8,0 - -NEXT_PAGE(level3_physmem_pgt) - .quad phys_level2_kernel_pgt | 0x007 /* so that __va works even before pagetable_init */ - .fill 511,8,0 + .fill (PTRS_PER_PMD - (KERNEL_TEXT_SIZE/PMD_SIZE)),8,0 +#undef PMDS #undef NEXT_PAGE .data
@@ -305,12 +302,10 @@ NEXT_PAGE(level3_physmem_pgt) #ifdef CONFIG_ACPI_SLEEP .align PAGE_SIZE ENTRY(wakeup_level4_pgt) - .quad phys_level3_ident_pgt | 0x007 - .fill 255,8,0 - .quad phys_level3_physmem_pgt | 0x007 - .fill 254,8,0 + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .fill 510,8,0 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad phys_level3_kernel_pgt | 0x007 + .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE #endif #ifndef CONFIG_HOTPLUG_CPU
@@ -324,12 +319,12 @@ ENTRY(wakeup_level4_pgt) */ .align PAGE_SIZE ENTRY(boot_level4_pgt) - .quad phys_level3_ident_pgt | 0x007 - .fill 255,8,0 - .quad phys_level3_physmem_pgt | 0x007 - .fill 254,8,0 + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .fill 257,8,0 + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .fill 252,8,0 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad phys_level3_kernel_pgt | 0x007 + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE .data
include/asm-x86_64/pgtable.h renamed from include/asm-x86_64/pgtable.h~x86_64-Cleanup-the-early-boot-page-table +0 -1
@@ -15,7 +15,6 @@#include <asm/pda.h> extern pud_t level3_kernel_pgt[512 ]; -extern pud_t level3_physmem_pgt[512 ];extern pud_t level3_ident_pgt[512 ];extern pmd_t level2_kernel_pgt[512 ];extern pgd_t init_level4_pgt[];
_
RFC PATCH 5/16 x86_64: Fix earlyprintk to use standard ISA mapping
In reply to Vivek Goyal---
arch/x86_64/kernel/early_printk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86_64/kernel/early_printk.c renamed from arch/x86_64/kernel/early_printk.c~x86_64-fix-early_printk-to-use-the-standard-ISA-mapping +1 -2
@@ -11,11 +11,10 @@#ifdef __i386__#include <asm/setup.h> -#define VGABASE (__ISA_IO_base + 0xb8000)#else #include <asm/bootsetup.h> -#define VGABASE ((void __iomem *)0xffffffff800b8000UL)#endif +#define VGABASE (__ISA_IO_base + 0xb8000)static int max_ypos =25 , max_xpos =80 ;static int current_ypos =25 , current_xpos =0 ;
_
RFC PATCH 6/16 x86_64: Modify copy_bootdata to to use virtual address
In reply to Vivek GoyalUse virtual addresses instead of physical addresses in copy bootdata. In addition fix the implementation of the old bootloader convention. Everything is at real_mode_data always. It is just that sometimes real_mode_data was relocated by setup.S to not sit at 0x90000.
---
arch/x86_64/kernel/head64.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
arch/x86_64/kernel/head64.c renamed from arch/x86_64/kernel/head64.c~x86_64-modify-copy_bootdata-to-use-virtual-addresses +8 -9
@@ -29,27 +29,26 @@ static void __init clear_bss(void) }#define NEW_CL_POINTER 0x228/* Relative to real mode data */ -#define OLD_CL_MAGIC_ADDR 0x90020 +#define OLD_CL_MAGIC_ADDR 0x20#define OLD_CL_MAGIC 0xA33F -#define OLD_CL_BASE_ADDR 0x90000 -#define OLD_CL_OFFSET 0x90022 +#define OLD_CL_OFFSET 0x22extern char saved_command_line[];static void __init copy_bootdata (char *real_mode_data) { -int new_data; +unsigned long new_data;char * command_line;memcpy (x86_boot_params, real_mode_data,BOOT_PARAM_SIZE ); - new_data = *(int *) (x86_boot_params +NEW_CL_POINTER ); + new_data = *(u32 *) (x86_boot_params +NEW_CL_POINTER );if (!new_data) { -if (OLD_CL_MAGIC != * (u16 *)OLD_CL_MAGIC_ADDR ) { +if (OLD_CL_MAGIC != *(u16 *)(real_mode_data +OLD_CL_MAGIC_ADDR )) {return ; } - new_data =OLD_CL_BASE_ADDR + * (u16 *)OLD_CL_OFFSET ; + new_data =__pa (real_mode_data) + *(u16 *)(real_mode_data +OLD_CL_OFFSET ); } - command_line = (char *) ((u64)(new_data)); + command_line =__va (new_data);memcpy (saved_command_line, command_line,COMMAND_LINE_SIZE ); }
@@ -74,7 +73,7 @@ void __init x86_64_start_kernel(char * rcpu_pda (i) = &boot_cpu_pda[i];pda_init (0 ); -copy_bootdata (real_mode_data); +copy_bootdata (__va (real_mode_data));#ifdef CONFIG_SMP cpu_set (0 , cpu_online_map);#endif
_
RFC PATCH 7/16 x86_64: cleanup segments
In reply to Vivek GoyalMove __KERNEL32_CS up into the unused gdt entry. __KERNEL32_CS is used when entering the kernel so putting it first is useful when trying to keep boot gdt sizes to a minimum.
Set the accessed bit on all gdt entries. We don't care so there is no need for the cpu to burn the extra cycles, and it potentially allows the pages to be immutable. Plus it is confusing when debugging and your gdt entries mysteriously change.
---
arch/x86_64/kernel/head.S | 12 ++++++------ include/asm-x86_64/segment.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-cleanup-segments +6 -6
@@ -354,13 +354,13 @@ gdt: ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* NULL descriptor */ + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */ + .quad 0x00af9b000000ffff /* __KERNEL_CS */ + .quad 0x00cf93000000ffff /* __KERNEL_DS */ + .quad 0x00cffb000000ffff /* __USER32_CS */ + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */ + .quad 0x00affb000000ffff /* __USER_CS */ .quad 0x0 /* unused */ - .quad 0x00af9a000000ffff /* __KERNEL_CS */ - .quad 0x00cf92000000ffff /* __KERNEL_DS */ - .quad 0x00cffa000000ffff /* __USER32_CS */ - .quad 0x00cff2000000ffff /* __USER_DS, __USER32_DS */ - .quad 0x00affa000000ffff /* __USER_CS */ - .quad 0x00cf9a000000ffff /* __KERNEL32_CS */ .quad 0,0 /* TSS */ .quad 0,0 /* LDT */ .quad 0,0,0 /* three TLS descriptors */
include/asm-x86_64/segment.h renamed from include/asm-x86_64/segment.h~x86_64-cleanup-segments +1 -1
@@ -6,7 +6,7 @@#define __KERNEL_CS 0x10#define __KERNEL_DS 0x18 -#define __KERNEL32_CS 0x38 +#define __KERNEL32_CS 0x08/* * we cannot use the same code segment descriptor for user and kernel
_
RFC PATCH 8/16 x86_64: Add EFER to the set registers saved by save_processor_state
In reply to Vivek GoyalEFER varies like %cr4 depending on the cpu capabilities, and which cpu capabilities we want to make use of. So save/restore it make certain we have the same EFER value when we are done.
---
arch/x86_64/kernel/suspend.c | 3 ++- include/asm-x86_64/suspend.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86_64/kernel/suspend.c renamed from arch/x86_64/kernel/suspend.c~x86_64-Add-EFER-to-the-set-registers-saved-by-save_processor_state +2 -1
@@ -33,7 +33,6 @@ void __save_processor_state(struct saved asmvolatile ("str %0" :"=m" (ctxt->tr));/* XMM0..XMM15 should be handled by kernel_fpu_begin(). */ -/* EFER should be constant for kernel version, no need to handle it. */ /* * segment registers */
@@ -50,6 +49,7 @@ void __save_processor_state(struct saved/* * control registers */ +rdmsrl (MSR_EFER , ctxt->efer); asmvolatile ("movq %%cr0, %0" :"=r" (ctxt->cr0)); asmvolatile ("movq %%cr2, %0" :"=r" (ctxt->cr2)); asmvolatile ("movq %%cr3, %0" :"=r" (ctxt->cr3));
@@ -75,6 +75,7 @@ void __restore_processor_state(struct sa/* * control registers */ +wrmsrl (MSR_EFER , ctxt->efer); asmvolatile ("movq %0, %%cr8" ::"r" (ctxt->cr8)); asmvolatile ("movq %0, %%cr4" ::"r" (ctxt->cr4)); asmvolatile ("movq %0, %%cr3" ::"r" (ctxt->cr3));
include/asm-x86_64/suspend.h renamed from include/asm-x86_64/suspend.h~x86_64-Add-EFER-to-the-set-registers-saved-by-save_processor_state +1 -0
@@ -17,6 +17,7 @@ struct saved_context {u16 ds, es, fs, gs, ss;unsigned long gs_base, gs_kernel_base, fs_base;unsigned long cr0, cr2, cr3, cr4, cr8; +unsigned long efer;u16 gdt_pad;u16 gdt_limit;unsigned long gdt_base;
_
RFC PATCH 9/16 x86_64: 64bit PIC SMP trampoline
In reply to Vivek GoyalThis modifies the SMP trampoline and all of the associated code so it can jump to a 64bit kernel loaded at an arbitrary address.
The dependencies on having an idenetity mapped page in the kernel page tables for SMP bootup have all been removed.
In addition the trampoline has been modified to verify that long mode is supported. Asking if long mode is implemented is down right silly but we have traditionally had some of these checks, and they can't hurt anything. So when the totally ludicrous happens we just might handle it correctly.
---
arch/x86_64/kernel/head.S | 1 arch/x86_64/kernel/setup.c | 9 -- arch/x86_64/kernel/trampoline.S | 168 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 156 insertions(+), 22 deletions(-)
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-64bit-PIC-SMP-trampoline +1 -0
@@ -101,6 +101,7 @@ startup_32: .org 0x100 .globl startup_64 startup_64: +ENTRY(secondary_startup_64) /* We come here either from startup_32 * or directly from a 64bit bootloader. * Since we may have come directly from a bootloader we
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~x86_64-64bit-PIC-SMP-trampoline +1 -8
@@ -446,15 +446,8 @@ void __init setup_arch(char **cmdline_p)reserve_bootmem_generic (ebda_addr, ebda_size);#ifdef CONFIG_SMP -/* -* But first pinch a few for the stack/trampoline stuff -* FIXME: Don't need the extra page at 4K, but need to fix -* trampoline before removing it. (see the GDT stuff) -*/ -reserve_bootmem_generic (PAGE_SIZE ,PAGE_SIZE ); -/* Reserve SMP trampoline */ -reserve_bootmem_generic (SMP_TRAMPOLINE_BASE ,PAGE_SIZE ); +reserve_bootmem_generic (SMP_TRAMPOLINE_BASE ,2 *PAGE_SIZE );#endif #ifdef CONFIG_ACPI_SLEEP
arch/x86_64/kernel/trampoline.S renamed from arch/x86_64/kernel/trampoline.S~x86_64-64bit-PIC-SMP-trampoline +154 -14
213 lines not on this page · raw message
_
Re: [RFC] [PATCH 9/16] x86_64: 64bit PIC SMP trampoline
Quoted 2 lines
+verify_cpu:
Another duplication. Please get rid of that.
-Andi
RFC PATCH 10/16 x86_64: 64bit PIC ACPI wakeup
In reply to Vivek Goyal- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Moved wakeup_level4_pgt into the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to match trampoline.S
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
---
arch/x86_64/kernel/acpi/sleep.c | 19 -- arch/x86_64/kernel/acpi/wakeup.S | 329 +++++++++++++++++---------------------- arch/x86_64/kernel/head.S | 9 - include/asm-x86_64/suspend.h | 12 - 4 files changed, 153 insertions(+), 216 deletions(-)
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +2 -17
@@ -60,17 +60,6 @@ extern char wakeup_start, wakeup_end;extern unsigned long FASTCALL (acpi_copy_wakeup_routine (unsigned long )); -static pgd_t low_ptr; - -static void init_low_mapping (void ) -{ -pgd_t *slot0 =pgd_offset (current->mm,0UL ); - low_ptr = *slot0; -set_pgd (slot0, *pgd_offset (current->mm,PAGE_OFFSET )); -WARN_ON (num_online_cpus () !=1 ); -local_flush_tlb (); -} -/** * acpi_save_state_mem - save kernel state *
@@ -79,8 +68,6 @@ static void init_low_mapping(void)*/ int acpi_save_state_mem (void ) { -init_low_mapping (); -memcpy ((void *)acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);acpi_copy_wakeup_routine (acpi_wakeup_address);
@@ -93,8 +80,6 @@ int acpi_save_state_mem(void)*/ void acpi_restore_state_mem (void ) { -set_pgd (pgd_offset (current->mm,0UL ), low_ptr); -local_flush_tlb (); }/**
@@ -107,8 +92,8 @@ void acpi_restore_state_mem(void)*/ void __init acpi_reserve_bootmem (void ) { - acpi_wakeup_address = (unsigned long )alloc_bootmem_low (PAGE_SIZE ); -if ((&wakeup_end - &wakeup_start) >PAGE_SIZE ) + acpi_wakeup_address = (unsigned long )alloc_bootmem_low (PAGE_SIZE *2 ); +if ((&wakeup_end - &wakeup_start) > (PAGE_SIZE *2 ))printk (KERN_CRIT "ACPI: Wakeup code way too big, will crash on attempt to suspend\n" ); }
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +145 -184
496 lines not on this page · raw message
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-64bit-PIC-ACPI-wakeup +0 -9
@@ -300,15 +300,6 @@ NEXT_PAGE(level2_kernel_pgt) .data -#ifdef CONFIG_ACPI_SLEEP - .align PAGE_SIZE -ENTRY(wakeup_level4_pgt) - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE - .fill 510,8,0 - /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE -#endif - #ifndef CONFIG_HOTPLUG_CPU __INITDATA #endif
include/asm-x86_64/suspend.h renamed from include/asm-x86_64/suspend.h~x86_64-64bit-PIC-ACPI-wakeup +6 -6
@@ -45,12 +45,12 @@ extern unsigned long saved_context_eflagextern void fix_processor_context (void );#ifdef CONFIG_ACPI_SLEEP -extern unsigned long saved_eip; -extern unsigned long saved_esp; -extern unsigned long saved_ebp; -extern unsigned long saved_ebx; -extern unsigned long saved_esi; -extern unsigned long saved_edi; +extern unsigned long saved_rip; +extern unsigned long saved_rsp; +extern unsigned long saved_rbp; +extern unsigned long saved_rbx; +extern unsigned long saved_rsi; +extern unsigned long saved_rdi;/* routines for saving/restoring kernel state */ extern int acpi_save_state_mem (void );
_
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 11 lines · Vivek Goyal
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.S
Quoted 6 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
Suspend is unfortunately quite fragile.
pavel, rafael can you please test and review this patch?
(full patch is on l-k)
arch/x86_64/kernel/acpi/wakeup.S check_vesaa: · line 303
Quoted 9 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +9
-0+verify_cpu: + pushl $0 # Kill any dangerous flags + popfl + + /* minimum CPUID flags for x86-64 */ + /* see http://www.x86-64.org/lists/discuss/msg02971.html */ +#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|\ + (1<<13)|(1<<15)|(1<<24)|(1<<25)|(1<<26)) +#define REQUIRED_MASK2 (1<<29)
It would be much better if this least this CPUID code was in a common shared file with head.S
-Andi
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
On Mon, Nov 13, 2006 at 06:22:43PM +0100, Andi Kleen wrote:
[..]
Quoted 13 lines
arch/x86_64/kernel/acpi/wakeup.S check_vesaa: · line 303
Quoted 10 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +9
-0+verify_cpu: + pushl $0 # Kill any dangerous flags + popfl + + /* minimum CPUID flags for x86-64 */ + /* see http://www.x86-64.org/lists/discuss/msg02971.html */ +#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|\ + (1<<13)|(1<<15)|(1<<24)|(1<<25)|(1<<26)) +#define REQUIRED_MASK2 (1<<29)It would be much better if this least this CPUID code was in a common shared file with
head.S
Hi Andi,
This code (verify_cpu) is called while we are still in real mode. So it has to be present in low 1MB. Now in trampoline has been designed to switch to 64bit mode and then jump to the kernel hence kernel can be loaded anywhere even beyond (4G). So if we move this code into say arch/x86_64/kernel/head.S then we can't even call it.
So I think we got to leave it in trampoline only.
Thanks
Vivek
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 6 lines
This code (
verify_cpu) is called while we are still in real mode. So it has to be present in low 1MB. Now in trampoline has been designed to switch to 64bit mode and then jump to the kernel hence kernel can be loaded anywhere even beyond (4G). So if we move this code into sayarch/x86_64/kernel/head.Sthen we can't even call it.
I didn't mean to call it. Just #include it from a common file
-Andi
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 7 lines · Andi Kleen
Quoted 5 lines
This code (
verify_cpu) is called while we are still in real mode. So it has to be present in low 1MB. Now in trampoline has been designed to switch to 64bit mode and then jump to the kernel hence kernel can be loaded anywhere even beyond (4G). So if we move this code into sayarch/x86_64/kernel/head.Sthen we can't even call it.I didn't mean to call it. Just #include it from a common file
I believe the duplication winds up happening in setup.S
Eric
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 8 lines · Eric W. Biederman
Quoted 6 lines · Andi Kleen
Quoted 5 lines
This code (
verify_cpu) is called while we are still in real mode. So it has to be present in low 1MB. Now in trampoline has been designed to switch to 64bit mode and then jump to the kernel hence kernel can be loaded anywhere even beyond (4G). So if we move this code into sayarch/x86_64/kernel/head.Sthen we can't even call it.
Quoted 4 lines
Quoted 1 line
I didn't mean to call it. Just #include it from a common file
I believe the duplication winds up happening in
setup.S
Yes. So boot cpu code in setup.S is also doing these checks. So one of the options is that I create a new file says verify_cpu.S and this code can be shared by setup.S, trampoline.S and wakeup.S.
Or, I can simply drop the verify_cpu bit from trampoline.S and wakeup.S. This looks like a non-essential bit and in the past we did not perform these checks in trampoline.S and wakeup.S
At this point of time, I will prefer to go with second option of dropping extended checks in trampoline.S and wakeup.S to keep things simple.
Does that make sense?
Thanks
Vivek
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 15 lines · Vivek Goyal
Quoted 6 lines · Eric W. Biederman
Quoted 4 lines · Andi Kleen
Quoted 4 lines
This code (
verify_cpu) is called while we are still in real mode. So it has to be present in low 1MB. Now in trampoline has been designed to switch to 64bit mode and then jump to the kernel hence kernel can be loaded anywhere even beyond (4G). So if we move this code into say
arch/x86_64/kernel/head.SQuoted 6 lines
Quoted 3 lines
Quoted 1 line
then we can't even call it.
I didn't mean to call it. Just #include it from a common file
I believe the duplication winds up happening in
setup.S
Quoted 7 lines
Yes. So boot cpu code in
setup.Sis also doing these checks. So one of the options is that I create a new file saysverify_cpu.Sand this code can be shared bysetup.S,trampoline.Sandwakeup.S.Or, I can simply drop the
verify_cpubit fromtrampoline.Sandwakeup.S. This looks like a non-essential bit and in the past we did not perform these checks intrampoline.Sandwakeup.S
We do it head.S instead. Although the version in head.S is less complete.
Quoted 4 lines
At this point of time, I will prefer to go with second option of dropping extended checks in
trampoline.Sandwakeup.Sto keep things simple.Does that make sense?
I think just making an arch/x86_64/kernel/verify_cpu.S that can be included from setup.S wakeup.S and trampoline.S will be just an exercise in code motion. It provides a good sanity check in case things are hideously wrong.
If we are looking at more then code motion then it make sense to reevaluate and probably drop the code.
Deduping this code path makes a lot of sense.
Eric
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Andi KleenHi!
Quoted 15 lines
Quoted 15 lines
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.SI don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Quoted 7 lines
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Suspend is unfortunately quite fragile.
pavel, rafael can you please test and review this patch?
(full patch is on l-k)
Based on comments, it looks like there'll be new version of patch, anyway? Vivek, would you cc me?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 21 lines · Pavel Machek
Hi!
Quoted 19 lines
Quoted 10 lines
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.SQuoted 6 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
Suspend is unfortunately quite fragile.
Quoted 7 lines
Quoted 3 lines
pavel, rafael can you please test and review this patch?
(full patch is on l-k)
Based on comments, it looks like there'll be new version of patch, anyway? Vivek, would you cc me?
Pavel
Hi Pavel,
Sure I will.
Thanks
Vivek
PATCH 1/1 x86_64: Move cpu long mode verification code to common file (was Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup)
In reply to Andi KleenQuoted 14 lines · Andi Kleen
Review
Quoted 10 lines
(quoted diff) +9
-0+verify_cpu: + pushl $0 # Kill any dangerous flags + popfl + + /* minimum CPUID flags for x86-64 */ + /* see http://www.x86-64.org/lists/discuss/msg02971.html */ +#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|\ + (1<<13)|(1<<15)|(1<<24)|(1<<25)|(1<<26)) +#define REQUIRED_MASK2 (1<<29)It would be much better if this least this CPUID code was in a common shared file with
head.S
Hi Andi,
Pleaese find attached the patch which moves verify_cpu code to a single file arch/x86_64/kernel/verify_cpu.S and this file is included by all to do the cpu long mode and SSE checks.
Thanks
Vivek
o This patch moves the code to verify long mode and SSE to a common file. This code is not shared by trampoline.S, wakeup.S, boot/setup.S and boot/compressed/head.S
o So far we used to do very limited check in trampoline.S, wakeup.S and in 32bit entry point. Now all the entry paths are forced to do the exhaustive check, including SSE because verify_cpu is shared.
o I am keeping this patch as last in the x86 relocatable series because previous patches have got quite some amount of testing done and don't want to distrub that. So that if there is problem introduced by this patch, at least it can be easily isolated.
---
arch/x86_64/boot/compressed/head.S | 19 ++++++ arch/x86_64/boot/setup.S | 65 ++--------------------- arch/x86_64/kernel/acpi/wakeup.S | 51 +----------------- arch/x86_64/kernel/trampoline.S | 51 +----------------- arch/x86_64/kernel/verify_cpu.S | 103 +++++++++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 155 deletions(-)
arch/x86_64/boot/compressed/head.S renamed from arch/x86_64/boot/compressed/head.S~x86_64-move-cpu-verfication-code-to-common-file +18 -1
@@ -54,6 +54,15 @@ startup_32: 1: popl %ebp subl $1b, %ebp +/* setup a stack and make sure cpu supports long mode. */ + movl $user_stack_end, %eax + addl %ebp, %eax + movl %eax, %esp + + call verify_cpu + testl %eax, %eax + jnz no_longmode + /* Compute the delta between where we were compiled to run at * and where the code will actually run at. */
@@ -150,13 +159,21 @@ startup_32: /* Jump from 32bit compatibility mode into 64bit mode. */ lret +no_longmode: + /* This isn't an x86-64 CPU so hang */ +1: + hlt + jmp 1b + +#include "../../kernel/verify_cpu.S" + /* Be careful here startup_64 needs to be at a predictable * address so I can export it in an ELF header. Bootloaders * should look at the ELF header to find this address, as * it may change in the future. */ .code64 - .org 0x100 + .org 0x200 ENTRY(startup_64) /* We come here either from startup_32 or directly from a * 64bit bootloader. If we come here from a bootloader we depend on
arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S~x86_64-move-cpu-verfication-code-to-common-file +6 -59
77 lines not on this page · raw message
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-move-cpu-verfication-code-to-common-file +4 -47
67 lines not on this page · raw message
arch/x86_64/kernel/trampoline.S renamed from arch/x86_64/kernel/trampoline.S~x86_64-move-cpu-verfication-code-to-common-file +3 -48
66 lines not on this page · raw message
arch/x86_64/kernel/verify_cpu.S new file +103 -0
103 lines not on this page · raw message
_
Re: [PATCH] x86_64: Move cpu long mode verification code to common file (was Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup)
Hi!
Quoted 7 lines
Quoted 2 lines
It would be much better if this least this CPUID code was in a common shared file with
head.SPleaese find attached the patch which moves
verify_cpucode to a single filearch/x86_64/kernel/verify_cpu.Sand this file is included by all to do the cpu long mode and SSE checks.
Looks ok to me on quick look...
arch/x86_64/kernel/verify_cpu.S line 5
Quoted 6 lines
arch/x86_64/kernel/verify_cpu.S new file +5
-0@@ -0,0 +1,103 @@ +/* + * + * verify_cpu.S + * + * 14 Nov 2006 Vivek Goyal: Created the file
Could we get copyright/GPL here, instead?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH] x86_64: Move cpu long mode verification code to common file (was Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup)
Quoted 12 lines · Pavel Machek
Hi!
Quoted 7 lines
Quoted 2 lines
It would be much better if this least this CPUID code was in a common shared file with
head.SPleaese find attached the patch which moves
verify_cpucode to a single filearch/x86_64/kernel/verify_cpu.Sand this file is included by all to do the cpu long mode and SSE checks.Looks ok to me on quick look...
Quoted 8 lines
Review line 5
Quoted 6 lines
(quoted diff) +5
-0@@ -0,0 +1,103 @@ +/* + * + * verify_cpu.S + * + * 14 Nov 2006 Vivek Goyal: Created the fileCould we get copyright/GPL here, instead?
Pavel, did the modifications to reflect copyright/GPL info. Please find attached the regenerated patch.
o This patch moves the code to verify long mode and SSE to a common file. This code is not shared by trampoline.S, wakeup.S, boot/setup.S and boot/compressed/head.S
o So far we used to do very limited check in trampoline.S, wakeup.S and in 32bit entry point. Now all the entry paths are forced to do the exhaustive check, including SSE because verify_cpu is shared.
o I am keeping this patch as last in the x86 relocatable series because previous patches have got quite some amount of testing done and don't want to distrub that. So that if there is problem introduced by this patch, at least it can be easily isolated.
---
arch/x86_64/boot/compressed/head.S | 19 ++++++ arch/x86_64/boot/setup.S | 65 ++-------------------- arch/x86_64/kernel/acpi/wakeup.S | 51 +---------------- arch/x86_64/kernel/trampoline.S | 51 +---------------- arch/x86_64/kernel/verify_cpu.S | 106 +++++++++++++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 155 deletions(-)
arch/x86_64/boot/compressed/head.S renamed from arch/x86_64/boot/compressed/head.S~x86_64-move-cpu-verfication-code-to-common-file +18 -1
@@ -54,6 +54,15 @@ startup_32: 1: popl %ebp subl $1b, %ebp +/* setup a stack and make sure cpu supports long mode. */ + movl $user_stack_end, %eax + addl %ebp, %eax + movl %eax, %esp + + call verify_cpu + testl %eax, %eax + jnz no_longmode + /* Compute the delta between where we were compiled to run at * and where the code will actually run at. */
@@ -150,13 +159,21 @@ startup_32: /* Jump from 32bit compatibility mode into 64bit mode. */ lret +no_longmode: + /* This isn't an x86-64 CPU so hang */ +1: + hlt + jmp 1b + +#include "../../kernel/verify_cpu.S" + /* Be careful here startup_64 needs to be at a predictable * address so I can export it in an ELF header. Bootloaders * should look at the ELF header to find this address, as * it may change in the future. */ .code64 - .org 0x100 + .org 0x200 ENTRY(startup_64) /* We come here either from startup_32 or directly from a * 64bit bootloader. If we come here from a bootloader we depend on
arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S~x86_64-move-cpu-verfication-code-to-common-file +6 -59
77 lines not on this page · raw message
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-move-cpu-verfication-code-to-common-file +4 -47
67 lines not on this page · raw message
arch/x86_64/kernel/trampoline.S renamed from arch/x86_64/kernel/trampoline.S~x86_64-move-cpu-verfication-code-to-common-file +3 -48
66 lines not on this page · raw message
arch/x86_64/kernel/verify_cpu.S new file +106 -0
106 lines not on this page · raw message
_
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Vivek GoyalHi!
Quoted 11 lines
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.SI don't have a configuration I can test this but it compiles cleanly
Ugh, now that's a big patch.. and untested, too :-(.
Why is PGE no longer required, for example?
Can we get it piece-by-piece?
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Ok, so it was tested on one config. Given that the patch deals with detecting CPU oddities... :-(
Pavel
Signature · 1 line
Thanks for all the (sleeping) penguins.
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 12 lines · Pavel Machek
Hi!
Quoted 10 lines
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.S
Quoted 3 lines
Quoted 1 line
I don't have a configuration I can test this but it compiles cleanly
Ugh, now that's a big patch.. and untested, too :-(.
It was very carefully code reviewed at least the first time, and the code was put in sync with code that was tested.
But things happens so the lack of testing was noted.
Quoted 1 line
Why is PGE no longer required, for example?
PGE is never required. Especially on a temporary page table. PGE is an optimization, to make context switches faster.
Quoted 7 lines
Can we get it piece-by-piece?
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Ok, so it was tested on one config. Given that the patch deals with detecting CPU oddities... :-(
Read the code. Given your scorn and the state of that mess when I started I'm not certain a productive conversation can be had.
Do you understand the code as it is currently written?
Eric
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 6 lines · Eric W. Biederman
Quoted 2 lines
Why is PGE no longer required, for example?
PGE is never required. Especially on a temporary page table. PGE is an optimization, to make context switches faster.
You cannot, however, set the Global bit unless PGE is supported by the CPU (you'll trap.)
-hpa
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Eric W. BiedermanHi!
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I don't have a configuration I can test this but it compiles cleanly
Ugh, now that's a big patch.. and untested, too :-(.
It was very carefully code reviewed at least the first time, and the code was put in sync with code that was tested.
So we had two very different versions of "switch to 64-bit" and now we have two mostly similar versions. Not a big improvement...
Quoted 4 lines
Quoted 1 line
Why is PGE no longer required, for example?
PGE is never required. Especially on a temporary page table. PGE is an optimization, to make context switches faster.
HPA tells me it is.
Quoted 1 line
Quoted 1 line
Can we get it piece-by-piece?
Please?
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Ok, so it was tested on one config. Given that the patch deals with detecting CPU oddities... :-(
Read the code. Given your scorn and the state of that mess when I started I'm not certain a productive conversation can be had.
Do you understand the code as it is currently written?
Mostly. I've written it at some point.
It may be a mess, but patch below is wholesale rewrite, mixing cleanups (ebx->rbx) with serious changes (PGE). And then you tell me it was tested on one machine. It is hard/impossible to rewrite, and changelog is not helpful, either.
Please split it up.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 11 lines · Pavel Machek
Hi!
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I don't have a configuration I can test this but it compiles cleanly
Ugh, now that's a big patch.. and untested, too :-(.
It was very carefully code reviewed at least the first time, and the code was put in sync with code that was tested.
So we had two very different versions of "switch to 64-bit" and now we have two mostly similar versions. Not a big improvement...
Hmm? That's an improvement in my book. Of course i would prefer truly shared code, but even more similar code is better.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Why is PGE no longer required, for example?
PGE is never required. Especially on a temporary page table. PGE is an optimization, to make context switches faster.
HPA tells me it is.
He was just nitpicking. Eric is right it is just an optimization (modulo hardware/software bugs)
-Andi
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Pavel MachekVivek. It looks like the patch had whitespace damage sometime in it's history. Do you know what happened to the to make the indentation inconsistent? I'm pretty certain the version I generated didn't have that problem.
Quoted 11 lines · Pavel Machek
Hi!
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I don't have a configuration I can test this but it compiles cleanly
Ugh, now that's a big patch.. and untested, too :-(.
It was very carefully code reviewed at least the first time, and the code was put in sync with code that was tested.
So we had two very different versions of "switch to 64-bit" and now we have two mostly similar versions. Not a big improvement...
Well we had two versions. It looks like the acpi wakeup was a cut and past of the primary kernel entry path, and it diverged and was less well maintained because it is less considered and get's used less often.
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Can we get it piece-by-piece?
Please?
I honestly think it would make the change less reviewable.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Ok, so it was tested on one config. Given that the patch deals with detecting CPU oddities... :-(
Read the code. Given your scorn and the state of that mess when I started I'm not certain a productive conversation can be had.
Quoted 8 lines
Quoted 1 line
Do you understand the code as it is currently written?
Mostly. I've written it at some point.
It may be a mess, but patch below is wholesale rewrite, mixing cleanups (
ebx->rbx) with serious changes (PGE). And then you tell me it was tested on one machine. It is hard/impossible to rewrite, and changelog is not helpful, either.
So there is one major change in the patch. Modifying the trampoline to take the code all of the way to 64bit mode, allowing us to switch to a kernel that is loaded above 4GB. Essentially everything else is required by that change.
The basic point is that I am completely changing the idiom for how cpus enter the kernel. If you focus on the details the change and miss the primary change itself you will simply not understand what is happening. The PGE change just happens to be part of the change in requirements for entering the kernel.
The code paths that are changed are not conditional code they will always execute. So a single test tells us a lot.
I just looked at the patch again, and it really is not that large. At this point I'm afraid splitting it up is more likely to cause review problems then the other way around. I don't any of the cleanups touch a code path I don't need to touch.
As for the hard/impossible to rewrite. It was a bit tedious because of all of the picky details, but I didn't find it hard. I suspect this is just a skill set difference. Or the fact that I wasn't messing with the actual code that interfaces with acpi.
Eric
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 6 lines · Eric W. Biederman
Vivek. It looks like the patch had whitespace damage sometime in it's history. Do you know what happened to the to make the indentation inconsistent? I'm pretty certain the version I generated didn't have that problem.
Hi Eric,
Sorry I did not get that. This patch has been posted twice on mailing list. First by you and now second time by me. Are you saying that original post did not had whitespace damage and now second post has got? (May be I goofed up while forward porting, though I can't spot the whitespace damage).
Thanks
Vivek
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Eric W. BiedermanHi!
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Can we get it piece-by-piece?
Please?
I honestly think it would make the change less reviewable.
It included mass renames, "unused" code removal, and miscellaus cleanups. At least seaparate cleanups from "real" changes.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Pavel MachekQuoted 16 lines · Pavel Machek
Hi!
Quoted 11 lines
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.SI don't have a configuration I can test this but it compiles cleanly
Ugh, now that's a big patch.. and untested, too :-(.
Quoted 8 lines
Why is PGE no longer required, for example?
Can we get it piece-by-piece?
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Ok, so it was tested on one config. Given that the patch deals with detecting CPU oddities... :-(
Hi Pavel,
This code has been lying in RHEL kernels for close to 3 months now. Have not heard of suspend/resume complaints. So hoping it got tested on wide variety of hardware too apart from testing on my machine.
Thanks
Vivek
Re: [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Hi!
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Vivek has tested this patch for suspend to memory and it works fine.
Ok, so it was tested on one config. Given that the patch deals with detecting CPU oddities... :-(
This code has been lying in RHEL kernels for close to 3 months now. Have not heard of suspend/resume complaints. So hoping it got tested on wide variety of hardware too apart from testing on my machine.
Well, unless you have some way to restore video in RHEL, I'd not expect many users of suspend to RAM... On systems without extensive whitelist, s2ram is fairly hard to test.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Vivek GoyalQuoted 12 lines · Vivek Goyal
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.S
Quoted 7 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
More update. Got hold of another machine and suspend/resume seems to be facing problems.
With 2.6.19-rc5-git2
--------------------
- echo 3 > /proc/acpi/sleep (Suspend to memory takes place)
- Press power button (System tries to come back but fails in MPT adapter initialization)
With 2.6.19-rc5-git2 + Reloc patches
------------------------------------
- echo 3 > /proc/acpi/sleep (Suspend to memory takes place)
- Press power button (Fan powers on but nothing additional is displayed on serial console.)
Will do a bisect and try to isolate the problem.
Pavel, I hope my testing procedure is right?
Thanks
Vivek
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Hi!
Quoted 23 lines
Quoted 7 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
More update. Got hold of another machine and suspend/resume seems to be facing problems.
With 2.6.19-rc5-git2
--------------------
- echo 3 >/proc/acpi/sleep(Suspend to memory takes place)
- Press power button (System tries to come back but fails in MPT adapter initialization)With 2.6.19-rc5-git2 + Reloc patches
------------------------------------
- echo 3 >/proc/acpi/sleep(Suspend to memory takes place)
- Press power button (Fan powers on but nothing additional is displayed on serial console.)
Quoted 3 lines
Will do a bisect and try to isolate the problem.
Pavel, I hope my testing procedure is right?
Yep, basically.
If you were end user, I'd tell you to use s2ram from suspend.sf.net to get video. But you have serial console, so you don't need VGA ;-).
I do not know what MPT is; SCSI adapter? Yep, I'd expect that to have problems.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
In reply to Vivek GoyalQuoted 30 lines · Vivek Goyal
Quoted 12 lines · Vivek Goyal
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.SQuoted 7 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
More update. Got hold of another machine and suspend/resume seems to be facing problems.
With 2.6.19-rc5-git2
--------------------
- echo 3 >/proc/acpi/sleep(Suspend to memory takes place)
- Press power button (System tries to come back but fails in MPT adapter initialization)
Quoted 8 lines
With 2.6.19-rc5-git2 + Reloc patches
------------------------------------
- echo 3 >/proc/acpi/sleep(Suspend to memory takes place)
- Press power button (Fan powers on but nothing additional is displayed on serial console.)Will do a bisect and try to isolate the problem.
Ok. In the new code NX bit protection feature is not being enabled and that seems to be causing the problem. I checked and enabled the NX bit feature in EFER in wakeup.S and it starts working.
I think my new machine supports NX bit protection feature and if while resuming if I don't enable that feature back probably it must have caused a GPF while loading the page tables which have got NX bit set. (A guess).
I know that previous machine I was testing on does not support NX bit feature and that could be the reason that previous machine did not run into the problems.
Thanks
Vivek
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 44 lines · Vivek Goyal
Quoted 30 lines · Vivek Goyal
Quoted 12 lines · Vivek Goyal
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Movedwakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to matchtrampoline.SQuoted 7 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
More update. Got hold of another machine and suspend/resume seems to be facing problems.
With 2.6.19-rc5-git2
--------------------
- echo 3 >/proc/acpi/sleep(Suspend to memory takes place)
- Press power button (System tries to come back but fails in MPT adapter initialization)Quoted 8 lines
With 2.6.19-rc5-git2 + Reloc patches
------------------------------------
- echo 3 >/proc/acpi/sleep(Suspend to memory takes place)
- Press power button (Fan powers on but nothing additional is displayed on serial console.)Will do a bisect and try to isolate the problem.
Ok. In the new code NX bit protection feature is not being enabled and that seems to be causing the problem. I checked and enabled the NX bit feature in EFER in
wakeup.Sand it starts working.
Quoted 8 lines
I think my new machine supports NX bit protection feature and if while resuming if I don't enable that feature back probably it must have caused a GPF while loading the page tables which have got NX bit set. (A guess).
I know that previous machine I was testing on does not support NX bit feature and that could be the reason that previous machine did not run into the problems.
Hi,
Fixed the resume problem happening on my second box which supported NX protection bit. Please find attached the regenerated patch.
Thanks
Vivek
- Killed lots of dead code
- Improve the cpu sanity checks to verify long mode
is enabled when we wake up.
- Removed the need for modifying any existing kernel page table.
- Moved wakeup_level4_pgt into the wakeup routine so we can run the kernel above 4G.
- Increased the size of the wakeup routine to 8K.
- Renamed the variables to use the 64bit register names.
- Lots of misc cleanups to match trampoline.S
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline, which I have tested. At least now the comments about still running in low memory are actually correct.
Vivek has tested this patch for suspend to memory and it works fine.
---
arch/x86_64/kernel/acpi/sleep.c | 19 -- arch/x86_64/kernel/acpi/wakeup.S | 334 +++++++++++++++++---------------------- arch/x86_64/kernel/head.S | 9 - include/asm-x86_64/suspend.h | 12 - 4 files changed, 162 insertions(+), 212 deletions(-)
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +2 -17
@@ -60,17 +60,6 @@ extern char wakeup_start, wakeup_end;extern unsigned long FASTCALL (acpi_copy_wakeup_routine (unsigned long )); -static pgd_t low_ptr; - -static void init_low_mapping (void ) -{ -pgd_t *slot0 =pgd_offset (current->mm,0UL ); - low_ptr = *slot0; -set_pgd (slot0, *pgd_offset (current->mm,PAGE_OFFSET )); -WARN_ON (num_online_cpus () !=1 ); -local_flush_tlb (); -} -/** * acpi_save_state_mem - save kernel state *
@@ -79,8 +68,6 @@ static void init_low_mapping(void)*/ int acpi_save_state_mem (void ) { -init_low_mapping (); -memcpy ((void *)acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);acpi_copy_wakeup_routine (acpi_wakeup_address);
@@ -93,8 +80,6 @@ int acpi_save_state_mem(void)*/ void acpi_restore_state_mem (void ) { -set_pgd (pgd_offset (current->mm,0UL ), low_ptr); -local_flush_tlb (); }/**
@@ -107,8 +92,8 @@ void acpi_restore_state_mem(void)*/ void __init acpi_reserve_bootmem (void ) { - acpi_wakeup_address = (unsigned long )alloc_bootmem_low (PAGE_SIZE ); -if ((&wakeup_end - &wakeup_start) >PAGE_SIZE ) + acpi_wakeup_address = (unsigned long )alloc_bootmem_low (PAGE_SIZE *2 ); +if ((&wakeup_end - &wakeup_start) > (PAGE_SIZE *2 ))printk (KERN_CRIT "ACPI: Wakeup code way too big, will crash on attempt to suspend\n" ); }
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +154 -180
505 lines not on this page · raw message
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-64bit-PIC-ACPI-wakeup +0 -9
@@ -300,15 +300,6 @@ NEXT_PAGE(level2_kernel_pgt) .data -#ifdef CONFIG_ACPI_SLEEP - .align PAGE_SIZE -ENTRY(wakeup_level4_pgt) - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE - .fill 510,8,0 - /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE -#endif - #ifndef CONFIG_HOTPLUG_CPU __INITDATA #endif
include/asm-x86_64/suspend.h renamed from include/asm-x86_64/suspend.h~x86_64-64bit-PIC-ACPI-wakeup +6 -6
@@ -45,12 +45,12 @@ extern unsigned long saved_context_eflagextern void fix_processor_context (void );#ifdef CONFIG_ACPI_SLEEP -extern unsigned long saved_eip; -extern unsigned long saved_esp; -extern unsigned long saved_ebp; -extern unsigned long saved_ebx; -extern unsigned long saved_esi; -extern unsigned long saved_edi; +extern unsigned long saved_rip; +extern unsigned long saved_rsp; +extern unsigned long saved_rbp; +extern unsigned long saved_rbx; +extern unsigned long saved_rsi; +extern unsigned long saved_rdi;/* routines for saving/restoring kernel state */ extern int acpi_save_state_mem (void );
_
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Hi!
Quoted 8 lines
Quoted 8 lines
Ok. In the new code NX bit protection feature is not being enabled and that seems to be causing the problem. I checked and enabled the NX bit feature in EFER in
wakeup.Sand it starts working.I think my new machine supports NX bit protection feature and if while resuming if I don't enable that feature back probably it must have caused a GPF while loading the page tables which have got NX bit set. (A guess).
Quoted 8 lines
Quoted 3 lines
I know that previous machine I was testing on does not support NX bit feature and that could be the reason that previous machine did not run into the problems.
Fixed the resume problem happening on my second box which supported NX protection bit. Please find attached the regenerated patch.
- Killed lots of dead code
Cleanup. (a)
Quoted 2 lines
- Improve the cpu sanity checks to verify long mode is enabled when we wake up.
Change. (b). I'm not sure if we really need this one. I do not think replacing cpu while suspended is supported operation.
Quoted 1 line
- Removed the need for modifying any existing kernel page table.
Unrelated change, probably good one. (c).
Quoted 2 lines
- Moved
wakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.
The change you really wanted to do in the first place. (d).
Quoted 1 line
- Increased the size of the wakeup routine to 8K.
You want bigger stack or what? (e)
Quoted 1 line
- Renamed the variables to use the 64bit register names.
Cleanup. (a)
Quoted 1 line
- Lots of misc cleanups to match
trampoline.S
More cleanups. (a).
Can we at least get (a) (b) (c) (d) and (e) separated?
Oh and please drop the whitespace changes.
Quoted 2 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline,
I assume you have configuration for test now?
Quoted 5 lines
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +0
-1@@ -60,17 +60,6 @@ extern char wakeup_start, wakeup_end;extern unsigned long FASTCALL (acpi_copy_wakeup_routine (unsigned long )); -static pgd_t low_ptr;
arch/x86_64/kernel/acpi/sleep.c extern char wakeup_start, wakeup_end; · line 73
Quoted 10 lines
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +0
-10- -static void init_low_mapping (void ) -{ -pgd_t *slot0 =pgd_offset (current->mm,0UL ); - low_ptr = *slot0; -set_pgd (slot0, *pgd_offset (current->mm,PAGE_OFFSET )); -WARN_ON (num_online_cpus () !=1 ); -local_flush_tlb (); -} -
So you no longer need identity mapping? Is not it specified that when you transition between modes, you should do that while in identity mapping?
arch/x86_64/kernel/acpi/wakeup.S line 21
Quoted 8 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +0
-1@@ -15,7 +16,6 @@ # cs = 0x1234, eip = 0x05 # - ALIGN .align 16 ENTRY(wakeup_start)
Whitespace changes.
Quoted 4 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +0
-0@@ -30,22 +30,25 @@ wakeup_code: cld # setup data segment movw %cs, %ax
arch/x86_64/kernel/acpi/wakeup.S wakeup_code: · line 39
Quoted 10 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +4
-3- movw %ax, %ds # Make ds:0 point to wakeup_start + movw %ax, %ds # Make ds:0 point to wakeup_start movw %ax, %ss - mov $(wakeup_stack - wakeup_code), %sp # Private stack is needed for ASUS board + # Private stack is needed for ASUS board + mov $(wakeup_stack - wakeup_code), %sp - pushl $0 # Kill any dangerous flags + pushl $0 # Kill any dangerous flags popfl
More whitespace changes.
arch/x86_64/kernel/acpi/wakeup.S wakeup_code: · line 46
Quoted 6 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +2
-0movl real_magic - wakeup_code, %eax cmpl $0x12345678, %eax jne bogus_real_magic + call verify_cpu # Verify the cpu supports long mode +
Check if cpu supports long mode... but we suspended when running long mode, why checking again?
arch/x86_64/kernel/acpi/wakeup.S wakeup_code: · line 53
Quoted 8 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +1
-1testl $1, video_flags - wakeup_code jz 1f lcall $0xc000,$3 movw %cs, %ax - movw %ax, %ds # Bios might have played with that + movw %ax, %ds # Bios might have played with that movw %ax, %ss 1:
More whitespace changes.
Quoted 17 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +0
-13@@ -228,25 +206,10 @@ wakeup_long64: .align 64 gdta: .word 0, 0, 0, 0 # dummy - - .word 0, 0, 0, 0 # unused - - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) - .word 0 # base address = 0 - .word 0x9B00 # code read/exec. ??? Why I need 0x9B00 (as opposed to 0x9A00 in order for this to work?) - .word 0x00CF # granularity = 4096, 386 - # (+5th nibble of limit) - - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) - .word 0 # base address = 0 - .word 0x9200 # data read/write - .word 0x00CF # granularity = 4096, 386
arch/x86_64/kernel/acpi/wakeup.S wakeup_long64: · line 212
Quoted 10 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +4
-6- # (+5th nibble of limit) -# this is 64bit descriptor for code - .word 0xFFFF - .word 0 - .word 0x9A00 # code read/exec - .word 0x00AF # as above, but it is long mode and with D=0 + /* ??? Why I need the accessed bit set in order for this to work? */ + .quad 0x00cf9b000000ffff # __KERNEL32_CS + .quad 0x00af9b000000ffff # __KERNEL_CS + .quad 0x00cf93000000ffff # __KERNEL_DS
Why this change, why did you change the values in here, and why you did not tell me about it in the changelog?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Quoted 19 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 8 lines
Ok. In the new code NX bit protection feature is not being enabled and that seems to be causing the problem. I checked and enabled the NX bit feature in EFER in
wakeup.Sand it starts working.I think my new machine supports NX bit protection feature and if while resuming if I don't enable that feature back probably it must have caused a GPF while loading the page tables which have got NX bit set. (A guess).
Quoted 8 lines
Quoted 3 lines
I know that previous machine I was testing on does not support NX bit feature and that could be the reason that previous machine did not run into the problems.
Fixed the resume problem happening on my second box which supported NX protection bit. Please find attached the regenerated patch.
- Killed lots of dead code
Quoted 8 lines
Cleanup. (a)
Quoted 2 lines
- Improve the cpu sanity checks to verify long mode is enabled when we wake up.
Change. (b). I'm not sure if we really need this one. I do not think replacing cpu while suspended is supported operation.
That's fine but it does not harm. Now all the entry path share the same sanity check (verify_cpu.S) and I believe it makes code more maintanable and more robust. It just makes our checks stronger in case somebody really replaces the cpus.
Quoted 4 lines
Quoted 1 line
- Removed the need for modifying any existing kernel page table.
Unrelated change, probably good one. (c).
Quoted 9 lines
Quoted 2 lines
- Moved
wakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.The change you really wanted to do in the first place. (d).
Quoted 1 line
- Increased the size of the wakeup routine to 8K.
You want bigger stack or what? (e)
I think this is because of wakeup_level4_pgt page tables which are now part of trampoline. And these page tables got to be at 4K byte boundary. Hence now we need two pages for trampoline instead of one.
Quoted 10 lines
Quoted 1 line
- Renamed the variables to use the 64bit register names.
Cleanup. (a)
Quoted 1 line
- Lots of misc cleanups to match
trampoline.SMore cleanups. (a).
Can we at least get (a) (b) (c) (d) and (e) separated?
Ok. I will separate the patches.
Quoted 2 lines
Oh and please drop the whitespace changes.
Sure. Will drop the whitespace too.
Quoted 5 lines
Quoted 2 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline,
I assume you have configuration for test now?
Eric did not have but now I have tested it already on two configurations. I think that's good enough. Isn't it?
Quoted 4 lines
Quoted 4 lines
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +0
-0@@ -60,17 +60,6 @@ extern char wakeup_start, wakeup_end;extern unsigned long FASTCALL (acpi_copy_wakeup_routine (unsigned long ));
Quoted 16 lines
arch/x86_64/kernel/acpi/sleep.c extern char wakeup_start, wakeup_end; · line 73
Quoted 11 lines
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +0
-11-static pgd_t low_ptr; - -static void init_low_mapping (void ) -{ -pgd_t *slot0 =pgd_offset (current->mm,0UL ); - low_ptr = *slot0; -set_pgd (slot0, *pgd_offset (current->mm,PAGE_OFFSET )); -WARN_ON (num_online_cpus () !=1 ); -local_flush_tlb (); -} -So you no longer need identity mapping? Is not it specified that when you transition between modes, you should do that while in identity mapping?
I am not sure where these mappings are required at all in first place? While going to sleep state? While resuming we are using wake page tables and they already got identity mappings so it should not be an issue.
[..]
Quoted 7 lines
More whitespace changes.
Quoted 4 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +0
-0movl real_magic - wakeup_code, %eax cmpl $0x12345678, %eax jne bogus_real_magic
Quoted 6 lines
arch/x86_64/kernel/acpi/wakeup.S wakeup_code: · line 46
Quoted 2 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +2
-0+ call verify_cpu # Verify the cpu supports long mode +Check if cpu supports long mode... but we suspended when running long mode, why checking again?
Please see above.
Quoted 33 lines
arch/x86_64/kernel/acpi/wakeup.S wakeup_code: · line 53
Quoted 8 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +1
-1testl $1, video_flags - wakeup_code jz 1f lcall $0xc000,$3 movw %cs, %ax - movw %ax, %ds # Bios might have played with that + movw %ax, %ds # Bios might have played with that movw %ax, %ss 1:More whitespace changes.
Quoted 22 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +0
-18@@ -228,25 +206,10 @@ wakeup_long64: .align 64 gdta: .word 0, 0, 0, 0 # dummy - - .word 0, 0, 0, 0 # unused - - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) - .word 0 # base address = 0 - .word 0x9B00 # code read/exec. ??? Why I need 0x9B00 (as opposed to 0x9A00 in order for this to work?) - .word 0x00CF # granularity = 4096, 386 - # (+5th nibble of limit) - - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) - .word 0 # base address = 0 - .word 0x9200 # data read/write - .word 0x00CF # granularity = 4096, 386 - # (+5th nibble of limit) -# this is 64bit descriptor for code - .word 0xFFFF - .word 0 - .word 0x9A00 # code read/exec
Quoted 9 lines
arch/x86_64/kernel/acpi/wakeup.S wakeup_long64: · line 212
Quoted 5 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +4
-1- .word 0x00AF # as above, but it is long mode and with D=0 + /* ??? Why I need the accessed bit set in order for this to work? */ + .quad 0x00cf9b000000ffff # __KERNEL32_CS + .quad 0x00af9b000000ffff # __KERNEL_CS + .quad 0x00cf93000000ffff # __KERNEL_DSWhy this change, why did you change the values in here, and why you did not tell me about it in the changelog?
I think mainly it has been modified to be consistent gdt table across the kernel (cpu_gdt_table, trampoline.S and wakeup.S). Now __KERNEL_32_CS entry has been moved up to keep the size of gdt small on trampoline. This change was done in patch number 7 (cleanup segments).
Seondly, I think it is just change of form from using .word to .quad. More compact form.
Thirdly I think it does not harm marking that gdt entry has been accessed. Eric can elaborate more on it. Patch 7 also has got details.
Thanks
Vivek
Re: [Fastboot] [RFC] [PATCH 10/16] x86_64: 64bit PIC ACPI wakeup
Hi!
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Fixed the resume problem happening on my second box which supported NX protection bit. Please find attached the regenerated patch.
- Killed lots of dead code
Cleanup. (a)
Quoted 2 lines
- Improve the cpu sanity checks to verify long mode is enabled when we wake up.
Quoted 8 lines
Quoted 3 lines
Change. (b). I'm not sure if we really need this one. I do not think replacing cpu while suspended is supported operation.
That's fine but it does not harm. Now all the entry path share the same sanity check (
verify_cpu.S) and I believe it makes code more maintanable and more robust. It just makes our checks stronger in case somebody really replaces the cpus.
It is probably okay if shared.
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
- Removed the need for modifying any existing kernel page table.
Unrelated change, probably good one. (c).
Quoted 2 lines
- Moved
wakeup_level4_pgtinto the wakeup routine so we can run the kernel above 4G.The change you really wanted to do in the first place. (d).
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
- Increased the size of the wakeup routine to 8K.
You want bigger stack or what? (e)
I think this is because of
wakeup_level4_pgtpage tables which are now part of trampoline. And these page tables got to be at 4K byte boundary. Hence now we need two pages for trampoline instead of one.
Aha, ok. Notice that in the changelog.
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
- Renamed the variables to use the 64bit register names.
Cleanup. (a)
Quoted 1 line
- Lots of misc cleanups to match
trampoline.SMore cleanups. (a).
Can we at least get (a) (b) (c) (d) and (e) separated?
Ok. I will separate the patches.
Thanks!
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I don't have a configuration I can test this but it compiles cleanly and it should work, the code is very similar to the SMP trampoline,
I assume you have configuration for test now?
Eric did not have but now I have tested it already on two configurations. I think that's good enough. Isn't it?
Should be... if it is in -mm for long enough. Unfortunately very little people are testing x86-64 on notebooks :-(. I guess I should force myself to install 64-bit distro on old arima here...
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +0
-7-static pgd_t low_ptr; - -static void init_low_mapping (void ) -{ -pgd_t *slot0 =pgd_offset (current->mm,0UL ); - low_ptr = *slot0; -set_pgd (slot0, *pgd_offset (current->mm,PAGE_OFFSET ));Quoted 9 lines
arch/x86_64/kernel/acpi/sleep.c extern char wakeup_start, wakeup_end; · line 73
Quoted 4 lines
arch/x86_64/kernel/acpi/sleep.c renamed from arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-PIC-ACPI-wakeup +0
-4-WARN_ON (num_online_cpus () !=1 ); -local_flush_tlb (); -} -So you no longer need identity mapping? Is not it specified that when you transition between modes, you should do that while in identity mapping?
Quoted 3 lines
I am not sure where these mappings are required at all in first place? While going to sleep state? While resuming we are using wake page tables and they already got identity mappings so it should not be an issue.
Ok, I guess that's okay.
Quoted 36 lines
Quoted 22 lines
Quoted 22 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +0
-18@@ -228,25 +206,10 @@ wakeup_long64: .align 64 gdta: .word 0, 0, 0, 0 # dummy - - .word 0, 0, 0, 0 # unused - - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) - .word 0 # base address = 0 - .word 0x9B00 # code read/exec. ??? Why I need 0x9B00 (as opposed to 0x9A00 in order for this to work?) - .word 0x00CF # granularity = 4096, 386 - # (+5th nibble of limit) - - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) - .word 0 # base address = 0 - .word 0x9200 # data read/write - .word 0x00CF # granularity = 4096, 386 - # (+5th nibble of limit) -# this is 64bit descriptor for code - .word 0xFFFF - .word 0 - .word 0x9A00 # code read/execQuoted 8 lines
arch/x86_64/kernel/acpi/wakeup.S wakeup_long64: · line 212
Quoted 5 lines
arch/x86_64/kernel/acpi/wakeup.S renamed from arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-PIC-ACPI-wakeup +4
-1- .word 0x00AF # as above, but it is long mode and with D=0 + /* ??? Why I need the accessed bit set in order for this to work? */ + .quad 0x00cf9b000000ffff # __KERNEL32_CS + .quad 0x00af9b000000ffff # __KERNEL_CS + .quad 0x00cf93000000ffff # __KERNEL_DSWhy this change, why did you change the values in here, and why you did not tell me about it in the changelog?
I think mainly it has been modified to be consistent gdt table across the kernel (
cpu_gdt_table,trampoline.Sandwakeup.S). Now__KERNEL_32_CSentry has been moved up to keep the size of gdt small on trampoline. This change was done in patch number 7 (cleanup segments).
Quoted 5 lines
Seondly, I think it is just change of form from using .word to .quad. More compact form.
Thirdly I think it does not harm marking that gdt entry has been accessed. Eric can elaborate more on it. Patch 7 also has got details.
Ok. Maybe it would be nice to #include the GDT's, too, so they do not drift apart? Or at least comment "this has to be kept in sync with..."?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
RFC PATCH 11/16 x86_64: Modify discover_ebda to use virtual address
In reply to Vivek Goyal---
arch/x86_64/kernel/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~x86_64-Modify-discover_ebda-to-use-virtual-addresses +2 -2
@@ -327,10 +327,10 @@ static void discover_ebda(void)* there is a real-mode segmented pointer pointing to the * 4K EBDA area at 0x40E */ - ebda_addr = *(unsigned short *)EBDA_ADDR_POINTER ; + ebda_addr = *(unsigned short *)__va (EBDA_ADDR_POINTER ); ebda_addr <<=4 ; - ebda_size = *(unsigned short *)(unsigned long )ebda_addr; + ebda_size = *(unsigned short *)__va (ebda_addr);/* Round EBDA up to pages */ if (ebda_size ==0 )
_
RFC PATCH 12/16 x86_64: Remove the identity mapping as early as possible
In reply to Vivek GoyalWith the rewrite of the SMP trampoline and the early page allocator there is nothing that needs identity mapped pages, once we start executing C code.
So add zap_identity_mappings into head64.c and remove zap_low_mappings() from much later in the code. The functions
are subtly different thus the name change.
This also kills boot_level4_pgt which was from an earlier attempt to move the identity mappings as early as possible, and is now no longer needed. Essentially I have replaced boot_level4_pgt with trampoline_level4_pgt in trampoline.S
---
arch/x86_64/kernel/head.S | 39 ++++++++++++++------------------------- arch/x86_64/kernel/head64.c | 16 ++++++++++------ arch/x86_64/kernel/setup.c | 2 -- arch/x86_64/kernel/setup64.c | 1 - arch/x86_64/mm/init.c | 24 ------------------------ include/asm-x86_64/pgtable.h | 1 - include/asm-x86_64/proto.h | 2 -- 7 files changed, 24 insertions(+), 61 deletions(-)
arch/x86_64/kernel/head64.c renamed from arch/x86_64/kernel/head64.c~x86_64-Remove-the-identity-mapping-as-early-as-possible +10 -6
@@ -18,8 +18,16 @@#include <asm/setup.h> #include <asm/desc.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #include <asm/sections.h> +static void __init zap_identity_mappings (void ) +{ +pgd_t *pgd =pgd_offset_k (0UL ); +pgd_clear (pgd); +__flush_tlb (); +} +/* Don't add a printk in there. printk relies on the PDA which is not initialized yet. */ static void __init clear_bss (void )
@@ -56,6 +64,8 @@ void __init x86_64_start_kernel(char * r {int i; +/* Make NULL pointers segfault */ +zap_identity_mappings ();for (i =0 ; i <256 ; i++)set_intr_gate (i, early_idt_handler); asmvolatile ("lidt %0" ::"m" (idt_descr));
@@ -63,12 +73,6 @@ void __init x86_64_start_kernel(char * rearly_printk ("Kernel alive\n" ); -/* -* switch to init_level4_pgt from boot_level4_pgt -*/ -memcpy (init_level4_pgt, boot_level4_pgt,PTRS_PER_PGD *sizeof (pgd_t)); - asmvolatile ("movq %0,%%cr3" ::"r" (__pa_symbol (&init_level4_pgt))); -for (i =0 ; i <NR_CPUS ; i++)cpu_pda (i) = &boot_cpu_pda[i];
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-Remove-the-identity-mapping-as-early-as-possible +14 -25
@@ -71,7 +71,7 @@ startup_32: movl %eax, %cr4 /* Setup early boot stage 4 level pagetables */ - movl $(boot_level4_pgt - __START_KERNEL_map), %eax + movl $(init_level4_pgt - __START_KERNEL_map), %eax movl %eax, %cr3 /* Setup EFER (Extended Feature Enable Register) */
@@ -115,7 +115,7 @@ ENTRY(secondary_startup_64) movq %rax, %cr4 /* Setup early boot stage 4 level pagetables. */ - movq $(boot_level4_pgt - __START_KERNEL_map), %rax + movq $(init_level4_pgt - __START_KERNEL_map), %rax movq %rax, %cr3 /* Check if nx is implemented */
@@ -266,9 +266,19 @@ ENTRY(name) i = i + 1 ; \ .endr + /* + * This default setting generates an ident mapping at address 0x100000 + * and a mapping for the kernel that precisely maps virtual address + * 0xffffffff80000000 to physical address 0x000000. (always using + * 2Mbyte large pages provided by PAE mode) + */ NEXT_PAGE(init_level4_pgt) - /* This gets initialized in x86_64_start_kernel */ - .fill 512,8,0 + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .fill 257,8,0 + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .fill 252,8,0 + /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE NEXT_PAGE(level3_ident_pgt) .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
@@ -299,27 +309,6 @@ NEXT_PAGE(level2_kernel_pgt) #undef NEXT_PAGE .data - -#ifndef CONFIG_HOTPLUG_CPU - __INITDATA -#endif - /* - * This default setting generates an ident mapping at address 0x100000 - * and a mapping for the kernel that precisely maps virtual address - * 0xffffffff80000000 to physical address 0x000000. (always using - * 2Mbyte large pages provided by PAE mode) - */ - .align PAGE_SIZE -ENTRY(boot_level4_pgt) - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE - .fill 257,8,0 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE - .fill 252,8,0 - /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE - - .data - .align 16 .globl cpu_gdt_descr cpu_gdt_descr:
arch/x86_64/kernel/setup64.c renamed from arch/x86_64/kernel/setup64.c~x86_64-Remove-the-identity-mapping-as-early-as-possible +0 -1
@@ -202,7 +202,6 @@ void __cpuinit cpu_init (void)/* CPU 0 is initialised in head64.c */ if (cpu !=0 ) {pda_init (cpu); -zap_low_mappings (cpu); }else estacks = boot_exception_stacks;
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~x86_64-Remove-the-identity-mapping-as-early-as-possible +0 -2
@@ -396,8 +396,6 @@ void __init setup_arch(char **cmdline_p)dmi_scan_machine (); -zap_low_mappings (0 ); -#ifdef CONFIG_ACPI /* * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
arch/x86_64/mm/init.c renamed from arch/x86_64/mm/init.c~x86_64-Remove-the-identity-mapping-as-early-as-possible +0 -24
@@ -378,21 +378,6 @@ void __meminit init_memory_mapping(unsig__flush_tlb_all (); } -void __cpuinit zap_low_mappings (int cpu) -{ -if (cpu ==0 ) { -pgd_t *pgd =pgd_offset_k (0UL ); -pgd_clear (pgd); - }else { -/* -* For AP's, zap the low identity mappings by changing the cr3 -* to init_level4_pgt and doing local flush tlb all -*/ - asmvolatile ("movq %0,%%cr3" ::"r" (__pa_symbol (&init_level4_pgt))); - } -__flush_tlb_all (); -} -#ifndef CONFIG_NUMA void __init paging_init (void ) {
@@ -576,15 +561,6 @@ void __init mem_init(void) reservedpages << (PAGE_SHIFT -10 ), datasize >>10 , initsize >> 10); - -#ifdef CONFIG_SMP -/* -* Sync boot_level4_pgt mappings with the init_level4_pgt -* except for the low identity mappings which are already zapped -* in init_level4_pgt. This sync-up is essential for AP's bringup -*/ -memcpy (boot_level4_pgt+1 , init_level4_pgt+1 , (PTRS_PER_PGD -1 )*sizeof (pgd_t)); -#endif }void free_init_pages (char *what,unsigned long begin,unsigned long end)
include/asm-x86_64/pgtable.h renamed from include/asm-x86_64/pgtable.h~x86_64-Remove-the-identity-mapping-as-early-as-possible +0 -1
@@ -18,7 +18,6 @@ extern pud_t level3_kernel_pgt[512];extern pud_t level3_ident_pgt[512 ];extern pmd_t level2_kernel_pgt[512 ];extern pgd_t init_level4_pgt[]; -extern pgd_t boot_level4_pgt[];extern unsigned long __supported_pte_mask;#define swapper_pg_dir init_level4_pgt
include/asm-x86_64/proto.h renamed from include/asm-x86_64/proto.h~x86_64-Remove-the-identity-mapping-as-early-as-possible +0 -2
@@ -11,8 +11,6 @@ struct pt_regs;extern void start_kernel (void );extern void pda_init (int ); -extern void zap_low_mappings (int cpu); -extern void early_idt_handler (void );extern void mcheck_init (struct cpuinfo_x86 *c);
_
RFC PATCH 13/16 x86_64: __pa and __pa_symbol address space separation
In reply to Vivek GoyalCurrently __pa_symbol is for use with symbols in the kernel address map and __pa is for use with pointers into the physical memory map. But the code is implemented so you can usually interchange the two.
__pa which is much more common can be implemented much more cheaply if it is it doesn't have to worry about any other kernel address spaces. This is especially true with a relocatable kernel as __pa_symbol needs to peform an extra variable read to resolve the address.
There is a third macro that is added for the vsyscall data __pa_vsymbol for finding the physical addesses of vsyscall pages.
Most of this patch is simply sorting through the references to __pa or __pa_symbol and using the proper one. A little of it is continuing to use a physical address when we have it instead of recalculating it several times.
swapper_pgd is now NULL. leave_mm now uses init_mm.pgd and init_mm.pgd is initialized at boot (instead of compile time) to the physmem virtual mapping of init_level4_pgd. The physical address changed.
Except for the for EMPTY_ZERO page all of the remaining references to __pa_symbol appear to be during kernel initialization. So this should reduce the cost of __pa in the common case, even on a relocated kernel.
As this is technically a semantic change we need to be on the lookout for anything I missed. But it works for me (tm).
---
arch/i386/kernel/alternative.c | 8 ++++---- arch/i386/mm/init.c | 15 ++++++++------- arch/x86_64/kernel/machine_kexec.c | 14 +++++++------- arch/x86_64/kernel/setup.c | 9 +++++---- arch/x86_64/kernel/smp.c | 2 +- arch/x86_64/kernel/vsyscall.c | 10 ++++++++-- arch/x86_64/mm/init.c | 21 +++++++++++---------- arch/x86_64/mm/pageattr.c | 17 ++++++++++------- include/asm-x86_64/page.h | 6 ++---- include/asm-x86_64/pgtable.h | 4 ++-- 10 files changed, 58 insertions(+), 48 deletions(-)
arch/i386/kernel/alternative.c renamed from arch/i386/kernel/alternative.c~x86_64-__pa-and-__pa_symbol-address-space-separation +4 -4
@@ -348,8 +348,8 @@ void __init alternative_instructions(voiif (no_replacement) {printk (KERN_INFO "(SMP-)alternatives turned off\n" );free_init_pages ("SMP alternatives" , - (unsigned long )__smp_alt_begin, - (unsigned long )__smp_alt_end); +__pa_symbol (&__smp_alt_begin), +__pa_symbol (&__smp_alt_end));return ; }
@@ -378,8 +378,8 @@ void __init alternative_instructions(voi _text, _etext); }free_init_pages ("SMP alternatives" , - (unsigned long )__smp_alt_begin, - (unsigned long )__smp_alt_end); +__pa_symbol (&__smp_alt_begin), +__pa_symbol (&__smp_alt_end)); }else {alternatives_smp_save (__smp_alt_instructions, __smp_alt_instructions_end);
arch/i386/mm/init.c renamed from arch/i386/mm/init.c~x86_64-__pa-and-__pa_symbol-address-space-separation +8 -7
@@ -778,10 +778,11 @@ void free_init_pages(char *what, unsigneunsigned long addr;for (addr = begin; addr < end; addr +=PAGE_SIZE ) { -ClearPageReserved (virt_to_page (addr)); -init_page_count (virt_to_page (addr)); -memset ((void *)addr,POISON_FREE_INITMEM ,PAGE_SIZE ); -free_page (addr); +struct page *page =pfn_to_page (addr >>PAGE_SHIFT ); +ClearPageReserved (page); +init_page_count (page); +memset (page_address (page),POISON_FREE_INITMEM ,PAGE_SIZE ); +__free_page (page); totalram_pages++; }printk (KERN_INFO "Freeing %s: %ldk freed\n" , what, (end - begin) >>10 );
@@ -790,14 +791,14 @@ void free_init_pages(char *what, unsignevoid free_initmem (void ) {free_init_pages ("unused kernel memory" , - (unsigned long )(&__init_begin), - (unsigned long )(&__init_end)); +__pa_symbol (&__init_begin), +__pa_symbol (&__init_end)); }#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) { -free_init_pages ("initrd memory" , start, end); +free_init_pages ("initrd memory" ,__pa (start),__pa (end)); }#endif
arch/x86_64/kernel/machine_kexec.c renamed from arch/x86_64/kernel/machine_kexec.c~x86_64-__pa-and-__pa_symbol-address-space-separation +7 -7
@@ -191,19 +191,19 @@ NORET_TYPE void machine_kexec(struct kim page_list[PA_CONTROL_PAGE ] =__pa (control_page); page_list[VA_CONTROL_PAGE ] = (unsigned long )relocate_kernel; - page_list[PA_PGD ] =__pa (kexec_pgd); + page_list[PA_PGD ] =__pa_symbol (&kexec_pgd); page_list[VA_PGD ] = (unsigned long )kexec_pgd; - page_list[PA_PUD_0 ] =__pa (kexec_pud0); + page_list[PA_PUD_0 ] =__pa_symbol (&kexec_pud0); page_list[VA_PUD_0 ] = (unsigned long )kexec_pud0; - page_list[PA_PMD_0 ] =__pa (kexec_pmd0); + page_list[PA_PMD_0 ] =__pa_symbol (&kexec_pmd0); page_list[VA_PMD_0 ] = (unsigned long )kexec_pmd0; - page_list[PA_PTE_0 ] =__pa (kexec_pte0); + page_list[PA_PTE_0 ] =__pa_symbol (&kexec_pte0); page_list[VA_PTE_0 ] = (unsigned long )kexec_pte0; - page_list[PA_PUD_1 ] =__pa (kexec_pud1); + page_list[PA_PUD_1 ] =__pa_symbol (&kexec_pud1); page_list[VA_PUD_1 ] = (unsigned long )kexec_pud1; - page_list[PA_PMD_1 ] =__pa (kexec_pmd1); + page_list[PA_PMD_1 ] =__pa_symbol (&kexec_pmd1); page_list[VA_PMD_1 ] = (unsigned long )kexec_pmd1; - page_list[PA_PTE_1 ] =__pa (kexec_pte1); + page_list[PA_PTE_1 ] =__pa_symbol (&kexec_pte1); page_list[VA_PTE_1 ] = (unsigned long )kexec_pte1; page_list[PA_TABLE_PAGE] =
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~x86_64-__pa-and-__pa_symbol-address-space-separation +5 -4
@@ -365,11 +365,12 @@ void __init setup_arch(char **cmdline_p) init_mm.end_code = (unsigned long ) &_etext; init_mm.end_data = (unsigned long ) &_edata; init_mm.brk = (unsigned long ) &_end; + init_mm.pgd =__va (__pa_symbol (&init_level4_pgt)); - code_resource.start =virt_to_phys (&_text); - code_resource.end =virt_to_phys (&_etext)-1 ; - data_resource.start =virt_to_phys (&_etext); - data_resource.end =virt_to_phys (&_edata)-1 ; + code_resource.start =__pa_symbol (&_text); + code_resource.end =__pa_symbol (&_etext)-1 ; + data_resource.start =__pa_symbol (&_etext); + data_resource.end =__pa_symbol (&_edata)-1 ;early_identify_cpu (&boot_cpu_data);
arch/x86_64/kernel/smp.c renamed from arch/x86_64/kernel/smp.c~x86_64-__pa-and-__pa_symbol-address-space-separation +1 -1
@@ -76,7 +76,7 @@ static inline void leave_mm(int cpu)if (read_pda (mmu_state) ==TLBSTATE_OK )BUG ();cpu_clear (cpu,read_pda (active_mm)->cpu_vm_mask); -load_cr3 (swapper_pg_dir); +load_cr3 (init_mm.pgd); }/*
arch/x86_64/kernel/vsyscall.c renamed from arch/x86_64/kernel/vsyscall.c~x86_64-__pa-and-__pa_symbol-address-space-separation +8 -2
@@ -46,6 +46,12 @@ int __vgetcpu_mode __section_vgetcpu_mod#include <asm/unistd.h> +#define __pa_vsymbol (x) \ + ({unsigned long v; \ + extern char __vsyscall_0; \ + asm("" : "=r" (v) : "0" (x)); \ + ((v - VSYSCALL_FIRST_PAGE) + __pa_symbol(&__vsyscall_0)); }) + static __always_inline void timeval_normalize(struct timeval * tv) {time_t __sec;
@@ -198,10 +204,10 @@ static int vsyscall_sysctl_change(ctl_tareturn ret;/* gcc has some trouble with __va(__pa()), so just do it this way. */ - map1 =ioremap (__pa_symbol (&vsysc1),2 ); + map1 =ioremap (__pa_vsymbol (&vsysc1),2 );if (!map1)return -ENOMEM ; - map2 =ioremap (__pa_symbol (&vsysc2),2 ); + map2 =ioremap (__pa_vsymbol (&vsysc2),2 );if (!map2) { ret = -ENOMEM ; goto out;
arch/x86_64/mm/init.c renamed from arch/x86_64/mm/init.c~x86_64-__pa-and-__pa_symbol-address-space-separation +11 -10
@@ -572,11 +572,11 @@ void free_init_pages(char *what, unsigneprintk (KERN_INFO "Freeing %s: %ldk freed\n" , what, (end - begin) >>10 );for (addr = begin; addr < end; addr +=PAGE_SIZE ) { -ClearPageReserved (virt_to_page (addr)); -init_page_count (virt_to_page (addr)); -memset ((void *)(addr & ~(PAGE_SIZE -1 )), -POISON_FREE_INITMEM ,PAGE_SIZE ); -free_page (addr); +struct page *page =pfn_to_page (addr >>PAGE_SHIFT ); +ClearPageReserved (page); +init_page_count (page); +memset (page_address (page),POISON_FREE_INITMEM ,PAGE_SIZE ); +__free_page (page); totalram_pages++; } }
@@ -586,17 +586,18 @@ void free_initmem(void)memset (__initdata_begin,POISON_FREE_INITDATA , __initdata_end - __initdata_begin);free_init_pages ("unused kernel memory" , - (unsigned long )(&__init_begin), - (unsigned long )(&__init_end)); +__pa_symbol (&__init_begin), +__pa_symbol (&__init_end)); }#ifdef CONFIG_DEBUG_RODATA void mark_rodata_ro (void ) { -unsigned long addr = (unsigned long )__start_rodata; +unsigned long addr = (unsigned long )__va (__pa_symbol (&__start_rodata)); +unsigned long end = (unsigned long )__va (__pa_symbol (&__end_rodata)); -for (; addr < (unsigned long )__end_rodata; addr +=PAGE_SIZE ) +for (; addr < end; addr +=PAGE_SIZE )change_page_attr_addr (addr,1 ,PAGE_KERNEL_RO ); printk ("Write protecting the kernel read-only data: %luk\n",
@@ -615,7 +616,7 @@ void mark_rodata_ro(void)#ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem (unsigned long start,unsigned long end) { -free_init_pages ("initrd memory" , start, end); +free_init_pages ("initrd memory" ,__pa (start),__pa (end)); }#endif
arch/x86_64/mm/pageattr.c renamed from arch/x86_64/mm/pageattr.c~x86_64-__pa-and-__pa_symbol-address-space-separation +10 -7
@@ -51,7 +51,6 @@ static struct page *split_large_page(unsSetPagePrivate (base);page_private (base) =0 ; - address =__pa (address); addr = address &LARGE_PAGE_MASK ; pbase = (pte_t *)page_address (base);for (i =0 ; i <PTRS_PER_PTE ; i++, addr +=PAGE_SIZE ) {
@@ -95,7 +94,7 @@ static inline void save_page(struct page* No more special protections in this 2/4MB area - revert to a * large page again. */ -static void revert_page (unsigned long address,pgprot_t ref_prot) +static void revert_page (unsigned long address,unsigned long pfn,pgprot_t ref_prot) {pgd_t *pgd;pud_t *pud;
@@ -108,7 +107,8 @@ static void revert_page(unsigned long adBUG_ON (pud_none (*pud)); pmd =pmd_offset (pud, address);BUG_ON (pmd_val (*pmd) & _PAGE_PSE); - large_pte =mk_pte_phys (__pa (address) &LARGE_PAGE_MASK , ref_prot); + large_pte =mk_pte_phys ((pfn <<PAGE_SHIFT ) &LARGE_PAGE_MASK , + ref_prot); large_pte =pte_mkhuge (large_pte);set_pte ((pte_t *)pmd, large_pte); }
@@ -133,7 +133,8 @@ __change_page_attr(unsigned long address*/ struct page *split; ref_prot2 =pte_pgprot (pte_clrhuge (*kpte)); - split =split_large_page (address, prot, ref_prot2); + split =split_large_page (pfn <<PAGE_SHIFT , prot, + ref_prot2);if (!split)return -ENOMEM ;set_pte (kpte,mk_pte (split, ref_prot2));
@@ -152,7 +153,7 @@ __change_page_attr(unsigned long addressif (page_private (kpte_page) ==0 ) {save_page (kpte_page); -revert_page (address, ref_prot); +revert_page (address, pfn, ref_prot); }return 0 ; }
@@ -172,6 +173,7 @@ __change_page_attr(unsigned long address*/ int change_page_attr_addr (unsigned long address,int numpages,pgprot_t prot) { +unsigned long phys_base_pfn =__pa_symbol (__START_KERNEL_map) >>PAGE_SHIFT ;int err =0 ;int i;
@@ -184,10 +186,11 @@ int change_page_attr_addr(unsigned longbreak ;/* Handle kernel mapping too which aliases part of the * lowmem */ -if (__pa (address) <KERNEL_TEXT_SIZE ) { +if ((pfn >= phys_base_pfn) && + ((pfn - phys_base_pfn) < (KERNEL_TEXT_SIZE >>PAGE_SHIFT ))) {unsigned long addr2;pgprot_t prot2; - addr2 = __START_KERNEL_map +__pa (address); + addr2 = __START_KERNEL_map + ((pfn - phys_base_pfn) <<PAGE_SHIFT );/* Make sure the kernel mappings stay executable */ prot2 =pte_pgprot (pte_mkexec (pfn_pte (0 , prot))); err = __change_page_attr(addr2, pfn, prot2,
include/asm-x86_64/page.h renamed from include/asm-x86_64/page.h~x86_64-__pa-and-__pa_symbol-address-space-separation +2 -4
@@ -102,17 +102,15 @@ typedef struct { unsigned long pgprot; }/* Note: __pa(&symbol_visible_to_c) should be always replaced with __pa_symbol. Otherwise you risk miscompilation. */ -#define __pa (x) (((unsigned long)(x)>=__START_KERNEL_map)?(unsigned long)(x) - (unsigned long)__START_KERNEL_map:(unsigned long)(x) - PAGE_OFFSET) +#define __pa (x) ((unsigned long)(x) - PAGE_OFFSET)/* __pa_symbol should be used for C visible symbols. This seems to be the official gcc blessed way to do such arithmetic. */ #define __pa_symbol (x) \ ({unsigned long v; \ asm("" : "=r" (v) : "0" (x)); \ - __pa(v); }) + (v - __START_KERNEL_map); })#define __va (x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) -#define __boot_va (x) __va(x) -#define __boot_pa (x) __pa(x)#ifdef CONFIG_FLATMEM #define pfn_valid (pfn) ((pfn) < end_pfn)#endif
include/asm-x86_64/pgtable.h renamed from include/asm-x86_64/pgtable.h~x86_64-__pa-and-__pa_symbol-address-space-separation +2 -2
@@ -20,7 +20,7 @@ extern pmd_t level2_kernel_pgt[512];extern pgd_t init_level4_pgt[];extern unsigned long __supported_pte_mask; -#define swapper_pg_dir init_level4_pgt +#define swapper_pg_dir ((pgd_t *)NULL)extern void paging_init (void );extern void clear_kernel_mapping (unsigned long addr,unsigned long size);
@@ -30,7 +30,7 @@ extern void clear_kernel_mapping(unsigne* for zero-mapped memory areas etc.. */ extern unsigned long empty_zero_page[PAGE_SIZE /sizeof (unsigned long )]; -#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page)) +#define ZERO_PAGE (vaddr) (pfn_to_page(__pa_symbol(&empty_zero_page) >> PAGE_SHIFT))#endif /* !__ASSEMBLY__ */
_
RFC PATCH 14/16 x86_64: Remove CONFIG_PHYSICAL_START
In reply to Vivek GoyalI am about to add relocatable kernel support which has essentially no cost so there is no point in retaining CONFIG_PHYSICAL_START and retaining CONFIG_PHYSICAL_START makes implementation of and testing of a relocatable kernel more difficult.
---
arch/x86_64/Kconfig | 19 ------------------- arch/x86_64/boot/compressed/head.S | 6 +++--- arch/x86_64/boot/compressed/misc.c | 6 +++--- arch/x86_64/defconfig | 1 - arch/x86_64/kernel/vmlinux.lds.S | 2 +- arch/x86_64/mm/fault.c | 4 ++-- include/asm-x86_64/page.h | 2 -- 7 files changed, 9 insertions(+), 31 deletions(-)
arch/x86_64/boot/compressed/head.S renamed from arch/x86_64/boot/compressed/head.S~x86_64-Remove-CONFIG_PHYSICAL_START +3 -3
@@ -76,7 +76,7 @@ startup_32: jnz 3f addl $8,%esp xorl %ebx,%ebx - ljmp $(__KERNEL_CS), $__PHYSICAL_START + ljmp $(__KERNEL_CS), $0x200000 /* * We come here, if we were loaded high.
@@ -102,7 +102,7 @@ startup_32: popl %ecx # lcount popl %edx # high_buffer_start popl %eax # hcount - movl $__PHYSICAL_START,%edi + movl $0x200000,%edi cli # make sure we don't get interrupted ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine
@@ -127,7 +127,7 @@ move_routine_start: movsl movl %ebx,%esi # Restore setup pointer xorl %ebx,%ebx - ljmp $(__KERNEL_CS), $__PHYSICAL_START + ljmp $(__KERNEL_CS), $0x200000 move_routine_end:
arch/x86_64/boot/compressed/misc.c renamed from arch/x86_64/boot/compressed/misc.c~x86_64-Remove-CONFIG_PHYSICAL_START +3 -3
@@ -288,7 +288,7 @@ static void setup_normal_output_buffer(v#else if ((RM_ALT_MEM_K >RM_EXT_MEM_K ?RM_ALT_MEM_K :RM_EXT_MEM_K ) <1024 )error ("Less than 2MB of memory" );#endif - output_data = (unsigned char *)__PHYSICAL_START;/* Normally Points to 1M */ + output_data = (unsigned char *)0x200000 ; free_mem_end_ptr = (long )real_mode; }
@@ -311,8 +311,8 @@ static void setup_output_buffer_if_we_ru low_buffer_size = low_buffer_end -LOW_BUFFER_START ; high_loaded =1 ; free_mem_end_ptr = (long )high_buffer_start; -if ( (__PHYSICAL_START + low_buffer_size) > ((ulg )high_buffer_start)) { - high_buffer_start = (uch *)(__PHYSICAL_START + low_buffer_size); +if ( (0x200000 + low_buffer_size) > ((ulg )high_buffer_start)) { + high_buffer_start = (uch *)(0x200000 + low_buffer_size); mv->hcount =0 ;/* say: we need not to move high_buffer */ }else mv->hcount =-1 ;
arch/x86_64/defconfig renamed from arch/x86_64/defconfig~x86_64-Remove-CONFIG_PHYSICAL_START +0 -1
@@ -165,7 +165,6 @@ CONFIG_X86_MCE_INTEL=y CONFIG_X86_MCE_AMD=y # CONFIG_KEXEC is not set # CONFIG_CRASH_DUMP is not set -CONFIG_PHYSICAL_START=0x200000 CONFIG_SECCOMP=y # CONFIG_CC_STACKPROTECTOR is not set # CONFIG_HZ_100 is not set
arch/x86_64/Kconfig renamed from arch/x86_64/Kconfig~x86_64-Remove-CONFIG_PHYSICAL_START +0 -19
@@ -513,25 +513,6 @@ config CRASH_DUMP PHYSICAL_START. For more details see Documentation/kdump/kdump.txt -config PHYSICAL_START - hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) - default "0x1000000" if CRASH_DUMP - default "0x200000" - help - This gives the physical address where the kernel is loaded. Normally - for regular kernels this value is 0x200000 (2MB). But in the case - of kexec on panic the fail safe kernel needs to run at a different - address than the panic-ed kernel. This option is used to set the load - address for kernels used to capture crash dump on being kexec'ed - after panic. The default value for crash dump kernels is - 0x1000000 (16MB). This can also be set based on the "X" value as - specified in the "crashkernel=YM@XM" command line boot parameter - passed to the panic-ed kernel. Typically this parameter is set as - crashkernel=64M@16M. Please take a look at - Documentation/kdump/kdump.txt for more details about crash dumps. - - Don't change this unless you know what you are doing. - config SECCOMP bool "Enable seccomp to safely compute untrusted bytecode" depends on PROC_FS
arch/x86_64/kernel/vmlinux.lds.S renamed from arch/x86_64/kernel/vmlinux.lds.S~x86_64-Remove-CONFIG_PHYSICAL_START +1 -1
@@ -22,7 +22,7 @@ PHDRS { } SECTIONS { - . = __START_KERNEL; + . = __START_KERNEL_map + 0x200000; phys_startup_64 = startup_64 - LOAD_OFFSET; _text = .; /* Text and read-only data */ .text : AT(ADDR(.text) - LOAD_OFFSET) {
arch/x86_64/mm/fault.c renamed from arch/x86_64/mm/fault.c~x86_64-Remove-CONFIG_PHYSICAL_START +2 -2
@@ -644,9 +644,9 @@ void vmalloc_sync_all(void) start = address +PGDIR_SIZE ; }/* Check that there is no need to do the same for the modules area. */ -BUILD_BUG_ON (!(MODULES_VADDR > __START_KERNEL)); +BUILD_BUG_ON (!(MODULES_VADDR > __START_KERNEL_map));BUILD_BUG_ON (!(((MODULES_END -1 ) &PGDIR_MASK ) == - (__START_KERNEL &PGDIR_MASK ))); + (__START_KERNEL_map &PGDIR_MASK ))); }static int __init enable_pagefaulttrace (char *str)
include/asm-x86_64/page.h renamed from include/asm-x86_64/page.h~x86_64-Remove-CONFIG_PHYSICAL_START +0 -2
@@ -75,8 +75,6 @@ typedef struct { unsigned long pgprot; }#endif /* !__ASSEMBLY__ */ -#define __PHYSICAL_START _AC(CONFIG_PHYSICAL_START,UL) -#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)#define __START_KERNEL_map _AC(0xffffffff80000000,UL)#define __PAGE_OFFSET _AC(0xffff810000000000,UL)
_
RFC PATCH 15/16 x86_64: Relocatable kernel support
In reply to Vivek GoyalThis patch modifies the x86_64 kernel so that it can be loaded and run at any 2M aligned address, below 512G. The technique used is to compile the decompressor with -fPIC and modify it so the decompressor is fully relocatable. For the main kernel the page tables are modified so the kernel remains at the same virtual address. In addition a variable phys_base is kept that holds the physical address the kernel is loaded at. __pa_symbol is modified to add that when we take the address of a kernel symbol.
When loaded with a normal bootloader the decompressor will decompress the kernel to 2M and it will run there. This both ensures the relocation code is always working, and makes it easier to use 2M pages for the kernel and the cpu.
---
arch/x86_64/boot/compressed/Makefile | 12 - arch/x86_64/boot/compressed/head.S | 311 ++++++++++++++++++++++---------- arch/x86_64/boot/compressed/misc.c | 251 +++++++++++++------------ arch/x86_64/boot/compressed/vmlinux.lds | 44 ++++ arch/x86_64/boot/compressed/vmlinux.scr | 5 arch/x86_64/kernel/head.S | 221 ++++++++++++---------- include/asm-x86_64/page.h | 6 7 files changed, 532 insertions(+), 318 deletions(-)
arch/x86_64/boot/compressed/head.S renamed from arch/x86_64/boot/compressed/head.S~x86_64-Relocatable-kernel-support +220 -91
@@ -26,116 +26,245 @@ #include <linux/linkage.h> #include <asm/segment.h> +#include <asm/pgtable.h> #include <asm/page.h> +#include <asm/msr.h> +.section ".text.head" .code32 .globl startup_32 startup_32: cld cli - movl $(__KERNEL_DS),%eax - movl %eax,%ds - movl %eax,%es - movl %eax,%fs - movl %eax,%gs - - lss stack_start,%esp - xorl %eax,%eax -1: incl %eax # check that A20 really IS enabled - movl %eax,0x000000 # loop forever if it isn't - cmpl %eax,0x100000 - je 1b - -/* - * Initialize eflags. Some BIOS's leave bits like NT set. This would - * confuse the debugger if this code is traced. - * XXX - best to initialize before switching to protected mode. + movl $(__KERNEL_DS), %eax + movl %eax, %ds + movl %eax, %es + movl %eax, %ss + +/* Calculate the delta between where we were compiled to run + * at and where we were actually loaded at. This can only be done + * with a short local call on x86. Nothing else will tell us what + * address we are running at. The reserved chunk of the real-mode + * data at 0x34-0x3f are used as the stack for this calculation. + * Only 4 bytes are needed. */ - pushl $0 - popfl + leal 0x40(%esi), %esp + call 1f +1: popl %ebp + subl $1b, %ebp + +/* Compute the delta between where we were compiled to run at + * and where the code will actually run at. + */ + movl %ebp, %ebx + addl $(LARGE_PAGE_SIZE -1), %ebx + andl $LARGE_PAGE_MASK, %ebx + + /* Replace the compressed data size with the uncompressed size */ + subl input_len(%ebp), %ebx + movl output_len(%ebp), %eax + addl %eax, %ebx + /* Add 8 bytes for every 32K input block */ + shrl $12, %eax + addl %eax, %ebx + /* Add 32K + 18 bytes of extra slack and align on a 4K boundary */ + addl $(32768 + 18 + 4095), %ebx + andl $~4095, %ebx + +/* + * Prepare for entering 64 bit mode + */ + + /* Load new GDT with the 64bit segments using 32bit descriptor */ + leal gdt(%ebp), %eax + movl %eax, gdt+2(%ebp) + lgdt gdt(%ebp) + + /* Enable PAE mode */ + xorl %eax, %eax + orl $(1 << 5), %eax + movl %eax, %cr4 + +/* + * Build early 4G boot pagetable + */ + /* Initialize Page tables to 0*/ + leal pgtable(%ebx), %edi + xorl %eax, %eax + movl $((4096*6)/4), %ecx + rep stosl + + /* Build Level 4 */ + leal pgtable + 0(%ebx), %edi + leal 0x1007 (%edi), %eax + movl %eax, 0(%edi) + + /* Build Level 3 */ + leal pgtable + 0x1000(%ebx), %edi + leal 0x1007(%edi), %eax + movl $4, %ecx +1: movl %eax, 0x00(%edi) + addl $0x00001000, %eax + addl $8, %edi + decl %ecx + jnz 1b + + /* Build Level 2 */ + leal pgtable + 0x2000(%ebx), %edi + movl $0x00000183, %eax + movl $2048, %ecx +1: movl %eax, 0(%edi) + addl $0x00200000, %eax + addl $8, %edi + decl %ecx + jnz 1b + + /* Enable the boot page tables */ + leal pgtable(%ebx), %eax + movl %eax, %cr3 + + /* Enable Long mode in EFER (Extended Feature Enable Register) */ + movl $MSR_EFER, %ecx + rdmsr + btsl $_EFER_LME, %eax + wrmsr + + /* Setup for the jump to 64bit mode + * + * When the jump is performend we will be in long mode but + * in 32bit compatibility mode with EFER.LME = 1, CS.L = 0, CS.D = 1 + * (and in turn EFER.LMA = 1). To jump into 64bit mode we use + * the new gdt/idt that has __KERNEL_CS with CS.L = 1. + * We place all of the values on our mini stack so lret can + * used to perform that far jump. + */ + pushl $__KERNEL_CS + leal startup_64(%ebp), %eax + pushl %eax + + /* Enter paged protected Mode, activating Long Mode */ + movl $0x80000001, %eax /* Enable Paging and Protected mode */ + movl %eax, %cr0 + + /* Jump from 32bit compatibility mode into 64bit mode. */ + lret + + /* Be careful here startup_64 needs to be at a predictable + * address so I can export it in an ELF header. Bootloaders + * should look at the ELF header to find this address, as + * it may change in the future. + */ + .code64 + .org 0x100 +ENTRY(startup_64) + /* We come here either from startup_32 or directly from a + * 64bit bootloader. If we come here from a bootloader we depend on + * an identity mapped page table being provied that maps our + * entire text+data+bss and hopefully all of memory. + */ + + /* Setup data segments. */ + xorl %eax, %eax + movl %eax, %ds + movl %eax, %es + movl %eax, %ss + + /* Compute the decompressed kernel start address. It is where + * we were loaded at aligned to a 2M boundary. + */ + leaq startup_32(%rip) /* - $startup_32 */, %rbp + addq $(LARGE_PAGE_SIZE - 1), %rbp + andq $LARGE_PAGE_MASK, %rbp + +/* Compute the delta between where we were compiled to run at + * and where the code will actually run at. + */ + /* Start with the delta to where the kernel will run at. */ + movq %rbp, %rbx + + /* Replace the compressed data size with the uncompressed size */ + movl input_len(%rip), %eax + subq %rax, %rbx + movl output_len(%rip), %eax + addq %rax, %rbx + /* Add 8 bytes for every 32K input block */ + shrq $12, %rax + addq %rax, %rbx + /* Add 32K + 18 bytes of extra slack and align on a 4K boundary */ + addq $(32768 + 18 + 4095), %rbx + andq $~4095, %rbx + +/* Copy the compressed kernel to the end of our buffer + * where decompression in place becomes safe. + */ + leaq _end(%rip), %r8 + leaq _end(%rbx), %r9 + movq $_end /* - $startup_32 */, %rcx +1: subq $8, %r8 + subq $8, %r9 + movq 0(%r8), %rax + movq %rax, 0(%r9) + subq $8, %rcx + jnz 1b + +/* + * Jump to the relocated address. + */ + leaq relocated(%rbx), %rax + jmp *%rax + +.section ".text" +relocated: + /* * Clear BSS */ - xorl %eax,%eax - movl $_edata,%edi - movl $_end,%ecx - subl %edi,%ecx + xorq %rax, %rax + leaq _edata(%rbx), %rdi + leaq _end(%rbx), %rcx + subq %rdi, %rcx cld rep stosb + + /* Setup the stack */ + leaq user_stack_end(%rip), %rsp + + /* zero EFLAGS after setting rsp */ + pushq $0 + popfq + /* * Do the decompression, and jump to the new kernel.. */ - subl $16,%esp # place for structure on the stack - movl %esp,%eax - pushl %esi # real mode pointer as second arg - pushl %eax # address of structure as first arg - call decompress_kernel - orl %eax,%eax - jnz 3f - addl $8,%esp - xorl %ebx,%ebx - ljmp $(__KERNEL_CS), $0x200000 - -/* - * We come here, if we were loaded high. - * We need to move the move-in-place routine down to 0x1000 - * and then start it with the buffer addresses in registers, - * which we got from the stack. - */ -3: - movl %esi,%ebx - movl $move_routine_start,%esi - movl $0x1000,%edi - movl $move_routine_end,%ecx - subl %esi,%ecx - addl $3,%ecx - shrl $2,%ecx - cld - rep - movsl - - popl %esi # discard the address - addl $4,%esp # real mode pointer - popl %esi # low_buffer_start - popl %ecx # lcount - popl %edx # high_buffer_start - popl %eax # hcount - movl $0x200000,%edi - cli # make sure we don't get interrupted - ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine - -/* - * Routine (template) for moving the decompressed kernel in place, - * if we were high loaded. This _must_ PIC-code ! - */ -move_routine_start: - movl %ecx,%ebp - shrl $2,%ecx - rep - movsl - movl %ebp,%ecx - andl $3,%ecx - rep - movsb - movl %edx,%esi - movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0 - addl $3,%ecx - shrl $2,%ecx - rep - movsl - movl %ebx,%esi # Restore setup pointer - xorl %ebx,%ebx - ljmp $(__KERNEL_CS), $0x200000 -move_routine_end: + pushq %rsi # Save the real mode argument + movq %rsi, %rdi # real mode address + leaq _heap(%rip), %rsi # _heap + leaq input_data(%rip), %rdx # input_data + movl input_len(%rip), %eax + movq %rax, %rcx # input_len + movq %rbp, %r8 # output + call decompress_kernel + popq %rsi +/* + * Jump to the decompressed kernel. + */ + jmp *%rbp -/* Stack for uncompression */ - .align 32 + .data +gdt: + .word gdt_end - gdt + .long gdt + .word 0 + .quad 0x0000000000000000 /* NULL descriptor */ + .quad 0x00af9a000000ffff /* __KERNEL_CS */ + .quad 0x00cf92000000ffff /* __KERNEL_DS */ +gdt_end: + .bss +/* Stack for uncompression */ + .balign 4 user_stack: .fill 4096,4,0 -stack_start: - .long user_stack+4096 - .word __KERNEL_DS - +user_stack_end:
arch/x86_64/boot/compressed/Makefile renamed from arch/x86_64/boot/compressed/Makefile~x86_64-Relocatable-kernel-support +5 -7
@@ -8,16 +8,14 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o EXTRA_AFLAGS := -traditional -AFLAGS := $(subst -m64,-m32,$(AFLAGS)) # cannot use EXTRA_CFLAGS because base CFLAGS contains -mkernel which conflicts with # -m32 -CFLAGS := -m32 -D__KERNEL__ -Iinclude -O2 -fno-strict-aliasing -LDFLAGS := -m elf_i386 +CFLAGS := -m64 -D__KERNEL__ -Iinclude -O2 -fno-strict-aliasing -fPIC -mcmodel=small -fno-builtin +LDFLAGS := -m elf_x86_64 -LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 -m elf_i386 - -$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE +LDFLAGS_vmlinux := -T +$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE $(call if_changed,ld) @:
@@ -27,7 +25,7 @@ $(obj)/vmlinux.bin: vmlinux FORCE $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE $(call if_changed,gzip) -LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T +LDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE $(call if_changed,ld)
arch/x86_64/boot/compressed/misc.c renamed from arch/x86_64/boot/compressed/misc.c~x86_64-Relocatable-kernel-support +132 -119
310 lines not on this page · raw message
arch/x86_64/boot/compressed/vmlinux.lds new file +44 -0
44 lines not on this page · raw message
arch/x86_64/boot/compressed/vmlinux.scr renamed from arch/x86_64/boot/compressed/vmlinux.scr~x86_64-Relocatable-kernel-support +3 -2
@@ -1,9 +1,10 @@ SECTIONS { - .data : { + .text.compressed : { input_len = .; LONG(input_data_end - input_data) input_data = .; - *(.data) + *(.data) + output_len = . - 4; input_data_end = .; } }
arch/x86_64/kernel/head.S renamed from arch/x86_64/kernel/head.S~x86_64-Relocatable-kernel-support +124 -97
297 lines not on this page · raw message
include/asm-x86_64/page.h renamed from include/asm-x86_64/page.h~x86_64-Relocatable-kernel-support +4 -2
@@ -61,6 +61,8 @@ typedef struct { unsigned long pgd; } pgtypedef struct {unsigned long pgprot; }pgprot_t ; +extern unsigned long phys_base; +#define pte_val (x) ((x).pte)#define pmd_val (x) ((x).pmd)#define pud_val (x) ((x).pud)
@@ -99,14 +101,14 @@ typedef struct { unsigned long pgprot; }#define PAGE_OFFSET __PAGE_OFFSET/* Note: __pa(&symbol_visible_to_c) should be always replaced with __pa_symbol. -Otherwise you risk miscompilation. */ +Otherwise you risk miscompilation. */ #define __pa (x) ((unsigned long)(x) - PAGE_OFFSET)/* __pa_symbol should be used for C visible symbols. This seems to be the official gcc blessed way to do such arithmetic. */ #define __pa_symbol (x) \ ({unsigned long v; \ asm("" : "=r" (v) : "0" (x)); \ - (v - __START_KERNEL_map); }) + ((v - __START_KERNEL_map) + phys_base); })#define __va (x) ((void *)((unsigned long)(x)+PAGE_OFFSET))#ifdef CONFIG_FLATMEM
_
RFC PATCH 16/16 x86_64: Extend bzImage protocol for relocatable bzImage
In reply to Vivek Goyalo Extend the bzImage protocol (same as i386) to allow bzImage loaders to load the protected mode kernel at non-1MB address. Now protected mode component is relocatable and can be loaded at non-1MB addresses.
o As of today kdump uses it to run a second kernel from a reserved memory area.
---
arch/x86_64/boot/setup.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/x86_64/boot/setup.S renamed from arch/x86_64/boot/setup.S~x86_64-extend-bzImage-protocol-for-relocatable-bzImage +7 -2
@@ -80,7 +80,7 @@ start: # This is the setup header, and it must start at %cs:2 (old 0x9020:2) .ascii "HdrS" # header signature - .word 0x0204 # header version number (>= 0x0105) + .word 0x0205 # header version number (>= 0x0105) # or else old loadlin-1.5 will fail) realmode_swtch: .word 0, 0 # default_switch, SETUPSEG start_sys_seg: .word SYSSEG
@@ -155,7 +155,12 @@ cmd_line_ptr: .long 0 # (Header versio # low memory 0x10000 or higher. ramdisk_max: .long 0xffffffff - +kernel_alignment: .long 0x200000 # physical addr alignment required for + # protected mode relocatable kernel +relocatable_kernel: .byte 1 +pad2: .byte 0 +pad3: .word 0 + trampoline: call start_of_setup .align 16 # The offset at this point is 0x240
_