diff options
author | emellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com> | 2005-10-30 19:23:36 +0100 |
---|---|---|
committer | emellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com> | 2005-10-30 19:23:36 +0100 |
commit | 07237aa4f333c3feeb9e11e172213d2d440af4dd (patch) | |
tree | 848e62a12744f5cb2f78e1beffda6140d2ca990c | |
parent | 371261ea1b77d150b28d8dfcfe45f3c4e26f33c7 (diff) | |
parent | 0bc575ba3abf09d0b90bdd305db79df3a0491fec (diff) | |
download | xen-07237aa4f333c3feeb9e11e172213d2d440af4dd.tar.gz xen-07237aa4f333c3feeb9e11e172213d2d440af4dd.tar.bz2 xen-07237aa4f333c3feeb9e11e172213d2d440af4dd.zip |
Merged.
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c | 2 | ||||
-rw-r--r-- | tools/ioemu/hw/ne2000.c | 7 | ||||
-rw-r--r-- | tools/ioemu/hw/pcnet.c | 11 | ||||
-rw-r--r-- | tools/ioemu/target-i386-dm/helper2.c | 24 | ||||
-rw-r--r-- | tools/ioemu/vl.c | 63 | ||||
-rw-r--r-- | tools/ioemu/vl.h | 4 | ||||
-rw-r--r-- | xen/arch/x86/shadow.c | 3 | ||||
-rw-r--r-- | xen/include/asm-x86/shadow.h | 2 |
8 files changed, 95 insertions, 21 deletions
diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index b7cfb56a74..da9eb62763 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -879,6 +879,7 @@ static int create_netdev(int handle, struct xenbus_device *dev, if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE, &np->gref_tx_head) < 0) { printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n"); + err = -ENOMEM; goto exit; } /* A grant for every rx ring slot */ @@ -886,6 +887,7 @@ static int create_netdev(int handle, struct xenbus_device *dev, &np->gref_rx_head) < 0) { printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n"); gnttab_free_grant_references(np->gref_tx_head); + err = -ENOMEM; goto exit; } diff --git a/tools/ioemu/hw/ne2000.c b/tools/ioemu/hw/ne2000.c index 79d3026c01..b3c901ddc0 100644 --- a/tools/ioemu/hw/ne2000.c +++ b/tools/ioemu/hw/ne2000.c @@ -327,6 +327,7 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val) break; } } + update_select_wakeup_events(); } static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr) @@ -373,6 +374,7 @@ static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr) break; } } + update_select_wakeup_events(); #ifdef DEBUG_NE2000 printf("NE2000: read addr=0x%x val=%02x\n", addr, ret); #endif @@ -476,6 +478,7 @@ static void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val) ne2000_mem_writeb(s, s->rsar, val); ne2000_dma_update(s, 1); } + update_select_wakeup_events(); } static uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr) @@ -492,6 +495,7 @@ static uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr) ret = ne2000_mem_readb(s, s->rsar); ne2000_dma_update(s, 1); } + update_select_wakeup_events(); #ifdef DEBUG_NE2000 printf("NE2000: asic read val=0x%04x\n", ret); #endif @@ -510,6 +514,7 @@ static void ne2000_asic_ioport_writel(void *opaque, uint32_t addr, uint32_t val) /* 32 bit access */ ne2000_mem_writel(s, s->rsar, val); ne2000_dma_update(s, 4); + update_select_wakeup_events(); } static uint32_t ne2000_asic_ioport_readl(void *opaque, uint32_t addr) @@ -520,6 +525,7 @@ static uint32_t ne2000_asic_ioport_readl(void *opaque, uint32_t addr) /* 32 bit access */ ret = ne2000_mem_readl(s, s->rsar); ne2000_dma_update(s, 4); + update_select_wakeup_events(); #ifdef DEBUG_NE2000 printf("NE2000: asic readl val=0x%04x\n", ret); #endif @@ -535,6 +541,7 @@ static uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr) { NE2000State *s = opaque; ne2000_reset(s); + update_select_wakeup_events(); return 0; } diff --git a/tools/ioemu/hw/pcnet.c b/tools/ioemu/hw/pcnet.c index b713996a2e..f3b577b1f6 100644 --- a/tools/ioemu/hw/pcnet.c +++ b/tools/ioemu/hw/pcnet.c @@ -50,7 +50,6 @@ typedef struct PCNetState_st PCNetState; struct PCNetState_st { PCIDevice dev; NetDriverState *nd; - QEMUTimer *poll_timer; int mmio_io_addr, rap, isr, lnkst; target_phys_addr_t rdra, tdra; uint8_t prom[16]; @@ -640,8 +639,6 @@ static void pcnet_poll_timer(void *opaque) { PCNetState *s = opaque; - qemu_del_timer(s->poll_timer); - if (CSR_TDMD(s)) { pcnet_transmit(s); } @@ -660,8 +657,6 @@ static void pcnet_poll_timer(void *opaque) } else CSR_POLL(s) = t; } - qemu_mod_timer(s->poll_timer, - pcnet_get_next_poll_time(s,qemu_get_clock(vm_clock))); } } @@ -941,6 +936,7 @@ static void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val) } } pcnet_update_irq(s); + update_select_wakeup_events(); } static uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr) @@ -966,6 +962,7 @@ static uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr) } } pcnet_update_irq(s); + update_select_wakeup_events(); #ifdef PCNET_DEBUG_IO printf("pcnet_ioport_readw addr=0x%08x val=0x%04x\n", addr, val & 0xffff); #endif @@ -1000,6 +997,7 @@ static void pcnet_ioport_writel(void *opaque, uint32_t addr, uint32_t val) #endif } pcnet_update_irq(s); + update_select_wakeup_events(); } static uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr) @@ -1025,6 +1023,7 @@ static uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr) } } pcnet_update_irq(s); + update_select_wakeup_events(); #ifdef PCNET_DEBUG_IO printf("pcnet_ioport_readl addr=0x%08x val=0x%08x\n", addr, val); #endif @@ -1210,8 +1209,6 @@ void pci_pcnet_init(PCIBus *bus, NetDriverState *nd) pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE, PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map); - d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d); - d->nd = nd; pcnet_h_reset(d); diff --git a/tools/ioemu/target-i386-dm/helper2.c b/tools/ioemu/target-i386-dm/helper2.c index acc82ebacb..c8039b42d0 100644 --- a/tools/ioemu/target-i386-dm/helper2.c +++ b/tools/ioemu/target-i386-dm/helper2.c @@ -387,12 +387,6 @@ cpu_handle_ioreq(CPUState *env) } } -void -cpu_timer_handler(CPUState *env) -{ - cpu_handle_ioreq(env); -} - int xc_handle; static __inline__ void atomic_set_bit(long nr, volatile void *addr) @@ -413,6 +407,8 @@ destroy_vmx_domain(void) fprintf(logfile, "%s failed.!\n", destroy_cmd); } +fd_set wakeup_rfds; +int highest_fds; int main_loop(void) { fd_set rfds; @@ -425,8 +421,9 @@ int main_loop(void) extern void main_loop_wait(int); /* Watch stdin (fd 0) to see when it has input. */ - FD_ZERO(&rfds); - + FD_ZERO(&wakeup_rfds); + FD_SET(evtchn_fd, &wakeup_rfds); + highest_fds = evtchn_fd; while (1) { if (vm_running) { if (shutdown_requested) { @@ -441,14 +438,16 @@ int main_loop(void) /* Wait up to one seconds. */ tv.tv_sec = 0; tv.tv_usec = 100000; - FD_SET(evtchn_fd, &rfds); env->send_event = 0; - retval = select(evtchn_fd+1, &rfds, NULL, NULL, &tv); + retval = select(highest_fds+1, &wakeup_rfds, NULL, NULL, &tv); if (retval == -1) { perror("select"); return 0; } + rfds = wakeup_rfds; + FD_ZERO(&wakeup_rfds); + FD_SET(evtchn_fd, &wakeup_rfds); #if __WORDSIZE == 32 #define ULONGLONG_MAX 0xffffffffffffffffULL @@ -460,7 +459,10 @@ int main_loop(void) #ifdef APIC_SUPPORT ioapic_update_EOI(); #endif - cpu_timer_handler(env); + tun_receive_handler(&rfds); + if ( FD_ISSET(evtchn_fd, &rfds) ) { + cpu_handle_ioreq(env); + } #ifdef APIC_SUPPORT if (ioapic_has_intr()) do_ioapic(); diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c index 56cf52314e..224d1929c1 100644 --- a/tools/ioemu/vl.c +++ b/tools/ioemu/vl.c @@ -1528,7 +1528,7 @@ static void tun_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read, IOReadHandler *fd_read, void *opaque) { - qemu_add_fd_read_handler(nd->fd, fd_can_read, fd_read, opaque); + qemu_add_fd_event_read_handler(nd->fd, fd_can_read, fd_read, opaque); } static int net_tun_init(NetDriverState *nd) @@ -1536,11 +1536,13 @@ static int net_tun_init(NetDriverState *nd) int pid, status; char *args[3]; char **parg; + extern int highest_fds; nd->fd = tun_open(nd->ifname, sizeof(nd->ifname)); if (nd->fd < 0) return -1; + if ( nd->fd > highest_fds ) highest_fds = nd->fd; /* try to launch network init script */ pid = fork(); if (pid >= 0) { @@ -1628,6 +1630,7 @@ typedef struct IOHandlerRecord { } IOHandlerRecord; static IOHandlerRecord *first_io_handler; +static IOHandlerRecord *first_eventio_handler; int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, IOReadHandler *fd_read, void *opaque) @@ -1646,6 +1649,23 @@ int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, return 0; } +int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read, + IOReadHandler *fd_read, void *opaque) +{ + IOHandlerRecord *ioh; + + ioh = qemu_mallocz(sizeof(IOHandlerRecord)); + if (!ioh) + return -1; + ioh->fd = fd; + ioh->fd_can_read = fd_can_read; + ioh->fd_read = fd_read; + ioh->opaque = opaque; + ioh->next = first_eventio_handler; + first_eventio_handler = ioh; + return 0; +} + void qemu_del_fd_read_handler(int fd) { IOHandlerRecord **pioh, *ioh; @@ -3257,3 +3277,44 @@ int main(int argc, char **argv) quit_timers(); return 0; } + +extern fd_set wakeup_rfds; +void tun_receive_handler(fd_set *rfds) +{ + IOHandlerRecord *ioh; + static uint8_t buf[4096]; + int n, max_size; + + for (ioh = first_eventio_handler; ioh != NULL; ioh = ioh->next) { + if ( FD_ISSET(ioh->fd, rfds) ) { + max_size = ioh->fd_can_read(ioh->opaque); + if (max_size > 0) { + if (max_size > sizeof(buf)) + max_size = sizeof(buf); + n = read(ioh->fd, buf, max_size); + if (n >= 0) { + ioh->fd_read(ioh->opaque, buf, n); + } + } + } + } + update_select_wakeup_events(); +} + +void update_select_wakeup_events(void) +{ + IOHandlerRecord *ioh; + int max_size; + + for(ioh = first_eventio_handler; ioh != NULL; ioh = ioh->next) { + FD_CLR(ioh->fd, &wakeup_rfds); + if (ioh->fd_can_read) { + max_size = ioh->fd_can_read(ioh->opaque); + if (max_size > 0) { + FD_SET(ioh->fd, &wakeup_rfds); + } + } + } +} + + diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index c26409c30f..43cf821947 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -178,6 +178,8 @@ typedef int IOCanRWHandler(void *opaque); int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, IOReadHandler *fd_read, void *opaque); +int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read, + IOReadHandler *fd_read, void *opaque); void qemu_del_fd_read_handler(int fd); /* character device */ @@ -791,5 +793,7 @@ void readline_start(const char *prompt, int is_password, #define DEFAULT_GDBSTUB_PORT 1234 int gdbserver_start(int port); +void update_select_wakeup_events(void); +void tun_receive_handler(); #endif /* VL_H */ diff --git a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c index fdd0c5aaf0..7ca116803b 100644 --- a/xen/arch/x86/shadow.c +++ b/xen/arch/x86/shadow.c @@ -1381,7 +1381,8 @@ static int resync_all(struct domain *d, u32 stype) perfc_incrc(resync_l1); perfc_incr_histo(wpt_updates, changed, PT_UPDATES); perfc_incr_histo(l1_entries_checked, max_shadow - min_shadow + 1, PT_UPDATES); - if (unshadow_l1) { + if ( d->arch.ops->guest_paging_levels == PAGING_L4 && + unshadow_l1 ) { pgentry_64_t l2e; __shadow_get_l2e(entry->v, entry->va, &l2e); diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 0a8112c3d3..9c2206ad05 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -387,7 +387,7 @@ shadow_get_page_from_l1e(l1_pgentry_t l1e, struct domain *d) nl1e = l1e; l1e_remove_flags(nl1e, _PAGE_GLOBAL); - if ( unlikely(l1e_get_flags(l1e) & L1_DISALLOW_MASK) ) + if ( unlikely(l1e_get_flags(nl1e) & L1_DISALLOW_MASK) ) return 0; res = get_page_from_l1e(nl1e, d); |