Xen-paravirt: Xen guest implementation for paravirt_ops interface
Subsystems (15)
cover Xen-paravirt: Xen guest implementation for paravirt_ops interface
Hi Andi,
This patch series implements the Linux Xen guest in terms of the paravirt-ops interface. The features in implemented this patch series are:
* domU only
* UP only (most code is SMP-safe, but there's no way to create a new vcpu)
* writable pagetables, with late pinning/early unpinning
(no shadow pagetable support)
* supports both PAE and non-PAE modes
* xen console
* virtual block device (blockfront)
* virtual network device (netfront)
The patch series is in two parts:
1-12: cleanups to the core kernel, either to fix outright problems,
or to add appropriate hooks for Xen
13-21: the Xen guest implementation itself
I've tried to make each patch as self-explanatory as possible. The series is based on 2.6.20 + Andi Kleen's firstfloor patches, specifically:
page-allocation-hooks-for-vmi-backend paravirt-cpu-batching.patch iopl-handling-for-paravirt-guests smp-boot-hook-for-paravirt vmi-backend-for-paravirt-ops
vmi-timer
Changes since the previous posting:
- made vga not crash when vga hardware isn't present
- cleaned up sign issues in xen-console
- cleaned up mm-lifetime hooks
- blockfront cleanups
- other stuff
Thanks,
J
PATCH 1/21 Xen-paravirt: Fix typo in sync_constant_test_bit()s name.
===================================================================
include/asm-i386/sync_bitops.h +1 -1
@@ -130,7 +130,7 @@ static inline int sync_test_and_change_breturn oldbit; } -static __always_inline int sync_const_test_bit(int nr, const volatile unsigned long *addr) +static __always_inline int sync_constant_test_bit(int nr, const volatile unsigned long *addr) {return ((1UL << (nr &31 )) & (((const volatile unsigned int *)addr)[nr >>5 ])) !=0 ;
PATCH 2/21 Xen-paravirt: Handle a zero-sized VT console
In reply to Jeremy FitzhardingeIf we're running under Xen, then there's no VT console. This results in vc->vc_screenbuf_size == 0, which causes alloc_bootmem to panic. Don't bother allocating a vc_screenbuf if its going to be 0 sized.
(Cleanup: remove unnecessary cast)
===================================================================
drivers/char/vt.c +4 -1
@@ -2638,7 +2638,10 @@ static int __init con_init(void)for (currcons =0 ; currcons <MIN_NR_CONSOLES ; currcons++) { vc_cons[currcons].d = vc =alloc_bootmem (sizeof (struct vc_data ));visual_init (vc, currcons,1 ); - vc->vc_screenbuf = (unsigned short *)alloc_bootmem (vc->vc_screenbuf_size); + + vc->vc_screenbuf =NULL ; +if (vc->vc_screenbuf_size) + vc->vc_screenbuf =alloc_bootmem (vc->vc_screenbuf_size); vc->vc_kmalloced =0 ;vc_init (vc, vc->vc_rows, vc->vc_cols, currcons || !vc->vc_sw->con_save_screen);
Gerd Hoffmann
NAKRe: [patch 02/21] Xen-paravirt: Handle a zero-sized VT console
Quoted 3 lines · Jeremy Fitzhardinge
If we're running under Xen, then there's no VT console. This results in
vc->vc_screenbuf_size== 0, which causesalloc_bootmemto panic. Don't bother allocating avc_screenbufif its going to be 0 sized.
NAK.
The *real* problem is that the real-mode boot code never ever runs, thus SCREEN_INFO is not initialized (all zeros), and vgacon doesn't catch that case. Instead it thinks it runs on a EGA card with 0 lines and 0 columns.
So better fix vgacon to catch this and switch to the 80x25 dummy console instead, patch attached.
cheers,
Gerd
--- drivers/video/console/vgacon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/console/vgacon.c +2 -1
@@ -372,7 +372,8 @@ static const char *vgacon_startup(void) }/* VGA16 modes are not handled by VGACON */ - if ((ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */ + if ((ORIG_VIDEO_MODE == 0x00) || /* SCREEN_INFO not initialized */ + (ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */ (ORIG_VIDEO_MODE == 0x0E) || /* 640x200/4 */ (ORIG_VIDEO_MODE == 0x10) || /* 640x350/4 */ (ORIG_VIDEO_MODE == 0x12) || /* 640x480/4 */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 3/21 Xen-paravirt: Add pagetable accessors to pack and unpack pagetable entries
In reply to Jeremy FitzhardingeAdd a set of accessors to pack, unpack and modify page table entries (at all levels). This allows a paravirt implementation to control the contents of pgd/pmd/pte entries. For example, Xen uses this to convert the (pseudo-)physical address into a machine address when populating a pagetable entry, and converting back to pphys address when an entry is read.
--
arch/i386/kernel/paravirt.c | 113 ++++++++++++++++++++++++++++++++---- arch/i386/kernel/vmlinux.lds.S | 3 include/asm-i386/page.h | 18 ++++- include/asm-i386/paravirt.h | 68 +++++++++++++++++++++ include/asm-i386/pgtable-2level.h | 5 - include/asm-i386/pgtable-3level.h | 27 ++++---- 6 files changed, 199 insertions(+), 35 deletions(-)
===================================================================
arch/i386/kernel/paravirt.c +101 -12
@@ -34,7 +34,7 @@#include <asm/tlbflush.h> /* nop stub */ -static void native_nop (void ) +void native_nop (void ) { }
@@ -400,38 +400,74 @@ static fastcall void native_flush_tlb_si }#ifndef CONFIG_X86_PAE -static fastcall void native_set_pte(pte_t *ptep, pte_t pteval) +fastcall void native_set_pte(pte_t *ptep, pte_t pteval) { *ptep = pteval; } -static fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval) +fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval) { *ptep = pteval; } -static fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval) +fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval) { *pmdp = pmdval; } +fastcall unsigned long native_pte_val (pte_t pte) +{ +return pte.pte_low; +} + +fastcall unsigned long native_pmd_val (pmd_t pmd) +{ +BUG (); +return 0 ; +} + +fastcall unsigned long native_pgd_val (pgd_t pgd) +{ +return pgd.pgd; +} + +fastcall pte_t native_make_pte(unsigned long pte) +{ +return (pte_t ){ pte }; +} + +fastcall pmd_t native_make_pmd(unsigned long pmd) +{ +BUG (); +} + +fastcall pgd_t native_make_pgd(unsigned long pgd) +{ +return (pgd_t ){ pgd }; +} + +fastcall pte_t native_ptep_get_and_clear(pte_t *ptep) +{ +return __pte (xchg (&(ptep)->pte_low,0 )); +} +#else /* CONFIG_X86_PAE */ -static fastcall void native_set_pte(pte_t *ptep, pte_t pte) +fastcall void native_set_pte(pte_t *ptep, pte_t pte) { ptep->pte_high = pte.pte_high;smp_wmb (); ptep->pte_low = pte.pte_low; } -static fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pte) +fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pte) { ptep->pte_high = pte.pte_high;smp_wmb (); ptep->pte_low = pte.pte_low; } -static fastcall void native_set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) +fastcall void native_set_pte_present(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pte) { ptep->pte_low =0 ;smp_wmb ();
@@ -440,34 +476,76 @@ static fastcall void native_set_pte_pres ptep->pte_low = pte.pte_low; } -static fastcall void native_set_pte_atomic(pte_t *ptep, pte_t pteval) +fastcall void native_set_pte_atomic(pte_t *ptep, pte_t pteval) {set_64bit ((unsigned long long *)ptep,pte_val (pteval)); } -static fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval) +fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval) {set_64bit ((unsigned long long *)pmdp,pmd_val (pmdval)); } -static fastcall void native_set_pud(pud_t *pudp, pud_t pudval) +fastcall void native_set_pud(pud_t *pudp, pud_t pudval) { *pudp = pudval; } -static fastcall void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) +fastcall void native_pte_clear(struct mm_struct *mm, u32 addr, pte_t *ptep) { ptep->pte_low =0 ;smp_wmb (); ptep->pte_high =0 ; } -static fastcall void native_pmd_clear(pmd_t *pmd) +fastcall void native_pmd_clear(pmd_t *pmd) {u32 *tmp = (u32 *)pmd; *tmp =0 ;smp_wmb (); *(tmp +1 ) =0 ; +} + +fastcall unsigned long long native_pte_val (pte_t pte) +{ +return pte.pte_low | ((unsigned long long )pte.pte_high <<32 ); +} + +fastcall unsigned long long native_pmd_val (pmd_t pmd) +{ +return pmd.pmd; +} + +fastcall unsigned long long native_pgd_val (pgd_t pgd) +{ +return pgd.pgd; +} + +fastcall pte_t native_make_pte(unsigned long long pte) +{ +return (pte_t ){ pte }; +} + +fastcall pmd_t native_make_pmd(unsigned long long pmd) +{ +return (pmd_t ){ pmd }; +} + +fastcall pgd_t native_make_pgd(unsigned long long pgd) +{ +return (pgd_t ){ pgd }; +} + +fastcall pte_t native_ptep_get_and_clear(pte_t *ptep) +{ +pte_t res; + +/* xchg acts as a barrier before the setting of the high bits */ + res.pte_low =xchg (&ptep->pte_low,0 ); + res.pte_high = ptep->pte_high; + ptep->pte_high =0 ; + +return res; }#endif /* CONFIG_X86_PAE */
@@ -555,6 +633,9 @@ struct paravirt_ops paravirt_ops = { .set_pmd = native_set_pmd, .pte_update = (void *)native_nop, .pte_update_defer = (void *)native_nop, + + .ptep_get_and_clear = native_ptep_get_and_clear, + #ifdef CONFIG_X86_PAE .set_pte_atomic = native_set_pte_atomic, .set_pte_present = native_set_pte_present,
@@ -563,6 +644,14 @@ struct paravirt_ops paravirt_ops = { .pmd_clear = native_pmd_clear, #endif + .pte_val = native_pte_val, + .pmd_val = native_pmd_val, + .pgd_val = native_pgd_val, + + .make_pte = native_make_pte, + .make_pmd = native_make_pmd, + .make_pgd = native_make_pgd, + .irq_enable_sysexit = native_irq_enable_sysexit, .iret = native_iret, };
===================================================================
arch/i386/kernel/vmlinux.lds.S +3 -0
@@ -21,6 +21,9 @@ #include <asm/page.h> #include <asm/cache.h> #include <asm/boot.h> + +#undef ENTRY +#undef ALIGN OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386)
===================================================================
include/asm-i386/page.h +14 -4
@@ -11,7 +11,6 @@#ifdef __KERNEL__#ifndef __ASSEMBLY__ -#ifdef CONFIG_X86_USE_3DNOW
@@ -48,9 +47,11 @@ typedef struct { unsigned long long pmd;typedef struct {unsigned long long pmd; }pmd_t ;typedef struct {unsigned long long pgd; }pgd_t ;typedef struct {unsigned long long pgprot; }pgprot_t ; +#ifndef CONFIG_PARAVIRT #define pmd_val (x) ((x).pmd)#define pte_val (x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))#define __pmd (x) ((pmd_t) { (x) } ) +#endif /* CONFIG_PARAVIRT */ #define HPAGE_SHIFT 21#include <asm-generic/pgtable-nopud.h> #else
@@ -58,7 +59,9 @@ typedef struct { unsigned long pgd; } pgtypedef struct {unsigned long pgd; }pgd_t ;typedef struct {unsigned long pgprot; }pgprot_t ;#define boot_pte_t pte_t/* or would you rather have a typedef */ +#ifndef CONFIG_PARAVIRT #define pte_val (x) ((x).pte_low) +#endif #define HPAGE_SHIFT 22#include <asm-generic/pgtable-nopmd.h> #endif
@@ -71,12 +74,14 @@ typedef struct { unsigned long pgprot; }#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA #endif +#define pgprot_val (x) ((x).pgprot) +#define __pgprot (x) ((pgprot_t) { (x) } ) + +#ifndef CONFIG_PARAVIRT #define pgd_val (x) ((x).pgd) -#define pgprot_val (x) ((x).pgprot) -#define __pte (x) ((pte_t) { (x) } )#define __pgd (x) ((pgd_t) { (x) } ) -#define __pgprot (x) ((pgprot_t) { (x) } ) +#endif #endif /* !__ASSEMBLY__ */
@@ -143,6 +148,11 @@ extern int page_is_ram(unsigned long pag#include <asm-generic/memory_model.h> #include <asm-generic/page.h> +#ifdef CONFIG_PARAVIRT +/* After pte_t, etc, have been defined */ +#include <asm/paravirt.h> +#endif +#ifndef CONFIG_COMPAT_VDSO #define __HAVE_ARCH_GATE_AREA 1#endif
===================================================================
include/asm-i386/paravirt.h +66 -2
108 lines not on this page · raw message
===================================================================
include/asm-i386/pgtable-2level.h +2 -3
@@ -15,6 +15,7 @@#define set_pte (pteptr, pteval) (*(pteptr) = pteval)#define set_pte_at (mm,addr,ptep,pteval) set_pte(ptep,pteval)#define set_pmd (pmdptr, pmdval) (*(pmdptr) = (pmdval)) +#define raw_ptep_get_and_clear (xp) __pte(xchg(&(xp)->pte_low, 0))#endif #define set_pte_atomic (pteptr, pteval) set_pte(pteptr,pteval)
@@ -23,11 +24,9 @@#define pte_clear (mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)#define pmd_clear (xp) do { set_pmd(xp, __pmd(0)); } while (0) -#define raw_ptep_get_and_clear (xp) __pte(xchg(&(xp)->pte_low, 0)) -#define pte_page (x) pfn_to_page(pte_pfn(x))#define pte_none (x) (!(x).pte_low) -#define pte_pfn (x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT))) +#define pte_pfn (x) (pte_val(x) >> PAGE_SHIFT)#define pfn_pte (pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))#define pfn_pmd (pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
===================================================================
include/asm-i386/pgtable-3level.h +13 -14
@@ -98,6 +98,18 @@ static inline void pmd_clear(pmd_t *pmd)smp_wmb (); *(tmp + 1) = 0; } + +static inline pte_t raw_ptep_get_and_clear (pte_t *ptep) +{ +pte_t res; + +/* xchg acts as a barrier before the setting of the high bits */ + res.pte_low =xchg (&ptep->pte_low,0 ); + res.pte_high = ptep->pte_high; + ptep->pte_high =0 ; + +return res; +}#endif /*
@@ -119,18 +131,6 @@ static inline void pud_clear (pud_t * pu#define pmd_offset (pud, address) ((pmd_t *) pud_page(*(pud)) + \ pmd_index(address)) -static inline pte_t raw_ptep_get_and_clear (pte_t *ptep) -{ -pte_t res; - -/* xchg acts as a barrier before the setting of the high bits */ - res.pte_low =xchg (&ptep->pte_low,0 ); - res.pte_high = ptep->pte_high; - ptep->pte_high =0 ; - -return res; -} -#define __HAVE_ARCH_PTE_SAMEstatic inline int pte_same (pte_t a,pte_t b) {
@@ -146,8 +146,7 @@ static inline int pte_none(pte_t pte)static inline unsigned long pte_pfn (pte_t pte) { -return (pte.pte_low >>PAGE_SHIFT ) | - (pte.pte_high << (32 -PAGE_SHIFT )); +return pte_val (pte) >>PAGE_SHIFT ; }extern unsigned long long __supported_pte_mask;
PATCH 4/21 Xen-paravirt: paravirt_ops: hooks to set up initial pagetable
In reply to Jeremy FitzhardingeThis patch introduces paravirt_ops hooks to control how the kernel's initial pagetable is set up.
In the case of a native boot, the very early bootstrap code creates a simple non-PAE pagetable to map the kernel and physical memory. When the VM subsystem is initialized, it creates a proper pagetable which respects the PAE mode, large pages, etc.
When booting under a hypervisor, there are many possibilities for what paging environment the hypervisor establishes for the guest kernel, so the constructon of the kernel's pagetable depends on the hypervisor.
In the case of Xen, the hypervisor boots the kernel with a fully constructed pagetable, which is already using PAE if necessary. Also, Xen requires particular care when constructing pagetables to make sure all pagetables are always mapped read-only.
In order to make this easier, kernel's initial pagetable construction has been changed to only allocate and initialize a pagetable page if there's no page already present in the pagetable. This allows the Xen paravirt backend to make a copy of the hypervisor-provided pagetable, allowing the kernel to establish any more mappings it needs while keeping the existing ones.
A slightly subtle point which is worth highlighting here is that Xen requires all kernel mappings to share the same pte_t pages between all pagetables, so that updating a kernel page's mapping in one pagetable is reflected in all other pagetables. This makes it possible to allocate a page and attach it to a pagetable without having to explicitly enumerate that page's mapping in all pagetables.
--
arch/i386/kernel/paravirt.c | 40 ++++++++++++++++++ arch/i386/mm/init.c | 89 +++++++++++++++++++++++++----------------- include/asm-i386/paravirt.h | 54 +++++++++++++++++++++++++ include/asm-i386/pgtable.h | 3 + 4 files changed, 150 insertions(+), 36 deletions(-)
===================================================================
arch/i386/kernel/paravirt.c +40 -0
@@ -379,6 +379,43 @@ static fastcall void native_io_delay(voi { asmvolatile ("outb %al,$0x80" ); } + +void native_pagetable_setup_start (pgd_t *base) +{ +#ifdef CONFIG_X86_PAE +int i; + +/* +* Init entries of the first-level page table to the +* zero page, if they haven't already been set up. +* +* In a normal native boot, we'll be running on a +* pagetable rooted in swapper_pg_dir, but not in PAE +* mode, so this will end up clobbering the mappings +* for the lower 24Mbytes of the address space, +* without affecting the kernel address space. +*/ +for (i =0 ; i <USER_PTRS_PER_PGD ; i++) +set_pgd (&base[i], +__pgd (__pa (empty_zero_page) | _PAGE_PRESENT)); +memset (&base[USER_PTRS_PER_PGD ],0 ,sizeof (pgd_t)); +#endif +} + +void native_pagetable_setup_done (pgd_t *base) +{ +#ifdef CONFIG_X86_PAE +/* +* Add low memory identity-mappings - SMP needs it when +* starting up on an AP from real-mode. In the non-PAE +* case we already have these mappings through head.S. +* All user-space mappings are explicitly cleared after +* SMP startup. +*/ +set_pgd (&base[0 ], base[USER_PTRS_PER_PGD ]); +#endif +} + static fastcall void native_flush_tlb(void) {
@@ -624,6 +661,9 @@ struct paravirt_ops paravirt_ops = { .apic_read = native_apic_read, #endif + .pagetable_setup_start = native_pagetable_setup_start, + .pagetable_setup_done = native_pagetable_setup_done, + .flush_tlb_user = native_flush_tlb, .flush_tlb_kernel = native_flush_tlb_global, .flush_tlb_single = native_flush_tlb_single,
===================================================================
arch/i386/mm/init.c +53 -36
150 lines not on this page · raw message
===================================================================
include/asm-i386/paravirt.h +54 -0
77 lines not on this page · raw message
===================================================================
include/asm-i386/pgtable.h +3 -0
@@ -15,7 +15,10 @@#include <asm/processor.h> #include <asm/fixmap.h> #include <linux/threads.h> + +#ifdef CONFIG_PARAVIRT /* guarded to prevent cyclic dependency */ #include <asm/paravirt.h> +#endif #ifndef _I386_BITOPS_H#include <asm/bitops.h>
PATCH 5/21 Xen-paravirt: paravirt_ops: allocate a fixmap slot
In reply to Jeremy FitzhardingeAllocate a fixmap slot for use by a paravirt_ops implementation. Xen uses this to map the hypervisor's shared info page, which doesn't have a pseudo-physical page number, and therefore can't be mapped ordinarily.
--
include/asm-i386/fixmap.h | 3 +++ 1 file changed, 3 insertions(+)
===================================================================
include/asm-i386/fixmap.h +3 -0
@@ -86,6 +86,9 @@ enum fixed_addresses {#ifdef CONFIG_PCI_MMCONFIG FIX_PCIE_MCFG,#endif +#ifdef CONFIG_PARAVIRT + FIX_PARAVIRT, +#endif __end_of_permanent_fixed_addresses,/* temporary boot-time mappings, used before ioremap() is functional */ #define NR_FIX_BTMAPS 16
Re: [patch 05/21] Xen-paravirt: paravirt_ops: allocate a fixmap slot
Quoted 5 lines · Jeremy Fitzhardinge
Allocate a fixmap slot for use by a
paravirt_opsimplementation. Xen uses this to map the hypervisor's shared info page, which doesn't have a pseudo-physical page number, and therefore can't be mapped ordinarily.
Why doesn't Xen allocate the shared_info page from the pseudo-physical space? Doesn't it already have to steal pages from the pseudo-physical space for e.g. initial page tables, console, etc? Why not do the same for shared_info, and then you don't need a reserve the fixmap slot.
Dan
Re: [patch 05/21] Xen-paravirt: paravirt_ops: allocate a fixmap slot
Quoted 5 lines · Dan Hecht
Why doesn't Xen allocate the
shared_infopage from the pseudo-physical space? Doesn't it already have to steal pages from the pseudo-physical space for e.g. initial page tables, console, etc? Why not do the same forshared_info, and then you don't need a reserve the fixmap slot.
Unlike the pagetable pages or the console page, the shared info page doesn't have a pseudo-physical address, so in order to map it we need to directly construct a pte containing the mfn for that page. Inserting this mapping into the fixmap space seems like the easiest way to do this. It's not like a fixmap slot costs anything.
J
Re: [patch 05/21] Xen-paravirt: paravirt_ops: allocate a fixmap slot
Quoted 10 lines · Jeremy Fitzhardinge
Quoted 5 lines · Dan Hecht
Why doesn't Xen allocate the
shared_infopage from the pseudo-physical space? Doesn't it already have to steal pages from the pseudo-physical space for e.g. initial page tables, console, etc? Why not do the same forshared_info, and then you don't need a reserve the fixmap slot.Unlike the pagetable pages or the console page, the shared info page doesn't have a pseudo-physical address, so in order to map it we need to directly construct a pte containing the mfn for that page.
Right. But that is only because Xen decides to allocate the page from the (machine) physical space, rather than from the pseudo-physical space. My question is: why doesn't Xen allocate shared_info from the pseudo-physical space? If it had, then this page wouldn't need to be treated specially. I'm not sure, but I seem to remember on 64-bit Xen/XenLinux allocated shared_info from pseudo-physical space already...
Inserting
Quoted 4 lines
this mapping into the fixmap space seems like the easiest way to do this. It's not like a fixmap slot costs anything.
I don't really have an objection to stealing a fixmap slot, just seems cleaner if you didn't have to special case the shared_info.
Dan
Re: [patch 05/21] Xen-paravirt: paravirt_ops: allocate a fixmap slot
Quoted 4 lines · Dan Hecht
Right. But that is only because Xen decides to allocate the page from the (machine) physical space, rather than from the pseudo-physical space. My question is: why doesn't Xen allocate
shared_infofrom the pseudo-physical space?
Historical reasons ...
Quoted 3 lines
If it had, then this page wouldn't need to be
treated specially. I'm not sure, but I seem to remember on 64-bit Xen/XenLinux allocatedshared_infofrom pseudo-physical space already...
Yep, the ia64 port which came later handles some things differently, specifically some "magic" pages are allocated more clever ;)
Changing that for x86 would break existing guests though.
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>
[Xen-devel] Re: [patch 05/21] Xen-paravirt: paravirt_ops: allocate a fixmap slot
In reply to Jeremy FitzhardingeQuoted 8 lines
Quoted 1 line
Quoted 1 line
Jeremy Fitzhardinge <[email protected]> 14.02.07 02:36 >>>
Quoted 5 lines · Dan Hecht
Why doesn't Xen allocate the
shared_infopage from the pseudo-physical space? Doesn't it already have to steal pages from the pseudo-physical space for e.g. initial page tables, console, etc? Why not do the same forshared_info, and then you don't need a reserve the fixmap slot.
Quoted 5 lines
Unlike the pagetable pages or the console page, the shared info page doesn't have a pseudo-physical address, so in order to map it we need to directly construct a pte containing the mfn for that page. Inserting this mapping into the fixmap space seems like the easiest way to do this. It's not like a fixmap slot costs anything.
Otoh there are many fixmap slots not used under Xen, perhaps it would be possible to use one of those... One slot certainly doesn't cost a lot, but many (like the IO-APIC group) may already matter, especially on PAE systems with lots of memory). Consequently, if these can't be squeezed out as needed, re-using would seem more appropriate than adding.
(I would certainly favor [conditionally] removing them, but can't easily see how to do this under CONFIG_PARAVIRT. Background being that we've already been hit by those [namely the LAPIC one] remaining present, hence the build not being able to detect that accesses to the LAPIC page can't work. While no such access was ever left in the base kernel, modules are more susceptible to this, and in our case it was the [native, i.e. pre-xenoprof] oprofile driver that had been forgotten to be disabled.)
Jan
Re: [Xen-devel] Re: [patch 05/21] Xen-paravirt: paravirt_ops: allocate a fixmap slot
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Jeremy Fitzhardinge <[email protected]> 14.02.07 02:36 >>>
Quoted 5 lines · Dan Hecht
Why doesn't Xen allocate the
shared_infopage from the pseudo-physical space? Doesn't it already have to steal pages from the pseudo-physical space for e.g. initial page tables, console, etc? Why not do the same forshared_info, and then you don't need a reserve the fixmap slot.
Quoted 8 lines
Quoted 5 lines
Unlike the pagetable pages or the console page, the shared info page doesn't have a pseudo-physical address, so in order to map it we need to directly construct a pte containing the mfn for that page. Inserting this mapping into the fixmap space seems like the easiest way to do this. It's not like a fixmap slot costs anything.
Otoh there are many fixmap slots not used under Xen, perhaps it would be possible to use one of those... One slot certainly doesn't cost a lot,
I don't have a problem with reserving one page for this.
-Andi
PATCH 6/21 Xen-paravirt: remove ctor for pgd cache
In reply to Jeremy FitzhardingeRemove the ctor for the pgd cache. There's no point in having the cache machinery do this via an indirect call when all pgd are freed in the one place anyway.
===================================================================
arch/i386/mm/init.c +3 -5
@@ -739,11 +739,9 @@ void __init pgtable_cache_init(void)panic ("pgtable_cache_init(): cannot create pmd cache" ); } pgd_cache =kmem_cache_create ("pgd" , -PTRS_PER_PGD *sizeof (pgd_t), -PTRS_PER_PGD *sizeof (pgd_t), -0 , - pgd_ctor, -PTRS_PER_PMD ==1 ? pgd_dtor :NULL ); +PTRS_PER_PGD *sizeof (pgd_t), +PTRS_PER_PGD *sizeof (pgd_t), +0 ,NULL ,NULL );if (!pgd_cache)panic ("pgtable_cache_init(): Cannot create pgd cache" ); }
===================================================================
arch/i386/mm/pgtable.c +11 -4
@@ -236,7 +236,7 @@ static inline void pgd_list_del(pgd_t *pset_page_private (next, (unsigned long )pprev); } -void pgd_ctor (void *pgd,struct kmem_cache *cache,unsigned long unused) +static void pgd_ctor (pgd_t *pgd) {unsigned long flags;
@@ -245,7 +245,7 @@ void pgd_ctor(void *pgd, struct kmem_cacspin_lock_irqsave (&pgd_lock, flags); } -clone_pgd_range ((pgd_t *)pgd +USER_PTRS_PER_PGD , +clone_pgd_range (pgd +USER_PTRS_PER_PGD , swapper_pg_dir +USER_PTRS_PER_PGD ,KERNEL_PGD_PTRS );
@@ -261,10 +261,12 @@ void pgd_ctor(void *pgd, struct kmem_cacspin_unlock_irqrestore (&pgd_lock, flags); } -/* never called when PTRS_PER_PMD > 1 */ -void pgd_dtor (void *pgd,struct kmem_cache *cache,unsigned long unused) +static void pgd_dtor (pgd_t *pgd) {unsigned long flags;/* can be called from interrupt context */ + +if (PTRS_PER_PMD ==1 ) +return ;paravirt_release_pd (__pa (pgd) >>PAGE_SHIFT );spin_lock_irqsave (&pgd_lock, flags);
@@ -276,6 +278,9 @@ pgd_t *pgd_alloc(struct mm_struct *mm) {int i;pgd_t *pgd =kmem_cache_alloc (pgd_cache,GFP_KERNEL ); + +if (pgd) +pgd_ctor (pgd);if (PTRS_PER_PMD ==1 || !pgd)return pgd;
@@ -296,6 +301,7 @@ out_oom:paravirt_release_pd (__pa (pmd) >>PAGE_SHIFT );kmem_cache_free (pmd_cache, pmd); } +pgd_dtor (pgd);kmem_cache_free (pgd_cache, pgd);return NULL ; }
@@ -313,5 +319,6 @@ void pgd_free(pgd_t *pgd)kmem_cache_free (pmd_cache, pmd); }/* in the non-PAE case, free_pgtables() clears user pgd entries */ +pgd_dtor (pgd);kmem_cache_free (pgd_cache, pgd); }
===================================================================
include/asm-i386/pgtable.h +0 -2
@@ -41,8 +41,6 @@ extern struct page *pgd_list;extern struct page *pgd_list;void pmd_ctor (void *,struct kmem_cache *,unsigned long ); -void pgd_ctor (void *,struct kmem_cache *,unsigned long ); -void pgd_dtor (void *,struct kmem_cache *,unsigned long );void pgtable_cache_init (void );void paging_init (void );
Re: [patch 06/21] Xen-paravirt: remove ctor for pgd cache
Quoted 7 lines · Jeremy Fitzhardinge
arch/i386/mm/pgtable.c +0
-1@@ -261,10 +261,12 @@ void pgd_ctor(void *pgd, struct kmem_cacspin_unlock_irqrestore (&pgd_lock, flags); } -/* never called when PTRS_PER_PMD > 1 */
arch/i386/mm/pgtable.c void pgd_ctor(void *pgd, struct kmem_cac · line 272
Quoted 10 lines
arch/i386/mm/pgtable.c +4
-1-void pgd_dtor (void *pgd,struct kmem_cache *cache,unsigned long unused) +static void pgd_dtor (pgd_t *pgd) {unsigned long flags;/* can be called from interrupt context */ + +if (PTRS_PER_PMD ==1 ) +return ;paravirt_release_pd (__pa (pgd) >>PAGE_SHIFT );spin_lock_irqsave (&pgd_lock, flags);
Acked, with exceptions. This bit breaks VMI. The paravirt_release_pd must happen unconditionally. But I would rather fix it after patches get applied just to make sure the entire allocation / deallocation order constraints are intact.
Zach
PATCH 7/21 Xen-paravirt: Allow paravirt backend to choose kernel PMD sharing
In reply to Jeremy FitzhardingeXen does not allow guests to have the kernel pmd shared between page tables, so parameterize pgtable.c to allow both modes of operation.
--
arch/i386/kernel/paravirt.c | 1 arch/i386/mm/fault.c | 6 +-- arch/i386/mm/pageattr.c | 2 - arch/i386/mm/pgtable.c | 61 +++++++++++++++++++------------ include/asm-i386/page.h | 7 ++- include/asm-i386/paravirt.h | 1 include/asm-i386/pgtable-2level-defs.h | 2 + include/asm-i386/pgtable-2level.h | 2 - include/asm-i386/pgtable-3level-defs.h | 6 +++ include/asm-i386/pgtable-3level.h | 16 ++------ include/asm-i386/pgtable.h | 7 +++ 11 files changed, 68 insertions(+), 43 deletions(-)
===================================================================
arch/i386/kernel/paravirt.c +1 -0
@@ -572,6 +572,7 @@ struct paravirt_ops paravirt_ops = { .name = "bare hardware", .paravirt_enabled = 0, .kernel_rpl = 0, + .shared_kernel_pmd = 1, /* Only used when CONFIG_X86_PAE is set */ .patch = native_patch, .banner = default_banner,
===================================================================
arch/i386/mm/fault.c +3 -3
@@ -616,8 +616,7 @@ do_sigbus:force_sig_info_fault (SIGBUS ,BUS_ADRERR , address, tsk); } -#ifndef CONFIG_X86_PAE -void vmalloc_sync_all (void ) +void _vmalloc_sync_all (void ) {/* * Note that races in the updates of insync and start aren't
@@ -628,6 +627,8 @@ void vmalloc_sync_all(void) static DECLARE_BITMAP(insync, PTRS_PER_PGD);static unsigned long start =TASK_SIZE ;unsigned long address; + +BUG_ON (SHARED_KERNEL_PMD );BUILD_BUG_ON (TASK_SIZE & ~PGDIR_MASK );for (address = start; address >=TASK_SIZE ; address +=PGDIR_SIZE ) {
@@ -651,4 +652,3 @@ void vmalloc_sync_all(void) start = address +PGDIR_SIZE ; } } -#endif
===================================================================
arch/i386/mm/pageattr.c +1 -1
@@ -91,7 +91,7 @@ static void set_pmd_pte(pte_t *kpte, unsunsigned long flags;set_pte_atomic (kpte, pte);/* change init_mm */ -if (PTRS_PER_PMD >1 ) +if (SHARED_KERNEL_PMD )return ;spin_lock_irqsave (&pgd_lock, flags);
===================================================================
arch/i386/mm/pgtable.c +39 -22
96 lines not on this page · raw message
===================================================================
include/asm-i386/page.h +4 -3
@@ -50,21 +50,23 @@ typedef struct { unsigned long long pgpr#ifndef CONFIG_PARAVIRT #define pmd_val (x) ((x).pmd)#define pte_val (x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) +#define __pte (x) ((pte_t) { .pte_low = (x), .pte_high = ((x) >> 32) } )#define __pmd (x) ((pmd_t) { (x) } )#endif /* CONFIG_PARAVIRT */ #define HPAGE_SHIFT 21#include <asm-generic/pgtable-nopud.h> -#else +#else /* !CONFIG_X86_PAE */ typedef struct {unsigned long pte_low; }pte_t ;typedef struct {unsigned long pgd; }pgd_t ;typedef struct {unsigned long pgprot; }pgprot_t ;#define boot_pte_t pte_t/* or would you rather have a typedef */ #ifndef CONFIG_PARAVIRT +#define __pte (x) ((pte_t) { (x) })#define pte_val (x) ((x).pte_low)#endif #define HPAGE_SHIFT 22#include <asm-generic/pgtable-nopmd.h> -#endif +#endif /* CONFIG_X86_PAE */ #define PTE_MASK PAGE_MASK#ifdef CONFIG_HUGETLB_PAGE
@@ -79,7 +81,6 @@ typedef struct { unsigned long pgprot; }#ifndef CONFIG_PARAVIRT #define pgd_val (x) ((x).pgd) -#define __pte (x) ((pte_t) { (x) } )#define __pgd (x) ((pgd_t) { (x) } )#endif
===================================================================
include/asm-i386/paravirt.h +1 -0
@@ -34,6 +34,7 @@ struct paravirt_opsstruct paravirt_ops {unsigned int kernel_rpl; +int shared_kernel_pmd;int paravirt_enabled;const char *name;
===================================================================
include/asm-i386/pgtable-2level-defs.h +2 -0
@@ -1,5 +1,7 @@#ifndef _I386_PGTABLE_2LEVEL_DEFS_H#define _I386_PGTABLE_2LEVEL_DEFS_H + +#define SHARED_KERNEL_PMD 0/* * traditional i386 two-level paging structure:
===================================================================
include/asm-i386/pgtable-2level.h +0 -2
@@ -66,6 +66,4 @@ static inline int pte_exec_kernel(pte_t#define __pte_to_swp_entry (pte) ((swp_entry_t) { (pte).pte_low })#define __swp_entry_to_pte (x) ((pte_t) { (x).val }) -void vmalloc_sync_all (void ); -#endif /* _I386_PGTABLE_2LEVEL_H */
===================================================================
include/asm-i386/pgtable-3level-defs.h +6 -0
@@ -1,5 +1,11 @@#ifndef _I386_PGTABLE_3LEVEL_DEFS_H#define _I386_PGTABLE_3LEVEL_DEFS_H + +#ifdef CONFIG_PARAVIRT +#define SHARED_KERNEL_PMD (paravirt_ops.shared_kernel_pmd) +#else +#define SHARED_KERNEL_PMD 1 +#endif /* * PGDIR_SHIFT determines what a top-level page table entry can map
===================================================================
include/asm-i386/pgtable-3level.h +4 -12
@@ -153,20 +153,14 @@ extern unsigned long long __supported_ptstatic inline pte_t pfn_pte (unsigned long page_nr,pgprot_t pgprot) { -pte_t pte; - - pte.pte_high = (page_nr >> (32 -PAGE_SHIFT )) | \ - (pgprot_val (pgprot) >>32 ); - pte.pte_high &= (__supported_pte_mask >>32 ); - pte.pte_low = ((page_nr <<PAGE_SHIFT ) |pgprot_val (pgprot)) & \ - __supported_pte_mask; -return pte; +return __pte ((((unsigned long long )page_nr <<PAGE_SHIFT ) | +pgprot_val (pgprot)) & __supported_pte_mask); }static inline pmd_t pfn_pmd (unsigned long page_nr,pgprot_t pgprot) { -return __pmd ((((unsigned long long )page_nr <<PAGE_SHIFT ) | \ -pgprot_val (pgprot)) & __supported_pte_mask); +return __pmd ((((unsigned long long )page_nr <<PAGE_SHIFT ) | +pgprot_val (pgprot)) & __supported_pte_mask); }/*
@@ -186,6 +180,4 @@ static inline pmd_t pfn_pmd(unsigned lon#define __pmd_free_tlb (tlb, x) do { } while (0) -#define vmalloc_sync_all () ((void)0) -#endif /* _I386_PGTABLE_3LEVEL_H */
===================================================================
include/asm-i386/pgtable.h +7 -0
@@ -239,6 +239,13 @@ static inline pte_t pte_mkwrite(pte_t ptstatic inline pte_t pte_mkwrite (pte_t pte) { (pte).pte_low |= _PAGE_RW;return pte; }static inline pte_t pte_mkhuge (pte_t pte) { (pte).pte_low |= _PAGE_PSE;return pte; } +extern void _vmalloc_sync_all (void ); +static inline void vmalloc_sync_all (void ) +{ +if (!SHARED_KERNEL_PMD ) +_vmalloc_sync_all (); +} +#ifdef CONFIG_X86_PAE # include <asm/pgtable-3level.h> #else
PATCH 8/21 Xen-paravirt: Allow paravirt backend to select PGD allocation alignment
In reply to Jeremy FitzhardingeXen requires pgds to be page-aligned, so make this a parameter which can be set in the paravirt_ops structure.
--
arch/i386/kernel/paravirt.c | 1 + arch/i386/mm/init.c | 2 +- include/asm-i386/paravirt.h | 5 ++++- include/asm-i386/pgtable.h | 6 ++++++ 4 files changed, 12 insertions(+), 2 deletions(-)
===================================================================
arch/i386/kernel/paravirt.c +1 -0
@@ -573,6 +573,7 @@ struct paravirt_ops paravirt_ops = { .paravirt_enabled = 0, .kernel_rpl = 0, .shared_kernel_pmd = 1, /* Only used when CONFIG_X86_PAE is set */ + .pgd_alignment = sizeof(pgd_t) * PTRS_PER_PGD, .patch = native_patch, .banner = default_banner,
===================================================================
arch/i386/mm/init.c +1 -1
@@ -745,7 +745,7 @@ void __init pgtable_cache_init(void) } pgd_cache =kmem_cache_create ("pgd" ,PTRS_PER_PGD *sizeof (pgd_t), -PTRS_PER_PGD *sizeof (pgd_t), +PGD_ALIGNMENT ,0 ,NULL ,NULL );if (!pgd_cache)panic ("pgtable_cache_init(): Cannot create pgd cache" );
===================================================================
include/asm-i386/paravirt.h +4 -1
@@ -33,9 +33,12 @@ struct mm_struct;struct mm_struct ;struct paravirt_ops { +int paravirt_enabled;unsigned int kernel_rpl; +int shared_kernel_pmd; -int paravirt_enabled; +int pgd_alignment; +const char *name;/*
===================================================================
include/asm-i386/pgtable.h +6 -0
@@ -270,6 +270,12 @@ static inline void vmalloc_sync_all(void#define pte_update_defer (mm, addr, ptep) do { } while (0)#endif +#ifdef CONFIG_PARAVIRT +#define PGD_ALIGNMENT (paravirt_ops.pgd_alignment) +#else +#define PGD_ALIGNMENT (sizeof(pgd_t) * PTRS_PER_PGD) +#endif +/* * We only update the dirty/accessed state if we set * the dirty bit by hand in the kernel, since the hardware
PATCH 9/21 Xen-paravirt: add hooks to intercept mm creation and destruction
In reply to Jeremy FitzhardingeAdd hooks to allow a paravirt implementation to track the lifetime of an mm.
--
arch/i386/kernel/paravirt.c | 4 ++++ include/asm-i386/mmu_context.h | 8 ++++++-- include/asm-i386/paravirt.h | 38 ++++++++++++++++++++++++++++++++++++++ kernel/fork.c | 3 +++ mm/mmap.c | 4 ++++ 5 files changed, 55 insertions(+), 2 deletions(-)
===================================================================
arch/i386/kernel/paravirt.c +4 -0
@@ -706,6 +706,10 @@ struct paravirt_ops paravirt_ops = { .irq_enable_sysexit = native_irq_enable_sysexit, .iret = native_iret, + .dup_mmap = (void *)native_nop, + .exit_mmap = (void *)native_nop, + .activate_mm = (void *)native_nop, + .startup_ipi_hook = (void *)native_nop, };
===================================================================
include/asm-i386/mmu_context.h +6 -2
@@ -5,6 +5,7 @@#include <asm/atomic.h> #include <asm/pgalloc.h> #include <asm/tlbflush.h> +#include <asm/paravirt.h> /* * Used for LDT copy/destruction.
@@ -65,7 +66,10 @@ static inline void switch_mm(struct mm_s#define deactivate_mm (tsk, mm) \ asm("movl %0,%%fs": :"r" (0)); -#define activate_mm (prev, next) \ - switch_mm((prev),(next),NULL) +#define activate_mm (prev, next) \ + do { \ + arch_activate_mm(prev, next); \ + switch_mm((prev),(next),NULL); \ + } while(0);#endif
===================================================================
include/asm-i386/paravirt.h +39 -0
@@ -126,6 +126,12 @@ struct paravirt_ops void (fastcall *io_delay)(void);void (*const_udelay)(unsigned long loops); + void (fastcall *activate_mm)(struct mm_struct *prev, +struct mm_struct *next); + void (fastcall *dup_mmap)(struct mm_struct *oldmm, +struct mm_struct *mm); + void (fastcall *exit_mmap)(struct mm_struct *mm); +#ifdef CONFIG_X86_LOCAL_APIC void (fastcall *apic_write)(unsigned long reg, unsigned long v); void (fastcall *apic_write_atomic)(unsigned long reg, unsigned long v);
@@ -429,6 +435,24 @@ static inline void paravirt_pagetable_se (*paravirt_ops.pagetable_setup_done)(base); } +#define __HAVE_ARCH_MM_LIFETIME +static inline void arch_activate_mm (struct mm_struct *prev, +struct mm_struct *next) +{ + paravirt_ops.activate_mm (prev, next); +} + +static inline void arch_dup_mmap (struct mm_struct *oldmm, +struct mm_struct *mm) +{ + paravirt_ops.dup_mmap (oldmm, mm); +} + +static inline void arch_exit_mmap (struct mm_struct *mm) +{ + paravirt_ops.exit_mmap (mm); +} +#define __flush_tlb () paravirt_ops.flush_tlb_user()#define __flush_tlb_global () paravirt_ops.flush_tlb_kernel()#define __flush_tlb_single (addr) paravirt_ops.flush_tlb_single(addr)
@@ -673,5 +697,20 @@ static inline void paravirt_pagetable_seset_pgd (&base[0 ], base[USER_PTRS_PER_PGD ]);#endif } + +static inline void paravirt_activate_mm (struct mm_struct *prev, +struct mm_struct *next) +{ +} + +static inline void paravirt_dup_mmap (struct mm_struct *oldmm, +struct mm_struct *mm) +{ +} + +static inline void paravirt_exit_mmap (struct mm_struct *mm) +{ +} +#endif /* CONFIG_PARAVIRT */ #endif /* __ASM_PARAVIRT_H */
===================================================================
include/linux/sched.h +6 -0
@@ -374,6 +374,12 @@ struct mm_struct {rwlock_t ioctx_list_lock;struct kioctx *ioctx_list; }; + +#ifndef __HAVE_ARCH_MM_LIFETIME +#define arch_activate_mm (prev, next) do {} while(0) +#define arch_dup_mmap (oldmm, mm) do {} while(0) +#define arch_exit_mmap (mm) do {} while(0) +#endif struct sighand_struct {atomic_t count;
===================================================================
kernel/fork.c +1 -0
@@ -286,6 +286,7 @@ static inline int dup_mmap(struct mm_strif (retval) goto out; } +arch_dup_mmap (oldmm, mm); retval =0 ; out:up_write (&mm->mmap_sem);
===================================================================
mm/mmap.c +2 -0
@@ -1976,6 +1976,8 @@ void exit_mmap(struct mm_struct *mm)struct vm_area_struct *vma = mm->mmap;unsigned long nr_accounted =0 ;unsigned long end; + +arch_exit_mmap (mm);lru_add_drain ();flush_cache_mm (mm);
PATCH 10/21 Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
In reply to Jeremy FitzhardingeWrap the paravirt_ops members we want to export in wrapper functions. Since we binary-patch the critical ones, this doesn't make a speed impact.
I moved drm_follow_page into the core, to avoid having to wrap the various pte ops. Unlining kernel_fpu_end and using that in the RAID6 code would remove the need to export clts/read_cr0/write_cr0 too.
===================================================================
arch/i386/kernel/paravirt.c +117 -8
@@ -596,6 +596,123 @@ static int __init print_banner(void)return 0 ; }core_initcall (print_banner); + +unsigned long paravirt_save_flags (void ) +{ +return paravirt_ops.save_fl (); +} +EXPORT_SYMBOL (paravirt_save_flags); + +void paravirt_restore_flags (unsigned long flags) +{ + paravirt_ops.restore_fl (flags); +} +EXPORT_SYMBOL (paravirt_restore_flags); + +void paravirt_irq_disable (void ) +{ + paravirt_ops.irq_disable (); +} +EXPORT_SYMBOL (paravirt_irq_disable); + +void paravirt_irq_enable (void ) +{ + paravirt_ops.irq_enable (); +} +EXPORT_SYMBOL (paravirt_irq_enable); + +void paravirt_io_delay (void ) +{ + paravirt_ops.io_delay (); +} +EXPORT_SYMBOL (paravirt_io_delay); + +void paravirt_const_udelay (unsigned long loops) +{ + paravirt_ops.const_udelay (loops); +} +EXPORT_SYMBOL (paravirt_const_udelay); + +u64 paravirt_read_msr (unsigned int msr,int *err) +{ +return paravirt_ops.read_msr (msr, err); +} +EXPORT_SYMBOL (paravirt_read_msr); + +int paravirt_write_msr (unsigned int msr,u64 val) +{ +return paravirt_ops.write_msr (msr, val); +} +EXPORT_SYMBOL (paravirt_write_msr); + +u64 paravirt_read_tsc (void ) +{ +return paravirt_ops.read_tsc (); +} +EXPORT_SYMBOL (paravirt_read_tsc); + +int paravirt_enabled (void ) +{ +return paravirt_ops.paravirt_enabled; +} +EXPORT_SYMBOL (paravirt_enabled); + +void clts (void ) +{ + paravirt_ops.clts (); +} +EXPORT_SYMBOL (clts); + +unsigned long read_cr0 (void ) +{ +return paravirt_ops.read_cr0 (); +} +EXPORT_SYMBOL_GPL (read_cr0); + +void write_cr0 (unsigned long cr0) +{ + paravirt_ops.write_cr0 (cr0); +} +EXPORT_SYMBOL_GPL (write_cr0); + +void wbinvd (void ) +{ + paravirt_ops.wbinvd (); +} +EXPORT_SYMBOL (wbinvd); + +void raw_safe_halt (void ) +{ + paravirt_ops.safe_halt (); +} +EXPORT_SYMBOL_GPL (raw_safe_halt); + +void halt (void ) +{ + paravirt_ops.safe_halt (); +} +EXPORT_SYMBOL_GPL (halt); + +#ifdef CONFIG_X86_LOCAL_APIC +void apic_write (unsigned long reg,unsigned long v) +{ + paravirt_ops.apic_write (reg,v); +} +EXPORT_SYMBOL_GPL (apic_write); + +unsigned long apic_read (unsigned long reg) +{ +return paravirt_ops.apic_read (reg); +} +EXPORT_SYMBOL_GPL (apic_read); +#endif + +void __cpuid (unsigned int *eax,unsigned int *ebx, +unsigned int *ecx,unsigned int *edx) +{ + paravirt_ops.cpuid (eax, ebx, ecx, edx); +} +EXPORT_SYMBOL (__cpuid);/* We simply declare start_kernel to be the paravirt probe of last resort. */ paravirt_probe (start_kernel);
@@ -712,11 +829,3 @@ struct paravirt_ops paravirt_ops = { .startup_ipi_hook = (void *)native_nop, }; - -/* -* NOTE: CONFIG_PARAVIRT is experimental and the paravirt_ops -* semantics are subject to change. Hence we only do this -* internal-only export of this, until it gets sorted out and -* all lowlevel CPU ops used by modules are separately exported. -*/ -EXPORT_SYMBOL_GPL (paravirt_ops);
===================================================================
include/asm-i386/delay.h +2 -2
@@ -17,9 +17,9 @@ extern void __delay(unsigned long loops)extern void __delay (unsigned long loops);#if defined(CONFIG_PARAVIRT ) && !defined(USE_REAL_TIME_DELAY ) -#define udelay (n) paravirt_ops.const_udelay((n) * 0x10c7ul) +#define udelay (n) paravirt_const_udelay((n) * 0x10c7ul) -#define ndelay (n) paravirt_ops.const_udelay((n) * 5ul) +#define ndelay (n) paravirt_const_udelay((n) * 5ul)#else /* !PARAVIRT || USE_REAL_TIME_DELAY */
===================================================================
include/asm-i386/paravirt.h +64 -76
254 lines not on this page · raw message
===================================================================
include/linux/irqflags.h +5 -5
@@ -74,11 +74,11 @@#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT -#define safe_halt () \ - do { \ - trace_hardirqs_on(); \ - raw_safe_halt(); \ - } while (0) +static inline void safe_halt (void ) +{ +trace_hardirqs_on (); +raw_safe_halt (); +}#define local_save_flags (flags) raw_local_save_flags(flags)
===================================================================
include/linux/mm.h +2 -0
@@ -1129,6 +1129,8 @@ struct page *follow_page(struct vm_area_#define FOLL_GET 0x04/* do get_page on page */ #define FOLL_ANON 0x08/* give ZERO_PAGE if no pgtable */ +unsigned long __follow_page (void *vaddr); +#ifdef CONFIG_PROC_FS void vm_stat_account (struct mm_struct *,unsigned long ,struct file *,long );#else
===================================================================
mm/memory.c +11 -0
@@ -976,6 +976,17 @@ no_page_table:return page; } +/* You don't want to use this function. It's for drm_memory.c. */ +unsigned long __follow_page (void *vaddr) +{ +pgd_t *pgd =pgd_offset_k ((unsigned long )vaddr); +pud_t *pud =pud_offset (pgd, (unsigned long )vaddr); +pmd_t *pmd =pmd_offset (pud, (unsigned long )vaddr); +pte_t *ptep =pte_offset_kernel (pmd, (unsigned long )vaddr); +return pte_pfn (*ptep) <<PAGE_SHIFT ; +} +EXPORT_SYMBOL_GPL (__follow_page); +int get_user_pages (struct task_struct *tsk,struct mm_struct *mm,unsigned long start,int len,int write,int force,struct page **pages,struct vm_area_struct **vmas)
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
Quoted 34 lines · Jeremy Fitzhardinge
Wrap the
paravirt_opsmembers we want to export in wrapper functions. Since we binary-patch the critical ones, this doesn't make a speed impact.I moved
drm_follow_pageinto the core, to avoid having to wrap the various pte ops. Unliningkernel_fpu_endand using that in the RAID6 code would remove the need to export clts/read_cr0/write_cr0 too.Signed-off-by Rusty Russell <[email protected]>Signed-off-by Chris Wright <[email protected]>Signed-off-by Jeremy Fitzhardinge <[email protected]>===================================================================
arch/i386/kernel/paravirt.c +15
-0@@ -596,6 +596,123 @@ static int __init print_banner(void)return 0 ; }core_initcall (print_banner); + +unsigned long paravirt_save_flags (void ) +{ +return paravirt_ops.save_fl (); +} +EXPORT_SYMBOL (paravirt_save_flags); + +void paravirt_restore_flags (unsigned long flags) +{ + paravirt_ops.restore_fl (flags); +} +EXPORT_SYMBOL (paravirt_restore_flags); + +void paravirt_irq_disable (void ) +{
arch/i386/kernel/paravirt.c static int __init print_banner(void) · line 623
Quoted 10 lines
arch/i386/kernel/paravirt.c +9
-0+ paravirt_ops.irq_disable (); +} +EXPORT_SYMBOL (paravirt_irq_disable); + +void paravirt_irq_enable (void ) +{ + paravirt_ops.irq_enable (); +} +EXPORT_SYMBOL (paravirt_irq_enable);
This turned out really hideous looking to me. Can't we split the struct into GPL'd and non-GPL'd functions instead? We still have the same granularity, and none of this function call to an indirect function call nonsense.
Zach
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
Quoted 4 lines · Zachary Amsden
This turned out really hideous looking to me. Can't we split the struct into GPL'd and non-GPL'd functions instead? We still have the same granularity, and none of this function call to an indirect function call nonsense.
It's not pretty, but I think having paravirt_ops and paravirt_ops_gpl would be worse. I'd be sympathetic to the idea of splitting paravirt_ops up by function groupings, but splitting it by license seems like a maintenance headache with no real upside. Besides, patching will solve everything (tm).
J
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 5 lines · Zachary Amsden
This turned out really hideous looking to me. Can't we split the struct into GPL'd and non-GPL'd functions instead? We still have the same granularity, and none of this function call to an indirect function call nonsense.
Quoted 6 lines
It's not pretty, but I think having
paravirt_opsandparavirt_ops_gplwould be worse. I'd be sympathetic to the idea of splittingparavirt_opsup by function groupings, but splitting it by license seems like a maintenance headache with no real upside. Besides, patching will solve everything (tm).
Ok. As long as we plan on patching CR2 and CR0 / clts accessors for FPU save during context switch and page fault paths in the future.
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
Quoted 2 lines · Zachary Amsden
Ok. As long as we plan on patching CR2 and CR0 / clts accessors for FPU save during context switch and page fault paths in the future.
That's up to each backend, right? Or do these need to be patched for a correctness reason?
J
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 3 lines · Zachary Amsden
Ok. As long as we plan on patching CR2 and CR0 / clts accessors for FPU save during context switch and page fault paths in the future.
That's up to each backend, right? Or do these need to be patched for a correctness reason?
No, it needs to be part of the general patch list first, which is still hand listed rather than just any op being patchable. Then it can be up to the backend.
Zach
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
Quoted 3 lines · Zachary Amsden
No, it needs to be part of the general patch list first, which is still hand listed rather than just any op being patchable. Then it can be up to the backend.
Ah, right, yes. We need to add all (most? some?) of the pte operations to that list too.
J
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
In reply to Zachary AmsdenQuoted 9 lines · Zachary Amsden
Quoted 3 lines · Jeremy Fitzhardinge
Wrap the
paravirt_opsmembers we want to export in wrapper functions. Since we binary-patch the critical ones, this doesn't make a speed impact.This turned out really hideous looking to me. Can't we split the struct into GPL'd and non-GPL'd functions instead? We still have the same granularity, and none of this function call to an indirect function call nonsense.
This patch, indeed, should not have been pushed in this series. But not for that reason: I actually prefer explicit exports.
KVM and lguest need more symbols, so the real patch will make them use native_XXX versions explicitly...
Cheers,
Rusty.
Re: [patch 10/21] Xen-paravirt: Name: dont export paravirt_ops structure, do individual functions
In reply to Zachary AmsdenQuoted 3 lines · Zachary Amsden
Quoted 3 lines
I moved
drm_follow_pageinto the core, to avoid having to wrap the various pte ops. Unliningkernel_fpu_endand using that in the RAID6 code would remove the need to export clts/read_cr0/write_cr0 too.
Please don't push the drm_follow_page part. Dave and I fixed drm to not need this junk anymore, and it should be part of the next drm merge.
PATCH 11/21 Xen-paravirt: Add apply_to_page_range() which applies a function to a pte range.
In reply to Jeremy FitzhardingeAdd a new mm function apply_to_page_range() which applies a given function to every pte in a given virtual address range in a given mm structure. This is a generic alternative to cut-and-pasting the Linux idiomatic pagetable walking code in every place that a sequence of PTEs must be accessed.
Although this interface is intended to be useful in a wide range of situations, it is currently used specifically by several Xen subsystems, for example: to ensure that pagetables have been allocated for a virtual address range, and to construct batched special pagetable update requests to map I/O memory (in ioremap()).
--- include/linux/mm.h | 5 ++ mm/memory.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
===================================================================
include/linux/mm.h +5 -0
@@ -1130,6 +1130,11 @@ struct page *follow_page(struct vm_area_unsigned long __follow_page (void *vaddr); +typedef int (*pte_fn_t )(pte_t *pte,struct page *pmd_page,unsigned long addr, +void *data); +extern int apply_to_page_range (struct mm_struct *mm,unsigned long address, +unsigned long size,pte_fn_t fn,void *data); +#ifdef CONFIG_PROC_FS void vm_stat_account (struct mm_struct *,unsigned long ,struct file *,long );#else
===================================================================
mm/memory.c +94 -0
100 lines not on this page · raw message
PATCH 12/21 Xen-paravirt: Allocate and free vmalloc areas
In reply to Jeremy FitzhardingeAllocate/destroy a 'vmalloc' VM area: alloc_vm_area and free_vm_area The alloc function ensures that page tables are constructed for the region of kernel virtual address space and mapped into init_mm.
Lock an area so that PTEs are accessible in the current address space:lock_vm_area and unlock_vm_area. The lock function prevents context switches to a lazy mm that doesn't have the area mapped into its page tables. It also ensures that the page tables are mapped into the current mm by causing the page fault handler to copy the page directory pointers from init_mm into the current mm.
These functions are not particularly Xen-specific, so they're put into mm/vmalloc.c.
--
include/linux/vmalloc.h | 8 +++++ mm/vmalloc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)
===================================================================
include/linux/vmalloc.h +8 -0
@@ -68,6 +68,14 @@ extern int map_vm_area(struct vm_struct struct page ***pages);extern void unmap_vm_area (struct vm_struct *area); +/* Allocate/destroy a 'vmalloc' VM area. */ +extern struct vm_struct *alloc_vm_area (unsigned long size); +extern void free_vm_area (struct vm_struct *area); + +/* Lock an area so that PTEs are accessible in the current address space. */ +extern void lock_vm_area (struct vm_struct *area); +extern void unlock_vm_area (struct vm_struct *area); +/* * Internals. Dont't use.. */
===================================================================
mm/vmalloc.c +62 -0
65 lines not on this page · raw message
PATCH 13/21 Xen-paravirt: Add nosegneg capability to the vsyscall page notes
In reply to Jeremy FitzhardingeAdd the "nosegneg" fake capabilty to the vsyscall page notes. This is used by the runtime linker to select a glibc version which then disables negative-offset accesses to the thread-local segment via %gs. These accesses require emulation in Xen (because segments are truncated to protect the hypervisor address space) and avoiding them provides a measurable performance boost.
--- arch/i386/kernel/vsyscall-note.S | 28 +++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+)
===================================================================
arch/i386/kernel/vsyscall-note.S +28 -0
@@ -23,3 +24,31 @@ 3: .balign 4; /* pad out section */ ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0) .long LINUX_VERSION_CODE ASM_ELF_NOTE_END + +#ifdef CONFIG_XEN +/* + * Add a special note telling glibc's dynamic linker a fake hardware + * flavor that it will use to choose the search path for libraries in the + * same way it uses real hardware capabilities like "mmx". + * We supply "nosegneg" as the fake capability, to indicate that we + * do not like negative offsets in instructions using segment overrides, + * since we implement those inefficiently. This makes it possible to + * install libraries optimized to avoid those access patterns in someplace + * like /lib/i686/tls/nosegneg. Note that an /etc/ld.so.conf.d/file + * corresponding to the bits here is needed to make ldconfig work right. + * It should contain: + * hwcap 0 nosegneg + * to match the mapping of bit to name that we give here. + */ +#define NOTE_KERNELCAP_BEGIN(ncaps, mask) \ + ASM_ELF_NOTE_BEGIN(".note.kernelcap", "a", "GNU", 2) \ + .long ncaps, mask +#define NOTE_KERNELCAP(bit, name) \ + .byte bit; .asciz name +#define NOTE_KERNELCAP_END ASM_ELF_NOTE_END + +NOTE_KERNELCAP_BEGIN(1, 1) +NOTE_KERNELCAP(1, "nosegneg") +NOTE_KERNELCAP_END +#endif +
Re: [patch 13/21] Xen-paravirt: Add nosegneg capability to the vsyscall page notes
Quoted 7 lines · Jeremy Fitzhardinge
Add the "nosegneg" fake capabilty to the vsyscall page notes. This is used by the runtime linker to select a glibc version which then disables negative-offset accesses to the thread-local segment via %gs. These accesses require emulation in Xen (because segments are truncated to protect the hypervisor address space) and avoiding them provides a measurable performance boost.
I don't like this because now a kernel compiled with both CONFIG_XEN and CONFIG_VMI has "nosegneg" turned on. We don't actually require this for performance or correctness, so it would be nice to be able to dynamically turn it off instead of having it forced.
Zach
Re: [patch 13/21] Xen-paravirt: Add nosegneg capability to the vsyscall page notes
Quoted 4 lines · Zachary Amsden
I don't like this because now a kernel compiled with both
CONFIG_XENandCONFIG_VMIhas "nosegneg" turned on. We don't actually require this for performance or correctness, so it would be nice to be able to dynamically turn it off instead of having it forced.
Any suggestions about how to do this? It seems hard to have a note dynamically appear and disappear in the vsyscall.so.
I wasn't terribly concerned about this, since there is effectively zero performance difference between the two library implementations.
J
Re: [patch 13/21] Xen-paravirt: Add nosegneg capability to the vsyscall page notes
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 5 lines · Zachary Amsden
I don't like this because now a kernel compiled with both
CONFIG_XENandCONFIG_VMIhas "nosegneg" turned on. We don't actually require this for performance or correctness, so it would be nice to be able to dynamically turn it off instead of having it forced.
Quoted 6 lines
Any suggestions about how to do this? It seems hard to have a note dynamically appear and disappear in the vsyscall.so.
I wasn't terribly concerned about this, since there is effectively zero performance difference between the two library implementations.
I'm not super concerned either, but I still don't like it. There already is dynamic replacement for vsyscall.so, so you could have just dropped in an an-note-ated version.
Zach
Re: [patch 13/21] Xen-paravirt: Add nosegneg capability to the vsyscall page notes
Quoted 3 lines · Zachary Amsden
I'm not super concerned either, but I still don't like it. There already is dynamic replacement for vsyscall.so, so you could have just dropped in an an-note-ated version.
Ah, OK. I'll have a look at that.
J
Re: [Xen-devel] Re: [patch 13/21] Xen-paravirt: Add nosegneg capability to the vsyscall page notes
In reply to Zachary AmsdenQuoted 9 lines · Zachary Amsden
Quoted 7 lines · Jeremy Fitzhardinge
Add the "nosegneg" fake capabilty to the vsyscall page notes. This is used by the runtime linker to select a glibc version which then disables negative-offset accesses to the thread-local segment via %gs. These accesses require emulation in Xen (because segments are truncated to protect the hypervisor address space) and avoiding them provides a measurable performance boost.
Quoted 4 lines
I don't like this because now a kernel compiled with both
CONFIG_XENandCONFIG_VMIhas "nosegneg" turned on. We don't actually require this for performance or correctness, so it would be nice to be able to dynamically turn it off instead of having it forced.
Ditto for lguest.
Rusty.
PATCH 14/21 Xen-paravirt: Add XEN config options and disable unsupported config options.
In reply to Jeremy FitzhardingeThe XEN config option enables the Xen paravirt_ops interface, which is installed when the kernel finds itself running under Xen. (By some as-yet fully defined mechanism, implemented in a future patch.)
Xen is no longer a sub-architecture, so the X86_XEN subarch config option has gone.
The disabled config options are:
- PREEMPT: Xen doesn't support it
- HZ: set to 100Hz for now, to cut down on VCPU context switch rate. This will be adapted to use tickless later.
- kexec: not yet supported
--- arch/i386/Kconfig | 7 +++++-- arch/i386/Kconfig.debug | 1 + arch/i386/xen/Kconfig | 10 ++++++++++ kernel/Kconfig.hz | 4 ++-- kernel/Kconfig.preempt | 1 + 5 files changed, 19 insertions(+), 4 deletions(-)
===================================================================
arch/i386/Kconfig +5 -2
@@ -192,6 +192,8 @@ config PARAVIRT under a hypervisor, improving performance significantly. However, when run without a hypervisor the kernel is theoretically slower. If in doubt, say N. + +source "arch/i386/xen/Kconfig" config ACPI_SRAT bool
@@ -298,12 +300,12 @@ config X86_UP_IOAPIC config X86_LOCAL_APIC bool - depends on X86_UP_APIC || ((X86_VISWS || SMP) && !X86_VOYAGER) || X86_GENERICARCH + depends on X86_UP_APIC || (((X86_VISWS || SMP) && !X86_VOYAGER) || X86_GENERICARCH) default y config X86_IO_APIC bool - depends on X86_UP_IOAPIC || (SMP && !(X86_VISWS || X86_VOYAGER)) || X86_GENERICARCH + depends on X86_UP_IOAPIC || ((SMP && !(X86_VISWS || X86_VOYAGER)) || X86_GENERICARCH) default y config X86_VISWS_APIC
@@ -743,6 +745,7 @@ source kernel/Kconfig.hz config KEXEC bool "kexec system call" + depends on !XEN help kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot
===================================================================
arch/i386/Kconfig.debug +1 -0
@@ -79,6 +79,7 @@ config DOUBLEFAULT config DOUBLEFAULT default y bool "Enable doublefault exception handler" if EMBEDDED + depends on !XEN help This option allows trapping of rare doublefault exceptions that would otherwise cause a system to silently reboot. Disabling this
===================================================================
arch/i386/xen/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +# +# This Kconfig describes xen options +# + +config XEN + bool "Enable support for Xen hypervisor" + depends PARAVIRT + default y + help + This is the Linux Xen port.
===================================================================
kernel/Kconfig.hz +2 -2
@@ -3,7 +3,7 @@ # choice - prompt "Timer frequency" + prompt "Timer frequency" if !XEN default HZ_250 help Allows the configuration of the timer frequency. It is customary
@@ -49,7 +49,7 @@ endchoice config HZ int - default 100 if HZ_100 + default 100 if HZ_100 || XEN default 250 if HZ_250 default 300 if HZ_300 default 1000 if HZ_1000
===================================================================
kernel/Kconfig.preempt +1 -0
@@ -35,6 +35,7 @@ config PREEMPT_VOLUNTARY config PREEMPT bool "Preemptible Kernel (Low-Latency Desktop)" + depends on !XEN help This option reduces the latency of the kernel by making all kernel code (that is not executing in a critical section)
Re: [patch 14/21] Xen-paravirt: Add XEN config options and disable unsupported config options.
Quoted 4 lines · Jeremy Fitzhardinge
The XEN config option enables the Xen
paravirt_opsinterface, which is installed when the kernel finds itself running under Xen. (By some as-yet fully defined mechanism, implemented in a future patch.)
Quoted 9 lines
Xen is no longer a sub-architecture, so the
X86_XENsubarch config option has gone.The disabled config options are:
- PREEMPT: Xen doesn't support it
- HZ: set to 100Hz for now, to cut down on VCPU context switch rate. This will be adapted to use tickless later.
- kexec: not yet supported
I assume you plan to eventually get all this stuff working but just want to prevent configurations that the Xen paravirt-ops isn't ready for at the moment?
Instead can you do it this way:
config XEN
depends on PARAVIRT && !PREEMPT && HZ_100 && !DOUBLEFAULT && !KEXEC
thanks,
Dan
Quoted 106 lines
Signed-off-by Jeremy Fitzhardinge <[email protected]>Signed-off-by Ian Pratt <[email protected]>Signed-off-by Christian Limpach <[email protected]>Signed-off-by Chris Wright <[email protected]>--- arch/i386/Kconfig | 7 +++++-- arch/i386/Kconfig.debug | 1 + arch/i386/xen/Kconfig | 10 ++++++++++ kernel/Kconfig.hz | 4 ++-- kernel/Kconfig.preempt | 1 + 5 files changed, 19 insertions(+), 4 deletions(-)===================================================================
arch/i386/Kconfig +5
-2@@ -192,6 +192,8 @@ config PARAVIRT under a hypervisor, improving performance significantly. However, when run without a hypervisor the kernel is theoretically slower. If in doubt, say N. + +source "arch/i386/xen/Kconfig" config ACPI_SRAT bool@@ -298,12 +300,12 @@ config X86_UP_IOAPIC config X86_LOCAL_APIC bool - depends on X86_UP_APIC || ((X86_VISWS || SMP) && !X86_VOYAGER) || X86_GENERICARCH + depends on X86_UP_APIC || (((X86_VISWS || SMP) && !X86_VOYAGER) || X86_GENERICARCH) default y config X86_IO_APIC bool - depends on X86_UP_IOAPIC || (SMP && !(X86_VISWS || X86_VOYAGER)) || X86_GENERICARCH + depends on X86_UP_IOAPIC || ((SMP && !(X86_VISWS || X86_VOYAGER)) || X86_GENERICARCH) default y config X86_VISWS_APIC@@ -743,6 +745,7 @@ source kernel/Kconfig.hz config KEXEC bool "kexec system call" + depends on !XEN help kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot===================================================================
arch/i386/Kconfig.debug +1
-0@@ -79,6 +79,7 @@ config DOUBLEFAULT config DOUBLEFAULT default y bool "Enable doublefault exception handler" if EMBEDDED + depends on !XEN help This option allows trapping of rare doublefault exceptions that would otherwise cause a system to silently reboot. Disabling this===================================================================
arch/i386/xen/Kconfig new file +10
-0@@ -0,0 +1,10 @@ +# +# This Kconfig describes xen options +# + +config XEN + bool "Enable support for Xen hypervisor" + depends PARAVIRT + default y + help + This is the Linux Xen port.===================================================================
kernel/Kconfig.hz +2
-2@@ -3,7 +3,7 @@ # choice - prompt "Timer frequency" + prompt "Timer frequency" if !XEN default HZ_250 help Allows the configuration of the timer frequency. It is customary@@ -49,7 +49,7 @@ endchoice config HZ int - default 100 if HZ_100 + default 100 if HZ_100 || XEN default 250 if HZ_250 default 300 if HZ_300 default 1000 if HZ_1000===================================================================
kernel/Kconfig.preempt +1
-0@@ -35,6 +35,7 @@ config PREEMPT_VOLUNTARY config PREEMPT bool "Preemptible Kernel (Low-Latency Desktop)" + depends on !XEN help This option reduces the latency of the kernel by making all kernel code (that is not executing in a critical section)
Re: [patch 14/21] Xen-paravirt: Add XEN config options and disable unsupported config options.
Quoted 8 lines · Dan Hecht
I assume you plan to eventually get all this stuff working but just want to prevent configurations that the Xen paravirt-ops isn't ready for at the moment?
Instead can you do it this way:
config XEN
depends on PARAVIRT && !PREEMPT && HZ_100 && !DOUBLEFAULT && !KEXEC
That's a bit simpler code-wise, but it does make it pretty complex to get everything just-so to even see the CONFIG_XEN option.
J
Re: [Xen-devel] Re: [patch 14/21] Xen-paravirt: Add XEN config options and disable unsupported config options.
Quoted 6 lines · Jeremy Fitzhardinge
Quoted 4 lines · Dan Hecht
I assume you plan to eventually get all this stuff working but just want to prevent configurations that the Xen paravirt-ops isn't ready for at the moment?
Quoted 9 lines
Quoted 5 lines
Instead can you do it this way:
config XEN
depends on PARAVIRT && !PREEMPT && HZ_100 && !DOUBLEFAULT && !KEXECThat's a bit simpler code-wise, but it does make it pretty complex to get everything just-so to even see the
CONFIG_XENoption.
Yes, but that is what you need to do to compile Xen - logically, to build a Xen kernel, you need to have a kernel configuration which can enable Xen - not limit the configuration of a kernel because Xen has been enabled. This is because with paravirt-ops, Xen compiled kernels may not actually run on Xen, so you can't arbitrarily drop features because you assume Xen is there.
One of these has an easy solution - doublefault. You don't need to install the doublefault gate if you don't want it, and the hypervisor doesn't need to freak out if you install it, it can just ignore the gate entirely and claim #DF is not supported.
Zach
Re: [patch 14/21] Xen-paravirt: Add XEN config options and disable unsupported config options.
In reply to Jeremy FitzhardingeQuoted 5 lines · Jeremy Fitzhardinge
Quoted 4 lines · Dan Hecht
I assume you plan to eventually get all this stuff working but just want to prevent configurations that the Xen paravirt-ops isn't ready for at the moment?
Quoted 8 lines
Quoted 4 lines
Instead can you do it this way:
config XEN
depends on PARAVIRT && !PREEMPT && HZ_100 && !DOUBLEFAULT && !KEXECThat's a bit simpler code-wise, but it does make it pretty complex to get everything just-so to even see the
CONFIG_XENoption.
Not only is it simpler code-wise, but it is more to the point... it is CONFIG_XEN that needs to be fixed to handle PREEMPT, KEXEC, different HZ values, etc. Not the other way around.
Enabling the compile of any paravirt-ops backend shouldn't cripple the kernel in any way... instead, the burden should be on the xen paravirt-ops backend to be completed. CONFIG_PREEMPT shouldn't care about which paravirt-ops are compiled in. Instead, CONFIG_XEN is the one that needs !PREEMPT.
Dan
PATCH 15/21 Xen-paravirt: Add Xen interface header files
In reply to Jeremy FitzhardingeAdd Xen interface header files. These are taken fairly directly from the Xen tree and hence the style is not entirely in accordance with Linux guidelines. There is a tension between fitting with Linux coding rules and ease of maintenance.
Define macros and inline functions for doing hypercalls into the hypervisor.
--
include/asm-i386/hypercall.h | 416 +++++++++++++++++++++++++++++ include/asm-i386/hypervisor.h | 72 +++++ include/xen/interface/arch-x86_32.h | 187 +++++++++++++ include/xen/interface/elfnote.h | 133 +++++++++ include/xen/interface/event_channel.h | 195 ++++++++++++++ include/xen/interface/features.h | 43 +++ include/xen/interface/grant_table.h | 301 +++++++++++++++++++++ include/xen/interface/io/blkif.h | 96 ++++++ include/xen/interface/io/console.h | 23 + include/xen/interface/io/netif.h | 152 ++++++++++ include/xen/interface/io/ring.h | 260 ++++++++++++++++++ include/xen/interface/io/xenbus.h | 42 +++ include/xen/interface/io/xs_wire.h | 87 ++++++ include/xen/interface/memory.h | 145 ++++++++++ include/xen/interface/physdev.h | 61 ++++ include/xen/interface/sched.h | 77 +++++ include/xen/interface/vcpu.h | 109 +++++++ include/xen/interface/version.h | 60 ++++ include/xen/interface/xen.h | 445 ++++++++++++++++++++++++++++++++ 19 files changed, 2904 insertions(+)
===================================================================
include/asm-i386/hypercall.h new file +416 -0
@@ -0,0 +1,416 @@ +/****************************************************************************** +* hypercall.h +* +* Linux-specific hypervisor handling. +* +* Copyright (c) 2002-2004, K A Fraser +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation; or, when distributed +* separately from the Linux kernel or incorporated into other +* software packages, subject to the following license: +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this source file (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, +* merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef __HYPERCALL_H__ +#define __HYPERCALL_H__ + +#include <linux/errno.h> +#include <linux/string.h> + +#include <xen/interface/xen.h> +#include <xen/interface/sched.h> +#include <xen/interface/physdev.h> + +#define __STR (x) #x +#define STR (x) __STR(x) + +extern struct {char _entry[32 ]; } hypercall_page[]; + +#define _hypercall0 (type, name) \ +({ \ + long __res; \ + asm volatile ( \ + "call %[call]" \ + : "=a" (__res) \ + : [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ + : "memory" ); \ + (type)__res; \ +}) + +#define _hypercall1 (type, name, a1) \ +({ \ + long __res, __ign1; \ + asm volatile ( \ + "call %[call]" \ + : "=a" (__res), "=b" (__ign1) \ + : "1" ((long)(a1)), \ + [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ + : "memory" ); \ + (type)__res; \ +}) + +#define _hypercall2 (type, name, a1, a2) \ +({ \ + long __res, __ign1, __ign2; \ + asm volatile ( \ + "call %[call]" \ + : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \ + : "1" ((long)(a1)), "2" ((long)(a2)), \ + [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ + : "memory" ); \ + (type)__res; \ +}) + +#define _hypercall3 (type, name, a1, a2, a3) \ +({ \ + long __res, __ign1, __ign2, __ign3; \ + asm volatile ( \ + "call %[call]" \ + : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ + "=d" (__ign3) \ + : "1" ((long)(a1)), "2" ((long)(a2)), \ + "3" ((long)(a3)), \ + [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ + : "memory" ); \ + (type)__res; \ +}) + +#define _hypercall4 (type, name, a1, a2, a3, a4) \ +({ \ + long __res, __ign1, __ign2, __ign3, __ign4; \ + asm volatile ( \ + "call %[call]" \ + : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ + "=d" (__ign3), "=S" (__ign4) \ + : "1" ((long)(a1)), "2" ((long)(a2)), \ + "3" ((long)(a3)), "4" ((long)(a4)), \ + [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ + : "memory" ); \ + (type)__res; \ +}) + +#define _hypercall5 (type, name, a1, a2, a3, a4, a5) \ +({ \ + long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \ + asm volatile ( \ + "call %[call]" \ + : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \ + "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \ + : "1" ((long)(a1)), "2" ((long)(a2)), \ + "3" ((long)(a3)), "4" ((long)(a4)), \ + "5" ((long)(a5)), \ + [call] "m" (hypercall_page[__HYPERVISOR_##name]) \ + : "memory" ); \ + (type)__res; \ +}) + +static inline int +HYPERVISOR_set_trap_table ( +struct trap_info *table) +{ +return _hypercall1 (int, set_trap_table, table); +} + +static inline int +HYPERVISOR_mmu_update ( +struct mmu_update *req,int count,int *success_count,domid_t domid) +{ +return _hypercall4 (int, mmu_update, req, count, success_count, domid); +} + +static inline int +HYPERVISOR_mmuext_op ( +struct mmuext_op *op,int count,int *success_count,domid_t domid) +{ +return _hypercall4 (int, mmuext_op, op, count, success_count, domid); +} + +static inline int +HYPERVISOR_set_gdt ( +unsigned long *frame_list,int entries) +{ +return _hypercall2 (int, set_gdt, frame_list, entries); +} + +static inline int +HYPERVISOR_stack_switch ( +unsigned long ss,unsigned long esp) +{ +return _hypercall2 (int, stack_switch, ss, esp); +} + +static inline int +HYPERVISOR_set_callbacks ( +unsigned long event_selector,unsigned long event_address, +unsigned long failsafe_selector,unsigned long failsafe_address) +{ +return _hypercall4 (int, set_callbacks, + event_selector, event_address, + failsafe_selector, failsafe_address); +} + +static inline int +HYPERVISOR_fpu_taskswitch ( +int set) +{ +return _hypercall1 (int, fpu_taskswitch, set); +} + +static inline int +HYPERVISOR_sched_op ( +int cmd,unsigned long arg) +{ +return _hypercall2 (int, sched_op, cmd, arg); +} + +static inline long +HYPERVISOR_set_timer_op ( +u64 timeout) +{ +unsigned long timeout_hi = (unsigned long )(timeout>>32 ); +unsigned long timeout_lo = (unsigned long )timeout; +return _hypercall2 (long, set_timer_op, timeout_lo, timeout_hi); +} + +static inline int +HYPERVISOR_set_debugreg ( +int reg,unsigned long value) +{ +return _hypercall2 (int, set_debugreg, reg, value); +} + +static inline unsigned long +HYPERVISOR_get_debugreg ( +int reg) +{ + return _hypercall1(unsigned long, get_debugreg, reg); +} + +static inline int +HYPERVISOR_update_descriptor ( +u64 ma,u64 desc) +{ +return _hypercall4 (int, update_descriptor, ma, ma>>32 , desc, desc>>32 ); +} + +static inline int +HYPERVISOR_memory_op ( +unsigned int cmd,void *arg) +{ +return _hypercall2 (int, memory_op, cmd, arg); +} + +static inline int +HYPERVISOR_multicall ( +void *call_list,int nr_calls) +{ +return _hypercall2 (int, multicall, call_list, nr_calls); +} + +static inline int +HYPERVISOR_update_va_mapping ( +unsigned long va,pte_t new_val,unsigned long flags) +{ +unsigned long pte_hi =0 ; +#ifdef CONFIG_X86_PAE + pte_hi = new_val.pte_high; +#endif +return _hypercall4 (int, update_va_mapping, va, + new_val.pte_low, pte_hi, flags); +} + +static inline int +HYPERVISOR_event_channel_op ( +int cmd,void *arg) +{ +int rc =_hypercall2 (int, event_channel_op, cmd, arg); +if (unlikely (rc == -ENOSYS )) { +struct evtchn_op op; + op.cmd = cmd; +memcpy (&op.u, arg,sizeof (op.u)); + rc =_hypercall1 (int, event_channel_op_compat, &op); +memcpy (arg, &op.u,sizeof (op.u)); + } +return rc; +} + +static inline int +HYPERVISOR_xen_version ( +int cmd,void *arg) +{ +return _hypercall2 (int, xen_version, cmd, arg); +} + +static inline int +HYPERVISOR_console_io ( +int cmd,int count,char *str) +{ +return _hypercall3 (int, console_io, cmd, count, str); +} + +static inline int +HYPERVISOR_physdev_op (int cmd,void *arg) +{ +int rc =_hypercall2 (int, physdev_op, cmd, arg); +if (unlikely (rc == -ENOSYS )) { +struct physdev_op op; + op.cmd = cmd; +memcpy (&op.u, arg,sizeof (op.u)); + rc =_hypercall1 (int, physdev_op_compat, &op); +memcpy (arg, &op.u,sizeof (op.u)); + } +return rc; +} + +static inline int +HYPERVISOR_grant_table_op ( +unsigned int cmd,void *uop,unsigned int count) +{ +return _hypercall3 (int, grant_table_op, cmd, uop, count); +} + +static inline int +HYPERVISOR_update_va_mapping_otherdomain ( +unsigned long va,pte_t new_val,unsigned long flags,domid_t domid) +{ +unsigned long pte_hi =0 ; +#ifdef CONFIG_X86_PAE + pte_hi = new_val.pte_high; +#endif +return _hypercall5 (int, update_va_mapping_otherdomain, va, + new_val.pte_low, pte_hi, flags, domid); +} + +static inline int +HYPERVISOR_vm_assist ( +unsigned int cmd,unsigned int type) +{ +return _hypercall2 (int, vm_assist, cmd, type); +} + +static inline int +HYPERVISOR_vcpu_op ( +int cmd,int vcpuid,void *extra_args) +{ +return _hypercall3 (int, vcpu_op, cmd, vcpuid, extra_args); +} + +static inline int +HYPERVISOR_suspend ( +unsigned long srec) +{ +return _hypercall3 (int, sched_op, SCHEDOP_shutdown, + SHUTDOWN_suspend, srec); +} + +static inline int +HYPERVISOR_nmi_op ( +unsigned long op, +unsigned long arg) +{ +return _hypercall2 (int, nmi_op, op, arg); +} + +static inline void +MULTI_update_va_mapping (struct multicall_entry *mcl,unsigned long va, +pte_t new_val,unsigned long flags) +{ + mcl->op = __HYPERVISOR_update_va_mapping; + mcl->args[0 ] = va; +#ifdef CONFIG_X86_PAE + mcl->args[1 ] = new_val.pte_low; + mcl->args[2 ] = new_val.pte_high; +#else + mcl->args[1 ] = new_val.pte_low; + mcl->args[2 ] =0 ; +#endif + mcl->args[3 ] = flags; +} + +static inline void +MULTI_grant_table_op (struct multicall_entry *mcl,unsigned int cmd, +void *uop,unsigned int count) +{ + mcl->op = __HYPERVISOR_grant_table_op; + mcl->args[0 ] = cmd; + mcl->args[1 ] = (unsigned long )uop; + mcl->args[2 ] = count; +} + +static inline void +MULTI_update_va_mapping_otherdomain (struct multicall_entry *mcl,unsigned long va, +pte_t new_val,unsigned long flags,domid_t domid) +{ + mcl->op = __HYPERVISOR_update_va_mapping_otherdomain; + mcl->args[0 ] = va; +#ifdef CONFIG_X86_PAE + mcl->args[1 ] = new_val.pte_low; + mcl->args[2 ] = new_val.pte_high; +#else + mcl->args[1 ] = new_val.pte_low; + mcl->args[2 ] =0 ; +#endif + mcl->args[3 ] = flags; + mcl->args[4 ] = domid; +} + +static inline void +MULTI_update_descriptor (struct multicall_entry *mcl,u64 maddr, +struct desc_struct desc) +{ + mcl->op = __HYPERVISOR_update_descriptor; + mcl->args[0 ] = maddr; + mcl->args[1 ] = maddr >>32 ; + mcl->args[2 ] = desc.a; + mcl->args[3 ] = desc.b; +} + +static inline void +MULTI_memory_op (struct multicall_entry *mcl,unsigned int cmd,void *arg) +{ + mcl->op = __HYPERVISOR_memory_op; + mcl->args[0 ] = cmd; + mcl->args[1 ] = (unsigned long )arg; +} + +static inline void +MULTI_mmu_update (struct multicall_entry *mcl,struct mmu_update *req, +int count,int *success_count,domid_t domid) +{ + mcl->op = __HYPERVISOR_mmu_update; + mcl->args[0 ] = (unsigned long )req; + mcl->args[1 ] = count; + mcl->args[2 ] = (unsigned long )success_count; + mcl->args[3 ] = domid; +} + +static inline void +MULTI_mmuext_op (struct multicall_entry *mcl,struct mmuext_op *op,int count, +int *success_count,domid_t domid) +{ + mcl->op = __HYPERVISOR_mmuext_op; + mcl->args[0 ] = (unsigned long )op; + mcl->args[1 ] = count; + mcl->args[2 ] = (unsigned long )success_count; + mcl->args[3 ] = domid; +} +#endif /* __HYPERCALL_H__ */
===================================================================
include/asm-i386/hypervisor.h new file +72 -0
72 lines not on this page · raw message
===================================================================
include/xen/interface/arch-x86_32.h new file +187 -0
187 lines not on this page · raw message
===================================================================
include/xen/interface/elfnote.h new file +133 -0
133 lines not on this page · raw message
===================================================================
include/xen/interface/event_channel.h new file +195 -0
195 lines not on this page · raw message
===================================================================
include/xen/interface/features.h new file +43 -0
43 lines not on this page · raw message
===================================================================
include/xen/interface/grant_table.h new file +301 -0
301 lines not on this page · raw message
===================================================================
include/xen/interface/io/blkif.h new file +96 -0
96 lines not on this page · raw message
===================================================================
include/xen/interface/io/console.h new file +23 -0
@@ -0,0 +1,23 @@ +/****************************************************************************** +* console.h +* +* Console I/O interface for Xen guest OSes. +* +* Copyright (c) 2005, Keir Fraser +*/ + +#ifndef __XEN_PUBLIC_IO_CONSOLE_H__ +#define __XEN_PUBLIC_IO_CONSOLE_H__ + +typedef uint32_t XENCONS_RING_IDX ; + +#define MASK_XENCONS_IDX (idx, ring) ((idx) & (sizeof(ring)-1)) + +struct xencons_interface { +char in[1024 ]; +char out[2048 ]; +XENCONS_RING_IDX in_cons, in_prod; +XENCONS_RING_IDX out_cons, out_prod; +}; + +#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */
===================================================================
include/xen/interface/io/netif.h new file +152 -0
152 lines not on this page · raw message
===================================================================
include/xen/interface/io/ring.h new file +260 -0
260 lines not on this page · raw message
===================================================================
include/xen/interface/io/xenbus.h new file +42 -0
42 lines not on this page · raw message
===================================================================
include/xen/interface/io/xs_wire.h new file +87 -0
87 lines not on this page · raw message
===================================================================
include/xen/interface/memory.h new file +145 -0
145 lines not on this page · raw message
===================================================================
include/xen/interface/physdev.h new file +61 -0
61 lines not on this page · raw message
===================================================================
include/xen/interface/sched.h new file +77 -0
77 lines not on this page · raw message
===================================================================
include/xen/interface/vcpu.h new file +109 -0
109 lines not on this page · raw message
===================================================================
include/xen/interface/version.h new file +60 -0
60 lines not on this page · raw message
===================================================================
include/xen/interface/xen.h new file +445 -0
445 lines not on this page · raw message
Re: [patch 15/21] Xen-paravirt: Add Xen interface header files
Quoted 14 lines · Jeremy Fitzhardinge
Add Xen interface header files. These are taken fairly directly from the Xen tree and hence the style is not entirely in accordance with Linux guidelines. There is a tension between fitting with Linux coding rules and ease of maintenance.
Define macros and inline functions for doing hypercalls into the hypervisor.
Signed-off-by Jeremy Fitzhardinge <[email protected]>Signed-off-by Ian Pratt <[email protected]>Signed-off-by Christian Limpach <[email protected]>Signed-off-by Chris Wright <[email protected]>
Quoted 3 lines
--
include/asm-i386/hypercall.h | 416 +++++++++++++++++++++++++++++ include/asm-i386/hypervisor.h | 72 +++++
Are hypercall.h and hypervisor.h generic or are they Xen specific. If they are Xen specific (as it appears) then are inappropriately named.
Quoted 1 line
include/xen/interface/arch-x86_32.h | 187 +++++++++++++
Why isn't this file include-asm-i386/xen/arch-x86_32.h ?
Quoted 9 lines
include/xen/interface/elfnote.h | 133 +++++++++ include/xen/interface/event_channel.h | 195 ++++++++++++++ include/xen/interface/features.h | 43 +++ include/xen/interface/grant_table.h | 301 +++++++++++++++++++++ include/xen/interface/io/blkif.h | 96 ++++++ include/xen/interface/io/console.h | 23 + include/xen/interface/io/netif.h | 152 ++++++++++ include/xen/interface/io/ring.h | 260 ++++++++++++++++++ include/xen/interface/io/xenbus.h | 42 +++
Quoted 8 lines
include/xen/interface/io/xs_wire.h | 87 ++++++ include/xen/interface/memory.h | 145 ++++++++++ include/xen/interface/physdev.h | 61 ++++ include/xen/interface/sched.h | 77 +++++ include/xen/interface/vcpu.h | 109 +++++++ include/xen/interface/version.h | 60 ++++ include/xen/interface/xen.h | 445 ++++++++++++++++++++++++++++++++ 19 files changed, 2904 insertions(+)
Eric
Re: [patch 15/21] Xen-paravirt: Add Xen interface header files
Quoted 17 lines · Eric W. Biederman
Quoted 14 lines · Jeremy Fitzhardinge
Add Xen interface header files. These are taken fairly directly from the Xen tree and hence the style is not entirely in accordance with Linux guidelines. There is a tension between fitting with Linux coding rules and ease of maintenance.
Define macros and inline functions for doing hypercalls into the hypervisor.
Signed-off-by Jeremy Fitzhardinge <[email protected]>Signed-off-by Ian Pratt <[email protected]>Signed-off-by Christian Limpach <[email protected]>Signed-off-by Chris Wright <[email protected]>
Quoted 9 lines
Quoted 4 lines
--
include/asm-i386/hypercall.h | 416 +++++++++++++++++++++++++++++ include/asm-i386/hypervisor.h | 72 +++++Are
hypercall.handhypervisor.hgeneric or are they Xen specific. If they are Xen specific (as it appears) then are inappropriately named.
Thanks for the reminder; I've been meaning to move/rename these.
Quoted 4 lines
Quoted 2 lines
include/xen/interface/arch-x86_32.h | 187 +++++++++++++Why isn't this file
include-asm-i386/xen/arch-x86_32.h?
Those files are more or less directly copied from the Xen tree, and its easier if they don't drift too far in name and directory structure.
J
Re: [patch 15/21] Xen-paravirt: Add Xen interface header files
Quoted 30 lines · Jeremy Fitzhardinge
Quoted 17 lines · Eric W. Biederman
Quoted 14 lines · Jeremy Fitzhardinge
Add Xen interface header files. These are taken fairly directly from the Xen tree and hence the style is not entirely in accordance with Linux guidelines. There is a tension between fitting with Linux coding rules and ease of maintenance.
Define macros and inline functions for doing hypercalls into the hypervisor.
Signed-off-by Jeremy Fitzhardinge <[email protected]>Signed-off-by Ian Pratt <[email protected]>Signed-off-by Christian Limpach <[email protected]>Signed-off-by Chris Wright <[email protected]>Quoted 9 lines
Quoted 4 lines
--
include/asm-i386/hypercall.h | 416 +++++++++++++++++++++++++++++ include/asm-i386/hypervisor.h | 72 +++++Are
hypercall.handhypervisor.hgeneric or are they Xen specific. If they are Xen specific (as it appears) then are inappropriately named.Thanks for the reminder; I've been meaning to move/rename these.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
include/xen/interface/arch-x86_32.h | 187 +++++++++++++Why isn't this file
include-asm-i386/xen/arch-x86_32.h?Those files are more or less directly copied from the Xen tree, and its easier if they don't drift too far in name and directory structure.
Nack, we don't put per-arch crap there. Either you'll have it in separate places, or you clean up the utterly braindead scheme in the Xen tree aswell.
PATCH 16/21 Xen-paravirt: Add code into head.S to handle being booted by Xen
In reply to Jeremy FitzhardingeThis adds a second entry point to head.S, which is jumped to when booted by Xen. This allows startup under Xen to be easily detected.
Because Xen starts the kernel in a fairly sane state, very little setup is needed here; it just needs to jump into xen_start_kernel to init the paravirt_ops structure, and then jump into start_kernel proper.
This also makes a few small adjustments to the gdt tables to make them properly suited to Xen.
One warty thing in this patch is the requirement to hard-code the location of the Xen entrypoint and hypervisor page, rather than letting the assembler/linker choose an appropriate place. This is because these addresses must be converted into a string at compile time, so the address must be known at compile rather than link time.
Subject: [patch 16/21] Xen-paravirt: Add outline of Xen paravirt interface code, plus boot-time init.
Create a new arch/i386/xen/ directory for all the Xen-specific paravirt code; I'd expect there would be parallel paravirt-vmi, etc directories.
This also contains an initial set of paravirt ops for Xen, mostly ones which can just be implemented with the generic native_* version. At boot time, the global paravirt_ops structure is populated with the Xen pointers in xen_start_kernel, which then jumps to the standard start_kernel.
Hook Xen entrypoint into common paravirt entrypoint.
Register Xen-specific architecture and memory setup functions.
--- arch/i386/Makefile | 3 arch/i386/kernel/cpu/common.c | 3 arch/i386/kernel/entry.S | 77 +++ arch/i386/kernel/head.S | 12 arch/i386/kernel/paravirt.c | 48 +- arch/i386/kernel/vmlinux.lds.S | 1 arch/i386/mm/pgtable.c | 1 arch/i386/xen/Makefile | 2 arch/i386/xen/enlighten.c | 807 +++++++++++++++++++++++++++++++++++++++ arch/i386/xen/events.c | 473 ++++++++++++++++++++++ arch/i386/xen/features.c | 29 + arch/i386/xen/mmu.c | 419 ++++++++++++++++++++ arch/i386/xen/mmu.h | 51 ++ arch/i386/xen/multicalls.c | 62 ++ arch/i386/xen/multicalls.h | 13 arch/i386/xen/setup.c | 95 ++++ arch/i386/xen/time.c | 452 +++++++++++++++++++++ arch/i386/xen/xen-head.S | 29 + arch/i386/xen/xen-ops.h | 20 include/asm-i386/hypercall.h | 21 - include/asm-i386/irq.h | 1 include/asm-i386/paravirt.h | 42 ++ include/asm-i386/pda.h | 11 include/xen/events.h | 28 + include/xen/features.h | 26 + include/xen/page.h | 175 ++++++++ 26 files changed, 2872 insertions(+), 29 deletions(-)
===================================================================
arch/i386/Makefile +3 -0
@@ -93,6 +93,9 @@ mcore-$(CONFIG_X86_ES7000) := mach-defau mcore-$(CONFIG_X86_ES7000) := mach-default core-$(CONFIG_X86_ES7000) := arch/i386/mach-es7000/ +# Xen paravirtualization support +core-$(CONFIG_XEN) += arch/i386/xen/ + # default subarch .h files mflags-y += -Iinclude/asm-i386/mach-default
===================================================================
arch/i386/kernel/cpu/common.c +3 -0
@@ -19,6 +19,7 @@#include <mach_apic.h> #endif #include <asm/pda.h> +#include <asm/paravirt.h> #include "cpu.h"
@@ -707,6 +708,8 @@ __cpuinit int init_gdt(int cpu, struct t pda->cpu_number = cpu; pda->pcurrent = idle; +paravirt_init_pda (pda, cpu); +return 1 ; }
===================================================================
arch/i386/kernel/entry.S +77 -0
83 lines not on this page · raw message
===================================================================
arch/i386/kernel/head.S +10 -2
@@ -519,6 +519,10 @@ 1: jmp 1b #endif +#ifdef CONFIG_XEN +#include "../xen/xen-head.S" +#endif + /* * Real beginning of normal "text" segment */
@@ -528,7 +532,7 @@ ENTRY(_stext) /* * BSS section */ -.section ".bss.page_aligned","w" +.section ".bss.page_aligned" ENTRY(swapper_pg_dir) .fill 1024,4,0 ENTRY(empty_zero_page)
@@ -598,7 +602,8 @@ ENTRY(boot_gdt_table) /* * The Global Descriptor Table contains 28 quadwords, per-CPU. */ - .align L1_CACHE_BYTES + .section ".data.page_aligned" + .align PAGE_SIZE_asm ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* NULL descriptor */ .quad 0x0000000000000000 /* 0x0b reserved */
@@ -647,3 +652,6 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0xf0 - unused */ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ + /* Be sure this is zeroed to avoid false validations in Xen */ + .fill PAGE_SIZE_asm / 8 - GDT_ENTRIES,8,0 + .previous
===================================================================
arch/i386/kernel/paravirt.c +24 -24
162 lines not on this page · raw message
===================================================================
arch/i386/kernel/vmlinux.lds.S +1 -0
@@ -93,6 +93,7 @@ SECTIONS . = ALIGN(4096); .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { + *(.data.page_aligned) *(.data.idt) }
===================================================================
arch/i386/mm/pgtable.c +1 -0
@@ -267,6 +267,7 @@ static void pgd_ctor(pgd_t *pgd) swapper_pg_dir +USER_PTRS_PER_PGD , KERNEL_PGD_PTRS); }else { +memset (pgd,0 ,USER_PTRS_PER_PGD *sizeof (pgd_t));spin_lock_irqsave (&pgd_lock, flags);pgd_list_add (pgd);spin_unlock_irqrestore (&pgd_lock, flags);
===================================================================
arch/i386/xen/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-y := enlighten.o setup.o events.o time.o \ + features.o mmu.o multicalls.o
===================================================================
arch/i386/xen/enlighten.c new file +807 -0
807 lines not on this page · raw message
===================================================================
arch/i386/xen/events.c new file +473 -0
473 lines not on this page · raw message
===================================================================
arch/i386/xen/features.c new file +29 -0
@@ -0,0 +1,29 @@ +/****************************************************************************** +* features.c +* +* Xen feature flags. +* +* Copyright (c) 2006, Ian Campbell, XenSource Inc. +*/ +#include <linux/types.h> +#include <linux/cache.h> +#include <linux/module.h> +#include <asm/hypervisor.h> +#include <xen/features.h> + +u8 xen_features[XENFEAT_NR_SUBMAPS *32 ]__read_mostly ; +EXPORT_SYMBOL_GPL (xen_features); + +void xen_setup_features (void ) +{ +struct xen_feature_info fi; +int i, j; + +for (i =0 ; i <XENFEAT_NR_SUBMAPS ; i++) { + fi.submap_idx = i; +if (HYPERVISOR_xen_version (XENVER_get_features, &fi) <0 ) +break ; +for (j=0 ; j<32 ; j++) + xen_features[i*32 +j] = !!(fi.submap &1 <<j); + } +}
===================================================================
arch/i386/xen/mmu.c new file +419 -0
419 lines not on this page · raw message
===================================================================
arch/i386/xen/mmu.h new file +51 -0
51 lines not on this page · raw message
===================================================================
arch/i386/xen/multicalls.c new file +62 -0
62 lines not on this page · raw message
===================================================================
arch/i386/xen/multicalls.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _XEN_MULTICALLS_H +#define _XEN_MULTICALLS_H + +struct multicall_space +{ +struct multicall_entry *mc; +void *args; +}; + +struct multicall_space xen_mc_entry (size_t args); +int xen_mc_flush (void ); + +#endif /* _XEN_MULTICALLS_H */
===================================================================
arch/i386/xen/setup.c new file +95 -0
95 lines not on this page · raw message
===================================================================
arch/i386/xen/time.c new file +452 -0
452 lines not on this page · raw message
===================================================================
arch/i386/xen/xen-head.S new file +29 -0
@@ -0,0 +1,29 @@ +/* Xen-specific pieces of head.S, intended to be included in the right + place in head.S */ + +#include <linux/elfnote.h> +#include <asm/boot.h> +#include <xen/interface/elfnote.h> + +ENTRY(startup_xen) + movl %esi,xen_start_info + jmp startup_paravirt + +.pushsection ".bss.page_aligned" +ENTRY(hypercall_page) + .skip 0x1000 +.popsection + + ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux") + ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6") + ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0") + ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long, __PAGE_OFFSET) + ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long, startup_xen) + ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long, hypercall_page) + ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "!writable_page_tables|pae_pgdir_above_4gb") +#ifdef CONFIG_X86_PAE + ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes") +#else + ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no") +#endif + ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
===================================================================
arch/i386/xen/xen-ops.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef XEN_OPS_H +#define XEN_OPS_H + +#include <linux/init.h> + +extern struct start_info *xen_start_info; +extern struct shared_info *HYPERVISOR_shared_info; + +char *__init xen_memory_setup (void ); +void __init xen_arch_setup (void ); +void __init xen_init_IRQ (void ); + +void __init xen_time_init (void ); +unsigned long xen_get_wallclock (void ); +int xen_set_wallclock (unsigned long time); + +void stop_hz_timer (void ); +void start_hz_timer (void ); + +#endif /* XEN_OPS_H */
===================================================================
include/asm-i386/hypercall.h +18 -3
@@ -39,9 +39,6 @@#include <xen/interface/xen.h> #include <xen/interface/sched.h> #include <xen/interface/physdev.h> - -#define __STR (x) #x -#define STR (x) __STR(x)extern struct {char _entry[32 ]; } hypercall_page[];
@@ -413,4 +410,22 @@ MULTI_mmuext_op(struct multicall_entry * mcl->args[2 ] = (unsigned long )success_count; mcl->args[3] = domid; } + +static inline void +MULTI_set_gdt (struct multicall_entry *mcl,unsigned long *frames,int entries) +{ + mcl->op = __HYPERVISOR_set_gdt; + mcl->args[0 ] = (unsigned long )frames; + mcl->args[1 ] = entries; +} + +static inline void +MULTI_stack_switch (struct multicall_entry *mcl, +unsigned long ss,unsigned long esp) +{ + mcl->op = __HYPERVISOR_stack_switch; + mcl->args[0 ] = ss; + mcl->args[1 ] = esp; +} +#endif /* __HYPERCALL_H__ */
===================================================================
include/asm-i386/irq.h +1 -0
@@ -43,6 +43,7 @@ extern void fixup_irqs(cpumask_t map);extern void fixup_irqs (cpumask_t map);#endif +fastcall unsigned int do_IRQ(struct pt_regs *regs);void init_IRQ (void );void __init native_init_IRQ (void );
===================================================================
include/asm-i386/paravirt.h +42 -0
71 lines not on this page · raw message
===================================================================
include/asm-i386/pda.h +11 -0
@@ -16,6 +16,17 @@ struct i386_pdaint cpu_number;struct task_struct *pcurrent;/* current process */ struct pt_regs *irq_regs; + +#ifdef CONFIG_PARAVIRT +union { +#ifdef CONFIG_XEN +struct { +struct vcpu_info *vcpu; +unsigned long cr3; + } xen; +#endif /* CONFIG_XEN */ + }; +#endif /* CONFIG_PARAVIRT */ };extern struct i386_pda *_cpu_pda[];
===================================================================
include/xen/events.h new file +28 -0
@@ -0,0 +1,28 @@ +#ifndef _XEN_EVENTS_H +#define _XEN_EVENTS_H + +#include <linux/irq.h> + +int bind_evtchn_to_irqhandler (unsigned int evtchn, +irqreturn_t (*handler)(int ,void *), +unsigned long irqflags,const char *devname, +void *dev_id); +int bind_virq_to_irqhandler (unsigned int virq,unsigned int cpu, +irqreturn_t (*handler)(int ,void *), +unsigned long irqflags,const char *devname,void *dev_id); + +/* +* Common unbind function for all event sources. Takes IRQ to unbind from. +* Automatically closes the underlying event channel (even for bindings +* made with bind_evtchn_to_irqhandler()). +*/ +void unbind_from_irqhandler (unsigned int irq,void *dev_id); + +static inline void notify_remote_via_evtchn (int port) +{ +struct evtchn_send send = { .port = port }; + (void )HYPERVISOR_event_channel_op (EVTCHNOP_send, &send); +} + +extern void notify_remote_via_irq (int irq); +#endif /* _XEN_EVENTS_H */
===================================================================
include/xen/features.h new file +26 -0
@@ -0,0 +1,26 @@ +/****************************************************************************** +* features.h +* +* Query the features reported by Xen. +* +* Copyright (c) 2006, Ian Campbell +*/ + +#ifndef __XEN_FEATURES_H__ +#define __XEN_FEATURES_H__ + +#include <xen/interface/features.h> + +void xen_setup_features (void ); + +extern u8 xen_features[XENFEAT_NR_SUBMAPS *32 ]; + +static inline int xen_feature (int flag) +{ +switch (flag) { + } + +return xen_features[flag]; +} + +#endif /* __ASM_XEN_FEATURES_H__ */
===================================================================
include/xen/page.h new file +175 -0
52 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 4 lines
arch/i386/kernel/entry.S +0
-0@@ -1001,6 +1001,83 @@ ENTRY(kernel_thread_helper) CFI_ENDPROC
arch/i386/kernel/entry.S ENTRY(kernel_thread_helper) · line 1011
Quoted 10 lines
arch/i386/kernel/entry.S +8
-0ENDPROC(kernel_thread_helper) +#ifdef CONFIG_XEN +/* Xen only supports sysenter/sysexit in ring0 guests, + and only if it the guest asks for it. So for now, + this should never be used. */ +ENTRY(xen_sti_sysexit) + CFI_STARTPROC + ud2 + CFI_ENDPROC
Please add ENDPROC()s too, otherwise Jan will be unhappy.
Could be written in C with a real BUG?
Quoted 7 lines
arch/i386/kernel/entry.S +7
-0+ENTRY(xen_failsafe_callback) + CFI_STARTPROC + pushl %eax + CFI_ADJUST_CFA_OFFSET 4 + movl $1,%eax +1: mov 4(%esp),%ds +2: mov 8(%esp),%es
arch/i386/kernel/entry.S ENTRY(kernel_thread_helper) · line 1049
Quoted 10 lines
arch/i386/kernel/entry.S +10
-0+3: mov 12(%esp),%fs +4: mov 16(%esp),%gs + testl %eax,%eax + popl %eax + CFI_ADJUST_CFA_OFFSET -4 + jz 5f + addl $16,%esp # EAX != 0 => Category 2 (Bad IRET) + CFI_ADJUST_CFA_OFFSET -16 + jmp iret_exc +5: addl $16,%esp # EAX == 0 => Category 1 (Bad segment)
If you use lea you could move the two adds before the jz
arch/i386/kernel/entry.S ENTRY(kernel_thread_helper) · line 1031
Quoted 3 lines
arch/i386/kernel/entry.S +3
-0+#ifdef CONFIG_XEN +#include "../xen/xen-head.S" +#endif
Can this really not be linked separately?
arch/i386/kernel/entry.S ENTRY(_stext) · line 535
Quoted 10 lines
arch/i386/kernel/entry.S +2
-1+ /* * Real beginning of normal "text" segment */@@ -528,7 +532,7 @@ ENTRY(_stext) /* * BSS section */ -.section ".bss.page_aligned","w" +.section ".bss.page_aligned"
Why?
arch/i386/kernel/entry.S ENTRY(_stext) · line 536
Quoted 2 lines
arch/i386/kernel/entry.S +1
-1-static fastcall void native_clts(void) +fastcall void native_clts(void)
Fastcalls should all go now
arch/i386/kernel/vmlinux.lds.S SECTIONS · line 96
Quoted 7 lines
arch/i386/kernel/vmlinux.lds.S +1
-0@@ -93,6 +93,7 @@ SECTIONS . = ALIGN(4096); .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { + *(.data.page_aligned)
Weird that that didn't work before -- we already had page aligned data and it somehow managed to work. But ok.
arch/i386/mm/pgtable.c static void pgd_ctor(pgd_t *pgd) · line 270
Quoted 11 lines
arch/i386/kernel/vmlinux.lds.S +0
-0*(.data.idt) }===================================================================
arch/i386/mm/pgtable.c +1
-0@@ -267,6 +267,7 @@ static void pgd_ctor(pgd_t *pgd) swapper_pg_dir +USER_PTRS_PER_PGD , KERNEL_PGD_PTRS); }else { +memset (pgd,0 ,USER_PTRS_PER_PGD *sizeof (pgd_t));
That looks strange here. Belongs in a different patch?
arch/i386/mm/pgtable.c static void pgd_ctor(pgd_t *pgd)
Quoted 4 lines
arch/i386/mm/pgtable.c +4
-0+ +extern struct Xgt_desc_struct cpu_gdt_descr; +extern struct i386_pda boot_pda; +extern unsigned long init_pg_tables_end;
No externs in .c files
arch/i386/mm/pgtable.c
Quoted 5 lines
arch/i386/mm/pgtable.c +5
-0+ +static DEFINE_PER_CPU(unsigned, lazy_mode); + +/* Code defined in entry.S (not a function) */ +extern const char xen_sti_sysexit[];
Ok except that
arch/i386/mm/pgtable.c
Quoted 3 lines
arch/i386/mm/pgtable.c +3
-0+{ +printk (KERN_INFO "Booting paravirtualized kernel on %s\n" , + paravirt_ops.name);
Say something about Xen here?
Quoted 4 lines
arch/i386/mm/pgtable.c +4
-0+} + +static fastcall void xen_restore_fl(unsigned long flags) +{
arch/i386/mm/pgtable.c
Quoted 10 lines
arch/i386/mm/pgtable.c +10
-0+struct vcpu_info *vcpu; + +preempt_disable (); + +/* convert from IF type flag */ + flags = !(flags &X86_EFLAGS_IF ); + vcpu =read_pda (xen.vcpu); + vcpu->evtchn_upcall_mask = flags; +if (flags ==0 ) { +barrier ();/* unmask then check (avoid races) */
If the barrier is needed shouldn't it be a rmb() ?
arch/i386/mm/pgtable.c
Quoted 3 lines
arch/i386/mm/pgtable.c +3
-0+ vcpu =read_pda (xen.vcpu); + vcpu->evtchn_upcall_mask =0 ; +barrier ();/* unmask then check (avoid races) */
Similar.
arch/i386/mm/pgtable.c
Quoted 9 lines
arch/i386/mm/pgtable.c +9
-0+static fastcall void xen_load_gdt(const struct Xgt_desc_struct *dtr) +{ +unsigned long va; +int f; +unsigned size = dtr->size +1 ; +unsigned long frames[16 ]; + +BUG_ON (size >16 *PAGE_SIZE ); +
Indentation broken
(more occurences in this file)
arch/i386/mm/pgtable.c
Quoted 13 lines
arch/i386/mm/pgtable.c +13
-0+ type = (high >>8 ) &0x1f ; + dpl = (high >>13 ) &3 ; + +if (type !=0xf && type !=0xe ) +return 0 ; + + info->vector = vector; + info->address = (high &0xffff0000 ) | (low &0x0000ffff ); + info->cs = low >>16 ; + info->flags = dpl; +/* interrupt gates clear IF */ +if (type ==0xe ) + info->flags |=4 ;
Nasty magic numbers?
Quoted 4 lines
arch/i386/mm/pgtable.c +4
-0+return 1 ; +} + +#if 0
arch/i386/mm/pgtable.c
Quoted 10 lines
arch/i386/mm/pgtable.c +10
-0+static void unpack_desc (u32 low,u32 high, +unsigned long *base,unsigned long *limit, +unsigned char *type,unsigned char *flags) +{ + *base = (high &0xff000000 ) | ((high <<16 ) &0x00ff0000 ) | ((low >>16 ) &0xffff ); + *limit = (high &0x000f0000 ) | (low &0xffff ); + *type = (high >>8 ) &0xff ; + *flags = (high >>20 ) &0xf ; +} +#endif
Remove?
arch/i386/mm/pgtable.c
Quoted 3 lines
arch/i386/mm/pgtable.c +3
-0+ +/* Locations of each CPU's IDT */ +static DEFINE_PER_CPU(struct Xgt_desc_struct, idt_desc);
Why is that private here?
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +6
-0+/* Switch to new pagetable. This is done before +pagetable_init has done anything so that the new pages +added to the table can be prepared properly for Xen. */ +printk ("about to switch to new pagetable %p...\n" , base); +xen_write_cr3 (__pa (base)); +printk ("done\n" );
KERN_* ?
arch/i386/mm/pgtable.c
Quoted 4 lines
arch/i386/mm/pgtable.c +4
-0+if (HYPERVISOR_update_descriptor (virt_to_machine (cpu_gdt_table + +GDT_ENTRY_PDA ).maddr, + (u64 )high <<32 | low)) +BUG ();
Does a BUG that early actually do anything good?
arch/i386/mm/pgtable.c
Quoted 4 lines
arch/i386/mm/pgtable.c +4
-0+ +/* +* Accessors for packed IRQ information. +*/
Wouldn't it be a little simpler to just use a bit field?
arch/i386/mm/pgtable.c
Quoted 8 lines
arch/i386/mm/pgtable.c +8
-0+static void bind_evtchn_to_cpu (unsigned int chn,unsigned int cpu) +{ +int irq = evtchn_to_irq[chn]; + +BUG_ON (irq ==-1 ); +set_native_irq_info (irq,cpumask_of_cpu (cpu)); + +__clear_bit (chn, (unsigned long *)cpu_evtchn_mask[cpu_evtchn[chn]]);
Why is the mask not unsigned long in the first place ?
arch/i386/mm/pgtable.c
Quoted 5 lines
arch/i386/mm/pgtable.c +5
-0+level is a bitset of pending events themselves. +*/ +asmlinkage fastcall void xen_evtchn_do_upcall(struct pt_regs *regs) +{ +int cpu =smp_processor_id ();
Doesn't a preemptive kernel complain about this?
arch/i386/mm/pgtable.c
Quoted 11 lines
arch/i386/mm/pgtable.c +11
-0+set_64bit ((u64 *)ptep,pte_val_ma (pte)); +} + +void fastcall xen_pte_clear(struct mm_struct *mm, u32 addr,pte_t *ptep) +{ +#if 1 + ptep->pte_low =0 ; +smp_wmb (); + ptep->pte_high =0 ; +#else +set_64bit ((u64 *)ptep,0 );
Eliminate #if please
arch/i386/mm/pgtable.c
Quoted 5 lines
arch/i386/mm/pgtable.c +5
-0+fastcall unsigned long long xen_pgd_val (pgd_t pgd) +{ +unsigned long long ret = pgd.pgd; +if (ret) + ret =machine_to_phys (XMADDR (ret)).paddr |1 ;
Why can they be 0 here anyways?
Normally they are all considered undefined when not present
arch/i386/mm/pgtable.c
Quoted 7 lines
arch/i386/mm/pgtable.c +7
-0+rdtscll (now); + delta = now - shadow->tsc_timestamp; +return scale_delta (delta, shadow->tsc_to_nsec_mul, shadow->tsc_shift); +} + + +static void xen_timer_interrupt_hook (void )
Timer code ... hopefully dyntick will not all mess this up. It is scheduled to go into mainline RSN. You might have to do some more merging.
arch/i386/mm/pgtable.c
Quoted 2 lines
arch/i386/mm/pgtable.c +2
-0+ +char *__init xen_memory_setup (void );
Prototypes don't need __init
arch/i386/mm/pgtable.c struct paravirt_ops · line 57
Quoted 8 lines
arch/i386/mm/pgtable.c +4
-0+void __init xen_arch_setup (void ); +void __init xen_init_IRQ (void ); +@@ -53,6 +54,7 @@ struct paravirt_opsvoid (*arch_setup)(void );char *(*memory_setup)(void );void (*init_IRQ)(void ); +void (*init_pda)(struct i386_pda *,int cpu);
Hmm weird. For what was that needed again?
-AndI
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 6 lines · Andi Kleen
Quoted 6 lines
arch/i386/kernel/entry.S +0
-0@@ -1001,6 +1001,83 @@ ENTRY(kernel_thread_helper) CFI_ENDPROC ENDPROC(kernel_thread_helper)
Quoted 12 lines
arch/i386/kernel/entry.S ENTRY(kernel_thread_helper)
Quoted 9 lines
arch/i386/kernel/entry.S +8
-0+#ifdef CONFIG_XEN +/* Xen only supports sysenter/sysexit in ring0 guests, + and only if it the guest asks for it. So for now, + this should never be used. */ +ENTRY(xen_sti_sysexit) + CFI_STARTPROC + ud2 + CFI_ENDPROCPlease add ENDPROC()s too, otherwise Jan will be unhappy.
Will do.
Quoted 2 lines
Could be written in C with a real BUG?
I guess, but this seems simpler. It could be removed altogether, but it would be nice to make sure it never happens.
Quoted 12 lines
Quoted 12 lines
arch/i386/kernel/entry.S +12
-0+ENTRY(xen_failsafe_callback) + CFI_STARTPROC + pushl %eax + CFI_ADJUST_CFA_OFFSET 4 + movl $1,%eax +1: mov 4(%esp),%ds +2: mov 8(%esp),%es +3: mov 12(%esp),%fs +4: mov 16(%esp),%gs + testl %eax,%eax + popl %eax + CFI_ADJUST_CFA_OFFSET -4
Quoted 9 lines
arch/i386/kernel/entry.S ENTRY(kernel_thread_helper) · line 1083
Quoted 6 lines
arch/i386/kernel/entry.S +5
-0+ jz 5f + addl $16,%esp # EAX != 0 => Category 2 (Bad IRET) + CFI_ADJUST_CFA_OFFSET -16 + jmp iret_exc +5: addl $16,%esp # EAX == 0 => Category 1 (Bad segment)If you use lea you could move the two adds before the jz
Yep.
Quoted 7 lines
arch/i386/kernel/entry.S ENTRY(kernel_thread_helper) · line 1034
Quoted 4 lines
arch/i386/kernel/entry.S +3
-0+#ifdef CONFIG_XEN +#include "../xen/xen-head.S" +#endifCan this really not be linked separately?
xen-head.S jumps back to startup_paravirt. That could be exported, and then it could be linked separately. There used to be a requirement that the code in xen-head.S be at a compile-time known address, but that's no longer the case.
Quoted 5 lines
Quoted 5 lines
arch/i386/kernel/entry.S +1
-0+ /* * Real beginning of normal "text" segment */@@ -528,7 +532,7 @@ ENTRY(_stext)
Quoted 9 lines
arch/i386/kernel/entry.S ENTRY(_stext) · line 536
Quoted 6 lines
arch/i386/kernel/entry.S +1
-1/* * BSS section */ -.section ".bss.page_aligned","w" +.section ".bss.page_aligned"Why?
I got complaints about section attribute mismatches without it.
Quoted 6 lines
arch/i386/kernel/entry.S ENTRY(_stext) · line 538
Quoted 3 lines
arch/i386/kernel/entry.S +1
-1-static fastcall void native_clts(void) +fastcall void native_clts(void)Fastcalls should all go now
Killing them here as we speak.
Quoted 16 lines
arch/i386/kernel/vmlinux.lds.S SECTIONS · line 97
Quoted 8 lines
arch/i386/kernel/vmlinux.lds.S +1
-0@@ -93,6 +93,7 @@ SECTIONS . = ALIGN(4096); .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { + *(.data.page_aligned)Weird that that didn't work before -- we already had page aligned data and it somehow managed to work. But ok.
Quoted 3 lines
arch/i386/kernel/vmlinux.lds.S +0
-0*(.data.idt) }
Quoted 12 lines
arch/i386/mm/pgtable.c static void pgd_ctor(pgd_t *pgd) · line 271
Quoted 9 lines
===================================================================
arch/i386/mm/pgtable.c +1
-0@@ -267,6 +267,7 @@ static void pgd_ctor(pgd_t *pgd) swapper_pg_dir +USER_PTRS_PER_PGD , KERNEL_PGD_PTRS); }else { +memset (pgd,0 ,USER_PTRS_PER_PGD *sizeof (pgd_t));That looks strange here. Belongs in a different patch?
This is a big rollup patch of all the core Xen stuff; the subject is wrong. But I added this for Xen because it needs to make sure the page is all zero and doesn't have some left-over pieces of old pagetable.
Quoted 8 lines
arch/i386/mm/pgtable.c static void pgd_ctor(pgd_t *pgd)
Quoted 5 lines
arch/i386/mm/pgtable.c +4
-0+ +extern struct Xgt_desc_struct cpu_gdt_descr; +extern struct i386_pda boot_pda; +extern unsigned long init_pg_tables_end;No externs in .c files
OK.
Quoted 10 lines
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +5
-0+ +static DEFINE_PER_CPU(unsigned, lazy_mode); + +/* Code defined in entry.S (not a function) */ +extern const char xen_sti_sysexit[];Ok except that
Quoted 7 lines
arch/i386/mm/pgtable.c
Quoted 4 lines
arch/i386/mm/pgtable.c +3
-0+{ +printk (KERN_INFO "Booting paravirtualized kernel on %s\n" , + paravirt_ops.name);Say something about Xen here?
paravirt_ops.name mentions Xen.
Quoted 19 lines
Quoted 5 lines
arch/i386/mm/pgtable.c +4
-0+} + +static fastcall void xen_restore_fl(unsigned long flags) +{arch/i386/mm/pgtable.c
Quoted 10 lines
arch/i386/mm/pgtable.c +10
-0+struct vcpu_info *vcpu; + +preempt_disable (); + +/* convert from IF type flag */ + flags = !(flags &X86_EFLAGS_IF ); + vcpu =read_pda (xen.vcpu); + vcpu->evtchn_upcall_mask = flags; +if (flags ==0 ) { +barrier ();/* unmask then check (avoid races) */ If the barrier is needed shouldn't it be a
rmb()?
Quoted 7 lines
arch/i386/mm/pgtable.c
Quoted 4 lines
arch/i386/mm/pgtable.c +3
-0+ vcpu =read_pda (xen.vcpu); + vcpu->evtchn_upcall_mask =0 ; +barrier ();/* unmask then check (avoid races) */ Similar.
Erm, not sure. The write needs to be complete before the read happens. Which is the right barrier for that?
Quoted 13 lines
arch/i386/mm/pgtable.c
Quoted 10 lines
arch/i386/mm/pgtable.c +9
-0+static fastcall void xen_load_gdt(const struct Xgt_desc_struct *dtr) +{ +unsigned long va; +int f; +unsigned size = dtr->size +1 ; +unsigned long frames[16 ]; + +BUG_ON (size >16 *PAGE_SIZE ); +Indentation broken
Quoted 2 lines
(more occurences in this file)
OK.
Quoted 8 lines
Quoted 8 lines
arch/i386/mm/pgtable.c +8
-0+ type = (high >>8 ) &0x1f ; + dpl = (high >>13 ) &3 ; + +if (type !=0xf && type !=0xe ) +return 0 ; + + info->vector = vector; + info->address = (high &0xffff0000 ) | (low &0x0000ffff );
Quoted 9 lines
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +5
-0+ info->cs = low >>16 ; + info->flags = dpl; +/* interrupt gates clear IF */ +if (type ==0xe ) + info->flags |=4 ;Nasty magic numbers?
Yeah. Are there any existing definitions of the x86 gate types?
Quoted 9 lines
Quoted 9 lines
arch/i386/mm/pgtable.c +9
-0+return 1 ; +} + +#if 0 +static void unpack_desc (u32 low,u32 high, +unsigned long *base,unsigned long *limit, +unsigned char *type,unsigned char *flags) +{ + *base = (high &0xff000000 ) | ((high <<16 ) &0x00ff0000 ) | ((low >>16 ) &0xffff );
Quoted 9 lines
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +5
-0+ *limit = (high &0x000f0000 ) | (low &0xffff ); + *type = (high >>8 ) &0xff ; + *flags = (high >> 20) & 0xf; +} +#endif Remove?
Yep.
Quoted 7 lines
arch/i386/mm/pgtable.c
Quoted 4 lines
arch/i386/mm/pgtable.c +3
-0+ +/* Locations of each CPU's IDT */ +static DEFINE_PER_CPU(struct Xgt_desc_struct, idt_desc);Why is that private here?
It's a local per-cpu cache of the idt as set by the kernel. Xen doesn't use the idt directly, but it remembers what idt has been set so it can tell if an idt descriptor update is affecting the current idt or something else. Its a bit over-engineered, since the idt isn't really touched much at all.
Quoted 10 lines
arch/i386/mm/pgtable.c
Quoted 7 lines
arch/i386/mm/pgtable.c +6
-0+/* Switch to new pagetable. This is done before +pagetable_init has done anything so that the new pages +added to the table can be prepared properly for Xen. */ +printk ("about to switch to new pagetable %p...\n" , base); +xen_write_cr3 (__pa (base)); +printk ("done\n" );KERN_* ?
Delete. Don't really need it any more.
Quoted 8 lines
arch/i386/mm/pgtable.c
Quoted 5 lines
arch/i386/mm/pgtable.c +4
-0+if (HYPERVISOR_update_descriptor (virt_to_machine (cpu_gdt_table + +GDT_ENTRY_PDA ).maddr, + (u64 )high <<32 | low)) +BUG ();Does a BUG that early actually do anything good?
Under Xen, an early BUG gets a nice register dump and backtrack from the hypervisor, so its pretty useful for debugging.
Quoted 8 lines
arch/i386/mm/pgtable.c
Quoted 5 lines
arch/i386/mm/pgtable.c +4
-0+ +/* +* Accessors for packed IRQ information. +*/ Wouldn't it be a little simpler to just use a bit field?
Yeah, or even just a simple structure, since the elements are short/byte/byte.
Quoted 12 lines
arch/i386/mm/pgtable.c
Quoted 9 lines
arch/i386/mm/pgtable.c +8
-0+static void bind_evtchn_to_cpu (unsigned int chn,unsigned int cpu) +{ +int irq = evtchn_to_irq[chn]; + +BUG_ON (irq ==-1 ); +set_native_irq_info (irq,cpumask_of_cpu (cpu)); + +__clear_bit (chn, (unsigned long *)cpu_evtchn_mask[cpu_evtchn[chn]]);Why is the mask not unsigned long in the first place ?
Hm, it was. Seems completely redundant.
Quoted 9 lines
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +5
-0+level is a bitset of pending events themselves. +*/ +asmlinkage fastcall void xen_evtchn_do_upcall(struct pt_regs *regs) +{ +int cpu =smp_processor_id ();Doesn't a preemptive kernel complain about this?
Xen doesn't support preempt.
Quoted 6 lines
Quoted 6 lines
arch/i386/mm/pgtable.c +6
-0+set_64bit ((u64 *)ptep,pte_val_ma (pte)); +} + +void fastcall xen_pte_clear(struct mm_struct *mm, u32 addr,pte_t *ptep) +{ +#if 1
Quoted 9 lines
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +5
-0+ ptep->pte_low =0 ; +smp_wmb (); + ptep->pte_high =0 ; +#else +set_64bit ((u64 *)ptep,0 );Eliminate #if please
I need to test this a bit. This is here because set_64bit doesn't work properly under qemu (its emulation mis-reports the eip if the instruction faults), but I haven't tested this under native.
Quoted 11 lines
arch/i386/mm/pgtable.c
Quoted 6 lines
arch/i386/mm/pgtable.c +5
-0+fastcall unsigned long long xen_pgd_val (pgd_t pgd) +{ +unsigned long long ret = pgd.pgd; +if (ret) + ret =machine_to_phys (XMADDR (ret)).paddr |1 ;Why can they be 0 here anyways?
Normally they are all considered undefined when not present
Not sure.
Quoted 12 lines
arch/i386/mm/pgtable.c
Quoted 8 lines
arch/i386/mm/pgtable.c +7
-0+rdtscll (now); + delta = now - shadow->tsc_timestamp; +return scale_delta (delta, shadow->tsc_to_nsec_mul, shadow->tsc_shift); +} + + +static void xen_timer_interrupt_hook (void )Timer code ... hopefully dyntick will not all mess this up. It is scheduled to go into mainline RSN. You might have to do some more merging.
Yep.
Quoted 6 lines
arch/i386/mm/pgtable.c
Quoted 3 lines
arch/i386/mm/pgtable.c +2
-0+ +char *__init xen_memory_setup (void );Prototypes don't need
__init
OK.
Quoted 12 lines
arch/i386/mm/pgtable.c struct paravirt_ops · line 58
Quoted 9 lines
arch/i386/mm/pgtable.c +4
-0+void __init xen_arch_setup (void ); +void __init xen_init_IRQ (void ); +@@ -53,6 +54,7 @@ struct paravirt_opsvoid (*arch_setup)(void );char *(*memory_setup)(void );void (*init_IRQ)(void ); +void (*init_pda)(struct i386_pda *,int cpu);Hmm weird. For what was that needed again?
The PDA structure contains some Xen-specific (or generally, paravirt backend specific) parts, which need initialization when the rest of the PDA is.
J
[Xen-devel] Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 11 lines
Quoted 10 lines
arch/i386/kernel/head.S ENTRY(_stext) · line 536
Quoted 7 lines
arch/i386/kernel/head.S +1
-1@@ -528,7 +532,7 @@ ENTRY(_stext) /* * BSS section */ -.section ".bss.page_aligned","w" +.section ".bss.page_aligned"Why?
Quoted 1 line
I got complaints about section attribute mismatches without it.
Then perhaps ... "aw" is meant?
Quoted 9 lines
Quoted 9 lines
arch/i386/xen/mmu.c line 196
Quoted 6 lines
arch/i386/xen/mmu.c new file +5
-0+fastcall unsigned long long xen_pgd_val (pgd_t pgd) +{ +unsigned long long ret = pgd.pgd; +if (ret) + ret =machine_to_phys (XMADDR (ret)).paddr |1 ;Why can they be 0 here anyways?
Quoted 4 lines
Quoted 2 lines
Normally they are all considered undefined when not present
Not sure.
This should probably get sync-ed up with the page table handling changes submitted to xen-devel yesterday. Using zero/non-zero tests in contexts like this was always broken; should check for _PAGE_PRESENT.
Jan
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
In reply to Andi KleenQuoted 6 lines · Andi Kleen
Review
Quoted 4 lines
(quoted diff) +3
-0+#ifdef CONFIG_XEN +#include "../xen/xen-head.S" +#endifCan this really not be linked separately?
I did a patch to do this (attached). In principle it should be pretty simple, but I think I'm running into toolchain issues. If I link xen-head.S separately (with appropriate headers added), it compiles OK and contains the right notes, but they don't appear in the final vmlinux properly. The note segment and section are there, but no tools will parse them as notes:
: ezr:pts/1; readelf -n vmlinux
: ezr:pts/1; ../../unstable/tools/xcutils/readnotes vmlinux : ezr:pts/1; readelf -l vmlinux
Elf file type is EXEC (Executable file) Entry point 0x2e1f70
There are 3 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xc0100000 0x00100000 0x2a8920 0x2a8920 R E 0x1000 LOAD 0x2aa000 0xc03a9000 0x003a9000 0x5f085 0xaf000 RWE 0x1000 NOTE 0x26d2910 0x00239010 0x00239010 0x000e8 0x00000 R 0x4
Section to Segment mapping:
Segment Sections...
00 .text .text.head __ex_table .rodata .pci_fixup __ksymtab __ksymtab_gpl __kcrctab __kcrctab_gpl __ksymtab_strings __param __bug_table 01 .data .paravirtprobe .data_nosave .data.page_aligned .data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .altinstructions .altinstr_replacement .parainstructions .exit.text .init.ramfs .bss 02 .notes
: ezr:pts/1; objdump -j .notes -s vmlinux
vmlinux: file format elf32-i386
Contents of section .notes:
239010 04000000 06000000 06000000 58656e00 ............Xen. 239020 6c696e75 78000000 04000000 04000000 linux........... 239030 07000000 58656e00 322e3600 04000000 ....Xen.2.6..... 239040 08000000 05000000 58656e00 78656e2d ........Xen.xen- 239050 332e3000 04000000 04000000 03000000 3.0............. 239060 58656e00 000000c0 04000000 04000000 Xen............. 239070 01000000 58656e00 c80710c0 04000000 ....Xen......... 239080 04000000 02000000 58656e00 00b040c0 ........Xen...@. 239090 04000000 2a000000 0a000000 58656e00 ....*.......Xen. 2390a0 21777269 7461626c 655f7061 67655f74 !writable_page_t 2390b0 61626c65 737c7061 655f7067 6469725f ables|pae_pgdir_ 2390c0 61626f76 655f3467 62000000 04000000 above_4gb....... 2390d0 04000000 09000000 58656e00 79657300 ........Xen.yes. 2390e0 04000000 08000000 08000000 58656e00 ............Xen. 2390f0 67656e65 72696300 generic.
I can't see what the problem is here, but it looks like a toolchain problem to me (I'm using binutils-2.17.50.0.6-2.fc6).
Any clues?
Thanks,
J
arch/i386/kernel/head.S +1 -5
@@ -504,7 +504,7 @@ ignore_int: .section .text #ifdef CONFIG_PARAVIRT -startup_paravirt: +ENTRY(startup_paravirt) cld movl $(init_thread_union+THREAD_SIZE),%esp
@@ -535,10 +535,6 @@ unhandled_paravirt: ud2 #endif -#ifdef CONFIG_XEN -#include "../xen/xen-head.S" -#endif - /* * Real beginning of normal "text" segment */
arch/i386/xen/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-y := enlighten.o setup.o events.o t -obj-y := enlighten.o setup.o events.o time.o \ +obj-y := xen-head.o enlighten.o setup.o events.o time.o \ features.o mmu.o multicalls.o
arch/i386/xen/xen-head.S +3 -0
@@ -1,8 +1,11 @@ /* Xen-specific pieces of head.S, intended to be included in the right place in head.S */ +.text #include <linux/elfnote.h> +#include <linux/linkage.h> #include <asm/boot.h> +#include <asm/page.h> #include <xen/interface/elfnote.h> ENTRY(startup_xen)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 60 lines · Jeremy Fitzhardinge
Quoted 6 lines · Andi Kleen
Review
Quoted 4 lines
(quoted diff) +3
-0+#ifdef CONFIG_XEN +#include "../xen/xen-head.S" +#endifCan this really not be linked separately?
I did a patch to do this (attached). In principle it should be pretty simple, but I think I'm running into toolchain issues. If I link
xen-head.Sseparately (with appropriate headers added), it compiles OK and contains the right notes, but they don't appear in the final vmlinux properly. The note segment and section are there, but no tools will parse them as notes:: ezr:pts/1; readelf -n vmlinux
: ezr:pts/1; ../../unstable/tools/xcutils/readnotes vmlinux : ezr:pts/1; readelf -l vmlinuxElf file type is EXEC (Executable file) Entry point
0x2e1f70
There are 3 program headers, starting at offset 52Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xc0100000 0x00100000 0x2a8920 0x2a8920 R E 0x1000 LOAD 0x2aa000 0xc03a9000 0x003a9000 0x5f085 0xaf000 RWE 0x1000 NOTE 0x26d2910 0x00239010 0x00239010 0x000e8 0x00000 R 0x4Section to Segment mapping:
Segment Sections...
00 .text .text.head__ex_table.rodata .pci_fixup__ksymtab__ksymtab_gpl__kcrctab__kcrctab_gpl__ksymtab_strings__param__bug_table
01 .data .paravirtprobe .data_nosave .data.page_aligned
.data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .altinstructions .altinstr_replacement .parainstructions .exit.text .init.ramfs .bss
02 .notes
: ezr:pts/1; objdump -j .notes -s vmlinuxvmlinux: file format elf32-i386
Contents of section .notes:
239010 04000000 06000000 06000000 58656e00 ............Xen. 239020 6c696e75 78000000 04000000 04000000 linux........... 239030 07000000 58656e00 322e3600 04000000 ....Xen.2.6..... 239040 08000000 05000000 58656e00 78656e2d ........Xen.xen- 239050 332e3000 04000000 04000000 03000000 3.0............. 239060 58656e00 000000c0 04000000 04000000 Xen............. 239070 01000000 58656e00 c80710c0 04000000 ....Xen......... 239080 04000000 02000000 58656e00 00b040c0 ........Xen...@. 239090 04000000 2a000000 0a000000 58656e00 ....*.......Xen. 2390a0 21777269 7461626c 655f7061 67655f74 !writable_page_t 2390b0 61626c65 737c7061 655f7067 6469725f ables|pae_pgdir_ 2390c0 61626f76 655f3467 62000000 04000000 above_4gb....... 2390d0 04000000 09000000 58656e00 79657300 ........Xen.yes. 2390e0 04000000 08000000 08000000 58656e00 ............Xen. 2390f0 67656e65 72696300 generic.
Quoted 2 lines
I can't see what the problem is here, but it looks like a toolchain problem to me (I'm using binutils-2.17.50.0.6-2.fc6).
Well I did a little by hand parsing and the not I parsed looked ok.
How does the output differ from a what you get when xen-head.S is included?
Eric
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 5 lines · Eric W. Biederman
Well I did a little by hand parsing and the not I parsed looked ok.
How does the output differ from a what you get when
xen-head.Sis included?
Ah!
The .notes section gets SHT_NOTE in vmlinux when xen-head.S is included; PROGBITS when linked. I tried putting @note on the .section in linux/elfnote.h, but that didn't seem to help (xen-note.o got a SHT_NOTE entry, but it didn't make it into vmlinux). I couldn't see any way of forcing the section type in vmlinux.lds; my experiments all ended with ld dumping core.
J
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 6 lines · Jeremy Fitzhardinge
Quoted 5 lines · Eric W. Biederman
Well I did a little by hand parsing and the not I parsed looked ok.
How does the output differ from a what you get when
xen-head.Sis included?
Quoted 8 lines
Ah!
The .notes section gets
SHT_NOTEin vmlinux whenxen-head.Sis included; PROGBITS when linked. I tried putting @note on the .section inlinux/elfnote.h, but that didn't seem to help (xen-note.o got aSHT_NOTEentry, but it didn't make it into vmlinux). I couldn't see any way of forcing the section type invmlinux.lds; my experiments all ended with ld dumping core.
Ok. If that is all this may be a difference that makes no difference. binutils has a bad habit of looking at sections (which are fully optional) instead of segments on ET_EXEC and ET_DYN objects. Only ET_REL objects (.o files) are required to have sections.
It is worth checking but as long as something looking strictly at the program headers can find the notes and read them we are in good shape.
That readelf -n has a problem there concerns me a little but as usually that program is better than the rest of binutils.
So I recommend for testing write a 100 line program that includes elf.h and reads out the note segment. If all is well we can split this code out.
Eric
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 5 lines · Eric W. Biederman
Ok. If that is all this may be a difference that makes no difference. binutils has a bad habit of looking at sections (which are fully optional) instead of segments on
ET_EXECandET_DYNobjects. OnlyET_RELobjects (.o files) are required to have sections.
The Xen domain loader will have to be changed to deal with that, which isn't too much of a problem.
My main concern is the randomness of it, and whether it will fail in some more harmful way on other versions of binutils.
Quoted 4 lines
So I recommend for testing write a 100 line program that includes
elf.hand reads out the note segment. If all is well we can split this code out.
The Xen readnotes utility is essentially that. I'll hack it.
J
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 5 lines · Eric W. Biederman
Ok. If that is all this may be a difference that makes no difference. binutils has a bad habit of looking at sections (which are fully optional) instead of segments on
ET_EXECandET_DYNobjects. OnlyET_RELobjects (.o files) are required to have sections.The Xen domain loader will have to be changed to deal with that, which isn't too much of a problem.
Ok. Please fix the Xen domain loader to not look at sections. It is a bug for any kind of executable loader to look at anything other then segments.
Quoted 2 lines
My main concern is the randomness of it, and whether it will fail in some more harmful way on other versions of binutils.
Reasonable and it's probably worth letting the binutils developer know.
I do agree that it is weird. It might be that something in binutils
doesn't like us dropping some of the notes.
Quoted 6 lines
Quoted 4 lines
So I recommend for testing write a 100 line program that includes
elf.hand reads out the note segment. If all is well we can split this code out.The Xen readnotes utility is essentially that. I'll hack it.
Sounds good.
Eric
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 4 lines · Eric W. Biederman
Reasonable and it's probably worth letting the binutils developer know.
I do agree that it is weird. It might be that something in binutils
doesn't like us dropping some of the notes.
What do you mean by "dropping some of the notes"? I think the only notes (at least in this case) are the Xen ones, and they're all included.
J
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 4 lines · Eric W. Biederman
Reasonable and it's probably worth letting the binutils developer know.
I do agree that it is weird. It might be that something in binutils
doesn't like us dropping some of the notes.What do you mean by "dropping some of the notes"? I think the only notes (at least in this case) are the Xen ones, and they're all included.
I'm pretty certain we explicitly drop the weird GNU note that is automatically generated by gcc and specifies something informational.
Basically into .note we include *(.note.*) but not *(.note).
I don't think anything we are doing is wrong but ld gets confused easily in the corner cases. I'm modestly surprised we didn't have to mark our .note.xxx scions as ".section .note.xxx @note" or whatever the proper gas syntax is.
Eric
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 3 lines · Eric W. Biederman
I'm pretty certain we explicitly drop the weird GNU note that is automatically generated by gcc and specifies something informational.
But that's something else again, since it appears as a PT_GNU_STACK phdr.
Quoted 4 lines
I don't think anything we are doing is wrong but ld gets confused easily in the corner cases. I'm modestly surprised we didn't have to mark our .note.xxx scions as ".section .note.xxx @note" or whatever the proper gas syntax is.
I did try that, and it didn't make a difference. The manual says that the output section type follows the input section type, so I agree its a bit surprising we ever get a SHT_NOTE out of it without the @note stuff.
J
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 5 lines · Jeremy Fitzhardinge
Quoted 3 lines · Eric W. Biederman
I'm pretty certain we explicitly drop the weird GNU note that is automatically generated by gcc and specifies something informational.
But that's something else again, since it appears as a
PT_GNU_STACKphdr.
Not that. It's more like abi version or gcc version or something like. At least there used to be one of those notes in every .o file and compiled program.
Quoted 8 lines
Quoted 4 lines
I don't think anything we are doing is wrong but ld gets confused easily in the corner cases. I'm modestly surprised we didn't have to mark our .note.xxx scions as ".section .note.xxx @note" or whatever the proper gas syntax is.
I did try that, and it didn't make a difference. The manual says that the output section type follows the input section type, so I agree its a bit surprising we ever get a
SHT_NOTEout of it without the @note stuff.
Right. So the surprise is that SHT_NOTE got set. There are some defaults based on the section name somewhere that appear to have done the right thing.
My best hunch really is that ld treated the .note sections normally and just mist the handling of the magic SHT_NOTE type. Which is why I'm not to worried.
Eric
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
In reply to Jeremy FitzhardingeJeremy Fitzhardinge <[email protected]> writes:
There need to be alignment directives for the page aligned chunks.
Placing the page aligned chunks in a special section is nice in that it ensures the linker packs everything tightly but should be completely unnecessary if the alignment is correct.
Quoted 87 lines
===================================================================
arch/i386/kernel/head.S +10
-2@@ -519,6 +519,10 @@ 1: jmp 1b #endif +#ifdef CONFIG_XEN +#include "../xen/xen-head.S" +#endif + /* * Real beginning of normal "text" segment */@@ -528,7 +532,7 @@ ENTRY(_stext) /* * BSS section */ -.section ".bss.page_aligned","w" +.section ".bss.page_aligned" ENTRY(swapper_pg_dir) .fill 1024,4,0 ENTRY(empty_zero_page)@@ -598,7 +602,8 @@ ENTRY(boot_gdt_table) /* * The Global Descriptor Table contains 28 quadwords, per-CPU. */ - .align L1_CACHE_BYTES + .section ".data.page_aligned" + .align PAGE_SIZE_asm ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* NULL descriptor */ .quad 0x0000000000000000 /* 0x0b reserved */@@ -647,3 +652,6 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0xf0 - unused */ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ + /* Be sure this is zeroed to avoid false validations in Xen */ + .fill PAGE_SIZE_asm / 8 - GDT_ENTRIES,8,0 + .previous===================================================================
arch/i386/kernel/vmlinux.lds.S +1
-0@@ -93,6 +93,7 @@ SECTIONS . = ALIGN(4096); .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { + *(.data.page_aligned) *(.data.idt) }arch/i386/xen/xen-head.S new file +23
-0@@ -0,0 +1,29 @@ +/* Xen-specific pieces of head.S, intended to be included in the right + place in head.S */ + +#include <linux/elfnote.h> +#include <asm/boot.h> +#include <xen/interface/elfnote.h> + +ENTRY(startup_xen) + movl %esi,xen_start_info + jmp startup_paravirt + +.pushsection ".bss.page_aligned" +ENTRY(hypercall_page) + .skip 0x1000 +.popsection + + ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux") + ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6") + ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0") + ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long, __PAGE_OFFSET) + ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long, startup_xen) + ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long, hypercall_page) + ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz,"!writable_page_tables|pae_pgdir_above_4gb")
arch/i386/xen/xen-head.S new file +6
-0+#ifdef CONFIG_X86_PAE + ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes") +#else + ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no") +#endif + ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
Re: [patch 16/21] Xen-paravirt: Add code into head.S to handle being booted by Xen
Quoted 4 lines · Eric W. Biederman
Jeremy Fitzhardinge <[email protected]> writes:
There need to be alignment directives for the page aligned chunks.
OK.
Quoted 4 lines
Placing the page aligned chunks in a special section is nice in that it ensures the linker packs everything tightly but should be completely unnecessary if the alignment is correct.
Yes, I made the extra section to get better packing.
J
PATCH 17/21 Xen-paravirt: Add the Xen virtual console driver.
In reply to Jeremy FitzhardingeThis provides a bootstrap and ongoing emergency console which is intended to be available from very early during boot and at all times thereafter, in contrast with alternatives such as UDP-based syslogd, or logging in via ssh. The protocol is based on a simple shared-memory ring buffer.
--- arch/i386/kernel/early_printk.c | 2 drivers/Makefile | 3 drivers/xen/Makefile | 1 drivers/xen/console/Makefile | 2 drivers/xen/console/console.c | 585 +++++++++++++++++++++++++++++++++++ drivers/xen/console/xencons_ring.c | 144 ++++++++ include/xen/xencons.h | 14 init/main.c | 2 8 files changed, 753 insertions(+)
===================================================================
arch/i386/kernel/early_printk.c +2 -0
@@ -1,2 +1,4 @@ +#ifndef CONFIG_XEN #include "../../x86_64/kernel/early_printk.c" +#endif
===================================================================
drivers/Makefile +3 -0
@@ -14,6 +14,9 @@ obj-$(CONFIG_ACPI) += acpi/ # was used and do nothing if so obj-$(CONFIG_PNP) += pnp/ obj-$(CONFIG_ARM_AMBA) += amba/ + +# Xen is the default console when running as a guest +obj-$(CONFIG_XEN) += xen/ # char/ comes before serial/ etc so that the VT console is the boot-time # default.
===================================================================
drivers/xen/Makefile new file +1 -0
@@ -0,0 +1,1 @@ +obj-y += console/
===================================================================
drivers/xen/console/Makefile new file +2 -0
@@ -0,0 +1,2 @@ + +obj-y := console.o xencons_ring.o
===================================================================
drivers/xen/console/console.c new file +585 -0
585 lines not on this page · raw message
===================================================================
drivers/xen/console/xencons_ring.c new file +144 -0
144 lines not on this page · raw message
===================================================================
include/xen/xencons.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __ASM_XENCONS_H__ +#define __ASM_XENCONS_H__ + +void xencons_force_flush (void ); +void xencons_resume (void ); + +/* Interrupt work hooks. Receive data, or kick data out. */ +void xencons_rx (char *buf,unsigned len); +void xencons_tx (void ); + +int xencons_ring_init (void ); +int xencons_ring_send (const char *data,unsigned len); + +#endif /* __ASM_XENCONS_H__ */
===================================================================
init/main.c +2 -0
@@ -495,6 +495,8 @@ asmlinkage void __init start_kernel(voidunwind_init ();lockdep_init (); +//setup_early_printk(NULL); +local_irq_disable ();early_boot_irqs_off ();early_init_irq_lock_class ();
PATCH 18/21 Xen-paravirt: Add Xen grant table support
In reply to Jeremy FitzhardingeAdd Xen 'grant table' driver which allows granting of access to selected local memory pages by other virtual machines and, symmetrically, the mapping of remote memory pages which other virtual machines have granted access to.
This driver is a prerequisite for many of the Xen virtual device drivers, which grant the 'device driver domain' restricted and temporary access to only those memory pages that are currently involved in I/O operations.
--- drivers/xen/Makefile | 1 drivers/xen/core/Makefile | 1 drivers/xen/core/grant_table.c | 446 +++++++++++++++++++++++++++++++++++++++ include/xen/grant_table.h | 107 +++++++++ 4 files changed, 555 insertions(+)
===================================================================
drivers/xen/Makefile +1 -0
@@ -1,1 +1,2 @@ obj-y += console/ +obj-y += core/ obj-y += console/
===================================================================
drivers/xen/core/Makefile new file +1 -0
@@ -0,0 +1,1 @@ +obj-y += grant_table.o
===================================================================
drivers/xen/core/grant_table.c new file +446 -0
446 lines not on this page · raw message
===================================================================
include/xen/grant_table.h new file +107 -0
107 lines not on this page · raw message
PATCH 19/21 Xen-paravirt: Add the Xenbus sysfs and virtual device hotplug driver.
In reply to Jeremy FitzhardingeThis communicates with the machine control software via a registry residing in a controlling virtual machine. This allows dynamic creation, destruction and modification of virtual device configurations (network devices, block devices and CPUS, to name some examples).
--- arch/i386/xen/Kconfig | 5 drivers/xen/Makefile | 1 drivers/xen/xenbus/Makefile | 9 drivers/xen/xenbus/xenbus_client.c | 566 +++++++++++++++++ drivers/xen/xenbus/xenbus_comms.c | 218 ++++++ drivers/xen/xenbus/xenbus_comms.h | 44 + drivers/xen/xenbus/xenbus_probe.c | 891 ++++++++++++++++++++++++++++ drivers/xen/xenbus/xenbus_probe.h | 72 ++ drivers/xen/xenbus/xenbus_probe_backend.c | 269 ++++++++ drivers/xen/xenbus/xenbus_xs.c | 840 ++++++++++++++++++++++++++ include/asm-i386/hypervisor.h | 1 include/xen/xenbus.h | 208 ++++++ 12 files changed, 3124 insertions(+)
===================================================================
arch/i386/xen/Kconfig +5 -0
@@ -8,3 +8,8 @@ config XEN default y help This is the Linux Xen port. + +config XEN_BACKEND + bool + depends XEN + default n
===================================================================
drivers/xen/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += core/ obj-y += core/ obj-y += console/ +obj-y += xenbus/
===================================================================
drivers/xen/xenbus/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +obj-y += xenbus.o + +xenbus-objs = +xenbus-objs += xenbus_client.o +xenbus-objs += xenbus_comms.o +xenbus-objs += xenbus_xs.o +xenbus-objs += xenbus_probe.o + +obj-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
===================================================================
drivers/xen/xenbus/xenbus_client.c new file +566 -0
566 lines not on this page · raw message
===================================================================
drivers/xen/xenbus/xenbus_comms.c new file +218 -0
218 lines not on this page · raw message
===================================================================
drivers/xen/xenbus/xenbus_comms.h new file +44 -0
44 lines not on this page · raw message
===================================================================
drivers/xen/xenbus/xenbus_probe.c new file +891 -0
891 lines not on this page · raw message
===================================================================
drivers/xen/xenbus/xenbus_probe.h new file +72 -0
72 lines not on this page · raw message
===================================================================
drivers/xen/xenbus/xenbus_probe_backend.c new file +269 -0
269 lines not on this page · raw message
===================================================================
drivers/xen/xenbus/xenbus_xs.c new file +840 -0
840 lines not on this page · raw message
===================================================================
include/asm-i386/hypervisor.h +1 -0
@@ -42,6 +42,7 @@#include <asm/ptrace.h> #include <asm/page.h> +#include <asm/desc.h> #if defined(__i386__)# ifdef CONFIG_X86_PAE # include <asm-generic/pgtable-nopud.h>
===================================================================
include/xen/xenbus.h new file +208 -0
73 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 20/21 Xen-paravirt: Add Xen virtual block device driver.
In reply to Jeremy FitzhardingeThe block device frontend driver allows the kernel to access block devices exported exported by a virtual machine containing a physical block device driver.
--- drivers/block/Kconfig | 1 drivers/block/Makefile | 1 drivers/block/xen/Kconfig | 14 drivers/block/xen/Makefile | 5 drivers/block/xen/blkfront.c | 844 +++++++++++++++++++++++++++++++++++++++++ drivers/block/xen/block.h | 135 ++++++ drivers/block/xen/vbd.c | 230 +++++++++++ include/linux/major.h | 2 8 files changed, 1232 insertions(+)
===================================================================
drivers/block/Kconfig +1 -0
@@ -461,6 +461,7 @@ config CDROM_PKTCDVD_WCACHE don't do deferred write error handling yet. source "drivers/s390/block/Kconfig" +source "drivers/block/xen/Kconfig" config ATA_OVER_ETH tristate "ATA over Ethernet support"
===================================================================
drivers/block/Makefile +1 -0
@@ -29,3 +29,4 @@ obj-$(CONFIG_BLK_DEV_SX8) += sx8.o obj-$(CONFIG_BLK_DEV_SX8) += sx8.o obj-$(CONFIG_BLK_DEV_UB) += ub.o +obj-$(CONFIG_XEN) += xen/
===================================================================
drivers/block/xen/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +menu "Xen block device drivers" + depends on XEN + +config XEN_BLKDEV_FRONTEND + tristate "Block device frontend driver" + depends on XEN + default y + help + The block device frontend driver allows the kernel to access block + devices exported from a device driver virtual machine. Unless you + are building a dedicated device driver virtual machine, then you + almost certainly want to say Y here. + +endmenu
===================================================================
drivers/block/xen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ + +obj-$(CONFIG_XEN_BLKDEV_FRONTEND) := xenblk.o + +xenblk-objs := blkfront.o vbd.o +
===================================================================
drivers/block/xen/blkfront.c new file +844 -0
844 lines not on this page · raw message
===================================================================
drivers/block/xen/block.h new file +135 -0
135 lines not on this page · raw message
===================================================================
drivers/block/xen/vbd.c new file +230 -0
230 lines not on this page · raw message
===================================================================
include/linux/major.h +2 -0
@@ -156,6 +156,8 @@#define VXSPEC_MAJOR 200/* VERITAS volume config driver */ #define VXDMP_MAJOR 201/* VERITAS volume multipath driver */ +#define XENVBD_MAJOR 202/* Xen virtual block device */ +#define MSR_MAJOR 202#define CPUID_MAJOR 203
PATCH 21/21 Xen-paravirt: Add the Xen virtual network device driver.
In reply to Jeremy FitzhardingeThe network device frontend driver allows the kernel to access network devices exported exported by a virtual machine containing a physical network device driver.
--- drivers/net/Kconfig | 2 drivers/xen/Kconfig.net | 14 drivers/xen/Makefile | 1 drivers/xen/netfront/Makefile | 4 drivers/xen/netfront/netfront.c | 2068 ++++++++++++++++++++++++++++++++++++++ include/xen/events.h | 2 6 files changed, 2091 insertions(+)
===================================================================
drivers/net/Kconfig +2 -0
@@ -2517,6 +2517,8 @@ source "drivers/atm/Kconfig" source "drivers/s390/net/Kconfig" +source "drivers/xen/Kconfig.net" + config ISERIES_VETH tristate "iSeries Virtual Ethernet driver support" depends on PPC_ISERIES
===================================================================
drivers/xen/Kconfig.net new file +14 -0
@@ -0,0 +1,14 @@ +menu "Xen network device drivers" + depends on NETDEVICES && XEN + +config XEN_NETDEV_FRONTEND + tristate "Network-device frontend driver" + depends on XEN + default y + help + The network-device frontend driver allows the kernel to access + network interfaces within another guest OS. Unless you are building a + dedicated device-driver domain, or your master control domain + (domain 0), then you almost certainly want to say Y here. + +endmenu
===================================================================
drivers/xen/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-y += core/ obj-y += core/ obj-y += console/ obj-y += xenbus/ +obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/
===================================================================
drivers/xen/netfront/Makefile new file +4 -0
@@ -0,0 +1,4 @@ + +obj-$(CONFIG_XEN_NETDEV_FRONTEND) := xennet.o + +xennet-objs := netfront.o
===================================================================
drivers/xen/netfront/netfront.c new file +2068 -0
2,068 lines not on this page · raw message
===================================================================
include/xen/events.h +2 -0
@@ -2,6 +2,8 @@#define _XEN_EVENTS_H#include <linux/irq.h> +#include <xen/interface/event_channel.h> +#include <asm/hypercall.h> int bind_evtchn_to_irqhandler(unsigned int evtchn, irqreturn_t (*handler)(int, void *),
Re: [patch 21/21] Xen-paravirt: Add the Xen virtual network device driver.
Quoted 4 lines · Jeremy Fitzhardinge
+++ b/drivers/xen/Kconfig.net
drivers/xen/Kconfig.net new file +2
-0@@ -0,0 +1,14 @@ +menu "Xen network device drivers" + depends on NETDEVICES && XEN
drivers/xen/Kconfig.net line 12
Quoted 10 lines
drivers/xen/Kconfig.net new file +10
-0+ +config XEN_NETDEV_FRONTEND + tristate "Network-device frontend driver" + depends on XEN + default y + help + The network-device frontend driver allows the kernel to access + network interfaces within another guest OS. Unless you are building a + dedicated device-driver domain, or your master control domain + (domain 0), then you almost certainly want to say Y here.
Am I reading this correctly I can directly use the network interface of another guest OS (no protection)?
I think this description is misleading, and probably say something about virtual hardware.
Eric