diff options
author | kaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk> | 2003-02-04 15:34:24 +0000 |
---|---|---|
committer | kaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk> | 2003-02-04 15:34:24 +0000 |
commit | 66a5ed835bf8a3a08418cb64260bb150337848ac (patch) | |
tree | 916d257e390e9484c25531ca32a4b13c2b41fd9d /xenolinux-2.4.16-sparse | |
parent | ab55278795d719166ff3684c06f11ab17ad0a38e (diff) | |
download | xen-66a5ed835bf8a3a08418cb64260bb150337848ac.tar.gz xen-66a5ed835bf8a3a08418cb64260bb150337848ac.tar.bz2 xen-66a5ed835bf8a3a08418cb64260bb150337848ac.zip |
bitkeeper revision 1.22.1.5 (3e3fdd804HE3wN54H1WWZNmL4_hwmg)
Many files:
XenoLinux now does proper physical-machine address conversion. phys_base has been removed from start_info.
Diffstat (limited to 'xenolinux-2.4.16-sparse')
-rw-r--r-- | xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S | 4 | ||||
-rw-r--r-- | xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c | 17 | ||||
-rw-r--r-- | xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c | 8 | ||||
-rw-r--r-- | xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c | 18 | ||||
-rw-r--r-- | xenolinux-2.4.16-sparse/arch/xeno/mm/init.c | 30 | ||||
-rw-r--r-- | xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h | 8 | ||||
-rw-r--r-- | xenolinux-2.4.16-sparse/include/asm-xeno/page.h | 25 |
7 files changed, 71 insertions, 39 deletions
diff --git a/xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S b/xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S index f05ebc7b6f..86a82b13dc 100644 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/head.S @@ -10,8 +10,8 @@ /* Offsets in start_info structure */ #define SHARED_INFO 4 -#define MOD_START 16 -#define MOD_LEN 20 +#define MOD_START 12 +#define MOD_LEN 16 startup_32: cld diff --git a/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c b/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c index 3bcb6dbdb4..979deacf5a 100644 --- a/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c +++ b/xenolinux-2.4.16-sparse/arch/xeno/kernel/setup.c @@ -46,6 +46,8 @@ shared_info_t *HYPERVISOR_shared_info; +unsigned long *phys_to_machine_mapping; + /* * Machine setup.. */ @@ -143,6 +145,7 @@ void __init setup_arch(char **cmdline_p) { unsigned long start_pfn, max_pfn, max_low_pfn; unsigned long bootmap_size; + unsigned long i; extern void hypervisor_callback(void); extern void failsafe_callback(void); @@ -254,12 +257,24 @@ void __init setup_arch(char **cmdline_p) { unsigned long pgde = *pgd++; if ( !(pgde & 1) ) continue; - pte = (pgde & PAGE_MASK) - start_info.phys_base; + pte = machine_to_phys(pgde & PAGE_MASK); reserve_bootmem(pte, PAGE_SIZE); } } cur_pgd = init_mm.pgd = (pgd_t *)start_info.pt_base; + /* Now initialise the physical->machine mapping table. */ + phys_to_machine_mapping = alloc_bootmem(max_pfn * sizeof(unsigned long)); + for ( i = 0; i < max_pfn; i++ ) + { + unsigned long pgde, *ppte; + unsigned long pfn = i + (PAGE_OFFSET >> PAGE_SHIFT); + pgde = *((unsigned long *)start_info.pt_base + (pfn >> 10)); + ppte = (unsigned long *)machine_to_phys(pgde & PAGE_MASK) + (pfn&1023); + phys_to_machine_mapping[i] = + (*(unsigned long *)__va(ppte)) >> PAGE_SHIFT; + } + #ifdef CONFIG_BLK_DEV_INITRD if (start_info.mod_start) { if ((__pa(start_info.mod_start) + start_info.mod_len) <= diff --git a/xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c b/xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c index c2cd7262e9..41d966901a 100644 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/fault.c @@ -314,14 +314,14 @@ no_context: printk(" printing eip:\n"); printk("%08lx\n", regs->eip); page = ((unsigned long *) cur_pgd)[address >> 22]; - printk(KERN_ALERT "*pde = %08lx(%08lx)\n", page, page - start_info.phys_base); + printk(KERN_ALERT "*pde=%08lx(%08lx)\n", page, machine_to_phys(page)); if (page & 1) { page &= PAGE_MASK; address &= 0x003ff000; - page -= start_info.phys_base; + page = machine_to_phys(page); page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT]; - printk(KERN_ALERT "*pte = %08lx(%08lx)\n", page, - page - start_info.phys_base); + printk(KERN_ALERT "*pte=%08lx(%08lx)\n", page, + machine_to_phys(page)); } die("Oops", regs, error_code); bust_spinlocks(0); diff --git a/xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c b/xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c index 7e33eaa53e..b051684aa2 100644 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/hypervisor.c @@ -31,7 +31,7 @@ static void DEBUG_allow_pt_reads(void) pte = update_debug_queue[i].ptep; if ( pte == NULL ) continue; update_debug_queue[i].ptep = NULL; - update.ptr = __pa(pte) + start_info.phys_base; + update.ptr = phys_to_machine(__pa(pte)); update.val = update_debug_queue[i].pteval; HYPERVISOR_pt_update(&update, 1); } @@ -51,7 +51,7 @@ static void DEBUG_disallow_pt_read(unsigned long pa) pgd = pgd_offset_k(va); pmd = pmd_offset(pgd, va); pte = pte_offset(pmd, va); - update.ptr = __pa(pte) + start_info.phys_base; + update.ptr = phys_to_machine(__pa(pte)); pteval = *(unsigned long *)pte; update.val = pteval & ~_PAGE_PRESENT; HYPERVISOR_pt_update(&update, 1); @@ -100,21 +100,21 @@ void queue_l1_entry_update(unsigned long ptr, unsigned long val) #if PT_UPDATE_DEBUG > 0 DEBUG_disallow_pt_read(ptr); #endif - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].val = val; increment_index(); } void queue_l2_entry_update(unsigned long ptr, unsigned long val) { - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].val = val; increment_index(); } void queue_pt_switch(unsigned long ptr) { - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND; update_queue[idx].val = PGEXT_NEW_BASEPTR; increment_index(); @@ -137,7 +137,7 @@ void queue_invlpg(unsigned long ptr) void queue_pgd_pin(unsigned long ptr) { - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND; update_queue[idx].val = PGEXT_PIN_L2_TABLE; increment_index(); @@ -145,7 +145,7 @@ void queue_pgd_pin(unsigned long ptr) void queue_pgd_unpin(unsigned long ptr) { - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND; update_queue[idx].val = PGEXT_UNPIN_TABLE; increment_index(); @@ -153,7 +153,7 @@ void queue_pgd_unpin(unsigned long ptr) void queue_pte_pin(unsigned long ptr) { - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND; update_queue[idx].val = PGEXT_PIN_L1_TABLE; increment_index(); @@ -161,7 +161,7 @@ void queue_pte_pin(unsigned long ptr) void queue_pte_unpin(unsigned long ptr) { - update_queue[idx].ptr = ptr + start_info.phys_base; + update_queue[idx].ptr = phys_to_machine(ptr); update_queue[idx].ptr |= PGREQ_EXTENDED_COMMAND; update_queue[idx].val = PGEXT_UNPIN_TABLE; increment_index(); diff --git a/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c b/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c index de06252e04..b1e75a6bcf 100644 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/init.c @@ -126,23 +126,23 @@ static inline void set_pte_phys (unsigned long vaddr, void __init paging_init(void) { + unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0}; + unsigned int max_dma, high, low; + + max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; + low = max_low_pfn; + high = highend_pfn; + + if (low < max_dma) { - unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0}; - unsigned int max_dma, high, low; - - max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; - low = max_low_pfn; - high = highend_pfn; - - if (low < max_dma) - zones_size[ZONE_DMA] = low; - else { - zones_size[ZONE_DMA] = max_dma; - zones_size[ZONE_NORMAL] = low - max_dma; - } - free_area_init(zones_size); + zones_size[ZONE_DMA] = low; } - return; + else + { + zones_size[ZONE_DMA] = max_dma; + zones_size[ZONE_NORMAL] = low - max_dma; + } + free_area_init(zones_size); } diff --git a/xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h b/xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h index 640c3a958e..e6b2c13024 100644 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/hypervisor.h @@ -27,8 +27,8 @@ void do_hypervisor_callback(struct pt_regs *regs); /* arch/xeno/mm/hypervisor.c */ /* - * NB. ptr values should be fake-physical. 'vals' should be already - * fully adjusted (ie. for start_info.phys_base). + * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already + * be MACHINE addresses. */ extern unsigned int pt_update_queue_idx; @@ -77,7 +77,7 @@ extern page_update_debug_t update_debug_queue[]; update_debug_queue[pt_update_queue_idx].line = __LINE__; \ update_debug_queue[pt_update_queue_idx].file = __FILE__; \ printk("L1 %s %d: %08lx (%08lx -> %08lx)\n", __FILE__, __LINE__, \ - (_p)+start_info.phys_base, *(unsigned long *)__va(_p), \ + phys_to_machine(_p), *(unsigned long *)__va(_p), \ (unsigned long)(_v)); \ queue_l1_entry_update((_p),(_v)); \ }) @@ -87,7 +87,7 @@ extern page_update_debug_t update_debug_queue[]; update_debug_queue[pt_update_queue_idx].line = __LINE__; \ update_debug_queue[pt_update_queue_idx].file = __FILE__; \ printk("L2 %s %d: %08lx (%08lx -> %08lx)\n", __FILE__, __LINE__, \ - (_p)+start_info.phys_base, *(unsigned long *)__va(_p), \ + phys_to_machine(_p), *(unsigned long *)__va(_p), \ (unsigned long)(_v)); \ queue_l2_entry_update((_p),(_v)); \ }) diff --git a/xenolinux-2.4.16-sparse/include/asm-xeno/page.h b/xenolinux-2.4.16-sparse/include/asm-xeno/page.h index 74c8824f94..ae2aa28b11 100644 --- a/xenolinux-2.4.16-sparse/include/asm-xeno/page.h +++ b/xenolinux-2.4.16-sparse/include/asm-xeno/page.h @@ -34,6 +34,23 @@ #define clear_user_page(page, vaddr) clear_page(page) #define copy_user_page(to, from, vaddr) copy_page(to, from) +/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/ +extern unsigned long *phys_to_machine_mapping; +#define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)]) +#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)]) +static inline unsigned long phys_to_machine(unsigned long phys) +{ + unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT); + machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK); + return machine; +} +static inline unsigned long machine_to_phys(unsigned long machine) +{ + unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT); + phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK); + return phys; +} + /* * These are used to make use of C type-checking.. */ @@ -49,7 +66,7 @@ typedef struct { unsigned long pgd; } pgd_t; static inline unsigned long pte_val(pte_t x) { unsigned long ret = x.pte_low; - if ( (ret & 1) ) ret -= start_info.phys_base; + if ( (ret & 1) ) ret = machine_to_phys(ret); return ret; } #endif @@ -60,7 +77,7 @@ typedef struct { unsigned long pgprot; } pgprot_t; static inline unsigned long pmd_val(pmd_t x) { unsigned long ret = x.pmd; - if ( (ret & 1) ) ret -= start_info.phys_base; + if ( (ret & 1) ) ret = machine_to_phys(ret); return ret; } #define pgd_val(x) ({ BUG(); (unsigned long)0; }) @@ -68,12 +85,12 @@ static inline unsigned long pmd_val(pmd_t x) static inline pte_t __pte(unsigned long x) { - if ( (x & 1) ) x += start_info.phys_base; + if ( (x & 1) ) x = phys_to_machine(x); return ((pte_t) { (x) }); } static inline pmd_t __pmd(unsigned long x) { - if ( (x & 1) ) x += start_info.phys_base; + if ( (x & 1) ) x = phys_to_machine(x); return ((pmd_t) { (x) }); } #define __pgd(x) ({ BUG(); (pgprot_t) { 0 }; }) |