Jan Beulich
2007-Feb-13 15:14 UTC
[Xen-devel] [PATCH] linux/x86: Advertise which page table entries contain MFNs
.. and hence need to be (un)canonicalized during save/restore. The patch should apply without the page table handling adjustment one, yet the values passed in the new note assume that patch to be applied. Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: 2007-02-08/linux-2.6-xen-sparse/arch/i386/kernel/Makefile ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/arch/i386/kernel/Makefile 2007-02-13 15:13:10.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/arch/i386/kernel/Makefile 2007-02-13 12:27:16.000000000 +0100 @@ -98,4 +98,5 @@ n-obj-xen := i8259.o timers/ reboot.o sm obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) obj-y := $(call cherrypickxen, $(obj-y)) extra-y := $(call cherrypickxen, $(extra-y)) +%/head-xen.o %/head-xen.s: EXTRA_AFLAGS : endif Index: 2007-02-08/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S 2007-02-13 15:13:12.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S 2007-02-13 15:13:52.000000000 +0100 @@ -6,6 +6,7 @@ #include <linux/linkage.h> #include <asm/segment.h> #include <asm/page.h> +#include <asm/pgtable.h> #include <asm/cache.h> #include <asm/thread_info.h> #include <asm/asm-offsets.h> @@ -198,7 +199,9 @@ ENTRY(cpu_gdt_table) ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel") #ifdef CONFIG_X86_PAE ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes") + ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT) #else ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no") + ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long, _PAGE_PRESENT,_PAGE_PRESENT) #endif ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic") Index: 2007-02-08/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile 2007-02-13 15:13:10.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile 2007-02-13 12:27:16.000000000 +0100 @@ -72,4 +72,5 @@ include $(srctree)/scripts/Makefile.xen obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) obj-y := $(call cherrypickxen, $(obj-y)) extra-y := $(call cherrypickxen, $(extra-y)) +%/head-xen.o %/head-xen.s: EXTRA_AFLAGS : endif Index: 2007-02-08/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S 2007-02-13 15:13:10.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S 2007-02-13 12:28:21.000000000 +0100 @@ -20,6 +20,7 @@ #include <asm/desc.h> #include <asm/segment.h> #include <asm/page.h> +#include <asm/pgtable.h> #include <asm/msr.h> #include <asm/cache.h> @@ -49,7 +50,7 @@ ENTRY(_stext) #define NEXT_PAGE(name) \ $page = $page + 1; \ .org $page * 0x1000; \ - phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \ + phys_##name = $page * 0x1000 + __PHYSICAL_START; \ ENTRY(name) NEXT_PAGE(init_level4_pgt) @@ -181,5 +182,6 @@ gdt_end: #endif /* !CONFIG_XEN_COMPAT_030002 */ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, startup_64) ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page) + ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT) ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel") ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic") Index: 2007-02-08/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable.h ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable.h 2007-02-13 14:14:47.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable.h 2007-02-13 12:27:16.000000000 +0100 @@ -1,6 +1,7 @@ #ifndef _I386_PGTABLE_H #define _I386_PGTABLE_H +#ifndef __ASSEMBLY__ #include <asm/hypervisor.h> /* @@ -12,7 +13,6 @@ * This file contains the functions and defines necessary to modify and use * the i386 page table tree. */ -#ifndef __ASSEMBLY__ #include <asm/processor.h> #include <asm/fixmap.h> #include <linux/threads.h> @@ -91,6 +91,8 @@ void paging_init(void); # define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) #endif +#endif /* !__ASSEMBLY__ */ + /* * _PAGE_PSE set in the page directory entry just means that * the page directory entry points directly to a 4MB-aligned block of @@ -160,6 +162,8 @@ void paging_init(void); #define _PAGE_KERNEL_EXEC \ (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) +#ifndef __ASSEMBLY__ + extern unsigned long long __PAGE_KERNEL, __PAGE_KERNEL_EXEC; #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW) #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD) @@ -469,8 +473,6 @@ void make_pages_writable(void *va, unsig m | ((unsigned long)(__va) & (PAGE_SIZE-1)); \ }) -#endif /* !__ASSEMBLY__ */ - #ifdef CONFIG_FLATMEM #define kern_addr_valid(addr) (1) #endif /* CONFIG_FLATMEM */ @@ -508,4 +510,6 @@ direct_remap_pfn_range(vma,from,pfn,size #define __HAVE_ARCH_PTE_SAME #include <asm-generic/pgtable.h> +#endif /* !__ASSEMBLY__ */ + #endif /* _I386_PGTABLE_H */ Index: 2007-02-08/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h 2007-02-13 14:14:47.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h 2007-02-13 12:27:16.000000000 +0100 @@ -5,6 +5,7 @@ * This file contains the functions and defines necessary to modify and use * the x86-64 page table tree. */ +#ifndef __ASSEMBLY__ #include <asm/processor.h> #include <asm/fixmap.h> #include <asm/bitops.h> @@ -172,7 +173,6 @@ static inline pte_t ptep_get_and_clear_f #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 @@ -180,6 +180,8 @@ static inline pte_t ptep_get_and_clear_f #define MODULES_END 0xfffffffffff00000UL #define MODULES_LEN (MODULES_END - MODULES_VADDR) +#endif /* !__ASSEMBLY__ */ + #define _PAGE_BIT_PRESENT 0 #define _PAGE_BIT_RW 1 #define _PAGE_BIT_USER 2 @@ -205,6 +207,8 @@ static inline pte_t ptep_get_and_clear_f #define _PAGE_PROTNONE 0x080 /* If not present */ #define _PAGE_NX (1UL<<_PAGE_BIT_NX) +#ifndef __ASSEMBLY__ + #ifdef CONFIG_XEN_COMPAT_030002 extern unsigned int __kernel_page_user; #else @@ -511,8 +515,6 @@ static inline pte_t pte_modify(pte_t pte extern struct page *pgd_list; void vmalloc_sync_all(void); -#endif /* !__ASSEMBLY__ */ - extern int kern_addr_valid(unsigned long addr); #define DOMID_LOCAL (0xFFFFU) @@ -566,4 +568,6 @@ int touch_pte_range(struct mm_struct *mm #define __HAVE_ARCH_PTE_SAME #include <asm-generic/pgtable.h> +#endif /* !__ASSEMBLY__ */ + #endif /* _X86_64_PGTABLE_H */ Index: 2007-02-08/linux-2.6-xen-sparse/include/linux/elfnote.h ==================================================================--- 2007-02-08/linux-2.6-xen-sparse/include/linux/elfnote.h 2007-02-13 15:13:10.000000000 +0100 +++ 2007-02-08/linux-2.6-xen-sparse/include/linux/elfnote.h 2007-02-13 12:27:16.000000000 +0100 @@ -38,7 +38,20 @@ * e.g. ELFNOTE(XYZCo, 42, .asciz, "forty-two") * ELFNOTE(XYZCo, 12, .long, 0xdeadbeef) */ -#define ELFNOTE(name, type, desctype, descdata) \ +#ifdef __STDC__ +#define ELFNOTE(name, type, desctype, descdata...) \ +.pushsection .note.name ; \ + .align 4 ; \ + .long 2f - 1f /* namesz */ ; \ + .long 4f - 3f /* descsz */ ; \ + .long type ; \ +1:.asciz #name ; \ +2:.align 4 ; \ +3:desctype descdata ; \ +4:.align 4 ; \ +.popsection +#else /* !__STDC__, i.e. -traditional */ +#define ELFNOTE(name, type, desctype, descdata) \ .pushsection .note.name ; \ .align 4 ; \ .long 2f - 1f /* namesz */ ; \ @@ -48,7 +61,8 @@ 2:.align 4 ; \ 3:desctype descdata ; \ 4:.align 4 ; \ -.popsection ; +.popsection +#endif /* __STDC__ */ #else /* !__ASSEMBLER__ */ #include <linux/elf.h> /* Index: 2007-02-08/xen/include/public/elfnote.h ==================================================================--- 2007-02-08/xen/include/public/elfnote.h 2007-02-13 15:13:10.000000000 +0100 +++ 2007-02-08/xen/include/public/elfnote.h 2007-02-13 12:27:16.000000000 +0100 @@ -151,6 +151,12 @@ #define XEN_ELFNOTE_HV_START_LOW 12 /* + * List of maddr_t-sized mask/value pairs describing how to recognize + * (non-present) L1 page table entries carrying valid MFNs (numeric). + */ +#define XEN_ELFNOTE_L1_MFN_VALID 13 + +/* * System information exported through crash notes. * * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2007-Feb-20 09:52 UTC
Re: [Xen-devel] [PATCH] linux/x86: Advertise which page table entries contain MFNs
On 13/2/07 15:14, "Jan Beulich" <jbeulich@novell.com> wrote:> .. and hence need to be (un)canonicalized during save/restore. > > The patch should apply without the page table handling adjustment one, yet > the values passed in the new note assume that patch to be applied. > > Signed-off-by: Jan Beulich <jbeulich@novell.com>Could we just define _PAGE_PRESENT in the header file (it''s not likely to change!) rather than have to mess up another couple of header files to allow inclusion in assembly files. I see the need to change the ELFNOTE macro, but is the vararg macro syntax ever unavailable when building Linux? Do you have to keep the old ELFNOTE definition hanging around? Why are the extra build rules required, which kill EXTRA_AFLAGS? Has it something to do with trying to cleanly include pgtable.h? I think I agree with the change to NEXT_PAGE() but the change belongs upstream, not in our patches. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel