ia64/xen-unstable

changeset 2439:aed97013f9fe

bitkeeper revision 1.1159.1.124 (413c80f8x6TVGW53WE2vlecpb4z_KA)

Avoid warning message when validating a linear pagedirectory mapping.
author cl349@freefall.cl.cam.ac.uk
date Mon Sep 06 15:23:36 2004 +0000 (2004-09-06)
parents b3a8b4facc8f f084fe1dc76b
children 25e6d3dde54a
files .rootkeys BitKeeper/etc/logging_ok linux-2.4.27-xen-sparse/arch/xen/kernel/time.c linux-2.4.27-xen-sparse/include/asm-xen/pgalloc.h linux-2.6.8.1-patches/agpgart.patch linux-2.6.8.1-patches/drm.patch linux-2.6.8.1-xen-sparse/arch/xen/Kconfig linux-2.6.8.1-xen-sparse/arch/xen/Kconfig.drivers linux-2.6.8.1-xen-sparse/arch/xen/configs/xen0_defconfig linux-2.6.8.1-xen-sparse/arch/xen/configs/xenU_defconfig linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/cpu/common.c linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/Makefile linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/hypervisor.c linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/init.c linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pageattr.c linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_post.h linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/pgalloc.h linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/system.h linux-2.6.8.1-xen-sparse/include/asm-xen/hypervisor.h tools/libxc/xc_linux_build.c tools/libxc/xc_linux_restore.c tools/libxc/xc_netbsd_build.c tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/messages.py tools/python/xen/xend/server/netif.py tools/python/xen/xend/server/params.py tools/python/xen/xm/main.py tools/xfrd/xen_domain.c tools/xfrd/xfrd.c xen/arch/x86/domain.c xen/arch/x86/memory.c xen/arch/x86/shadow.c xen/arch/x86/traps.c xen/common/dom0_ops.c xen/common/dom_mem_ops.c xen/common/domain.c xen/common/page_alloc.c xen/common/schedule.c xen/include/asm-x86/mm.h xen/include/hypervisor-ifs/dom0_ops.h xen/include/hypervisor-ifs/hypervisor-if.h xen/include/hypervisor-ifs/io/domain_controller.h
line diff
     1.1 --- a/.rootkeys	Fri Sep 03 10:57:00 2004 +0000
     1.2 +++ b/.rootkeys	Mon Sep 06 15:23:36 2004 +0000
     1.3 @@ -126,6 +126,8 @@ 3e5a4e681xMPdF9xCMwpyfuYMySU5g linux-2.4
     1.4  409ba2e7akOFqQUg6Qyg2s28xcXiMg linux-2.4.27-xen-sparse/mm/page_alloc.c
     1.5  3e5a4e683HKVU-sxtagrDasRB8eBVw linux-2.4.27-xen-sparse/mm/swapfile.c
     1.6  41180721bNns9Na7w1nJ0ZVt8bhUNA linux-2.4.27-xen-sparse/mm/vmalloc.c
     1.7 +413aa1d0oNP8HXLvfPuMe6cSroUfSA linux-2.6.8.1-patches/agpgart.patch
     1.8 +413aa1d0ewvSv-ohnNnQQNGsbPTTNA linux-2.6.8.1-patches/drm.patch
     1.9  40f562372u3A7_kfbYYixPHJJxYUxA linux-2.6.8.1-xen-sparse/arch/xen/Kconfig
    1.10  40f56237utH41NPukqHksuNf29IC9A linux-2.6.8.1-xen-sparse/arch/xen/Kconfig.drivers
    1.11  40f56237penAAlWVBVDpeQZNFIg8CA linux-2.6.8.1-xen-sparse/arch/xen/Makefile
    1.12 @@ -161,6 +163,7 @@ 4118cc35CbY8rfGVspF5O-7EkXBEAA linux-2.6
    1.13  40f562383SKvDStdtrvzr5fyCbW4rw linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/hypervisor.c
    1.14  40f56239xcNylAxuGsQHwi1AyMLV8w linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/init.c
    1.15  41062ab7CjxC1UBaFhOMWWdhHkIUyg linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c
    1.16 +413b5ab8LIowAnQrEmaOJSdmqm96jQ linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pageattr.c
    1.17  40f5623906UYHv1rsVUeRc0tFT0dWw linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pgtable.c
    1.18  4107adf12ndy94MidCaivDibJ3pPAg linux-2.6.8.1-xen-sparse/arch/xen/i386/pci/Makefile
    1.19  4107adf1WcCgkhsdLTRGX52cOG1vJg linux-2.6.8.1-xen-sparse/arch/xen/i386/pci/direct.c
     2.1 --- a/BitKeeper/etc/logging_ok	Fri Sep 03 10:57:00 2004 +0000
     2.2 +++ b/BitKeeper/etc/logging_ok	Mon Sep 06 15:23:36 2004 +0000
     2.3 @@ -19,6 +19,7 @@ iap10@striker.cl.cam.ac.uk
     2.4  iap10@tetris.cl.cam.ac.uk
     2.5  jws22@gauntlet.cl.cam.ac.uk
     2.6  jws@cairnwell.research
     2.7 +kaf24@camelot.eng.3leafnetworks.com
     2.8  kaf24@freefall.cl.cam.ac.uk
     2.9  kaf24@labyrinth.cl.cam.ac.uk
    2.10  kaf24@penguin.local
     3.1 --- a/linux-2.4.27-xen-sparse/arch/xen/kernel/time.c	Fri Sep 03 10:57:00 2004 +0000
     3.2 +++ b/linux-2.4.27-xen-sparse/arch/xen/kernel/time.c	Mon Sep 06 15:23:36 2004 +0000
     3.3 @@ -604,12 +604,15 @@ static struct irqaction dbg_time = {
     3.4  void __init time_init(void)
     3.5  {
     3.6      unsigned long long alarm;
     3.7 -    u64 __cpu_khz, cpu_freq, scale, scale2;
     3.8 +    u64 __cpu_khz, __cpu_ghz, cpu_freq, scale, scale2;
     3.9      unsigned int cpu_ghz;
    3.10  
    3.11 -    __cpu_khz = HYPERVISOR_shared_info->cpu_freq;
    3.12 -    do_div(__cpu_khz, 1000);
    3.13 +    __cpu_khz = __cpu_ghz = cpu_freq = HYPERVISOR_shared_info->cpu_freq;
    3.14 +    do_div(__cpu_khz, 1000UL);
    3.15      cpu_khz = (u32)__cpu_khz;
    3.16 +    do_div(__cpu_ghz, 1000000000UL);
    3.17 +    cpu_ghz = (unsigned int)__cpu_ghz;
    3.18 +
    3.19      printk("Xen reported: %lu.%03lu MHz processor.\n", 
    3.20             cpu_khz / 1000, cpu_khz % 1000);
    3.21  
    3.22 @@ -617,9 +620,6 @@ void __init time_init(void)
    3.23      xtime.tv_usec = HYPERVISOR_shared_info->wc_usec;
    3.24      processed_system_time = shadow_system_time;
    3.25  
    3.26 -    cpu_freq = HYPERVISOR_shared_info->cpu_freq;
    3.27 -
    3.28 -    cpu_ghz = do_div(cpu_freq, 1000000000UL);
    3.29      for ( rdtsc_bitshift = 0; cpu_ghz != 0; rdtsc_bitshift++, cpu_ghz >>= 1 )
    3.30          continue;
    3.31  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/linux-2.6.8.1-patches/agpgart.patch	Mon Sep 06 15:23:36 2004 +0000
     5.3 @@ -0,0 +1,346 @@
     5.4 +--- linux-2.6.8.1/drivers/char/agp/ali-agp.c	2004-08-14 11:55:35.000000000 +0100
     5.5 ++++ linux-2.6.8.1-xen0/drivers/char/agp/ali-agp.c	2004-09-05 05:55:58.876495340 +0100
     5.6 +@@ -150,7 +150,7 @@
     5.7 + 	pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
     5.8 + 	pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
     5.9 + 			(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
    5.10 +-			  virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN ));
    5.11 ++			  virt_to_bus(addr)) | ALI_CACHE_FLUSH_EN ));
    5.12 + 	return addr;
    5.13 + }
    5.14 + 
    5.15 +@@ -174,7 +174,7 @@
    5.16 + 	pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
    5.17 + 	pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
    5.18 + 			(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
    5.19 +-			  virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN));
    5.20 ++			  virt_to_bus(addr)) | ALI_CACHE_FLUSH_EN));
    5.21 + 	agp_generic_destroy_page(addr);
    5.22 + }
    5.23 + 
    5.24 +--- linux-2.6.8.1/drivers/char/agp/amd-k7-agp.c	2004-08-14 11:56:24.000000000 +0100
    5.25 ++++ linux-2.6.8.1-xen0/drivers/char/agp/amd-k7-agp.c	2004-09-05 05:55:58.877495108 +0100
    5.26 +@@ -43,7 +43,7 @@
    5.27 + 
    5.28 + 	SetPageReserved(virt_to_page(page_map->real));
    5.29 + 	global_cache_flush();
    5.30 +-	page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
    5.31 ++	page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real),
    5.32 + 					    PAGE_SIZE);
    5.33 + 	if (page_map->remapped == NULL) {
    5.34 + 		ClearPageReserved(virt_to_page(page_map->real));
    5.35 +@@ -152,7 +152,7 @@
    5.36 + 
    5.37 + 	agp_bridge->gatt_table_real = (u32 *)page_dir.real;
    5.38 + 	agp_bridge->gatt_table = (u32 *)page_dir.remapped;
    5.39 +-	agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
    5.40 ++	agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real);
    5.41 + 
    5.42 + 	/* Get the address for the gart region.
    5.43 + 	 * This is a bus address even on the alpha, b/c its
    5.44 +@@ -166,7 +166,7 @@
    5.45 + 	/* Calculate the agp offset */
    5.46 + 	for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
    5.47 + 		page_dir.remapped[GET_PAGE_DIR_OFF(addr)] =
    5.48 +-			virt_to_phys(amd_irongate_private.gatt_pages[i]->real);
    5.49 ++			virt_to_bus(amd_irongate_private.gatt_pages[i]->real);
    5.50 + 		page_dir.remapped[GET_PAGE_DIR_OFF(addr)] |= 0x00000001;
    5.51 + 	}
    5.52 + 
    5.53 +--- linux-2.6.8.1/drivers/char/agp/amd64-agp.c	2004-08-14 11:55:47.000000000 +0100
    5.54 ++++ linux-2.6.8.1-xen0/drivers/char/agp/amd64-agp.c	2004-09-05 05:55:58.877495108 +0100
    5.55 +@@ -212,7 +212,7 @@
    5.56 + 
    5.57 + static int amd_8151_configure(void)
    5.58 + {
    5.59 +-	unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real);
    5.60 ++	unsigned long gatt_bus = virt_to_bus(agp_bridge->gatt_table_real);
    5.61 + 
    5.62 + 	/* Configure AGP regs in each x86-64 host bridge. */
    5.63 + 	for_each_nb() {
    5.64 +@@ -521,7 +521,7 @@
    5.65 + {
    5.66 + 	struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
    5.67 + 
    5.68 +-	release_mem_region(virt_to_phys(bridge->gatt_table_real),
    5.69 ++	release_mem_region(virt_to_bus(bridge->gatt_table_real),
    5.70 + 			   amd64_aperture_sizes[bridge->aperture_size_idx].size);
    5.71 + 	agp_remove_bridge(bridge);
    5.72 + 	agp_put_bridge(bridge);
    5.73 +--- linux-2.6.8.1/drivers/char/agp/ati-agp.c	2004-08-14 11:55:48.000000000 +0100
    5.74 ++++ linux-2.6.8.1-xen0/drivers/char/agp/ati-agp.c	2004-09-05 05:55:58.877495108 +0100
    5.75 +@@ -64,7 +64,7 @@
    5.76 + 
    5.77 + 	/* CACHE_FLUSH(); */
    5.78 + 	global_cache_flush();
    5.79 +-	page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
    5.80 ++	page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real),
    5.81 + 					    PAGE_SIZE);
    5.82 + 	if (page_map->remapped == NULL || err) {
    5.83 + 		ClearPageReserved(virt_to_page(page_map->real));
    5.84 +--- linux-2.6.8.1/drivers/char/agp/backend.c	2004-08-14 11:55:47.000000000 +0100
    5.85 ++++ linux-2.6.8.1-xen0/drivers/char/agp/backend.c	2004-09-05 05:55:58.878494876 +0100
    5.86 +@@ -142,7 +142,7 @@
    5.87 + 			return -ENOMEM;
    5.88 + 		}
    5.89 + 
    5.90 +-		bridge->scratch_page_real = virt_to_phys(addr);
    5.91 ++		bridge->scratch_page_real = virt_to_bus(addr);
    5.92 + 		bridge->scratch_page =
    5.93 + 		    bridge->driver->mask_memory(bridge->scratch_page_real, 0);
    5.94 + 	}
    5.95 +@@ -186,7 +186,7 @@
    5.96 + err_out:
    5.97 + 	if (bridge->driver->needs_scratch_page)
    5.98 + 		bridge->driver->agp_destroy_page(
    5.99 +-				phys_to_virt(bridge->scratch_page_real));
   5.100 ++				bus_to_virt(bridge->scratch_page_real));
   5.101 + 	if (got_gatt)
   5.102 + 		bridge->driver->free_gatt_table();
   5.103 + 	if (got_keylist) {
   5.104 +@@ -211,7 +211,7 @@
   5.105 + 	if (bridge->driver->agp_destroy_page &&
   5.106 + 	    bridge->driver->needs_scratch_page)
   5.107 + 		bridge->driver->agp_destroy_page(
   5.108 +-				phys_to_virt(bridge->scratch_page_real));
   5.109 ++				bus_to_virt(bridge->scratch_page_real));
   5.110 + }
   5.111 + 
   5.112 + static const drm_agp_t drm_agp = {
   5.113 +--- linux-2.6.8.1/drivers/char/agp/generic.c	2004-08-14 11:55:10.000000000 +0100
   5.114 ++++ linux-2.6.8.1-xen0/drivers/char/agp/generic.c	2004-09-05 05:55:58.879494644 +0100
   5.115 +@@ -127,7 +127,7 @@
   5.116 + 	}
   5.117 + 	if (curr->page_count != 0) {
   5.118 + 		for (i = 0; i < curr->page_count; i++) {
   5.119 +-			agp_bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[i]));
   5.120 ++			agp_bridge->driver->agp_destroy_page(bus_to_virt(curr->memory[i]));
   5.121 + 		}
   5.122 + 	}
   5.123 + 	agp_free_key(curr->key);
   5.124 +@@ -181,7 +181,7 @@
   5.125 + 			return NULL;
   5.126 + 		}
   5.127 + 		new->memory[i] =
   5.128 +-			agp_bridge->driver->mask_memory(virt_to_phys(addr), type);
   5.129 ++			agp_bridge->driver->mask_memory(virt_to_bus(addr), type);
   5.130 + 		new->page_count++;
   5.131 + 	}
   5.132 + 
   5.133 +@@ -636,6 +636,7 @@
   5.134 + 	int i;
   5.135 + 	void *temp;
   5.136 + 	struct page *page;
   5.137 ++	dma_addr_t dma;
   5.138 + 
   5.139 + 	/* The generic routines can't handle 2 level gatt's */
   5.140 + 	if (agp_bridge->driver->size_type == LVL2_APER_SIZE)
   5.141 +@@ -674,8 +675,10 @@
   5.142 + 				break;
   5.143 + 			}
   5.144 + 
   5.145 +-			table = (char *) __get_free_pages(GFP_KERNEL,
   5.146 +-							  page_order);
   5.147 ++			table = dma_alloc_coherent(
   5.148 ++					&agp_bridge->dev->dev,
   5.149 ++					PAGE_SIZE << page_order, &dma,
   5.150 ++					GFP_KERNEL);
   5.151 + 
   5.152 + 			if (table == NULL) {
   5.153 + 				i++;
   5.154 +@@ -706,7 +709,9 @@
   5.155 + 		size = ((struct aper_size_info_fixed *) temp)->size;
   5.156 + 		page_order = ((struct aper_size_info_fixed *) temp)->page_order;
   5.157 + 		num_entries = ((struct aper_size_info_fixed *) temp)->num_entries;
   5.158 +-		table = (char *) __get_free_pages(GFP_KERNEL, page_order);
   5.159 ++		table = dma_alloc_coherent(
   5.160 ++				&agp_bridge->dev->dev,
   5.161 ++				PAGE_SIZE << page_order, &dma, GFP_KERNEL);
   5.162 + 	}
   5.163 + 
   5.164 + 	if (table == NULL)
   5.165 +@@ -721,7 +726,7 @@
   5.166 + 	agp_gatt_table = (void *)table;
   5.167 + 
   5.168 + 	agp_bridge->driver->cache_flush();
   5.169 +-	agp_bridge->gatt_table = ioremap_nocache(virt_to_phys(table),
   5.170 ++	agp_bridge->gatt_table = ioremap_nocache(virt_to_bus(table),
   5.171 + 					(PAGE_SIZE * (1 << page_order)));
   5.172 + 	agp_bridge->driver->cache_flush();
   5.173 + 
   5.174 +@@ -729,11 +734,12 @@
   5.175 + 		for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
   5.176 + 			ClearPageReserved(page);
   5.177 + 
   5.178 +-		free_pages((unsigned long) table, page_order);
   5.179 ++		dma_free_coherent(&agp_bridge->dev->dev, PAGE_SIZE<<page_order,
   5.180 ++					table, dma);
   5.181 + 
   5.182 + 		return -ENOMEM;
   5.183 + 	}
   5.184 +-	agp_bridge->gatt_bus_addr = virt_to_phys(agp_bridge->gatt_table_real);
   5.185 ++	agp_bridge->gatt_bus_addr = virt_to_bus(table);
   5.186 + 
   5.187 + 	/* AK: bogus, should encode addresses > 4GB */
   5.188 + 	for (i = 0; i < num_entries; i++)
   5.189 +@@ -785,7 +791,8 @@
   5.190 + 	for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
   5.191 + 		ClearPageReserved(page);
   5.192 + 
   5.193 +-	free_pages((unsigned long) agp_bridge->gatt_table_real, page_order);
   5.194 ++	dma_free_coherent(&agp_bridge->dev->dev, PAGE_SIZE<<page_order,
   5.195 ++		agp_bridge->gatt_table_real, agp_bridge->gatt_bus_addr);
   5.196 + 
   5.197 + 	agp_gatt_table = NULL;
   5.198 + 	agp_bridge->gatt_table = NULL;
   5.199 +--- linux-2.6.8.1/drivers/char/agp/hp-agp.c	2004-08-14 11:55:59.000000000 +0100
   5.200 ++++ linux-2.6.8.1-xen0/drivers/char/agp/hp-agp.c	2004-09-05 05:55:58.879494644 +0100
   5.201 +@@ -110,7 +110,7 @@
   5.202 + 	hp->gart_size = HP_ZX1_GART_SIZE;
   5.203 + 	hp->gatt_entries = hp->gart_size / hp->io_page_size;
   5.204 + 
   5.205 +-	hp->io_pdir = phys_to_virt(INREG64(hp->ioc_regs, HP_ZX1_PDIR_BASE));
   5.206 ++	hp->io_pdir = bus_to_virt(INREG64(hp->ioc_regs, HP_ZX1_PDIR_BASE));
   5.207 + 	hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)];
   5.208 + 
   5.209 + 	if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
   5.210 +@@ -248,7 +248,7 @@
   5.211 + 	agp_bridge->mode = INREG32(hp->lba_regs, hp->lba_cap_offset + PCI_AGP_STATUS);
   5.212 + 
   5.213 + 	if (hp->io_pdir_owner) {
   5.214 +-		OUTREG64(hp->ioc_regs, HP_ZX1_PDIR_BASE, virt_to_phys(hp->io_pdir));
   5.215 ++		OUTREG64(hp->ioc_regs, HP_ZX1_PDIR_BASE, virt_to_bus(hp->io_pdir));
   5.216 + 		OUTREG64(hp->ioc_regs, HP_ZX1_TCNFG, hp->io_tlb_ps);
   5.217 + 		OUTREG64(hp->ioc_regs, HP_ZX1_IMASK, ~(HP_ZX1_IOVA_SIZE - 1));
   5.218 + 		OUTREG64(hp->ioc_regs, HP_ZX1_IBASE, hp->iova_base | 0x1);
   5.219 +--- linux-2.6.8.1/drivers/char/agp/i460-agp.c	2004-08-14 11:55:34.000000000 +0100
   5.220 ++++ linux-2.6.8.1-xen0/drivers/char/agp/i460-agp.c	2004-09-05 05:55:58.879494644 +0100
   5.221 +@@ -371,7 +371,7 @@
   5.222 + 	}
   5.223 + 	memset(lp->alloced_map, 0, map_size);
   5.224 + 
   5.225 +-	lp->paddr = virt_to_phys(lpage);
   5.226 ++	lp->paddr = virt_to_bus(lpage);
   5.227 + 	lp->refcount = 0;
   5.228 + 	atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
   5.229 + 	return 0;
   5.230 +@@ -382,7 +382,7 @@
   5.231 + 	kfree(lp->alloced_map);
   5.232 + 	lp->alloced_map = NULL;
   5.233 + 
   5.234 +-	free_pages((unsigned long) phys_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
   5.235 ++	free_pages((unsigned long) bus_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
   5.236 + 	atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
   5.237 + }
   5.238 + 
   5.239 +--- linux-2.6.8.1/drivers/char/agp/intel-agp.c	2004-08-14 11:55:32.000000000 +0100
   5.240 ++++ linux-2.6.8.1-xen0/drivers/char/agp/intel-agp.c	2004-09-05 05:55:58.880494412 +0100
   5.241 +@@ -285,7 +285,7 @@
   5.242 + 	if (new == NULL)
   5.243 + 		return NULL;
   5.244 + 
   5.245 +-	new->memory[0] = virt_to_phys(addr);
   5.246 ++	new->memory[0] = virt_to_bus(addr);
   5.247 + 	if (pg_count == 4) {
   5.248 + 		/* kludge to get 4 physical pages for ARGB cursor */
   5.249 + 		new->memory[1] = new->memory[0] + PAGE_SIZE;
   5.250 +@@ -328,10 +328,10 @@
   5.251 + 	agp_free_key(curr->key);
   5.252 + 	if(curr->type == AGP_PHYS_MEMORY) {
   5.253 + 		if (curr->page_count == 4)
   5.254 +-			i8xx_destroy_pages(phys_to_virt(curr->memory[0]));
   5.255 ++			i8xx_destroy_pages(bus_to_virt(curr->memory[0]));
   5.256 + 		else
   5.257 + 	   		agp_bridge->driver->agp_destroy_page(
   5.258 +-				 phys_to_virt(curr->memory[0]));
   5.259 ++				 bus_to_virt(curr->memory[0]));
   5.260 + 		vfree(curr->memory);
   5.261 + 	}
   5.262 + 	kfree(curr);
   5.263 +--- linux-2.6.8.1/drivers/char/agp/intel-mch-agp.c	2004-08-14 11:54:49.000000000 +0100
   5.264 ++++ linux-2.6.8.1-xen0/drivers/char/agp/intel-mch-agp.c	2004-09-05 05:55:58.880494412 +0100
   5.265 +@@ -51,7 +51,7 @@
   5.266 + 	if (new == NULL)
   5.267 + 		return NULL;
   5.268 + 
   5.269 +-	new->memory[0] = agp_bridge->driver->mask_memory(virt_to_phys(addr), type);
   5.270 ++	new->memory[0] = agp_bridge->driver->mask_memory(virt_to_bus(addr), type);
   5.271 + 	new->page_count = 1;
   5.272 + 	new->num_scratch_pages = 1;
   5.273 + 	new->type = AGP_PHYS_MEMORY;
   5.274 +@@ -63,7 +63,7 @@
   5.275 + {
   5.276 + 	agp_free_key(curr->key);
   5.277 + 	if(curr->type == AGP_PHYS_MEMORY) {
   5.278 +-		agp_bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[0]));
   5.279 ++		agp_bridge->driver->agp_destroy_page(bus_to_virt(curr->memory[0]));
   5.280 + 		vfree(curr->memory);
   5.281 + 	}
   5.282 + 	kfree(curr);
   5.283 +--- linux-2.6.8.1/drivers/char/agp/sworks-agp.c	2004-08-14 11:55:10.000000000 +0100
   5.284 ++++ linux-2.6.8.1-xen0/drivers/char/agp/sworks-agp.c	2004-09-05 05:55:58.881494180 +0100
   5.285 +@@ -51,7 +51,7 @@
   5.286 + 	}
   5.287 + 	SetPageReserved(virt_to_page(page_map->real));
   5.288 + 	global_cache_flush();
   5.289 +-	page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), 
   5.290 ++	page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real), 
   5.291 + 					    PAGE_SIZE);
   5.292 + 	if (page_map->remapped == NULL) {
   5.293 + 		ClearPageReserved(virt_to_page(page_map->real));
   5.294 +@@ -164,7 +164,7 @@
   5.295 + 	for(i = 0; i < 1024; i++) {
   5.296 + 		serverworks_private.scratch_dir.remapped[i] = (unsigned long) agp_bridge->scratch_page;
   5.297 + 		page_dir.remapped[i] =
   5.298 +-			virt_to_phys(serverworks_private.scratch_dir.real);
   5.299 ++			virt_to_bus(serverworks_private.scratch_dir.real);
   5.300 + 		page_dir.remapped[i] |= 0x00000001;
   5.301 + 	}
   5.302 + 
   5.303 +@@ -177,7 +177,7 @@
   5.304 + 
   5.305 + 	agp_bridge->gatt_table_real = (u32 *)page_dir.real;
   5.306 + 	agp_bridge->gatt_table = (u32 *)page_dir.remapped;
   5.307 +-	agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
   5.308 ++	agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real);
   5.309 + 
   5.310 + 	/* Get the address for the gart region.
   5.311 + 	 * This is a bus address even on the alpha, b/c its
   5.312 +@@ -191,7 +191,7 @@
   5.313 + 
   5.314 + 	for(i = 0; i < value->num_entries / 1024; i++) {
   5.315 + 		page_dir.remapped[i] =
   5.316 +-			virt_to_phys(serverworks_private.gatt_pages[i]->real);
   5.317 ++			virt_to_bus(serverworks_private.gatt_pages[i]->real);
   5.318 + 		page_dir.remapped[i] |= 0x00000001;
   5.319 + 	}
   5.320 + 
   5.321 +--- linux-2.6.8.1/drivers/char/agp/uninorth-agp.c	2004-08-14 11:55:32.000000000 +0100
   5.322 ++++ linux-2.6.8.1-xen0/drivers/char/agp/uninorth-agp.c	2004-09-05 05:55:58.881494180 +0100
   5.323 +@@ -200,7 +200,7 @@
   5.324 + 
   5.325 + 	agp_bridge->gatt_table_real = (u32 *) table;
   5.326 + 	agp_bridge->gatt_table = (u32 *)table;
   5.327 +-	agp_bridge->gatt_bus_addr = virt_to_phys(table);
   5.328 ++	agp_bridge->gatt_bus_addr = virt_to_bus(table);
   5.329 + 
   5.330 + 	for (i = 0; i < num_entries; i++) {
   5.331 + 		agp_bridge->gatt_table[i] =
   5.332 +--- linux-2.6.8.1/include/asm-i386/agp.h	2004-08-14 11:54:47.000000000 +0100
   5.333 ++++ linux-2.6.8.1-xen0/include/asm-i386/agp.h	2004-09-05 05:57:26.040268956 +0100
   5.334 +@@ -3,6 +3,7 @@
   5.335 + 
   5.336 + #include <asm/pgtable.h>
   5.337 + #include <asm/cacheflush.h>
   5.338 ++#include <asm/system.h>
   5.339 + 
   5.340 + /* 
   5.341 +  * Functions to keep the agpgart mappings coherent with the MMU.
   5.342 +@@ -19,6 +20,6 @@
   5.343 + /* Could use CLFLUSH here if the cpu supports it. But then it would
   5.344 +    need to be called for each cacheline of the whole page so it may not be 
   5.345 +    worth it. Would need a page for it. */
   5.346 +-#define flush_agp_cache() asm volatile("wbinvd":::"memory")
   5.347 ++#define flush_agp_cache() wbinvd()
   5.348 + 
   5.349 + #endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/linux-2.6.8.1-patches/drm.patch	Mon Sep 06 15:23:36 2004 +0000
     6.3 @@ -0,0 +1,11 @@
     6.4 +--- linux-2.6.8.1/drivers/char/drm/ati_pcigart.h	2004-08-14 11:56:14.000000000 +0100
     6.5 ++++ linux-2.6.8.1-xen0/drivers/char/drm/ati_pcigart.h	2004-09-05 06:14:51.751782846 +0100
     6.6 +@@ -158,7 +158,7 @@
     6.7 + 	ret = 1;
     6.8 + 
     6.9 + #if defined(__i386__) || defined(__x86_64__)
    6.10 +-	asm volatile ( "wbinvd" ::: "memory" );
    6.11 ++	wbinvd();
    6.12 + #else
    6.13 + 	mb();
    6.14 + #endif
     7.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig	Fri Sep 03 10:57:00 2004 +0000
     7.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig	Mon Sep 06 15:23:36 2004 +0000
     7.3 @@ -26,13 +26,12 @@ menu "XEN"
     7.4  config XEN_PRIVILEGED_GUEST
     7.5  	bool "Privileged Guest (domain 0)"
     7.6  	default n
     7.7 +        select XEN_PHYSDEV_ACCESS
     7.8  	help
     7.9  	  Support for privileged operation (domain 0)
    7.10  
    7.11  config XEN_PHYSDEV_ACCESS
    7.12  	bool "Device-driver domain (physical device access)"
    7.13 -	default y if XEN_PRIVILEGED_GUEST
    7.14 -	default n
    7.15  	help
    7.16  	  Device-driver domain (physical device access)
    7.17  
     8.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig.drivers	Fri Sep 03 10:57:00 2004 +0000
     8.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig.drivers	Mon Sep 06 15:23:36 2004 +0000
     8.3 @@ -4,84 +4,52 @@ menu "Device Drivers"
     8.4  
     8.5  source "drivers/base/Kconfig"
     8.6  
     8.7 -source "drivers/scsi/Kconfig"
     8.8 +if XEN_PHYSDEV_ACCESS
     8.9 +source "drivers/mtd/Kconfig"
    8.10 +source "drivers/parport/Kconfig"
    8.11 +source "drivers/pnp/Kconfig"
    8.12 +endif
    8.13 +
    8.14  source "drivers/block/Kconfig"
    8.15 -source "drivers/md/Kconfig"
    8.16 -
    8.17 -# Always include scsi and block to enable iscsi, loop0 etc.
    8.18  
    8.19  if XEN_PHYSDEV_ACCESS
    8.20  source "drivers/ide/Kconfig"
    8.21 +endif
    8.22 +
    8.23 +source "drivers/scsi/Kconfig"
    8.24 +
    8.25 +if XEN_PHYSDEV_ACCESS
    8.26  source "drivers/cdrom/Kconfig"
    8.27  endif
    8.28  
    8.29 +source "drivers/md/Kconfig"
    8.30 +
    8.31 +if XEN_PHYSDEV_ACCESS
    8.32 +source "drivers/message/fusion/Kconfig"
    8.33 +source "drivers/ieee1394/Kconfig"
    8.34 +source "drivers/message/i2o/Kconfig"
    8.35 +endif
    8.36 +
    8.37  source "net/Kconfig"
    8.38  
    8.39 -if XEN_PRIVILEGED_GUEST
    8.40 +if XEN_PHYSDEV_ACCESS
    8.41 +source "drivers/isdn/Kconfig"
    8.42 +source "drivers/telephony/Kconfig"
    8.43  source "drivers/input/Kconfig"
    8.44 -endif
    8.45 -
    8.46 -config INPUT
    8.47 -	tristate "Input devices (needed for keyboard, mouse, ...)" if EMBEDDED
    8.48 -	default y
    8.49 -	---help---
    8.50 -	  Say Y here if you have any input device (mouse, keyboard, tablet,
    8.51 -	  joystick, steering wheel ...) connected to your system and want
    8.52 -	  it to be available to applications. This includes standard PS/2
    8.53 -	  keyboard and mouse.
    8.54 -
    8.55 -	  Say N here if you have a headless (no monitor, no keyboard) system.
    8.56 -
    8.57 -	  More information is available: <file:Documentation/input/input.txt>
    8.58 -
    8.59 -	  If unsure, say Y.
    8.60 -
    8.61 -	  To compile this driver as a module, choose M here: the
    8.62 -	  module will be called input.
    8.63 -
    8.64 -if XEN_PRIVILEGED_GUEST
    8.65  source "drivers/char/Kconfig"
    8.66 +source "drivers/i2c/Kconfig"
    8.67 +source "drivers/w1/Kconfig"
    8.68 +source "drivers/misc/Kconfig"
    8.69 +source "drivers/media/Kconfig"
    8.70 +source "drivers/video/Kconfig"
    8.71 +source "sound/Kconfig"
    8.72 +source "drivers/usb/Kconfig"
    8.73  endif
    8.74  
    8.75 +if !XEN_PHYSDEV_ACCESS
    8.76  config UNIX98_PTYS
    8.77 -	bool "Unix98 PTY support" if EMBEDDED
    8.78 +	bool
    8.79  	default y
    8.80 -	---help---
    8.81 -	  A pseudo terminal (PTY) is a software device consisting of two
    8.82 -	  halves: a master and a slave. The slave device behaves identical to
    8.83 -	  a physical terminal; the master device is used by a process to
    8.84 -	  read data from and write data to the slave, thereby emulating a
    8.85 -	  terminal. Typical programs for the master side are telnet servers
    8.86 -	  and xterms.
    8.87 -
    8.88 -	  Linux has traditionally used the BSD-like names /dev/ptyxx for
    8.89 -	  masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
    8.90 -	  has a number of problems. The GNU C library glibc 2.1 and later,
    8.91 -	  however, supports the Unix98 naming standard: in order to acquire a
    8.92 -	  pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
    8.93 -	  terminal is then made available to the process and the pseudo
    8.94 -	  terminal slave can be accessed as /dev/pts/<number>. What was
    8.95 -	  traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
    8.96 -
    8.97 -	  All modern Linux systems use the Unix98 ptys.  Say Y unless
    8.98 -	  you're on an embedded system and want to conserve memory.
    8.99 -
   8.100 -
   8.101 -if XEN_PHYSDEV_ACCESS
   8.102 -source "drivers/i2c/Kconfig"
   8.103 -source "drivers/video/Kconfig"
   8.104  endif
   8.105  
   8.106 -#config XEN_EVTCHN
   8.107 -#	bool "Xen Event Channel"
   8.108 -#	depends on XEN
   8.109 -#	default Y
   8.110 -#
   8.111 -#config XEN_CONSOLE
   8.112 -#	bool "Xen Console"
   8.113 -#	depends on XEN && XEN_EVTCHN
   8.114 -#	default Y
   8.115 -#	help
   8.116 -#	  Say Y to build a console driver for Xen.
   8.117 -
   8.118  endmenu
     9.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/configs/xen0_defconfig	Fri Sep 03 10:57:00 2004 +0000
     9.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/configs/xen0_defconfig	Mon Sep 06 15:23:36 2004 +0000
     9.3 @@ -176,6 +176,105 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
     9.4  # CONFIG_DEBUG_DRIVER is not set
     9.5  
     9.6  #
     9.7 +# Memory Technology Devices (MTD)
     9.8 +#
     9.9 +# CONFIG_MTD is not set
    9.10 +
    9.11 +#
    9.12 +# Parallel port support
    9.13 +#
    9.14 +# CONFIG_PARPORT is not set
    9.15 +
    9.16 +#
    9.17 +# Plug and Play support
    9.18 +#
    9.19 +# CONFIG_PNP is not set
    9.20 +
    9.21 +#
    9.22 +# Block devices
    9.23 +#
    9.24 +# CONFIG_BLK_DEV_FD is not set
    9.25 +# CONFIG_BLK_DEV_XD is not set
    9.26 +# CONFIG_BLK_CPQ_DA is not set
    9.27 +# CONFIG_BLK_CPQ_CISS_DA is not set
    9.28 +# CONFIG_BLK_DEV_DAC960 is not set
    9.29 +# CONFIG_BLK_DEV_UMEM is not set
    9.30 +CONFIG_BLK_DEV_LOOP=y
    9.31 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
    9.32 +CONFIG_BLK_DEV_NBD=y
    9.33 +# CONFIG_BLK_DEV_SX8 is not set
    9.34 +CONFIG_BLK_DEV_RAM=y
    9.35 +CONFIG_BLK_DEV_RAM_SIZE=4096
    9.36 +CONFIG_BLK_DEV_INITRD=y
    9.37 +# CONFIG_LBD is not set
    9.38 +
    9.39 +#
    9.40 +# ATA/ATAPI/MFM/RLL support
    9.41 +#
    9.42 +CONFIG_IDE=y
    9.43 +CONFIG_BLK_DEV_IDE=y
    9.44 +
    9.45 +#
    9.46 +# Please see Documentation/ide.txt for help/info on IDE drives
    9.47 +#
    9.48 +# CONFIG_BLK_DEV_IDE_SATA is not set
    9.49 +# CONFIG_BLK_DEV_HD_IDE is not set
    9.50 +CONFIG_BLK_DEV_IDEDISK=y
    9.51 +# CONFIG_IDEDISK_MULTI_MODE is not set
    9.52 +# CONFIG_BLK_DEV_IDECS is not set
    9.53 +CONFIG_BLK_DEV_IDECD=y
    9.54 +# CONFIG_BLK_DEV_IDETAPE is not set
    9.55 +# CONFIG_BLK_DEV_IDEFLOPPY is not set
    9.56 +# CONFIG_BLK_DEV_IDESCSI is not set
    9.57 +# CONFIG_IDE_TASK_IOCTL is not set
    9.58 +# CONFIG_IDE_TASKFILE_IO is not set
    9.59 +
    9.60 +#
    9.61 +# IDE chipset support/bugfixes
    9.62 +#
    9.63 +CONFIG_IDE_GENERIC=y
    9.64 +# CONFIG_BLK_DEV_CMD640 is not set
    9.65 +CONFIG_BLK_DEV_IDEPCI=y
    9.66 +# CONFIG_IDEPCI_SHARE_IRQ is not set
    9.67 +# CONFIG_BLK_DEV_OFFBOARD is not set
    9.68 +CONFIG_BLK_DEV_GENERIC=y
    9.69 +# CONFIG_BLK_DEV_OPTI621 is not set
    9.70 +# CONFIG_BLK_DEV_RZ1000 is not set
    9.71 +CONFIG_BLK_DEV_IDEDMA_PCI=y
    9.72 +# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
    9.73 +CONFIG_IDEDMA_PCI_AUTO=y
    9.74 +# CONFIG_IDEDMA_ONLYDISK is not set
    9.75 +CONFIG_BLK_DEV_ADMA=y
    9.76 +# CONFIG_BLK_DEV_AEC62XX is not set
    9.77 +# CONFIG_BLK_DEV_ALI15X3 is not set
    9.78 +# CONFIG_BLK_DEV_AMD74XX is not set
    9.79 +# CONFIG_BLK_DEV_ATIIXP is not set
    9.80 +# CONFIG_BLK_DEV_CMD64X is not set
    9.81 +# CONFIG_BLK_DEV_TRIFLEX is not set
    9.82 +# CONFIG_BLK_DEV_CY82C693 is not set
    9.83 +# CONFIG_BLK_DEV_CS5520 is not set
    9.84 +# CONFIG_BLK_DEV_CS5530 is not set
    9.85 +# CONFIG_BLK_DEV_HPT34X is not set
    9.86 +# CONFIG_BLK_DEV_HPT366 is not set
    9.87 +# CONFIG_BLK_DEV_SC1200 is not set
    9.88 +CONFIG_BLK_DEV_PIIX=y
    9.89 +# CONFIG_BLK_DEV_NS87415 is not set
    9.90 +# CONFIG_BLK_DEV_PDC202XX_OLD is not set
    9.91 +# CONFIG_BLK_DEV_PDC202XX_NEW is not set
    9.92 +CONFIG_BLK_DEV_SVWKS=y
    9.93 +# CONFIG_BLK_DEV_SIIMAGE is not set
    9.94 +# CONFIG_BLK_DEV_SIS5513 is not set
    9.95 +# CONFIG_BLK_DEV_SLC90E66 is not set
    9.96 +# CONFIG_BLK_DEV_TRM290 is not set
    9.97 +# CONFIG_BLK_DEV_VIA82CXXX is not set
    9.98 +# CONFIG_IDE_ARM is not set
    9.99 +# CONFIG_IDE_CHIPSETS is not set
   9.100 +CONFIG_BLK_DEV_IDEDMA=y
   9.101 +# CONFIG_IDEDMA_IVB is not set
   9.102 +CONFIG_IDEDMA_AUTO=y
   9.103 +# CONFIG_BLK_DEV_HD is not set
   9.104 +
   9.105 +#
   9.106  # SCSI device support
   9.107  #
   9.108  CONFIG_SCSI=y
   9.109 @@ -295,22 +394,9 @@ CONFIG_SCSI_QLA2XXX=y
   9.110  # CONFIG_PCMCIA_SYM53C500 is not set
   9.111  
   9.112  #
   9.113 -# Block devices
   9.114 +# Old CD-ROM drivers (not SCSI, not IDE)
   9.115  #
   9.116 -# CONFIG_BLK_DEV_FD is not set
   9.117 -# CONFIG_BLK_DEV_XD is not set
   9.118 -# CONFIG_BLK_CPQ_DA is not set
   9.119 -# CONFIG_BLK_CPQ_CISS_DA is not set
   9.120 -# CONFIG_BLK_DEV_DAC960 is not set
   9.121 -# CONFIG_BLK_DEV_UMEM is not set
   9.122 -CONFIG_BLK_DEV_LOOP=y
   9.123 -# CONFIG_BLK_DEV_CRYPTOLOOP is not set
   9.124 -CONFIG_BLK_DEV_NBD=y
   9.125 -# CONFIG_BLK_DEV_SX8 is not set
   9.126 -CONFIG_BLK_DEV_RAM=y
   9.127 -CONFIG_BLK_DEV_RAM_SIZE=4096
   9.128 -CONFIG_BLK_DEV_INITRD=y
   9.129 -# CONFIG_LBD is not set
   9.130 +# CONFIG_CD_NO_IDESCSI is not set
   9.131  
   9.132  #
   9.133  # Multi-device support (RAID and LVM)
   9.134 @@ -330,75 +416,19 @@ CONFIG_DM_MIRROR=y
   9.135  # CONFIG_DM_ZERO is not set
   9.136  
   9.137  #
   9.138 -# ATA/ATAPI/MFM/RLL support
   9.139 -#
   9.140 -CONFIG_IDE=y
   9.141 -CONFIG_BLK_DEV_IDE=y
   9.142 -
   9.143 -#
   9.144 -# Please see Documentation/ide.txt for help/info on IDE drives
   9.145 +# Fusion MPT device support
   9.146  #
   9.147 -# CONFIG_BLK_DEV_IDE_SATA is not set
   9.148 -# CONFIG_BLK_DEV_HD_IDE is not set
   9.149 -CONFIG_BLK_DEV_IDEDISK=y
   9.150 -# CONFIG_IDEDISK_MULTI_MODE is not set
   9.151 -# CONFIG_BLK_DEV_IDECS is not set
   9.152 -CONFIG_BLK_DEV_IDECD=y
   9.153 -# CONFIG_BLK_DEV_IDETAPE is not set
   9.154 -# CONFIG_BLK_DEV_IDEFLOPPY is not set
   9.155 -# CONFIG_BLK_DEV_IDESCSI is not set
   9.156 -# CONFIG_IDE_TASK_IOCTL is not set
   9.157 -# CONFIG_IDE_TASKFILE_IO is not set
   9.158 +# CONFIG_FUSION is not set
   9.159  
   9.160  #
   9.161 -# IDE chipset support/bugfixes
   9.162 +# IEEE 1394 (FireWire) support
   9.163  #
   9.164 -CONFIG_IDE_GENERIC=y
   9.165 -# CONFIG_BLK_DEV_CMD640 is not set
   9.166 -CONFIG_BLK_DEV_IDEPCI=y
   9.167 -# CONFIG_IDEPCI_SHARE_IRQ is not set
   9.168 -# CONFIG_BLK_DEV_OFFBOARD is not set
   9.169 -CONFIG_BLK_DEV_GENERIC=y
   9.170 -# CONFIG_BLK_DEV_OPTI621 is not set
   9.171 -# CONFIG_BLK_DEV_RZ1000 is not set
   9.172 -CONFIG_BLK_DEV_IDEDMA_PCI=y
   9.173 -# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
   9.174 -CONFIG_IDEDMA_PCI_AUTO=y
   9.175 -# CONFIG_IDEDMA_ONLYDISK is not set
   9.176 -CONFIG_BLK_DEV_ADMA=y
   9.177 -# CONFIG_BLK_DEV_AEC62XX is not set
   9.178 -# CONFIG_BLK_DEV_ALI15X3 is not set
   9.179 -# CONFIG_BLK_DEV_AMD74XX is not set
   9.180 -# CONFIG_BLK_DEV_ATIIXP is not set
   9.181 -# CONFIG_BLK_DEV_CMD64X is not set
   9.182 -# CONFIG_BLK_DEV_TRIFLEX is not set
   9.183 -# CONFIG_BLK_DEV_CY82C693 is not set
   9.184 -# CONFIG_BLK_DEV_CS5520 is not set
   9.185 -# CONFIG_BLK_DEV_CS5530 is not set
   9.186 -# CONFIG_BLK_DEV_HPT34X is not set
   9.187 -# CONFIG_BLK_DEV_HPT366 is not set
   9.188 -# CONFIG_BLK_DEV_SC1200 is not set
   9.189 -CONFIG_BLK_DEV_PIIX=y
   9.190 -# CONFIG_BLK_DEV_NS87415 is not set
   9.191 -# CONFIG_BLK_DEV_PDC202XX_OLD is not set
   9.192 -# CONFIG_BLK_DEV_PDC202XX_NEW is not set
   9.193 -CONFIG_BLK_DEV_SVWKS=y
   9.194 -# CONFIG_BLK_DEV_SIIMAGE is not set
   9.195 -# CONFIG_BLK_DEV_SIS5513 is not set
   9.196 -# CONFIG_BLK_DEV_SLC90E66 is not set
   9.197 -# CONFIG_BLK_DEV_TRM290 is not set
   9.198 -# CONFIG_BLK_DEV_VIA82CXXX is not set
   9.199 -# CONFIG_IDE_ARM is not set
   9.200 -# CONFIG_IDE_CHIPSETS is not set
   9.201 -CONFIG_BLK_DEV_IDEDMA=y
   9.202 -# CONFIG_IDEDMA_IVB is not set
   9.203 -CONFIG_IDEDMA_AUTO=y
   9.204 -# CONFIG_BLK_DEV_HD is not set
   9.205 +# CONFIG_IEEE1394 is not set
   9.206  
   9.207  #
   9.208 -# Old CD-ROM drivers (not SCSI, not IDE)
   9.209 +# I2O device support
   9.210  #
   9.211 -# CONFIG_CD_NO_IDESCSI is not set
   9.212 +# CONFIG_I2O is not set
   9.213  
   9.214  #
   9.215  # Networking support
   9.216 @@ -646,6 +676,16 @@ CONFIG_TIGON3=y
   9.217  # CONFIG_NETCONSOLE is not set
   9.218  
   9.219  #
   9.220 +# ISDN subsystem
   9.221 +#
   9.222 +# CONFIG_ISDN is not set
   9.223 +
   9.224 +#
   9.225 +# Telephony Support
   9.226 +#
   9.227 +# CONFIG_PHONE is not set
   9.228 +
   9.229 +#
   9.230  # Input device support
   9.231  #
   9.232  CONFIG_INPUT=y
   9.233 @@ -753,6 +793,26 @@ CONFIG_LEGACY_PTY_COUNT=256
   9.234  # CONFIG_I2C is not set
   9.235  
   9.236  #
   9.237 +# Dallas's 1-wire bus
   9.238 +#
   9.239 +# CONFIG_W1 is not set
   9.240 +
   9.241 +#
   9.242 +# Misc devices
   9.243 +#
   9.244 +# CONFIG_IBM_ASM is not set
   9.245 +
   9.246 +#
   9.247 +# Multimedia devices
   9.248 +#
   9.249 +# CONFIG_VIDEO_DEV is not set
   9.250 +
   9.251 +#
   9.252 +# Digital Video Broadcasting Devices
   9.253 +#
   9.254 +# CONFIG_DVB is not set
   9.255 +
   9.256 +#
   9.257  # Graphics support
   9.258  #
   9.259  # CONFIG_FB is not set
   9.260 @@ -766,6 +826,21 @@ CONFIG_VGA_CONSOLE=y
   9.261  CONFIG_DUMMY_CONSOLE=y
   9.262  
   9.263  #
   9.264 +# Sound
   9.265 +#
   9.266 +# CONFIG_SOUND is not set
   9.267 +
   9.268 +#
   9.269 +# USB support
   9.270 +#
   9.271 +# CONFIG_USB is not set
   9.272 +
   9.273 +#
   9.274 +# USB Gadget Support
   9.275 +#
   9.276 +# CONFIG_USB_GADGET is not set
   9.277 +
   9.278 +#
   9.279  # File systems
   9.280  #
   9.281  CONFIG_EXT2_FS=y
    10.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/configs/xenU_defconfig	Fri Sep 03 10:57:00 2004 +0000
    10.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/configs/xenU_defconfig	Mon Sep 06 15:23:36 2004 +0000
    10.3 @@ -132,6 +132,18 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
    10.4  # CONFIG_FW_LOADER is not set
    10.5  
    10.6  #
    10.7 +# Block devices
    10.8 +#
    10.9 +# CONFIG_BLK_DEV_FD is not set
   10.10 +CONFIG_BLK_DEV_LOOP=m
   10.11 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
   10.12 +CONFIG_BLK_DEV_NBD=m
   10.13 +CONFIG_BLK_DEV_RAM=y
   10.14 +CONFIG_BLK_DEV_RAM_SIZE=4096
   10.15 +CONFIG_BLK_DEV_INITRD=y
   10.16 +# CONFIG_LBD is not set
   10.17 +
   10.18 +#
   10.19  # SCSI device support
   10.20  #
   10.21  CONFIG_SCSI=m
   10.22 @@ -168,18 +180,6 @@ CONFIG_BLK_DEV_SD=m
   10.23  # CONFIG_SCSI_DEBUG is not set
   10.24  
   10.25  #
   10.26 -# Block devices
   10.27 -#
   10.28 -# CONFIG_BLK_DEV_FD is not set
   10.29 -CONFIG_BLK_DEV_LOOP=m
   10.30 -# CONFIG_BLK_DEV_CRYPTOLOOP is not set
   10.31 -CONFIG_BLK_DEV_NBD=m
   10.32 -CONFIG_BLK_DEV_RAM=y
   10.33 -CONFIG_BLK_DEV_RAM_SIZE=4096
   10.34 -CONFIG_BLK_DEV_INITRD=y
   10.35 -# CONFIG_LBD is not set
   10.36 -
   10.37 -#
   10.38  # Multi-device support (RAID and LVM)
   10.39  #
   10.40  # CONFIG_MD is not set
   10.41 @@ -283,7 +283,6 @@ CONFIG_NETDEVICES=y
   10.42  # CONFIG_SLIP is not set
   10.43  # CONFIG_SHAPER is not set
   10.44  # CONFIG_NETCONSOLE is not set
   10.45 -CONFIG_INPUT=y
   10.46  CONFIG_UNIX98_PTYS=y
   10.47  
   10.48  #
    11.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Fri Sep 03 10:57:00 2004 +0000
    11.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Sep 06 15:23:36 2004 +0000
    11.3 @@ -20,6 +20,8 @@ struct cpu_dev * cpu_devs[X86_VENDOR_NUM
    11.4  
    11.5  extern void mcheck_init(struct cpuinfo_x86 *c);
    11.6  
    11.7 +extern void machine_specific_modify_cpu_capabilities(struct cpuinfo_x86 *c);
    11.8 +
    11.9  extern int disable_pse;
   11.10  
   11.11  static void default_init(struct cpuinfo_x86 * c)
   11.12 @@ -392,6 +394,8 @@ void __init identify_cpu(struct cpuinfo_
   11.13  				c->x86_vendor, c->x86_model);
   11.14  	}
   11.15  
   11.16 +	machine_specific_modify_cpu_capabilities(c);
   11.17 +
   11.18  	/* Now the feature flags better reflect actual CPU features! */
   11.19  
   11.20  	printk(KERN_DEBUG "CPU: After all inits, caps:        %08lx %08lx %08lx %08lx\n",
   11.21 @@ -504,7 +508,7 @@ void __init cpu_gdt_init(struct Xgt_desc
   11.22  	     va < gdt_descr->address + gdt_descr->size;
   11.23  	     va += PAGE_SIZE, f++) {
   11.24  		frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
   11.25 -		wrprotect_bootpt(swapper_pg_dir, (void *)va, 1);
   11.26 +		protect_page(swapper_pg_dir, (void *)va, PROT_ON);
   11.27  	}
   11.28  	flush_page_update_queue();
   11.29  	if (HYPERVISOR_set_gdt(frames, gdt_descr->size / 8))
    12.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/Makefile	Fri Sep 03 10:57:00 2004 +0000
    12.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/Makefile	Mon Sep 06 15:23:36 2004 +0000
    12.3 @@ -6,8 +6,8 @@ XENARCH	:= $(subst ",,$(CONFIG_XENARCH))
    12.4  
    12.5  CFLAGS	+= -Iarch/$(XENARCH)/mm
    12.6  
    12.7 -obj-y	:= init.o fault.o ioremap.o pgtable.o hypervisor.o
    12.8 -c-obj-y	:= extable.o pageattr.o 
    12.9 +obj-y	:= init.o fault.o ioremap.o pgtable.o hypervisor.o pageattr.o
   12.10 +c-obj-y	:= extable.o
   12.11  
   12.12  c-obj-$(CONFIG_DISCONTIGMEM)	+= discontig.o
   12.13  c-obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
    14.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/init.c	Fri Sep 03 10:57:00 2004 +0000
    14.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/init.c	Mon Sep 06 15:23:36 2004 +0000
    14.3 @@ -76,11 +76,9 @@ static pte_t * __init one_page_table_ini
    14.4  	if (pmd_none(*pmd)) {
    14.5  		pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
    14.6  		set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
    14.7 -		flush_page_update_queue();
    14.8  		if (page_table != pte_offset_kernel(pmd, 0))
    14.9  			BUG();	
   14.10  
   14.11 -		wrprotect_bootpt((pgd_t *)start_info.pt_base, page_table, 1);
   14.12  		return page_table;
   14.13  	}
   14.14  	
   14.15 @@ -125,8 +123,7 @@ static void __init page_table_range_init
   14.16  	}
   14.17  }
   14.18  
   14.19 -/* NOTE: caller must call flush_page_update_queue() */
   14.20 -void __init wrprotect_bootpt(pgd_t *pgd, void *page, int set)
   14.21 +void __init protect_page(pgd_t *pgd, void *page, int mode)
   14.22  {
   14.23  	pmd_t *pmd;
   14.24  	pte_t *pte;
   14.25 @@ -138,31 +135,25 @@ void __init wrprotect_bootpt(pgd_t *pgd,
   14.26  	pte = pte_offset_kernel(pmd, addr);
   14.27  	if (!pte_present(*pte))
   14.28  		return;
   14.29 -	queue_l1_entry_update(pte, set ? pte_val_ma(*pte) & ~_PAGE_RW :
   14.30 -	    pte_val_ma(*pte) | _PAGE_RW);
   14.31 +	queue_l1_entry_update(pte, mode ? pte_val_ma(*pte) & ~_PAGE_RW :
   14.32 +					pte_val_ma(*pte) | _PAGE_RW);
   14.33  }
   14.34  
   14.35 -/* NOTE: caller must call flush_page_update_queue() */
   14.36 -static void __init protect_bootpt_entries(pgd_t *spgd, pgd_t *dpgd, int set,
   14.37 -    int pmdupdate, int pmdset)
   14.38 +void __init protect_pagetable(pgd_t *dpgd, pgd_t *spgd, int mode)
   14.39  {
   14.40  	pmd_t *pmd;
   14.41  	pte_t *pte;
   14.42  	int pgd_idx, pmd_idx;
   14.43  
   14.44 +	protect_page(dpgd, spgd, mode);
   14.45 +
   14.46  	for (pgd_idx = 0; pgd_idx < PTRS_PER_PGD_NO_HV; spgd++, pgd_idx++) {
   14.47  		pmd = pmd_offset(spgd, 0);
   14.48  		if (pmd_none(*pmd))
   14.49  			continue;
   14.50 -		if (pmdupdate)
   14.51 -			wrprotect_bootpt(dpgd, pmd, pmdset);
   14.52  		for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD; pmd++, pmd_idx++) {
   14.53 -			if (cpu_has_pse) {
   14.54 -				/* XXX */
   14.55 -			} else {
   14.56 -				pte = pte_offset_kernel(pmd, 0);
   14.57 -				wrprotect_bootpt(dpgd, pte, set);
   14.58 -			}
   14.59 +			pte = pte_offset_kernel(pmd, 0);
   14.60 +			protect_page(dpgd, pte, mode);
   14.61  		}
   14.62  	}
   14.63  }
   14.64 @@ -537,18 +528,6 @@ out:
   14.65  #endif
   14.66  
   14.67  /*
   14.68 - * - write protect new L1 pages in old pgd
   14.69 - * - write protect new pgd page in old pgd
   14.70 - * - write protect new pgd page in new pgd
   14.71 - * - write protect new L1 pages in new pgd
   14.72 - * - write protect old L1 pages in new pgd and write protect old pgd in
   14.73 - *   new pgd
   14.74 - * - pin new pgd
   14.75 - * - switch to new pgd
   14.76 - * - unpin old pgd
   14.77 - * - make old L1 pages and old pgd page writeable in new pgd
   14.78 - */
   14.79 -/*
   14.80   * paging_init() sets up the page tables - note that the first 8MB are
   14.81   * already mapped by head.S.
   14.82   *
   14.83 @@ -557,6 +536,8 @@ out:
   14.84   */
   14.85  void __init paging_init(void)
   14.86  {
   14.87 +	pgd_t *old_pgd = (pgd_t *)start_info.pt_base;
   14.88 +	pgd_t *new_pgd = swapper_pg_dir;
   14.89  #ifdef CONFIG_XEN_PHYSDEV_ACCESS
   14.90  	int i;
   14.91  #endif
   14.92 @@ -569,20 +550,24 @@ void __init paging_init(void)
   14.93  
   14.94  	pagetable_init();
   14.95  
   14.96 -	wrprotect_bootpt((pgd_t *)start_info.pt_base, swapper_pg_dir, 1);
   14.97 -	wrprotect_bootpt(swapper_pg_dir, swapper_pg_dir, 1);
   14.98 +	/*
   14.99 +	 * Write-protect both page tables within both page tables.
  14.100 +	 * That's three ops, as the old p.t. is already protected
  14.101 +	 * within the old p.t. Then pin the new table, switch tables,
  14.102 +	 * and unprotect the old table.
  14.103 +	 */
  14.104 +	protect_pagetable(new_pgd, old_pgd, PROT_ON);
  14.105 +	protect_pagetable(new_pgd, new_pgd, PROT_ON);
  14.106 +	protect_pagetable(old_pgd, new_pgd, PROT_ON);
  14.107 +	queue_pgd_pin(__pa(new_pgd));
  14.108 +	load_cr3(new_pgd);
  14.109 +	queue_pgd_unpin(__pa(old_pgd));
  14.110 +	__flush_tlb_all(); /* implicit flush */
  14.111 +	protect_pagetable(new_pgd, old_pgd, PROT_OFF);
  14.112  	flush_page_update_queue();
  14.113 -	protect_bootpt_entries(swapper_pg_dir, swapper_pg_dir, 1, 0, 0);
  14.114 -	protect_bootpt_entries((pgd_t *)start_info.pt_base, swapper_pg_dir,
  14.115 -	    1, 1, 1);
  14.116 -	queue_pgd_pin(__pa(swapper_pg_dir));
  14.117 -	load_cr3(swapper_pg_dir);
  14.118 -	__flush_tlb_all(); /* implicit flush */
  14.119 -	queue_pgd_unpin(__pa(start_info.pt_base));
  14.120 -	protect_bootpt_entries((pgd_t *)start_info.pt_base, swapper_pg_dir,
  14.121 -	    0, 1, 0);
  14.122 -	wrprotect_bootpt((pgd_t *)start_info.pt_base, swapper_pg_dir, 0);
  14.123 -	flush_page_update_queue();
  14.124 +
  14.125 +	/* Completely detached from old tables, so free them. */
  14.126 +	free_bootmem(__pa(old_pgd), start_info.nr_pt_frames << PAGE_SHIFT);
  14.127  
  14.128  #ifdef CONFIG_X86_PAE
  14.129  	/*
  14.130 @@ -741,9 +726,18 @@ void __init mem_init(void)
  14.131  
  14.132  kmem_cache_t *pgd_cache;
  14.133  kmem_cache_t *pmd_cache;
  14.134 +kmem_cache_t *pte_cache;
  14.135  
  14.136  void __init pgtable_cache_init(void)
  14.137  {
  14.138 +	pte_cache = kmem_cache_create("pte",
  14.139 +				PTRS_PER_PTE*sizeof(pte_t),
  14.140 +				PTRS_PER_PTE*sizeof(pte_t),
  14.141 +				0,
  14.142 +				pte_ctor,
  14.143 +				pte_dtor);
  14.144 +	if (!pte_cache)
  14.145 +		panic("pgtable_cache_init(): Cannot create pte cache");
  14.146  	if (PTRS_PER_PMD > 1) {
  14.147  		pmd_cache = kmem_cache_create("pmd",
  14.148  					PTRS_PER_PMD*sizeof(pmd_t),
    15.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Sep 03 10:57:00 2004 +0000
    15.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c	Mon Sep 06 15:23:36 2004 +0000
    15.3 @@ -17,6 +17,25 @@
    15.4  #include <asm/tlbflush.h>
    15.5  #include <asm/pgtable.h>
    15.6  
    15.7 +#ifndef CONFIG_XEN_PHYSDEV_ACCESS
    15.8 +
    15.9 +void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
   15.10 +{ return NULL; }
   15.11 +
   15.12 +void *ioremap_nocache (unsigned long phys_addr, unsigned long size)
   15.13 +{ return NULL; }
   15.14 +
   15.15 +void iounmap(void *addr)
   15.16 +{ }
   15.17 +
   15.18 +void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
   15.19 +{ return NULL; }
   15.20 +
   15.21 +void __init bt_iounmap(void *addr, unsigned long size)
   15.22 +{ }
   15.23 +
   15.24 +#else
   15.25 +
   15.26  static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
   15.27  	unsigned long phys_addr, unsigned long flags)
   15.28  {
   15.29 @@ -133,11 +152,11 @@ void * __ioremap(unsigned long phys_addr
   15.30  	/*
   15.31  	 * Don't allow anybody to remap normal RAM that we're using..
   15.32  	 */
   15.33 -	if (phys_addr < virt_to_phys(high_memory)) {
   15.34 +	if (machine_to_phys(phys_addr) < virt_to_phys(high_memory)) {
   15.35  		char *t_addr, *t_end;
   15.36  		struct page *page;
   15.37  
   15.38 -		t_addr = __va(phys_addr);
   15.39 +		t_addr = bus_to_virt(phys_addr);
   15.40  		t_end = t_addr + (size - 1);
   15.41  	   
   15.42  		for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++)
   15.43 @@ -200,8 +219,8 @@ void *ioremap_nocache (unsigned long phy
   15.44  	/* Guaranteed to be > phys_addr, as per __ioremap() */
   15.45  	last_addr = phys_addr + size - 1;
   15.46  
   15.47 -	if (last_addr < virt_to_phys(high_memory)) { 
   15.48 -		struct page *ppage = virt_to_page(__va(phys_addr));		
   15.49 +	if (machine_to_phys(last_addr) < virt_to_phys(high_memory)) { 
   15.50 +		struct page *ppage = virt_to_page(bus_to_virt(phys_addr));
   15.51  		unsigned long npages;
   15.52  
   15.53  		phys_addr &= PAGE_MASK;
   15.54 @@ -237,8 +256,8 @@ void iounmap(void *addr)
   15.55  		return;
   15.56  	} 
   15.57  
   15.58 -	if (p->flags && p->phys_addr < virt_to_phys(high_memory)) { 
   15.59 -		change_page_attr(virt_to_page(__va(p->phys_addr)),
   15.60 +	if (p->flags && machine_to_phys(p->phys_addr) < virt_to_phys(high_memory)) { 
   15.61 +		change_page_attr(virt_to_page(bus_to_virt(p->phys_addr)),
   15.62  				 p->size >> PAGE_SHIFT,
   15.63  				 PAGE_KERNEL); 				 
   15.64  		global_flush_tlb();
   15.65 @@ -316,6 +335,7 @@ void __init bt_iounmap(void *addr, unsig
   15.66  	}
   15.67  }
   15.68  
   15.69 +#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
   15.70  
   15.71  #if defined(CONFIG_XEN_PRIVILEGED_GUEST)
   15.72  
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pageattr.c	Mon Sep 06 15:23:36 2004 +0000
    16.3 @@ -0,0 +1,215 @@
    16.4 +/* 
    16.5 + * Copyright 2002 Andi Kleen, SuSE Labs. 
    16.6 + * Thanks to Ben LaHaise for precious feedback.
    16.7 + */ 
    16.8 +
    16.9 +#include <linux/config.h>
   16.10 +#include <linux/mm.h>
   16.11 +#include <linux/sched.h>
   16.12 +#include <linux/highmem.h>
   16.13 +#include <linux/module.h>
   16.14 +#include <linux/slab.h>
   16.15 +#include <asm/uaccess.h>
   16.16 +#include <asm/processor.h>
   16.17 +#include <asm/tlbflush.h>
   16.18 +
   16.19 +static spinlock_t cpa_lock = SPIN_LOCK_UNLOCKED;
   16.20 +static struct list_head df_list = LIST_HEAD_INIT(df_list);
   16.21 +
   16.22 +
   16.23 +pte_t *lookup_address(unsigned long address) 
   16.24 +{ 
   16.25 +	pgd_t *pgd = pgd_offset_k(address); 
   16.26 +	pmd_t *pmd;
   16.27 +	if (pgd_none(*pgd))
   16.28 +		return NULL;
   16.29 +	pmd = pmd_offset(pgd, address); 	       
   16.30 +	if (pmd_none(*pmd))
   16.31 +		return NULL;
   16.32 +	if (pmd_large(*pmd))
   16.33 +		return (pte_t *)pmd;
   16.34 +        return pte_offset_kernel(pmd, address);
   16.35 +} 
   16.36 +
   16.37 +static struct page *split_large_page(unsigned long address, pgprot_t prot)
   16.38 +{ 
   16.39 +	int i; 
   16.40 +	unsigned long addr;
   16.41 +	struct page *base;
   16.42 +	pte_t *pbase;
   16.43 +
   16.44 +	spin_unlock_irq(&cpa_lock);
   16.45 +	base = alloc_pages(GFP_KERNEL, 0);
   16.46 +	spin_lock_irq(&cpa_lock);
   16.47 +	if (!base) 
   16.48 +		return NULL;
   16.49 +
   16.50 +	address = __pa(address);
   16.51 +	addr = address & LARGE_PAGE_MASK; 
   16.52 +	pbase = (pte_t *)page_address(base);
   16.53 +	for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) {
   16.54 +		pbase[i] = pfn_pte(addr >> PAGE_SHIFT, 
   16.55 +				   addr == address ? prot : PAGE_KERNEL);
   16.56 +	}
   16.57 +	return base;
   16.58 +} 
   16.59 +
   16.60 +static void flush_kernel_map(void *dummy) 
   16.61 +{ 
   16.62 +	/* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */
   16.63 +	if (boot_cpu_data.x86_model >= 4) 
   16.64 +		wbinvd();
   16.65 +	/* Flush all to work around Errata in early athlons regarding 
   16.66 +	 * large page flushing. 
   16.67 +	 */
   16.68 +	__flush_tlb_all(); 	
   16.69 +}
   16.70 +
   16.71 +static void set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) 
   16.72 +{ 
   16.73 +	struct page *page;
   16.74 +	unsigned long flags;
   16.75 +
   16.76 +	set_pte_atomic(kpte, pte); 	/* change init_mm */
   16.77 +	if (PTRS_PER_PMD > 1)
   16.78 +		return;
   16.79 +
   16.80 +	spin_lock_irqsave(&pgd_lock, flags);
   16.81 +	for (page = pgd_list; page; page = (struct page *)page->index) {
   16.82 +		pgd_t *pgd;
   16.83 +		pmd_t *pmd;
   16.84 +		pgd = (pgd_t *)page_address(page) + pgd_index(address);
   16.85 +		pmd = pmd_offset(pgd, address);
   16.86 +		set_pte_atomic((pte_t *)pmd, pte);
   16.87 +	}
   16.88 +	spin_unlock_irqrestore(&pgd_lock, flags);
   16.89 +}
   16.90 +
   16.91 +/* 
   16.92 + * No more special protections in this 2/4MB area - revert to a
   16.93 + * large page again. 
   16.94 + */
   16.95 +static inline void revert_page(struct page *kpte_page, unsigned long address)
   16.96 +{
   16.97 +	pte_t *linear = (pte_t *) 
   16.98 +		pmd_offset(pgd_offset(&init_mm, address), address);
   16.99 +	set_pmd_pte(linear,  address,
  16.100 +		    pfn_pte((__pa(address) & LARGE_PAGE_MASK) >> PAGE_SHIFT,
  16.101 +			    PAGE_KERNEL_LARGE));
  16.102 +}
  16.103 +
  16.104 +static int
  16.105 +__change_page_attr(struct page *page, pgprot_t prot)
  16.106 +{ 
  16.107 +	pte_t *kpte; 
  16.108 +	unsigned long address;
  16.109 +	struct page *kpte_page;
  16.110 +
  16.111 +#ifdef CONFIG_HIGHMEM
  16.112 +	if (page >= highmem_start_page) 
  16.113 +		BUG(); 
  16.114 +#endif
  16.115 +	address = (unsigned long)page_address(page);
  16.116 +
  16.117 +	kpte = lookup_address(address);
  16.118 +	if (!kpte)
  16.119 +		return -EINVAL;
  16.120 +	kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
  16.121 +	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) { 
  16.122 +		if ((pte_val(*kpte) & _PAGE_PSE) == 0) { 
  16.123 +			pte_t old = *kpte;
  16.124 +			pte_t standard = mk_pte(page, PAGE_KERNEL); 
  16.125 +			set_pte_atomic(kpte, mk_pte(page, prot)); 
  16.126 +			if (pte_same(old,standard))
  16.127 +				get_page(kpte_page);
  16.128 +		} else {
  16.129 +			struct page *split = split_large_page(address, prot); 
  16.130 +			if (!split)
  16.131 +				return -ENOMEM;
  16.132 +			get_page(kpte_page);
  16.133 +			set_pmd_pte(kpte,address,mk_pte(split, PAGE_KERNEL));
  16.134 +		}	
  16.135 +	} else if ((pte_val(*kpte) & _PAGE_PSE) == 0) { 
  16.136 +		set_pte_atomic(kpte, mk_pte(page, PAGE_KERNEL));
  16.137 +		__put_page(kpte_page);
  16.138 +	}
  16.139 +
  16.140 +	if (cpu_has_pse && (page_count(kpte_page) == 1)) {
  16.141 +		list_add(&kpte_page->lru, &df_list);
  16.142 +		revert_page(kpte_page, address);
  16.143 +	} 
  16.144 +	return 0;
  16.145 +} 
  16.146 +
  16.147 +static inline void flush_map(void)
  16.148 +{
  16.149 +	on_each_cpu(flush_kernel_map, NULL, 1, 1);
  16.150 +}
  16.151 +
  16.152 +/*
  16.153 + * Change the page attributes of an page in the linear mapping.
  16.154 + *
  16.155 + * This should be used when a page is mapped with a different caching policy
  16.156 + * than write-back somewhere - some CPUs do not like it when mappings with
  16.157 + * different caching policies exist. This changes the page attributes of the
  16.158 + * in kernel linear mapping too.
  16.159 + * 
  16.160 + * The caller needs to ensure that there are no conflicting mappings elsewhere.
  16.161 + * This function only deals with the kernel linear map.
  16.162 + * 
  16.163 + * Caller must call global_flush_tlb() after this.
  16.164 + */
  16.165 +int change_page_attr(struct page *page, int numpages, pgprot_t prot)
  16.166 +{
  16.167 +	int err = 0; 
  16.168 +	int i; 
  16.169 +	unsigned long flags;
  16.170 +
  16.171 +	spin_lock_irqsave(&cpa_lock, flags);
  16.172 +	for (i = 0; i < numpages; i++, page++) { 
  16.173 +		err = __change_page_attr(page, prot);
  16.174 +		if (err) 
  16.175 +			break; 
  16.176 +	} 	
  16.177 +	spin_unlock_irqrestore(&cpa_lock, flags);
  16.178 +	return err;
  16.179 +}
  16.180 +
  16.181 +void global_flush_tlb(void)
  16.182 +{ 
  16.183 +	LIST_HEAD(l);
  16.184 +	struct list_head* n;
  16.185 +
  16.186 +	BUG_ON(irqs_disabled());
  16.187 +
  16.188 +	spin_lock_irq(&cpa_lock);
  16.189 +	list_splice_init(&df_list, &l);
  16.190 +	spin_unlock_irq(&cpa_lock);
  16.191 +	flush_map();
  16.192 +	n = l.next;
  16.193 +	while (n != &l) {
  16.194 +		struct page *pg = list_entry(n, struct page, lru);
  16.195 +		n = n->next;
  16.196 +		__free_page(pg);
  16.197 +	}
  16.198 +} 
  16.199 +
  16.200 +#ifdef CONFIG_DEBUG_PAGEALLOC
  16.201 +void kernel_map_pages(struct page *page, int numpages, int enable)
  16.202 +{
  16.203 +	if (PageHighMem(page))
  16.204 +		return;
  16.205 +	/* the return value is ignored - the calls cannot fail,
  16.206 +	 * large pages are disabled at boot time.
  16.207 +	 */
  16.208 +	change_page_attr(page, numpages, enable ? PAGE_KERNEL : __pgprot(0));
  16.209 +	/* we should perform an IPI and flush all tlbs,
  16.210 +	 * but that can deadlock->flush only current cpu.
  16.211 +	 */
  16.212 +	__flush_tlb_all();
  16.213 +}
  16.214 +EXPORT_SYMBOL(kernel_map_pages);
  16.215 +#endif
  16.216 +
  16.217 +EXPORT_SYMBOL(change_page_attr);
  16.218 +EXPORT_SYMBOL(global_flush_tlb);
    17.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Sep 03 10:57:00 2004 +0000
    17.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/pgtable.c	Mon Sep 06 15:23:36 2004 +0000
    17.3 @@ -185,32 +185,44 @@ pte_t *pte_alloc_one_kernel(struct mm_st
    17.4  	return pte;
    17.5  }
    17.6  
    17.7 +void pte_ctor(void *pte, kmem_cache_t *cache, unsigned long unused)
    17.8 +{
    17.9 +
   17.10 +	clear_page(pte);
   17.11 +	__make_page_readonly(pte);
   17.12 +	queue_pte_pin(virt_to_phys(pte));
   17.13 +	flush_page_update_queue();
   17.14 +}
   17.15 +
   17.16 +void pte_dtor(void *pte, kmem_cache_t *cache, unsigned long unused)
   17.17 +{
   17.18 +
   17.19 +	queue_pte_unpin(virt_to_phys(pte));
   17.20 +	__make_page_writable(pte);
   17.21 +	flush_page_update_queue();
   17.22 +}
   17.23 +
   17.24  struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
   17.25  {
   17.26 -	struct page *pte;
   17.27 +	pte_t *ptep;
   17.28  
   17.29  #ifdef CONFIG_HIGHPTE
   17.30 +	struct page *pte;
   17.31 +
   17.32  	pte = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT, 0);
   17.33 -#else
   17.34 -	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
   17.35 -#endif
   17.36 -	if (pte) {
   17.37 -#ifdef CONFIG_HIGHPTE
   17.38 -		void *kaddr = kmap_atomic(pte, KM_USER0);
   17.39 -		clear_page(kaddr);
   17.40 -		kunmap_atomic_force(kaddr, KM_USER0);
   17.41 -#else
   17.42 +	if (pte == NULL)
   17.43 +		return pte;
   17.44 +	if (pte >= highmem_start_page) {
   17.45  		clear_highpage(pte);
   17.46 -#endif
   17.47 -#ifdef CONFIG_HIGHPTE
   17.48 -		if (pte < highmem_start_page)
   17.49 +		return pte;
   17.50 +	}
   17.51 +	/* not a highmem page -- free page and grab one from the cache */
   17.52 +	__free_page(pte);
   17.53  #endif
   17.54 -		{
   17.55 -			__make_page_readonly(phys_to_virt(page_to_pseudophys(pte)));
   17.56 -			flush_page_update_queue();
   17.57 -		}
   17.58 -	}
   17.59 -	return pte;
   17.60 +	ptep = kmem_cache_alloc(pte_cache, GFP_KERNEL);
   17.61 +	if (ptep)
   17.62 +		return virt_to_page(ptep);
   17.63 +	return NULL;
   17.64  }
   17.65  
   17.66  void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags)
    18.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Sep 03 10:57:00 2004 +0000
    18.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Sep 06 15:23:36 2004 +0000
    18.3 @@ -1148,6 +1148,12 @@ static void blkif_status_change(blkif_fe
    18.4  
    18.5          break;
    18.6  
    18.7 +    case BLKIF_INTERFACE_STATUS_CHANGED:
    18.8 +        /* The domain controller is notifying us that a device has been
    18.9 +        * added or removed.
   18.10 +        */
   18.11 +        break;
   18.12 +
   18.13      default:
   18.14          printk(KERN_WARNING "Status change to unknown value %d\n", 
   18.15                 status->status);
    19.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c	Fri Sep 03 10:57:00 2004 +0000
    19.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c	Mon Sep 06 15:23:36 2004 +0000
    19.3 @@ -26,6 +26,9 @@
    19.4  #include <asm-xen/hypervisor-ifs/io/netif.h>
    19.5  #include <asm/page.h>
    19.6  
    19.7 +#include <net/arp.h>
    19.8 +#include <net/route.h>
    19.9 +
   19.10  #if 0
   19.11  #define DPRINTK(fmt, args...) \
   19.12      printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args)
   19.13 @@ -171,6 +174,32 @@ static int netctrl_connected_count(void)
   19.14      return connected;
   19.15  }
   19.16  
   19.17 +/** Send a packet on a net device to encourage switches to learn the
   19.18 + * MAC. We send a fake ARP request.
   19.19 + *
   19.20 + * @param dev device
   19.21 + * @return 0 on success, error code otherwise
   19.22 + */
   19.23 +static int vif_wake(struct net_device *dev){
   19.24 +    int err = 0;
   19.25 +    struct sk_buff *skb;
   19.26 +    u32 src_ip;
   19.27 +    u32 dst_ip = INADDR_BROADCAST;
   19.28 +    unsigned char dst_hw[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
   19.29 +
   19.30 +    src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
   19.31 +    skb = arp_create(ARPOP_REQUEST, ETH_P_ARP,
   19.32 +                     dst_ip, dev, src_ip,
   19.33 +                     dst_hw, dev->dev_addr, NULL);
   19.34 +    if(skb == NULL){
   19.35 +        err = -ENOMEM;
   19.36 +        goto exit;
   19.37 +    }
   19.38 +    err = dev_queue_xmit(skb);
   19.39 +  exit:
   19.40 +    return err;
   19.41 +}
   19.42 +
   19.43  static inline struct sk_buff *alloc_skb_page(void)
   19.44  {
   19.45      struct sk_buff *skb;
   19.46 @@ -739,6 +768,13 @@ static void netif_status_change(netif_fe
   19.47          (void)request_irq(np->irq, netif_int, SA_SAMPLE_RANDOM, 
   19.48                            dev->name, dev);
   19.49          netctrl_connected_count();
   19.50 +        vif_wake(dev);
   19.51 +        break;
   19.52 +
   19.53 +    case NETIF_INTERFACE_STATUS_CHANGED:
   19.54 +        /* The domain controller is notifying us that a device has been
   19.55 +        * added or removed.
   19.56 +        */
   19.57          break;
   19.58  
   19.59      default:
    20.1 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h	Fri Sep 03 10:57:00 2004 +0000
    20.2 +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h	Mon Sep 06 15:23:36 2004 +0000
    20.3 @@ -128,12 +128,12 @@ extern void bt_iounmap(void *addr, unsig
    20.4  /*
    20.5   * ISA I/O bus memory addresses are 1:1 with the physical address.
    20.6   */
    20.7 -#define isa_virt_to_bus(_x) BUG() // should be (void *)((FIX_ISAMAP_BEGIN - __virt_to_fix((_x))) << PAGE_SHIFT)
    20.8 -#define isa_page_to_bus(_x) BUG()  // page_to_phys(_x)
    20.9 +#define isa_virt_to_bus(_x) isa_virt_to_bus_is_UNSUPPORTED->x
   20.10 +#define isa_page_to_bus(_x) isa_page_to_bus_is_UNSUPPORTED->x
   20.11  #ifdef CONFIG_XEN_PRIVILEGED_GUEST
   20.12  #define isa_bus_to_virt(_x) (void *)__fix_to_virt(FIX_ISAMAP_BEGIN - ((_x) >> PAGE_SHIFT))
   20.13  #else
   20.14 -#define isa_bus_to_virt(_x) (void *)0L /* XXXcl */
   20.15 +#define isa_bus_to_virt(_x) isa_bus_to_virt_needs_PRIVILEGED_BUILD
   20.16  #endif
   20.17  
   20.18  /*
    21.1 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_post.h	Fri Sep 03 10:57:00 2004 +0000
    21.2 +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_post.h	Mon Sep 06 15:23:36 2004 +0000
    21.3 @@ -22,6 +22,17 @@ static char * __init machine_specific_me
    21.4  	return who;
    21.5  }
    21.6  
    21.7 +void __init machine_specific_modify_cpu_capabilities(struct cpuinfo_x86 *c)
    21.8 +{
    21.9 +	clear_bit(X86_FEATURE_VME, c->x86_capability);
   21.10 +	clear_bit(X86_FEATURE_DE, c->x86_capability);
   21.11 +	clear_bit(X86_FEATURE_PSE, c->x86_capability);
   21.12 +	clear_bit(X86_FEATURE_TSC, c->x86_capability);
   21.13 +	clear_bit(X86_FEATURE_PGE, c->x86_capability);
   21.14 +	clear_bit(X86_FEATURE_MTRR, c->x86_capability);
   21.15 +	clear_bit(X86_FEATURE_FXSR, c->x86_capability);
   21.16 +}
   21.17 +
   21.18  extern void hypervisor_callback(void);
   21.19  extern void failsafe_callback(void);
   21.20  
   21.21 @@ -31,11 +42,5 @@ static void __init machine_specific_arch
   21.22  	    __KERNEL_CS, (unsigned long)hypervisor_callback,
   21.23  	    __KERNEL_CS, (unsigned long)failsafe_callback);
   21.24  
   21.25 -	clear_bit(X86_FEATURE_VME, boot_cpu_data.x86_capability);
   21.26 -	clear_bit(X86_FEATURE_DE, boot_cpu_data.x86_capability);
   21.27 -	clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
   21.28 -	clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
   21.29 -	clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
   21.30 -	clear_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability);
   21.31 -	clear_bit(X86_FEATURE_FXSR, boot_cpu_data.x86_capability);
   21.32 +	machine_specific_modify_cpu_capabilities(&boot_cpu_data);
   21.33  }
    22.1 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Fri Sep 03 10:57:00 2004 +0000
    22.2 +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Mon Sep 06 15:23:36 2004 +0000
    22.3 @@ -41,19 +41,16 @@ static inline void pte_free(struct page 
    22.4  #ifdef CONFIG_HIGHPTE
    22.5  	if (pte < highmem_start_page)
    22.6  #endif
    22.7 -	{
    22.8 -		__make_page_writable(phys_to_virt(page_to_pseudophys(pte)));
    22.9 +		kmem_cache_free(pte_cache,
   22.10 +				phys_to_virt(page_to_pseudophys(pte)));
   22.11 +#ifdef CONFIG_HIGHPTE
   22.12 +	else
   22.13  		__free_page(pte);
   22.14 -		flush_page_update_queue();
   22.15 -	}
   22.16 +#endif
   22.17  }
   22.18  
   22.19  
   22.20 -#define __pte_free_tlb(tlb,pte) do {			\
   22.21 -	tlb_remove_page((tlb),(pte));			\
   22.22 -	flush_page_update_queue();			\
   22.23 -	/* XXXcl queue */ \
   22.24 -} while (0)
   22.25 +#define __pte_free_tlb(tlb,pte)		pte_free(pte)
   22.26  
   22.27  /*
   22.28   * allocating and freeing a pmd is trivial: the 1-entry pmd is
    23.1 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Sep 03 10:57:00 2004 +0000
    23.2 +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Mon Sep 06 15:23:36 2004 +0000
    23.3 @@ -35,9 +35,12 @@ extern unsigned long empty_zero_page[102
    23.4  extern pgd_t swapper_pg_dir[1024];
    23.5  extern kmem_cache_t *pgd_cache;
    23.6  extern kmem_cache_t *pmd_cache;
    23.7 +extern kmem_cache_t *pte_cache;
    23.8  extern spinlock_t pgd_lock;
    23.9  extern struct page *pgd_list;
   23.10  
   23.11 +void pte_ctor(void *, kmem_cache_t *, unsigned long);
   23.12 +void pte_dtor(void *, kmem_cache_t *, unsigned long);
   23.13  void pmd_ctor(void *, kmem_cache_t *, unsigned long);
   23.14  void pgd_ctor(void *, kmem_cache_t *, unsigned long);
   23.15  void pgd_dtor(void *, kmem_cache_t *, unsigned long);
   23.16 @@ -315,9 +318,7 @@ static inline pte_t pte_modify(pte_t pte
   23.17  ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
   23.18  
   23.19  #define pmd_clear(xp)	do {					\
   23.20 -	pmd_t p = *(xp);					\
   23.21  	set_pmd(xp, __pmd(0));					\
   23.22 -	__make_page_writable((void *)pmd_page_kernel(p));	\
   23.23  	xen_flush_page_update_queue();				\
   23.24  } while (0)
   23.25  
    24.1 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/system.h	Fri Sep 03 10:57:00 2004 +0000
    24.2 +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/system.h	Mon Sep 06 15:23:36 2004 +0000
    24.3 @@ -122,9 +122,13 @@ static inline unsigned long _get_base(ch
    24.4  
    24.5  #endif	/* __KERNEL__ */
    24.6  
    24.7 -#define wbinvd() \
    24.8 -	BUG();
    24.9 -//	__asm__ __volatile__ ("wbinvd": : :"memory");
   24.10 +static inline void wbinvd(void)
   24.11 +{
   24.12 +    mmu_update_t u;
   24.13 +    u.ptr = MMU_EXTENDED_COMMAND;
   24.14 +    u.val = MMUEXT_FLUSH_CACHE;
   24.15 +    (void)HYPERVISOR_mmu_update(&u, 1, NULL);
   24.16 +}
   24.17  
   24.18  static inline unsigned long get_limit(unsigned long segment)
   24.19  {
    25.1 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/hypervisor.h	Fri Sep 03 10:57:00 2004 +0000
    25.2 +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/hypervisor.h	Mon Sep 06 15:23:36 2004 +0000
    25.3 @@ -34,7 +34,11 @@ void xen_cpu_idle (void);
    25.4  void do_hypervisor_callback(struct pt_regs *regs);
    25.5  
    25.6  /* arch/xen/i386/mm/init.c */
    25.7 -void wrprotect_bootpt(pgd_t *, void *, int);
    25.8 +/* NOTE: caller must call flush_page_update_queue() */
    25.9 +#define PROT_ON  1
   25.10 +#define PROT_OFF 0
   25.11 +void /* __init */ protect_page(pgd_t *dpgd, void *page, int mode);
   25.12 +void /* __init */ protect_pagetable(pgd_t *dpgd, pgd_t *spgd, int mode);
   25.13  
   25.14  /* arch/xen/i386/kernel/head.S */
   25.15  void lgdt_finish(void);
    29.1 --- a/tools/python/xen/xend/XendClient.py	Fri Sep 03 10:57:00 2004 +0000
    29.2 +++ b/tools/python/xen/xend/XendClient.py	Mon Sep 06 15:23:36 2004 +0000
    29.3 @@ -548,7 +548,7 @@ class Xend:
    29.4          return self.xendPost(self.domainurl(id),
    29.5                               {'op'      : 'device_destroy',
    29.6                                'type'    : type,
    29.7 -                              'index'   : idx })
    29.8 +                              'idx'     : idx })
    29.9  
   29.10      def xend_consoles(self):
   29.11          return self.xendGet(self.consoleurl())
    30.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Sep 03 10:57:00 2004 +0000
    30.2 +++ b/tools/python/xen/xend/XendDomain.py	Mon Sep 06 15:23:36 2004 +0000
    30.3 @@ -243,12 +243,12 @@ class XendDomain:
    30.4              if d['shutdown']:
    30.5                  reason = XendDomainInfo.shutdown_reason(d['shutdown_reason'])
    30.6                  log.debug('XendDomain>reap> shutdown id=%s reason=%s', id, reason)
    30.7 +                dominfo = self.domain_by_id.get(id)
    30.8 +                name = (dominfo and dominfo.name) or '??'
    30.9                  if reason in ['suspend']:
   30.10 -                    dominfo = self.domain_by_id.get(id)
   30.11                      if dominfo.is_terminated():
   30.12                          log.debug('XendDomain>reap> Suspended domain died id=%s', id)
   30.13                      else:
   30.14 -                        name = (dominfo and dominfo.name) or '??'
   30.15                          eserver.inject('xend.domain.suspended', [name, id])
   30.16                          continue
   30.17                  if reason in ['poweroff', 'reboot']:
    31.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 03 10:57:00 2004 +0000
    31.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Sep 06 15:23:36 2004 +0000
    31.3 @@ -576,6 +576,16 @@ class XendDomainInfo:
    31.4          dl.append(dev)
    31.5          self.devices[type] = dl
    31.6  
    31.7 +    def remove_device(self, type, dev):
    31.8 +        """Remove a device from a virtual machine.
    31.9 +
   31.10 +        @param type: device type
   31.11 +        @param dev:  device
   31.12 +        """
   31.13 +        dl = self.devices.get(type, [])
   31.14 +        if dev in dl:
   31.15 +            dl.remove(dev)
   31.16 +
   31.17      def get_devices(self, type):
   31.18          """Get a list of the devices of a given type.
   31.19  
   31.20 @@ -812,7 +822,7 @@ class XendDomainInfo:
   31.21          devs = self.get_devices(dev_name)
   31.22          dev_index = len(devs)
   31.23          self.config.append(['device', dev_config])
   31.24 -        d = dev_handler(self, dev_config, dev_index)
   31.25 +        d = dev_handler(self, dev_config, dev_index, change=1)
   31.26          return d
   31.27  
   31.28      def device_destroy(self, type, idx):
   31.29 @@ -829,7 +839,8 @@ class XendDomainInfo:
   31.30          dev_config = self.config_device(type, index)
   31.31          if dev_config:
   31.32              self.config.remove(['device', dev_config])
   31.33 -        dev.destroy()
   31.34 +        dev.destroy(change=1)
   31.35 +        self.remove_device(type, dev)
   31.36  
   31.37      def configure_memory(self):
   31.38          """Configure vm memory limit.
   31.39 @@ -1053,7 +1064,7 @@ def vm_image_netbsd(vm, image):
   31.40      return vm
   31.41  
   31.42  
   31.43 -def vm_dev_vif(vm, val, index):
   31.44 +def vm_dev_vif(vm, val, index, change=0):
   31.45      """Create a virtual network interface (vif).
   31.46  
   31.47      @param vm:        virtual machine
   31.48 @@ -1069,11 +1080,13 @@ def vm_dev_vif(vm, val, index):
   31.49      def cbok(dev):
   31.50          dev.vifctl('up', vmname=vm.name)
   31.51          vm.add_device('vif', dev)
   31.52 +        if change:
   31.53 +            dev.interfaceChanged()
   31.54          return dev
   31.55      defer.addCallback(cbok)
   31.56      return defer
   31.57  
   31.58 -def vm_dev_vbd(vm, val, index):
   31.59 +def vm_dev_vbd(vm, val, index, change=0):
   31.60      """Create a virtual block device (vbd).
   31.61  
   31.62      @param vm:        virtual machine
   31.63 @@ -1094,6 +1107,8 @@ def vm_dev_vbd(vm, val, index):
   31.64          vbd.dev = dev
   31.65          vbd.uname = uname
   31.66          vm.add_device('vbd', vbd)
   31.67 +        if change:
   31.68 +            vbd.interfaceChanged()
   31.69          return vbd
   31.70      defer.addCallback(fn)
   31.71      return defer
   31.72 @@ -1110,7 +1125,7 @@ def parse_pci(val):
   31.73          v = val
   31.74      return v
   31.75  
   31.76 -def vm_dev_pci(vm, val, index):
   31.77 +def vm_dev_pci(vm, val, index, change=0):
   31.78      """Add a pci device.
   31.79  
   31.80      @param vm: virtual machine
    32.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Fri Sep 03 10:57:00 2004 +0000
    32.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Mon Sep 06 15:23:36 2004 +0000
    32.3 @@ -23,7 +23,6 @@ from twisted.internet import reactor
    32.4  from twisted.internet import protocol
    32.5  from twisted.internet import abstract
    32.6  from twisted.internet import defer
    32.7 -#defer.Deferred.debug = 1
    32.8  
    32.9  from xen.lowlevel import xu
   32.10  
   32.11 @@ -45,127 +44,6 @@ from params import *
   32.12  
   32.13  DEBUG = 1
   32.14  
   32.15 -class MgmtProtocol(protocol.DatagramProtocol):
   32.16 -    """Handler for the management socket (unix-domain).
   32.17 -    """
   32.18 -
   32.19 -    def __init__(self, daemon):
   32.20 -        #protocol.DatagramProtocol.__init__(self)
   32.21 -        self.daemon = daemon
   32.22 -    
   32.23 -    def write(self, data, addr):
   32.24 -        return self.transport.write(data, addr)
   32.25 -
   32.26 -    def datagramReceived(self, data, addr):
   32.27 -        if DEBUG: print 'datagramReceived> addr=', addr, 'data=', data
   32.28 -        io = StringIO.StringIO(data)
   32.29 -        try:
   32.30 -            vals = sxp.parse(io)
   32.31 -            res = self.dispatch(vals[0])
   32.32 -            self.send_result(addr, res)
   32.33 -        except SystemExit:
   32.34 -            raise
   32.35 -        except:
   32.36 -            if DEBUG:
   32.37 -                raise
   32.38 -            else:
   32.39 -                self.send_error(addr)
   32.40 -
   32.41 -    def send_reply(self, addr, sxpr):
   32.42 -        io = StringIO.StringIO()
   32.43 -        sxp.show(sxpr, out=io)
   32.44 -        io.seek(0)
   32.45 -        self.write(io.getvalue(), addr)
   32.46 -
   32.47 -    def send_result(self, addr, res):
   32.48 -        
   32.49 -        def fn(res, self=self, addr=addr):
   32.50 -            self.send_reply(addr, ['ok', res])
   32.51 -            
   32.52 -        if isinstance(res, defer.Deferred):
   32.53 -            res.addCallback(fn)
   32.54 -        else:
   32.55 -            fn(res)
   32.56 -
   32.57 -    def send_error(self, addr):
   32.58 -        (extype, exval) = sys.exc_info()[:2]
   32.59 -        self.send_reply(addr, ['err',
   32.60 -                               ['type',  str(extype) ],
   32.61 -                               ['value', str(exval)  ] ] )
   32.62 -
   32.63 -    def opname(self, name):
   32.64 -        """Get the name of the method for an operation.
   32.65 -        """
   32.66 -        return 'op_' + name.replace('.', '_')
   32.67 -
   32.68 -    def operror(self, name, v):
   32.69 -        """Default operation handler - signals an error.
   32.70 -        """
   32.71 -        raise NotImplementedError('Invalid operation: ' +name)
   32.72 -
   32.73 -    def dispatch(self, req):
   32.74 -        """Dispatch a request to its handler.
   32.75 -        """
   32.76 -        op_name = sxp.name(req)
   32.77 -        op_method_name = self.opname(op_name)
   32.78 -        op_method = getattr(self, op_method_name, self.operror)
   32.79 -        return op_method(op_name, req)
   32.80 -
   32.81 -    def op_console_create(self, name, req):
   32.82 -        """Create a new control interface - console for a domain.
   32.83 -        """
   32.84 -        print name, req
   32.85 -        dom = sxp.child_value(req, 'domain')
   32.86 -        if not dom: raise XendError('Missing domain')
   32.87 -        dom = int(dom)
   32.88 -        console_port = sxp.child_value(req, 'console_port')
   32.89 -        if console_port:
   32.90 -            console_port = int(console_port)
   32.91 -        resp = self.daemon.console_create(dom, console_port).sxpr()
   32.92 -        print name, resp
   32.93 -        return resp
   32.94 -
   32.95 -    def op_consoles(self, name, req):
   32.96 -        """Get a list of the consoles.
   32.97 -        """
   32.98 -        return self.daemon.consoles()
   32.99 -
  32.100 -    def op_console_disconnect(self, name, req):
  32.101 -        id = sxp.child_value(req, 'id')
  32.102 -        if not id:
  32.103 -            raise XendError('Missing console id')
  32.104 -        id = int(id)
  32.105 -        console = self.daemon.get_console(id)
  32.106 -        if not console:
  32.107 -            raise XendError('Invalid console id')
  32.108 -        if console.conn:
  32.109 -            console.conn.loseConnection()
  32.110 -        return ['ok']
  32.111 -
  32.112 -    def op_blkifs(self, name, req):
  32.113 -        pass
  32.114 -    
  32.115 -    def op_blkif_devs(self, name, req):
  32.116 -        pass
  32.117 -
  32.118 -    def op_blkif_create(self, name, req):
  32.119 -        pass
  32.120 -    
  32.121 -    def op_blkif_dev_create(self, name, req):
  32.122 -        pass
  32.123 -
  32.124 -    def op_netifs(self, name, req):
  32.125 -        pass
  32.126 -
  32.127 -    def op_netif_devs(self, name, req):
  32.128 -        pass
  32.129 -
  32.130 -    def op_netif_create(self, name, req):
  32.131 -        pass
  32.132 -
  32.133 -    def op_netif_dev_create(self, name, req):
  32.134 -        pass
  32.135 -
  32.136  class NotifierProtocol(protocol.Protocol):
  32.137      """Asynchronous handler for i/o on the notifier (event channel).
  32.138      """
  32.139 @@ -245,17 +123,14 @@ class NotifierPort(abstract.FileDescript
  32.140              del self.d
  32.141          
  32.142      def doRead(self):
  32.143 -        #print 'NotifierPort>doRead>', self
  32.144          count = 0
  32.145          while 1:            
  32.146 -            #print 'NotifierPort>doRead>', count
  32.147              notification = self.notifier.read()
  32.148              if not notification:
  32.149                  break
  32.150              self.protocol.notificationReceived(notification)
  32.151              self.notifier.unmask(notification)
  32.152              count += 1
  32.153 -        #print 'NotifierPort>doRead<'
  32.154  
  32.155  class EventProtocol(protocol.Protocol):
  32.156      """Asynchronous handler for a connected event socket.
  32.157 @@ -481,25 +356,69 @@ class Daemon:
  32.158              err = 1
  32.159              print "Daemon already running: ", pids
  32.160          return err
  32.161 -            
  32.162 +
  32.163 +    def read_pid(self, pidfile):
  32.164 +        """Read process id from a file.
  32.165 +
  32.166 +        @param pidfile: file to read
  32.167 +        @return pid or 0
  32.168 +        """
  32.169 +        pid = 0
  32.170 +        if os.path.isfile(pidfile) and os.path.getsize(pidfile):
  32.171 +            try:
  32.172 +                pid = open(pidfile, 'r').read()
  32.173 +                pid = int(pid)
  32.174 +            except:
  32.175 +                pid = 0
  32.176 +        return pid
  32.177 +
  32.178 +    def find_process(self, pid, name):
  32.179 +        """Search for a process.
  32.180 +
  32.181 +        @param pid: process id
  32.182 +        @param name: process name
  32.183 +        @return: pid if found, 0 otherwise
  32.184 +        """
  32.185 +        running = 0
  32.186 +        if pid:
  32.187 +            lines = os.popen('ps %d 2>/dev/null' % pid).readlines()
  32.188 +            exp = '^ *%d.+%s' % (pid, name)
  32.189 +            for line in lines:
  32.190 +                if re.search(exp, line):
  32.191 +                    running = pid
  32.192 +                    break
  32.193 +        return running
  32.194 +
  32.195 +    def cleanup_process(self, pidfile, name, kill):
  32.196 +        """Clean up the pidfile for a process.
  32.197 +        If a running process is found, kills it if 'kill' is true.
  32.198 +
  32.199 +        @param pidfile: pid file
  32.200 +        @param name: process name
  32.201 +        @param kill: whether to kill the process
  32.202 +        @return running process id or 0
  32.203 +        """
  32.204 +        running = 0
  32.205 +        pid = self.read_pid(pidfile)
  32.206 +        if self.find_process(pid, name):
  32.207 +            if kill:
  32.208 +                os.kill(pid, 1)
  32.209 +            else:
  32.210 +                running = pid
  32.211 +        if running == 0 and os.path.isfile(pidfile):
  32.212 +            os.remove(pidfile)
  32.213 +        return running
  32.214 +
  32.215 +    def cleanup_xend(self, kill=False):
  32.216 +        return self.cleanup_process(XEND_PID_FILE, "xend", kill)
  32.217 +
  32.218 +    def cleanup_xfrd(self, kill=False):
  32.219 +        return self.cleanup_process(XFRD_PID_FILE, "xfrd", kill)
  32.220 +
  32.221      def cleanup(self, kill=False):
  32.222 -        # No cleanup to do if PID_FILE is empty.
  32.223 -        if not os.path.isfile(PID_FILE) or not os.path.getsize(PID_FILE):
  32.224 -            return 0
  32.225 -        # Read the pid of the previous invocation and search active process list.
  32.226 -        pid = open(PID_FILE, 'r').read()
  32.227 -        lines = os.popen('ps ' + pid + ' 2>/dev/null').readlines()
  32.228 -        for line in lines:
  32.229 -            if re.search('^ *' + pid + '.+xend', line):
  32.230 -                if not kill:
  32.231 -                    print "Daemon is already running (pid %d)" % int(pid)
  32.232 -                    return 1
  32.233 -                # Old daemon is still active: terminate it.
  32.234 -                os.kill(int(pid), 1)
  32.235 -        # Delete the stale PID_FILE.
  32.236 -        os.remove(PID_FILE)
  32.237 -        return 0
  32.238 -
  32.239 +        self.cleanup_xend(kill=kill)
  32.240 +        self.cleanup_xfrd(kill=kill)
  32.241 +            
  32.242      def install_child_reaper(self):
  32.243          #signal.signal(signal.SIGCHLD, self.onSIGCHLD)
  32.244          # Ensure that zombie children are automatically reaped.
  32.245 @@ -510,42 +429,65 @@ class Daemon:
  32.246          while code > 0:
  32.247              code = os.waitpid(-1, os.WNOHANG)
  32.248  
  32.249 +    def fork_pid(self, pidfile):
  32.250 +        """Fork and write the pid of the child to 'pidfile'.
  32.251 +
  32.252 +        @param pidfile: pid file
  32.253 +        @return: pid of child in parent, 0 in child
  32.254 +        """
  32.255 +        pid = os.fork()
  32.256 +        if pid:
  32.257 +            # Parent
  32.258 +            pidfile = open(pidfile, 'w')
  32.259 +            pidfile.write(str(pid))
  32.260 +            pidfile.close()
  32.261 +        return pid
  32.262 +
  32.263 +    def start_xfrd(self):
  32.264 +        """Fork and exec xfrd, writing its pid to XFRD_PID_FILE.
  32.265 +        """
  32.266 +        if self.fork_pid(XFRD_PID_FILE):
  32.267 +            # Parent
  32.268 +            pass
  32.269 +        else:
  32.270 +            # Child
  32.271 +            self.set_user()
  32.272 +            os.execl("/usr/sbin/xfrd", "xfrd")
  32.273 +            
  32.274      def start(self, trace=0):
  32.275 -        if self.cleanup(kill=False):
  32.276 +        xend_pid = self.cleanup_xend()
  32.277 +        xfrd_pid = self.cleanup_xfrd()
  32.278 +        if xfrd_pid == 0:
  32.279 +            self.start_xfrd()
  32.280 +        if xend_pid > 0:
  32.281              return 1
  32.282  
  32.283          # Detach from TTY.
  32.284          if not DEBUG:
  32.285              os.setsid()
  32.286 -
  32.287          if self.set_user():
  32.288              return 1
  32.289 -
  32.290          self.install_child_reaper()
  32.291  
  32.292 -        # Fork -- parent writes PID_FILE and exits.
  32.293 -        pid = os.fork()
  32.294 -        if pid:
  32.295 -            # Parent
  32.296 -            pidfile = open(PID_FILE, 'w')
  32.297 -            pidfile.write(str(pid))
  32.298 -            pidfile.close()
  32.299 -            return 0
  32.300 -        # Child
  32.301 -        self.tracing(trace)
  32.302 -        self.run()
  32.303 +        if self.fork_pid(XEND_PID_FILE):
  32.304 +            #Parent
  32.305 +            pass
  32.306 +        else:
  32.307 +            # Child
  32.308 +            self.tracing(trace)
  32.309 +            self.run()
  32.310          return 0
  32.311  
  32.312      def tracing(self, traceon):
  32.313          """Turn tracing on or off.
  32.314  
  32.315 -        traceon tracing flag
  32.316 +        @param traceon: tracing flag
  32.317          """
  32.318          if traceon == self.traceon:
  32.319              return
  32.320          self.traceon = traceon
  32.321          if traceon:
  32.322 -            self.tracefile = open('/var/log/xend.trace', 'w+', 1)
  32.323 +            self.tracefile = open(XEND_TRACE_FILE, 'w+', 1)
  32.324              self.traceindent = 0
  32.325              sys.settrace(self.trace)
  32.326              try:
  32.327 @@ -620,7 +562,6 @@ class Daemon:
  32.328          xroot = XendRoot.instance()
  32.329          log.info("Xend Daemon started")
  32.330          self.createFactories()
  32.331 -        self.listenMgmt()
  32.332          self.listenEvent()
  32.333          self.listenNotifier()
  32.334          self.listenVirq()
  32.335 @@ -634,13 +575,6 @@ class Daemon:
  32.336          self.netifCF = netif.NetifControllerFactory()
  32.337          self.consoleCF = console.ConsoleControllerFactory()
  32.338  
  32.339 -    def listenMgmt(self):
  32.340 -        protocol = MgmtProtocol(self)
  32.341 -        s = os.path.join(CONTROL_DIR, MGMT_SOCK)
  32.342 -        if os.path.exists(s):
  32.343 -            os.unlink(s)
  32.344 -        return reactor.listenUNIXDatagram(s, protocol)
  32.345 -
  32.346      def listenEvent(self):
  32.347          protocol = EventFactory(self)
  32.348          return reactor.listenTCP(EVENT_PORT, protocol)
  32.349 @@ -656,7 +590,7 @@ class Daemon:
  32.350          virqChan.registerClient(VirqClient(self))
  32.351  
  32.352      def exit(self):
  32.353 -        reactor.diconnectAll()
  32.354 +        reactor.disconnectAll()
  32.355          sys.exit(0)
  32.356  
  32.357      def getDomChannel(self, dom):
    33.1 --- a/tools/python/xen/xend/server/blkif.py	Fri Sep 03 10:57:00 2004 +0000
    33.2 +++ b/tools/python/xen/xend/server/blkif.py	Mon Sep 06 15:23:36 2004 +0000
    33.3 @@ -3,7 +3,6 @@
    33.4  """
    33.5  
    33.6  from twisted.internet import defer
    33.7 -#defer.Deferred.debug = 1
    33.8  
    33.9  from xen.xend import sxp
   33.10  from xen.xend.XendLogging import log
   33.11 @@ -88,14 +87,12 @@ class BlkifBackendInterface(controller.B
   33.12          self.send_be_disconnect(response=d)
   33.13          
   33.14      def send_be_disconnect(self, response=None):
   33.15 -        log.debug('>BlkifBackendController>send_be_disconnect> %s', str(self))
   33.16          msg = packMsg('blkif_be_disconnect_t',
   33.17                        { 'domid'        : self.controller.dom,
   33.18                          'blkif_handle' : self.handle })
   33.19          self.writeRequest(msg, response=response)
   33.20  
   33.21      def send_be_destroy(self, response=None):
   33.22 -        log.debug('>BlkifBackendController>send_be_destroy> %s', str(self))
   33.23          msg = packMsg('blkif_be_destroy_t',
   33.24                        { 'domid'        : self.controller.dom,
   33.25                          'blkif_handle' : self.handle })
   33.26 @@ -127,9 +124,28 @@ class BlkifBackendInterface(controller.B
   33.27          msg = packMsg('blkif_fe_interface_status_changed_t',
   33.28                        { 'handle' : self.handle,
   33.29                          'status' : BLKIF_INTERFACE_STATUS_CONNECTED,
   33.30 -                        'domid'  : 0, ## FIXME: should be domid of backend
   33.31 +                        'domid'  : self.dom,
   33.32                          'evtchn' : self.evtchn['port2'] })
   33.33          self.controller.writeRequest(msg, response=response)
   33.34 +
   33.35 +    def interfaceDisconnected(self):
   33.36 +        msg = packMsg('blkif_fe_interface_status_changed_t',
   33.37 +                      { 'handle' : self.handle,
   33.38 +                        'status' : BLKIF_INTERFACE_STATUS_DISCONNECTED,
   33.39 +                        'domid'  : self.dom,
   33.40 +                        'evtchn' : 0 })
   33.41 +        self.controller.writeRequest(msg)
   33.42 +        
   33.43 +    def interfaceChanged(self):
   33.44 +        """Notify the front-end that devices have been added or removed.
   33.45 +        The front-end should then probe for devices.
   33.46 +        """
   33.47 +        msg = packMsg('blkif_fe_interface_status_changed_t',
   33.48 +                      { 'handle' : self.handle,
   33.49 +                        'status' : BLKIF_INTERFACE_STATUS_CHANGED,
   33.50 +                        'domid'  : self.dom,
   33.51 +                        'evtchn' : 0 })
   33.52 +        self.controller.writeRequest(msg)
   33.53          
   33.54  class BlkifControllerFactory(controller.SplitControllerFactory):
   33.55      """Factory for creating block device interface controllers.
   33.56 @@ -230,9 +246,21 @@ class BlkDev(controller.SplitDev):
   33.57              val.append(['uname', self.uname])
   33.58          return val
   33.59  
   33.60 -    def destroy(self):
   33.61 +    def destroy(self, change=0):
   33.62 +        """Destroy the device. If 'change' is true notify the front-end interface.
   33.63 +
   33.64 +        @param change: change flag
   33.65 +        """
   33.66          log.debug("Destroying vbd domain=%d vdev=%d", self.controller.dom, self.vdev)
   33.67 -        self.send_be_vbd_destroy()
   33.68 +        d = self.send_be_vbd_destroy()
   33.69 +        if change:
   33.70 +            d.addCallback(lambda val: self.interfaceChanged())
   33.71 +
   33.72 +    def interfaceChanged(self):
   33.73 +        """Tell the back-end to notify the front-end that a device has been
   33.74 +        added or removed.
   33.75 +        """
   33.76 +        self.getBackendInterface().interfaceChanged()
   33.77  
   33.78      def attach(self):
   33.79          """Attach the device to its controller.
   33.80 @@ -295,16 +323,16 @@ class BlkDev(controller.SplitDev):
   33.81                              % (self.vdev, status))
   33.82          return self
   33.83  
   33.84 -    def send_be_vbd_destroy(self, response=None):
   33.85 -        log.debug('>BlkDev>send_be_vbd_destroy> dom=%d vdev=%d',
   33.86 -                  self.controller.dom, self.vdev)
   33.87 +    def send_be_vbd_destroy(self):
   33.88 +        d = defer.Deferred()
   33.89          backend = self.getBackendInterface()
   33.90          msg = packMsg('blkif_be_vbd_destroy_t',
   33.91                        { 'domid'                : self.controller.dom,
   33.92                          'blkif_handle'         : backend.handle,
   33.93                          'vdevice'              : self.vdev })
   33.94          self.controller.delDevice(self.vdev)
   33.95 -        backend.writeRequest(msg, response=response)
   33.96 +        backend.writeRequest(msg, response=d)
   33.97 +        return d
   33.98          
   33.99          
  33.100  class BlkifController(controller.SplitController):
  33.101 @@ -399,13 +427,8 @@ class BlkifController(controller.SplitCo
  33.102  
  33.103      def recv_fe_driver_status_changed(self, msg, req):
  33.104          val = unpackMsg('blkif_fe_driver_status_changed_t', msg)
  33.105 -        # For each backend?
  33.106 -        msg = packMsg('blkif_fe_interface_status_changed_t',
  33.107 -                      { 'handle' : 0,
  33.108 -                        'status' : BLKIF_INTERFACE_STATUS_DISCONNECTED,
  33.109 -                        'domid'  : 0, ## FIXME: should be domid of backend
  33.110 -                        'evtchn' : 0 })
  33.111 -        self.writeRequest(msg)
  33.112 +        for backend in self.getBackendInterfaces():
  33.113 +            backend.interfaceDisconnected()
  33.114  
  33.115      def recv_fe_interface_connect(self, msg, req):
  33.116          val = unpackMsg('blkif_fe_interface_connect_t', msg)
    34.1 --- a/tools/python/xen/xend/server/messages.py	Fri Sep 03 10:57:00 2004 +0000
    34.2 +++ b/tools/python/xen/xend/server/messages.py	Mon Sep 06 15:23:36 2004 +0000
    34.3 @@ -50,6 +50,7 @@ BLKIF_DRIVER_STATUS_UP    = 1
    34.4  BLKIF_INTERFACE_STATUS_DESTROYED    = 0 #/* Interface doesn't exist.    */
    34.5  BLKIF_INTERFACE_STATUS_DISCONNECTED = 1 #/* Exists but is disconnected. */
    34.6  BLKIF_INTERFACE_STATUS_CONNECTED    = 2 #/* Exists and is connected.    */
    34.7 +BLKIF_INTERFACE_STATUS_CHANGED      = 3 #/* A device has been added or removed. */
    34.8  
    34.9  BLKIF_BE_STATUS_OKAY                = 0
   34.10  BLKIF_BE_STATUS_ERROR               = 1
   34.11 @@ -117,6 +118,7 @@ CMSG_NETIF_BE_DRIVER_STATUS_CHANGED    =
   34.12  NETIF_INTERFACE_STATUS_DESTROYED    = 0 #/* Interface doesn't exist.    */
   34.13  NETIF_INTERFACE_STATUS_DISCONNECTED = 1 #/* Exists but is disconnected. */
   34.14  NETIF_INTERFACE_STATUS_CONNECTED    = 2 #/* Exists and is connected.    */
   34.15 +NETIF_INTERFACE_STATUS_CHANGED      = 3 #/* A device has been added or removed. */
   34.16  
   34.17  NETIF_DRIVER_STATUS_DOWN   = 0
   34.18  NETIF_DRIVER_STATUS_UP     = 1
    35.1 --- a/tools/python/xen/xend/server/netif.py	Fri Sep 03 10:57:00 2004 +0000
    35.2 +++ b/tools/python/xen/xend/server/netif.py	Mon Sep 06 15:23:36 2004 +0000
    35.3 @@ -5,7 +5,6 @@
    35.4  import random
    35.5  
    35.6  from twisted.internet import defer
    35.7 -#defer.Deferred.debug = 1
    35.8  
    35.9  from xen.xend import sxp
   35.10  from xen.xend import Vifctl
   35.11 @@ -208,13 +207,17 @@ class NetDev(controller.SplitDev):
   35.12          val = unpackMsg('netif_be_create_t', msg)
   35.13          return self
   35.14  
   35.15 -    def destroy(self):
   35.16 +    def destroy(self, change=0):
   35.17          """Destroy the device's resources and disconnect from the back-end
   35.18 -        device controller.
   35.19 +        device controller. If 'change' is true notify the front-end interface.
   35.20 +
   35.21 +        @param change: change flag
   35.22          """
   35.23          def cb_destroy(val):
   35.24              self.send_be_destroy()
   35.25              self.getBackendInterface().close()
   35.26 +            if change:
   35.27 +                self.interfaceChanged()
   35.28          log.debug("Destroying vif domain=%d vif=%d", self.controller.dom, self.vif)
   35.29          self.vifctl('down')
   35.30          d = self.send_be_disconnect()
   35.31 @@ -256,7 +259,7 @@ class NetDev(controller.SplitDev):
   35.32                        { 'handle' : self.vif,
   35.33                          'status' : NETIF_INTERFACE_STATUS_CONNECTED,
   35.34                          'evtchn' : self.evtchn['port2'],
   35.35 -                        'domid'  : 0, ## FIXME: should be domid of backend
   35.36 +                        'domid'  : self.backendDomain,
   35.37                          'mac'    : self.mac })
   35.38          self.controller.writeRequest(msg)
   35.39  
   35.40 @@ -265,7 +268,19 @@ class NetDev(controller.SplitDev):
   35.41                        { 'handle' : self.vif,
   35.42                          'status' : NETIF_INTERFACE_STATUS_DISCONNECTED,
   35.43                          'evtchn' : 0,
   35.44 -                        'domid'  : 0, ## FIXME: should be domid of backend
   35.45 +                        'domid'  : self.backendDomain,
   35.46 +                        'mac'    : self.mac })
   35.47 +        self.controller.writeRequest(msg)
   35.48 +
   35.49 +    def interfaceChanged(self):
   35.50 +        """Notify the font-end that a device has been added or removed.
   35.51 +        The front-end should then probe the devices.
   35.52 +        """
   35.53 +        msg = packMsg('netif_fe_interface_status_changed_t',
   35.54 +                      { 'handle' : self.vif,
   35.55 +                        'status' : NETIF_INTERFACE_STATUS_CHANGED,
   35.56 +                        'evtchn' : 0,
   35.57 +                        'domid'  : self.backendDomain,
   35.58                          'mac'    : self.mac })
   35.59          self.controller.writeRequest(msg)
   35.60          
    36.1 --- a/tools/python/xen/xend/server/params.py	Fri Sep 03 10:57:00 2004 +0000
    36.2 +++ b/tools/python/xen/xend/server/params.py	Mon Sep 06 15:23:36 2004 +0000
    36.3 @@ -1,8 +1,10 @@
    36.4  # The following parameters could be placed in a configuration file.
    36.5 -PID_FILE  = '/var/run/xend.pid'
    36.6 +XEND_PID_FILE = '/var/run/xend.pid'
    36.7 +XFRD_PID_FILE = '/var/run/xfrd.pid'
    36.8 +XEND_TRACE_FILE = '/var/log/xend.trace'
    36.9 +
   36.10  USER = 'root'
   36.11 -CONTROL_DIR  = '/var/run/xend'
   36.12 -MGMT_SOCK    = 'xendsock' # relative to CONTROL_DIR
   36.13 +
   36.14  EVENT_PORT = 8001
   36.15  
   36.16  CONSOLE_PORT_BASE = 9600
    37.1 --- a/tools/python/xen/xm/main.py	Fri Sep 03 10:57:00 2004 +0000
    37.2 +++ b/tools/python/xen/xm/main.py	Mon Sep 06 15:23:36 2004 +0000
    37.3 @@ -737,22 +737,26 @@ class ProgVbdCreate(Prog):
    37.4      info = """Create a new virtual block device for a domain"""
    37.5  
    37.6      def help(self, args):
    37.7 -        print args[0], "DOM UNAME DEV MODE"
    37.8 +        print args[0], "DOM UNAME DEV MODE [BACKEND]"
    37.9          print """
   37.10  Create a virtual block device for a domain.
   37.11  
   37.12 -  UNAME - device to export, e.g. phys:hda2
   37.13 -  DEV   - device name in the domain, e.g. xda1
   37.14 -  MODE  - access mode: r for read, w for read-write
   37.15 +  UNAME   - device to export, e.g. phy:hda2
   37.16 +  DEV     - device name in the domain, e.g. xda1
   37.17 +  MODE    - access mode: r for read, w for read-write
   37.18 +  BACKEND - backend driver domain
   37.19  """
   37.20  
   37.21      def main(self, args):
   37.22 -        if len(args) != 5: self.err("%s: Invalid argument(s)" % args[0])
   37.23 +        n = len(args)
   37.24 +        if n < 5 or n > 6: self.err("%s: Invalid argument(s)" % args[0])
   37.25          dom = args[1]
   37.26          vbd = ['vbd',
   37.27                 ['uname', args[2]],
   37.28                 ['dev',   args[3]],
   37.29                 ['mode',  args[4]]]
   37.30 +        if n == 6:
   37.31 +            vbd.append(['backend', args[5]])
   37.32          server.xend_domain_device_create(dom, vbd)
   37.33  
   37.34  xm.prog(ProgVbdCreate)
   37.35 @@ -766,13 +770,15 @@ class ProgVbdDestroy(Prog):
   37.36          print args[0], "DOM DEV"
   37.37          print """
   37.38  Destroy vbd DEV attached to domain DOM. Detaches the device
   37.39 -from the domain, but does not destroy the device contents."""
   37.40 +from the domain, but does not destroy the device contents.
   37.41 +The device indentifier DEV is the idx field in the device
   37.42 +information. This is visible in 'xm vbd-list'."""
   37.43  
   37.44      def main(self, args):
   37.45 -        if len(args!=3): self.err("%s: Invalid argument(s)" % args[0])
   37.46 +        if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
   37.47          dom = args[1]
   37.48          dev = args[2]
   37.49 -        sever.xend_domain_device_destroy(dom, "vbd", dev)
   37.50 +        server.xend_domain_device_destroy(dom, "vbd", dev)
   37.51  
   37.52  xm.prog(ProgVbdDestroy)
   37.53  
    38.1 --- a/tools/xfrd/xen_domain.c	Fri Sep 03 10:57:00 2004 +0000
    38.2 +++ b/tools/xfrd/xen_domain.c	Mon Sep 06 15:23:36 2004 +0000
    38.3 @@ -16,6 +16,7 @@ typedef unsigned long u32;
    38.4  
    38.5  #define MODULE_NAME "XFRD"
    38.6  #define DEBUG 1
    38.7 +#undef DEBUG
    38.8  #include "debug.h"
    38.9  
   38.10  
    39.1 --- a/tools/xfrd/xfrd.c	Fri Sep 03 10:57:00 2004 +0000
    39.2 +++ b/tools/xfrd/xfrd.c	Mon Sep 06 15:23:36 2004 +0000
    39.3 @@ -50,6 +50,7 @@
    39.4  
    39.5  #define MODULE_NAME "XFRD"
    39.6  #define DEBUG 0
    39.7 +#undef DEBUG
    39.8  #include "debug.h"
    39.9  
   39.10  /*
   39.11 @@ -1142,7 +1143,11 @@ int main(int argc, char *argv[]){
   39.12      int err = 0;
   39.13      int key = 0;
   39.14      int long_index = 0;
   39.15 +    static const char * LOGFILE = "/var/log/xfrd.log";
   39.16  
   39.17 +    freopen(LOGFILE, "w+", stdout);
   39.18 +    fclose(stderr);
   39.19 +    stderr = stdout;
   39.20      dprintf(">\n");
   39.21      set_defaults(args);
   39.22      while(1){
    40.1 --- a/xen/arch/x86/domain.c	Fri Sep 03 10:57:00 2004 +0000
    40.2 +++ b/xen/arch/x86/domain.c	Mon Sep 06 15:23:36 2004 +0000
    40.3 @@ -449,12 +449,68 @@ long do_iopl(domid_t domain, unsigned in
    40.4  
    40.5  #endif
    40.6  
    40.7 -void domain_relinquish_memory(struct domain *d)
    40.8 +
    40.9 +static void relinquish_list(struct domain *d, struct list_head *list)
   40.10  {
   40.11 -    struct list_head *ent, *tmp;
   40.12 +    struct list_head *ent;
   40.13      struct pfn_info  *page;
   40.14      unsigned long     x, y;
   40.15  
   40.16 +    /* Use a recursive lock, as we may enter 'free_domheap_page'. */
   40.17 +    spin_lock_recursive(&d->page_alloc_lock);
   40.18 +
   40.19 +    ent = list->next;
   40.20 +    while ( ent != list )
   40.21 +    {
   40.22 +        page = list_entry(ent, struct pfn_info, list);
   40.23 +
   40.24 +        /* Grab a reference to the page so it won't disappear from under us. */
   40.25 +        if ( unlikely(!get_page(page, d)) )
   40.26 +        {
   40.27 +            /* Couldn't get a reference -- someone is freeing this page. */
   40.28 +            ent = ent->next;
   40.29 +            continue;
   40.30 +        }
   40.31 +
   40.32 +        if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
   40.33 +            put_page_and_type(page);
   40.34 +
   40.35 +        if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
   40.36 +            put_page(page);
   40.37 +
   40.38 +        /*
   40.39 +         * Forcibly invalidate base page tables at this point to break circular
   40.40 +         * 'linear page table' references. This is okay because MMU structures
   40.41 +         * are not shared across domains and this domain is now dead. Thus base
   40.42 +         * tables are not in use so a non-zero count means circular reference.
   40.43 +         */
   40.44 +        y = page->u.inuse.type_info;
   40.45 +        for ( ; ; )
   40.46 +        {
   40.47 +            x = y;
   40.48 +            if ( likely((x & (PGT_type_mask|PGT_validated)) != 
   40.49 +                        (PGT_base_page_table|PGT_validated)) )
   40.50 +                break;
   40.51 +
   40.52 +            y = cmpxchg(&page->u.inuse.type_info, x, x & ~PGT_validated);
   40.53 +            if ( likely(y == x) )
   40.54 +            {
   40.55 +                free_page_type(page, PGT_base_page_table);
   40.56 +                break;
   40.57 +            }
   40.58 +        }
   40.59 +
   40.60 +        /* Follow the list chain and /then/ potentially free the page. */
   40.61 +        ent = ent->next;
   40.62 +        put_page(page);
   40.63 +    }
   40.64 +
   40.65 +    spin_unlock_recursive(&d->page_alloc_lock);
   40.66 +}
   40.67 +
   40.68 +
   40.69 +void domain_relinquish_memory(struct domain *d)
   40.70 +{
   40.71      /* Ensure that noone is running over the dead domain's page tables. */
   40.72      synchronise_pagetables(~0UL);
   40.73  
   40.74 @@ -472,49 +528,9 @@ void domain_relinquish_memory(struct dom
   40.75       */
   40.76      destroy_gdt(d);
   40.77  
   40.78 -    /* Use a recursive lock, as we may enter 'free_domheap_page'. */
   40.79 -    spin_lock_recursive(&d->page_alloc_lock);
   40.80 -
   40.81 -    /* Relinquish Xen-heap pages. */
   40.82 -    list_for_each_safe ( ent, tmp, &d->xenpage_list )
   40.83 -    {
   40.84 -        page = list_entry(ent, struct pfn_info, list);
   40.85 -
   40.86 -        if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
   40.87 -            put_page(page);
   40.88 -    }
   40.89 -
   40.90 -    /* Relinquish all pages on the domain's allocation list. */
   40.91 -    list_for_each_safe ( ent, tmp, &d->page_list )
   40.92 -    {
   40.93 -        page = list_entry(ent, struct pfn_info, list);
   40.94 -
   40.95 -        if ( test_and_clear_bit(_PGC_guest_pinned, &page->count_info) )
   40.96 -            put_page_and_type(page);
   40.97 -
   40.98 -        if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
   40.99 -            put_page(page);
  40.100 -
  40.101 -        /*
  40.102 -         * Forcibly invalidate base page tables at this point to break circular
  40.103 -         * 'linear page table' references. This is okay because MMU structures
  40.104 -         * are not shared across domains and this domain is now dead. Thus base
  40.105 -         * tables are not in use so a non-zero count means circular reference.
  40.106 -         */
  40.107 -        y = page->u.inuse.type_info;
  40.108 -        do {
  40.109 -            x = y;
  40.110 -            if ( likely((x & (PGT_type_mask|PGT_validated)) != 
  40.111 -                        (PGT_base_page_table|PGT_validated)) )
  40.112 -                break;
  40.113 -            y = cmpxchg(&page->u.inuse.type_info, x, x & ~PGT_validated);
  40.114 -            if ( likely(y == x) )
  40.115 -                free_page_type(page, PGT_base_page_table);
  40.116 -        }
  40.117 -        while ( unlikely(y != x) );
  40.118 -    }
  40.119 -
  40.120 -    spin_unlock_recursive(&d->page_alloc_lock);
  40.121 +    /* Relinquish every page of memory. */
  40.122 +    relinquish_list(d, &d->xenpage_list);
  40.123 +    relinquish_list(d, &d->page_list);
  40.124  }
  40.125  
  40.126  
  40.127 @@ -739,12 +755,15 @@ int construct_dom0(struct domain *p,
  40.128              /* Get another ref to L2 page so that it can be pinned. */
  40.129              if ( !get_page_and_type(page, p, PGT_l2_page_table) )
  40.130                  BUG();
  40.131 -            set_bit(_PGC_guest_pinned, &page->count_info);
  40.132 +            set_bit(_PGT_pinned, &page->u.inuse.type_info);
  40.133          }
  40.134          else
  40.135          {
  40.136              page->u.inuse.type_info &= ~PGT_type_mask;
  40.137              page->u.inuse.type_info |= PGT_l1_page_table;
  40.138 +	    page->u.inuse.type_info |= 
  40.139 +		((v_start>>L2_PAGETABLE_SHIFT)+(count-1))<<PGT_va_shift;
  40.140 +
  40.141              get_page(page, p); /* an extra ref because of readable mapping */
  40.142          }
  40.143          l1tab++;
    41.1 --- a/xen/arch/x86/memory.c	Fri Sep 03 10:57:00 2004 +0000
    41.2 +++ b/xen/arch/x86/memory.c	Mon Sep 06 15:23:36 2004 +0000
    41.3 @@ -142,8 +142,6 @@ static struct domain *dom_xen, *dom_io;
    41.4  
    41.5  void arch_init_memory(void)
    41.6  {
    41.7 -    static void ptwr_init_backpointers(void);
    41.8 -    static void ptwr_disable(void);
    41.9      unsigned long mfn;
   41.10  
   41.11      /*
   41.12 @@ -165,10 +163,15 @@ void arch_init_memory(void)
   41.13  
   41.14      memset(percpu_info, 0, sizeof(percpu_info));
   41.15  
   41.16 +/* XXXX WRITEABLE PAGETABLES SHOULD BE A DOMAIN CREATION-TIME
   41.17 +   DECISION, NOT SOMETHING THAT IS CHANGED ON A RUNNING DOMAIN 
   41.18 +   !!! FIX ME !!!! 
   41.19 + */
   41.20 +
   41.21      vm_assist_info[VMASST_TYPE_writable_pagetables].enable =
   41.22 -        ptwr_init_backpointers;
   41.23 +        NULL;
   41.24      vm_assist_info[VMASST_TYPE_writable_pagetables].disable =
   41.25 -        ptwr_disable;
   41.26 +        NULL;
   41.27  
   41.28      for ( mfn = 0; mfn < max_page; mfn++ )
   41.29          frame_table[mfn].count_info |= PGC_always_set;
   41.30 @@ -322,17 +325,6 @@ static int get_page_and_type_from_pagenr
   41.31  }
   41.32  
   41.33  
   41.34 -static inline void set_l1_page_va(unsigned long pfn,
   41.35 -                                  unsigned long va_idx)
   41.36 -{
   41.37 -    struct pfn_info *page;
   41.38 -    
   41.39 -    page = &frame_table[pfn];
   41.40 -    page->u.inuse.type_info &= ~PGT_va_mask;
   41.41 -    page->u.inuse.type_info |= va_idx << PGT_va_shift;
   41.42 -}
   41.43 -
   41.44 -
   41.45  /*
   41.46   * We allow an L2 tables to map each other (a.k.a. linear page tables). It
   41.47   * needs some special care with reference counst and access permissions:
   41.48 @@ -466,8 +458,11 @@ get_page_from_l1e(
   41.49  /* NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. */
   41.50  static int 
   41.51  get_page_from_l2e(
   41.52 -    l2_pgentry_t l2e, unsigned long pfn, struct domain *d)
   41.53 +    l2_pgentry_t l2e, unsigned long pfn,
   41.54 +    struct domain *d, unsigned long va_idx)
   41.55  {
   41.56 +    int rc;
   41.57 +
   41.58      if ( !(l2_pgentry_val(l2e) & _PAGE_PRESENT) )
   41.59          return 1;
   41.60  
   41.61 @@ -478,8 +473,11 @@ get_page_from_l2e(
   41.62          return 0;
   41.63      }
   41.64  
   41.65 -    if ( unlikely(!get_page_and_type_from_pagenr(
   41.66 -        l2_pgentry_to_pagenr(l2e), PGT_l1_page_table, d)) )
   41.67 +    rc = get_page_and_type_from_pagenr(
   41.68 +        l2_pgentry_to_pagenr(l2e), 
   41.69 +        PGT_l1_page_table | (va_idx<<PGT_va_shift), d);
   41.70 +
   41.71 +    if ( unlikely(!rc) )
   41.72          return get_linear_pagetable(l2e, pfn, d);
   41.73  
   41.74      return 1;
   41.75 @@ -553,9 +551,8 @@ static int alloc_l2_table(struct pfn_inf
   41.76      pl2e = map_domain_mem(page_nr << PAGE_SHIFT);
   41.77  
   41.78      for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ ) {
   41.79 -        if ( unlikely(!get_page_from_l2e(pl2e[i], page_nr, d)) )
   41.80 +        if ( unlikely(!get_page_from_l2e(pl2e[i], page_nr, d, i)) )
   41.81              goto fail;
   41.82 -        set_l1_page_va(l2_pgentry_val(pl2e[i]) >> PAGE_SHIFT, i);
   41.83      }
   41.84      
   41.85  #if defined(__i386__)
   41.86 @@ -677,11 +674,10 @@ static int mod_l2_entry(l2_pgentry_t *pl
   41.87          if ( ((l2_pgentry_val(ol2e) ^ l2_pgentry_val(nl2e)) & ~0xffe) == 0 )
   41.88              return update_l2e(pl2e, ol2e, nl2e);
   41.89  
   41.90 -        if ( unlikely(!get_page_from_l2e(nl2e, pfn, current)) )
   41.91 +        if ( unlikely(!get_page_from_l2e(nl2e, pfn, current, 
   41.92 +					((unsigned long)pl2e & 
   41.93 +                                         ~PAGE_MASK) >> 2)) )
   41.94              return 0;
   41.95 -        
   41.96 -        set_l1_page_va(l2_pgentry_val(nl2e) >> PAGE_SHIFT,
   41.97 -                       ((unsigned long)pl2e & (PAGE_SIZE-1)) >> 2);
   41.98  
   41.99          if ( unlikely(!update_l2e(pl2e, ol2e, nl2e)) )
  41.100          {
  41.101 @@ -836,10 +832,17 @@ static int do_extended_command(unsigned 
  41.102      {
  41.103      case MMUEXT_PIN_L1_TABLE:
  41.104      case MMUEXT_PIN_L2_TABLE:
  41.105 +        /*
  41.106 +         * We insist that, if you pin an L1 page, it's the first thing that
  41.107 +         * you do to it. This is because we require the backptr to still be
  41.108 +         * mutable. This assumption seems safe.
  41.109 +         */
  41.110          okay = get_page_and_type_from_pagenr(
  41.111              pfn, 
  41.112 -            (cmd==MMUEXT_PIN_L2_TABLE) ? PGT_l2_page_table : PGT_l1_page_table,
  41.113 +            ((cmd==MMUEXT_PIN_L2_TABLE) ? 
  41.114 +	     PGT_l2_page_table : (PGT_l1_page_table|PGT_va_mutable)),
  41.115              FOREIGNDOM);
  41.116 +
  41.117          if ( unlikely(!okay) )
  41.118          {
  41.119              MEM_LOG("Error while pinning pfn %08lx", pfn);
  41.120 @@ -847,8 +850,8 @@ static int do_extended_command(unsigned 
  41.121              break;
  41.122          }
  41.123  
  41.124 -        if ( unlikely(test_and_set_bit(_PGC_guest_pinned,
  41.125 -                                       &page->count_info)) )
  41.126 +        if ( unlikely(test_and_set_bit(_PGT_pinned,
  41.127 +                                       &page->u.inuse.type_info)) )
  41.128          {
  41.129              MEM_LOG("Pfn %08lx already pinned", pfn);
  41.130              put_page_and_type(page);
  41.131 @@ -864,8 +867,8 @@ static int do_extended_command(unsigned 
  41.132              MEM_LOG("Page %08lx bad domain (dom=%p)",
  41.133                      ptr, page->u.inuse.domain);
  41.134          }
  41.135 -        else if ( likely(test_and_clear_bit(_PGC_guest_pinned, 
  41.136 -                                            &page->count_info)) )
  41.137 +        else if ( likely(test_and_clear_bit(_PGT_pinned, 
  41.138 +                                            &page->u.inuse.type_info)) )
  41.139          {
  41.140              put_page_and_type(page);
  41.141              put_page(page);
  41.142 @@ -897,8 +900,7 @@ static int do_extended_command(unsigned 
  41.143              /*
  41.144               * Note that we tick the clock /after/ dropping the old base's
  41.145               * reference count. If the page tables got freed then this will
  41.146 -             * avoid unnecessary TLB flushes when the pages are reused.
  41.147 -             */
  41.148 +             * avoid unnecessary TLB flushes when the pages are reused.  */
  41.149              tlb_clocktick();
  41.150          }
  41.151          else
  41.152 @@ -915,6 +917,18 @@ static int do_extended_command(unsigned 
  41.153          __flush_tlb_one(ptr);
  41.154          break;
  41.155  
  41.156 +    case MMUEXT_FLUSH_CACHE:
  41.157 +        if ( unlikely(!IS_CAPABLE_PHYSDEV(d)) )
  41.158 +        {
  41.159 +            MEM_LOG("Non-physdev domain tried to FLUSH_CACHE.\n");
  41.160 +            okay = 0;
  41.161 +        }
  41.162 +        else
  41.163 +        {
  41.164 +            wbinvd();
  41.165 +        }
  41.166 +        break;
  41.167 +
  41.168      case MMUEXT_SET_LDT:
  41.169      {
  41.170          unsigned long ents = val >> MMUEXT_CMD_SHIFT;
  41.171 @@ -1040,13 +1054,18 @@ static int do_extended_command(unsigned 
  41.172  
  41.173          spin_lock(&e->page_alloc_lock);
  41.174  
  41.175 -        /* Check that 'e' will accept the page and has reservation headroom. */
  41.176 +        /*
  41.177 +         * Check that 'e' will accept the page and has reservation headroom.
  41.178 +         * Also, a domain mustn't have PGC_allocated pages when it is dying.
  41.179 +         */
  41.180          ASSERT(e->tot_pages <= e->max_pages);
  41.181 -        if ( unlikely(e->tot_pages == e->max_pages) ||
  41.182 +        if ( unlikely(test_bit(DF_DYING, &e->flags)) ||
  41.183 +             unlikely(e->tot_pages == e->max_pages) ||
  41.184               unlikely(!gnttab_prepare_for_transfer(e, d, gntref)) )
  41.185          {
  41.186              MEM_LOG("Transferee has no reservation headroom (%d,%d), or "
  41.187 -                    "provided a bad grant ref.\n", e->tot_pages, e->max_pages);
  41.188 +                    "provided a bad grant ref, or is dying (%08lx).\n",
  41.189 +                    e->tot_pages, e->max_pages, e->flags);
  41.190              spin_unlock(&e->page_alloc_lock);
  41.191              put_domain(e);
  41.192              okay = 0;
  41.193 @@ -1182,6 +1201,7 @@ int do_mmu_update(mmu_update_t *ureqs, i
  41.194      unsigned long prev_spfn = 0;
  41.195      l1_pgentry_t *prev_spl1e = 0;
  41.196      struct domain *d = current;
  41.197 +    u32 type_info;
  41.198  
  41.199      perfc_incrc(calls_to_mmu_update); 
  41.200      perfc_addc(num_page_updates, count);
  41.201 @@ -1230,10 +1250,11 @@ int do_mmu_update(mmu_update_t *ureqs, i
  41.202              }
  41.203  
  41.204              page = &frame_table[pfn];
  41.205 -            switch ( (page->u.inuse.type_info & PGT_type_mask) )
  41.206 +            switch ( (type_info = page->u.inuse.type_info) & PGT_type_mask )
  41.207              {
  41.208              case PGT_l1_page_table: 
  41.209 -                if ( likely(get_page_type(page, PGT_l1_page_table)) )
  41.210 +                if ( likely(get_page_type(
  41.211 +                    page, type_info & (PGT_type_mask|PGT_va_mask))) )
  41.212                  {
  41.213                      okay = mod_l1_entry((l1_pgentry_t *)va, 
  41.214                                          mk_l1_pgentry(req.val)); 
  41.215 @@ -1483,11 +1504,11 @@ void ptwr_reconnect_disconnected(unsigne
  41.216          [ptwr_info[cpu].writable_l1>>PAGE_SHIFT];
  41.217  
  41.218  #ifdef PTWR_TRACK_DOMAIN
  41.219 -    if (ptwr_domain[cpu] != get_current()->domain)
  41.220 +    if (ptwr_domain[cpu] != current->domain)
  41.221          printk("ptwr_reconnect_disconnected domain mismatch %d != %d\n",
  41.222 -               ptwr_domain[cpu], get_current()->domain);
  41.223 +               ptwr_domain[cpu], current->domain);
  41.224  #endif
  41.225 -    PTWR_PRINTK(("[A] page fault in disconnected space: addr %08lx space %08lx\n",
  41.226 +    PTWR_PRINTK(("[A] page fault in disconn space: addr %08lx space %08lx\n",
  41.227                   addr, ptwr_info[cpu].disconnected << L2_PAGETABLE_SHIFT));
  41.228      pl2e = &linear_l2_table[ptwr_info[cpu].disconnected];
  41.229  
  41.230 @@ -1559,9 +1580,9 @@ void ptwr_flush_inactive(void)
  41.231      int i, idx;
  41.232  
  41.233  #ifdef PTWR_TRACK_DOMAIN
  41.234 -    if (ptwr_info[cpu].domain != get_current()->domain)
  41.235 +    if (ptwr_info[cpu].domain != current->domain)
  41.236          printk("ptwr_flush_inactive domain mismatch %d != %d\n",
  41.237 -               ptwr_info[cpu].domain, get_current()->domain);
  41.238 +               ptwr_info[cpu].domain, current->domain);
  41.239  #endif
  41.240  #if 0
  41.241      {
  41.242 @@ -1626,9 +1647,11 @@ int ptwr_do_page_fault(unsigned long add
  41.243      PTWR_PRINTK(("get user %p for va %08lx\n",
  41.244                   &linear_pg_table[addr>>PAGE_SHIFT], addr));
  41.245  #endif
  41.246 +
  41.247 +    /* Testing for page_present in the L2 avoids lots of unncessary fixups */
  41.248      if ( (l2_pgentry_val(linear_l2_table[addr >> L2_PAGETABLE_SHIFT]) &
  41.249 -          _PAGE_PRESENT) &&
  41.250 -         (__get_user(pte, (unsigned long *)
  41.251 +      _PAGE_PRESENT) &&
  41.252 +	 (__get_user(pte, (unsigned long *)
  41.253                       &linear_pg_table[addr >> PAGE_SHIFT]) == 0) )
  41.254      {
  41.255          pfn = pte >> PAGE_SHIFT;
  41.256 @@ -1640,9 +1663,9 @@ int ptwr_do_page_fault(unsigned long add
  41.257          if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l1_page_table )
  41.258          {
  41.259  #ifdef PTWR_TRACK_DOMAIN
  41.260 -            if ( ptwr_info[cpu].domain != get_current()->domain )
  41.261 +            if ( ptwr_info[cpu].domain != current->domain )
  41.262                  printk("ptwr_do_page_fault domain mismatch %d != %d\n",
  41.263 -                       ptwr_info[cpu].domain, get_current()->domain);
  41.264 +                       ptwr_info[cpu].domain, current->domain);
  41.265  #endif
  41.266              pl2e = &linear_l2_table[(page->u.inuse.type_info &
  41.267                                       PGT_va_mask) >> PGT_va_shift];
  41.268 @@ -1653,6 +1676,7 @@ int ptwr_do_page_fault(unsigned long add
  41.269  
  41.270              if ( l2_pgentry_val(*pl2e) >> PAGE_SHIFT != pfn )
  41.271              {
  41.272 +		/* this L1 is not in the current address space */
  41.273                  l1_pgentry_t *pl1e;
  41.274                  PTWR_PRINTK(("[I] freeing l1 page %p taf %08x/%08x\n", page,
  41.275                               page->u.inuse.type_info,
  41.276 @@ -1718,36 +1742,6 @@ int ptwr_do_page_fault(unsigned long add
  41.277      return 0;
  41.278  }
  41.279  
  41.280 -static void ptwr_init_backpointers(void)
  41.281 -{
  41.282 -    struct pfn_info *page;
  41.283 -    unsigned long pde;
  41.284 -    int va_idx;
  41.285 -
  41.286 -    for ( va_idx = 0; va_idx < DOMAIN_ENTRIES_PER_L2_PAGETABLE; va_idx++ )
  41.287 -    {
  41.288 -        /* check if entry valid */
  41.289 -        pde = l2_pgentry_val(linear_l2_table[va_idx]);
  41.290 -        if ( (pde & _PAGE_PRESENT) == 0 )
  41.291 -            continue;
  41.292 -
  41.293 -        page = &frame_table[pde >> PAGE_SHIFT];
  41.294 -        /* assert that page is an l1_page_table   XXXcl maybe l2? */
  41.295 -        if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) {
  41.296 -	    MEM_LOG("ptwr: Inconsistent pagetable: pde %lx not an l1 page\n",
  41.297 -		    pde >> PAGE_SHIFT);
  41.298 -	    domain_crash();
  41.299 -	}
  41.300 -        page->u.inuse.type_info &= ~PGT_va_mask;
  41.301 -        page->u.inuse.type_info |= va_idx << PGT_va_shift;
  41.302 -    }
  41.303 -}
  41.304 -
  41.305 -static void ptwr_disable(void)
  41.306 -{
  41.307 -    __cleanup_writable_pagetable(PTWR_CLEANUP_ACTIVE | PTWR_CLEANUP_INACTIVE);
  41.308 -}
  41.309 -
  41.310  #ifndef NDEBUG
  41.311  void ptwr_status(void)
  41.312  {
    42.1 --- a/xen/arch/x86/shadow.c	Fri Sep 03 10:57:00 2004 +0000
    42.2 +++ b/xen/arch/x86/shadow.c	Mon Sep 06 15:23:36 2004 +0000
    42.3 @@ -262,7 +262,7 @@ void __shadow_mode_disable(struct domain
    42.4      __free_shadow_table(m);
    42.5      m->shadow_mode = 0;
    42.6  
    42.7 -    SH_LOG("freed tables count=%d l1=%d l2=%d",
    42.8 +    SH_VLOG("freed tables count=%d l1=%d l2=%d",
    42.9             m->shadow_page_count, perfc_value(shadow_l1_pages), 
   42.10             perfc_value(shadow_l2_pages));
   42.11  
    43.1 --- a/xen/arch/x86/traps.c	Fri Sep 03 10:57:00 2004 +0000
    43.2 +++ b/xen/arch/x86/traps.c	Mon Sep 06 15:23:36 2004 +0000
    43.3 @@ -330,9 +330,9 @@ asmlinkage void do_page_fault(struct pt_
    43.4              return; /* successfully copied the mapping */
    43.5      }
    43.6  
    43.7 -    if ( unlikely(VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) )
    43.8 +    if ( likely(VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) )
    43.9      {
   43.10 -        if ( (addr >> L2_PAGETABLE_SHIFT) == ptwr_info[cpu].disconnected )
   43.11 +        if ( unlikely((addr >> L2_PAGETABLE_SHIFT) == ptwr_info[cpu].disconnected ))
   43.12          {
   43.13              ptwr_reconnect_disconnected(addr);
   43.14              return;
    44.1 --- a/xen/common/dom0_ops.c	Fri Sep 03 10:57:00 2004 +0000
    44.2 +++ b/xen/common/dom0_ops.c	Mon Sep 06 15:23:36 2004 +0000
    44.3 @@ -628,7 +628,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    44.4                          break;
    44.5                      }
    44.6  
    44.7 -		    if ( page->count_info & PGC_guest_pinned )
    44.8 +		    if ( page->u.inuse.type_info & PGT_pinned )
    44.9  			type |= LPINTAB;
   44.10  		    l_arr[j] |= type;
   44.11                      put_page(page);
    45.1 --- a/xen/common/dom_mem_ops.c	Fri Sep 03 10:57:00 2004 +0000
    45.2 +++ b/xen/common/dom_mem_ops.c	Mon Sep 06 15:23:36 2004 +0000
    45.3 @@ -82,7 +82,7 @@ static long free_dom_mem(struct domain *
    45.4                  return i;
    45.5              }
    45.6  
    45.7 -            if ( test_and_clear_bit(_PGC_guest_pinned, &page->count_info) )
    45.8 +            if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
    45.9                  put_page_and_type(page);
   45.10              
   45.11              if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
    46.1 --- a/xen/common/domain.c	Fri Sep 03 10:57:00 2004 +0000
    46.2 +++ b/xen/common/domain.c	Mon Sep 06 15:23:36 2004 +0000
    46.3 @@ -65,7 +65,7 @@ struct domain *do_createdomain(domid_t d
    46.4          strncpy(d->name, buf, MAX_DOMAIN_NAME);
    46.5          d->name[MAX_DOMAIN_NAME-1] = '\0';
    46.6  
    46.7 -	arch_do_createdomain(d);
    46.8 +        arch_do_createdomain(d);
    46.9  
   46.10          sched_add_domain(d);
   46.11  
   46.12 @@ -152,8 +152,8 @@ void domain_crash(void)
   46.13  {
   46.14      struct domain *d;
   46.15  
   46.16 -    if (current->domain == 0)
   46.17 -	BUG();
   46.18 +    if ( current->domain == 0 )
   46.19 +        BUG();
   46.20  
   46.21      set_bit(DF_CRASHED, &current->flags);
   46.22  
    47.1 --- a/xen/common/page_alloc.c	Fri Sep 03 10:57:00 2004 +0000
    47.2 +++ b/xen/common/page_alloc.c	Mon Sep 06 15:23:36 2004 +0000
    47.3 @@ -393,10 +393,13 @@ struct pfn_info *alloc_domheap_pages(str
    47.4  
    47.5      spin_lock(&d->page_alloc_lock);
    47.6  
    47.7 -    if ( unlikely((d->tot_pages + (1 << order)) > d->max_pages) )
    47.8 +    if ( unlikely(test_bit(DF_DYING, &d->flags)) ||
    47.9 +         unlikely((d->tot_pages + (1 << order)) > d->max_pages) )
   47.10      {
   47.11          DPRINTK("Over-allocation for domain %u: %u > %u\n",
   47.12                  d->domain, d->tot_pages + (1 << order), d->max_pages);
   47.13 +        DPRINTK("...or the domain is dying (%d)\n", 
   47.14 +                !!test_bit(DF_DYING, &d->flags));
   47.15          spin_unlock(&d->page_alloc_lock);
   47.16          free_heap_pages(MEMZONE_DOM, pg, order);
   47.17          return NULL;
   47.18 @@ -427,6 +430,7 @@ void free_domheap_pages(struct pfn_info 
   47.19  
   47.20      if ( unlikely(IS_XEN_HEAP_FRAME(pg)) )
   47.21      {
   47.22 +        /* NB. May recursively lock from domain_relinquish_memory(). */
   47.23          spin_lock_recursive(&d->page_alloc_lock);
   47.24  
   47.25          for ( i = 0; i < (1 << order); i++ )
    48.1 --- a/xen/common/schedule.c	Fri Sep 03 10:57:00 2004 +0000
    48.2 +++ b/xen/common/schedule.c	Mon Sep 06 15:23:36 2004 +0000
    48.3 @@ -374,20 +374,6 @@ void __enter_scheduler(void)
    48.4      cleanup_writable_pagetable(
    48.5          prev, PTWR_CLEANUP_ACTIVE | PTWR_CLEANUP_INACTIVE);
    48.6  
    48.7 -#ifdef PTWR_TRACK_DOMAIN
    48.8 -    {
    48.9 -        extern domid_t ptwr_domain[];
   48.10 -        int cpu = smp_processor_id();
   48.11 -        if (ptwr_domain[cpu] != prev->domain)
   48.12 -            printk("switch_to domain mismatch %d != %d\n",
   48.13 -                   ptwr_domain[cpu], prev->domain);
   48.14 -        ptwr_domain[cpu] = next->domain;
   48.15 -        if (ptwr_disconnected[cpu] != ENTRIES_PER_L2_PAGETABLE ||
   48.16 -            ptwr_writable_idx[cpu])
   48.17 -            printk("switch_to ptwr dirty!!!\n");
   48.18 -    }
   48.19 -#endif
   48.20 -
   48.21      perfc_incrc(sched_ctx);
   48.22  
   48.23  #if defined(WAKE_HISTO)
    49.1 --- a/xen/include/asm-x86/mm.h	Fri Sep 03 10:57:00 2004 +0000
    49.2 +++ b/xen/include/asm-x86/mm.h	Mon Sep 06 15:23:36 2004 +0000
    49.3 @@ -71,26 +71,27 @@ struct pfn_info
    49.4   /* Has this page been validated for use as its current type? */
    49.5  #define _PGT_validated      28
    49.6  #define PGT_validated       (1<<_PGT_validated)
    49.7 - /* 10-bit most significant bits of va address if used as l1 page table */
    49.8 -#define PGT_va_shift        18
    49.9 + /* Owning guest has pinned this page to its current type? */
   49.10 +#define _PGT_pinned         27
   49.11 +#define PGT_pinned          (1<<_PGT_pinned)
   49.12 + /* The 10 most significant bits of virt address if this is a page table. */
   49.13 +#define PGT_va_shift        17
   49.14  #define PGT_va_mask         (((1<<10)-1)<<PGT_va_shift)
   49.15 - /* 18-bit count of uses of this frame as its current type. */
   49.16 -#define PGT_count_mask      ((1<<18)-1)
   49.17 +#define PGT_va_mutable      PGT_va_mask /* va backpointer is mutable? */
   49.18 + /* 17-bit count of uses of this frame as its current type. */
   49.19 +#define PGT_count_mask      ((1<<17)-1)
   49.20  
   49.21   /* For safety, force a TLB flush when this page's type changes. */
   49.22  #define _PGC_tlb_flush_on_type_change 31
   49.23  #define PGC_tlb_flush_on_type_change  (1<<_PGC_tlb_flush_on_type_change)
   49.24 - /* Owning guest has pinned this page to its current type? */
   49.25 -#define _PGC_guest_pinned             30
   49.26 -#define PGC_guest_pinned              (1<<_PGC_guest_pinned)
   49.27   /* Cleared when the owning guest 'frees' this page. */
   49.28 -#define _PGC_allocated                29
   49.29 +#define _PGC_allocated                30
   49.30  #define PGC_allocated                 (1<<_PGC_allocated)
   49.31   /* This bit is always set, guaranteeing that the count word is never zero. */
   49.32 -#define _PGC_always_set               28
   49.33 +#define _PGC_always_set               29
   49.34  #define PGC_always_set                (1<<_PGC_always_set)
   49.35 - /* 27-bit count of references to this frame. */
   49.36 -#define PGC_count_mask                ((1<<28)-1)
   49.37 + /* 29-bit count of references to this frame. */
   49.38 +#define PGC_count_mask                ((1<<29)-1)
   49.39  
   49.40  /* We trust the slab allocator in slab.c, and our use of it. */
   49.41  #define PageSlab(page)		(1)
   49.42 @@ -198,6 +199,12 @@ static inline void put_page_type(struct 
   49.43                  nx &= ~PGT_validated;
   49.44              }
   49.45          }
   49.46 +	else if ( unlikely((nx & (PGT_pinned | PGT_count_mask)) == 
   49.47 +                           (PGT_pinned | 1)) )
   49.48 +	{
   49.49 +            /* Page is now only pinned. Make the back pointer mutable again. */
   49.50 +	    nx |= PGT_va_mutable;
   49.51 +	}
   49.52      }
   49.53      while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) );
   49.54  }
   49.55 @@ -217,29 +224,45 @@ static inline int get_page_type(struct p
   49.56          }
   49.57          else if ( unlikely((x & PGT_count_mask) == 0) )
   49.58          {
   49.59 -            if ( (x & PGT_type_mask) != type )
   49.60 +            if ( (x & (PGT_type_mask|PGT_va_mask)) != type )
   49.61              {
   49.62 -                nx &= ~(PGT_type_mask | PGT_validated);
   49.63 +                nx &= ~(PGT_type_mask | PGT_va_mask | PGT_validated);
   49.64                  nx |= type;
   49.65                  /* No extra validation needed for writable pages. */
   49.66                  if ( type == PGT_writable_page )
   49.67                      nx |= PGT_validated;
   49.68              }
   49.69          }
   49.70 -        else if ( unlikely((x & PGT_type_mask) != type) )
   49.71 +        else if ( unlikely((x & (PGT_type_mask|PGT_va_mask)) != type) )
   49.72          {
   49.73 +            if ( unlikely((x & PGT_type_mask) != (type & PGT_type_mask) ) )
   49.74 +            {
   49.75  #ifdef VERBOSE
   49.76 -	    if ((x & PGT_type_mask) != PGT_l2_page_table &&
   49.77 -		type != PGT_l1_page_table)
   49.78 -		DPRINTK("Unexpected type (saw %08x != exp %08x) for pfn %08lx\n",
   49.79 -			x & PGT_type_mask, type, page_to_pfn(page));
   49.80 +                if ( ((x & PGT_type_mask) != PGT_l2_page_table) ||
   49.81 +                     ((type & PGT_type_mask) != PGT_l1_page_table) )
   49.82 +                    DPRINTK("Bad type (saw %08x != exp %08x) for pfn %08lx\n",
   49.83 +                            x & PGT_type_mask, type, page_to_pfn(page));
   49.84  #endif
   49.85 -            return 0;
   49.86 +                return 0;
   49.87 +            }
   49.88 +            else if ( (x & PGT_va_mask) == PGT_va_mutable )
   49.89 +            {
   49.90 +                /* The va backpointer is mutable, hence we update it. */
   49.91 +                nx &= ~PGT_va_mask;
   49.92 +                nx |= type; /* we know the actual type is correct */
   49.93 +            }
   49.94 +            else if ( unlikely((x & PGT_va_mask) != (type & PGT_va_mask)) )
   49.95 +            {
   49.96 +                /* The va backpointer wasn't mutable, and is different. */
   49.97 +                DPRINTK("Unexpected va backpointer (saw %08x != exp %08x)"
   49.98 +                        " for pfn %08lx\n", x, type, page_to_pfn(page));
   49.99 +                return 0;
  49.100 +            }
  49.101          }
  49.102 -        else if ( unlikely(!(x & PGT_validated)) )
  49.103 +	else if ( unlikely(!(x & PGT_validated)) )
  49.104          {
  49.105              /* Someone else is updating validation of this page. Wait... */
  49.106 -            while ( (y = page->u.inuse.type_info) != x )
  49.107 +            while ( (y = page->u.inuse.type_info) == x )
  49.108              {
  49.109                  rep_nop();
  49.110                  barrier();
  49.111 @@ -252,7 +275,7 @@ static inline int get_page_type(struct p
  49.112      if ( unlikely(!(nx & PGT_validated)) )
  49.113      {
  49.114          /* Try to validate page type; drop the new reference on failure. */
  49.115 -        if ( unlikely(!alloc_page_type(page, type)) )
  49.116 +        if ( unlikely(!alloc_page_type(page, type & PGT_type_mask)) )
  49.117          {
  49.118              DPRINTK("Error while validating pfn %08lx for type %08x."
  49.119                      " caf=%08x taf=%08x\n",
  49.120 @@ -262,6 +285,7 @@ static inline int get_page_type(struct p
  49.121              put_page_type(page);
  49.122              return 0;
  49.123          }
  49.124 +
  49.125          set_bit(_PGT_validated, &page->u.inuse.type_info);
  49.126      }
  49.127  
    50.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Fri Sep 03 10:57:00 2004 +0000
    50.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Mon Sep 06 15:23:36 2004 +0000
    50.3 @@ -19,7 +19,7 @@
    50.4   * This makes sure that old versions of dom0 tools will stop working in a
    50.5   * well-defined way (rather than crashing the machine, for instance).
    50.6   */
    50.7 -#define DOM0_INTERFACE_VERSION   0xAAAA0012
    50.8 +#define DOM0_INTERFACE_VERSION   0xAAAA0014
    50.9  
   50.10  #define MAX_DOMAIN_NAME    16
   50.11  
    51.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h	Fri Sep 03 10:57:00 2004 +0000
    51.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h	Mon Sep 06 15:23:36 2004 +0000
    51.3 @@ -117,6 +117,9 @@
    51.4   *   val[7:0] == MMUEXT_INVLPG:
    51.5   *   ptr[:2]  -- Linear address to be flushed from the TLB.
    51.6   * 
    51.7 + *   val[7:0] == MMUEXT_FLUSH_CACHE:
    51.8 + *   No additional arguments. Writes back and flushes cache contents.
    51.9 + * 
   51.10   *   val[7:0] == MMUEXT_SET_LDT:
   51.11   *   ptr[:2]  -- Linear address of LDT base (NB. must be page-aligned).
   51.12   *   val[:8]  -- Number of entries in LDT.
   51.13 @@ -150,11 +153,12 @@
   51.14  #define MMUEXT_NEW_BASEPTR       5 /* ptr = MA of new pagetable base         */
   51.15  #define MMUEXT_TLB_FLUSH         6 /* ptr = NULL                             */
   51.16  #define MMUEXT_INVLPG            7 /* ptr = VA to invalidate                 */
   51.17 -#define MMUEXT_SET_LDT           8 /* ptr = VA of table; val = # entries     */
   51.18 -#define MMUEXT_TRANSFER_PAGE     9 /* ptr = MA of frame; val[31:16] = dom    */
   51.19 +#define MMUEXT_FLUSH_CACHE       8
   51.20 +#define MMUEXT_SET_LDT           9 /* ptr = VA of table; val = # entries     */
   51.21  #define MMUEXT_SET_FOREIGNDOM   10 /* val[31:16] = dom                       */
   51.22  #define MMUEXT_CLEAR_FOREIGNDOM 11
   51.23 -#define MMUEXT_REASSIGN_PAGE    12
   51.24 +#define MMUEXT_TRANSFER_PAGE    12 /* ptr = MA of frame; val[31:16] = dom    */
   51.25 +#define MMUEXT_REASSIGN_PAGE    13
   51.26  #define MMUEXT_CMD_MASK        255
   51.27  #define MMUEXT_CMD_SHIFT         8
   51.28  
    52.1 --- a/xen/include/hypervisor-ifs/io/domain_controller.h	Fri Sep 03 10:57:00 2004 +0000
    52.2 +++ b/xen/include/hypervisor-ifs/io/domain_controller.h	Mon Sep 06 15:23:36 2004 +0000
    52.3 @@ -93,6 +93,7 @@ typedef struct {
    52.4  #define BLKIF_INTERFACE_STATUS_DESTROYED    0 /* Interface doesn't exist.    */
    52.5  #define BLKIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
    52.6  #define BLKIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
    52.7 +#define BLKIF_INTERFACE_STATUS_CHANGED      3 /* A device has been added or removed. */
    52.8  typedef struct {
    52.9      u32 handle; /*  0 */
   52.10      u32 status; /*  4 */
   52.11 @@ -357,6 +358,7 @@ typedef struct {
   52.12  #define NETIF_INTERFACE_STATUS_DESTROYED    0 /* Interface doesn't exist.    */
   52.13  #define NETIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
   52.14  #define NETIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
   52.15 +#define NETIF_INTERFACE_STATUS_CHANGED      3 /* A device has been added or removed. */
   52.16  typedef struct {
   52.17      u32        handle; /*  0 */
   52.18      u32        status; /*  4 */