direct-io.hg

changeset 7565:43676a509982

Merged.
author emellor@leeni.uk.xensource.com
date Sun Oct 30 19:23:36 2005 +0100 (2005-10-30)
parents 127d856ce124 32695e99cfc8
children f33f18fbf2cb
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Sun Oct 30 19:22:31 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Sun Oct 30 19:23:36 2005 +0100
     1.3 @@ -879,6 +879,7 @@ static int create_netdev(int handle, str
     1.4  	if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE,
     1.5  					  &np->gref_tx_head) < 0) {
     1.6  		printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
     1.7 +		err = -ENOMEM;
     1.8  		goto exit;
     1.9  	}
    1.10  	/* A grant for every rx ring slot */
    1.11 @@ -886,6 +887,7 @@ static int create_netdev(int handle, str
    1.12  					  &np->gref_rx_head) < 0) {
    1.13  		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
    1.14  		gnttab_free_grant_references(np->gref_tx_head);
    1.15 +		err = -ENOMEM;
    1.16  		goto exit;
    1.17  	}
    1.18  
     2.1 --- a/tools/ioemu/hw/ne2000.c	Sun Oct 30 19:22:31 2005 +0100
     2.2 +++ b/tools/ioemu/hw/ne2000.c	Sun Oct 30 19:23:36 2005 +0100
     2.3 @@ -327,6 +327,7 @@ static void ne2000_ioport_write(void *op
     2.4              break;
     2.5          }
     2.6      }
     2.7 +    update_select_wakeup_events();
     2.8  }
     2.9  
    2.10  static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr)
    2.11 @@ -373,6 +374,7 @@ static uint32_t ne2000_ioport_read(void 
    2.12              break;
    2.13          }
    2.14      }
    2.15 +    update_select_wakeup_events();
    2.16  #ifdef DEBUG_NE2000
    2.17      printf("NE2000: read addr=0x%x val=%02x\n", addr, ret);
    2.18  #endif
    2.19 @@ -476,6 +478,7 @@ static void ne2000_asic_ioport_write(voi
    2.20          ne2000_mem_writeb(s, s->rsar, val);
    2.21          ne2000_dma_update(s, 1);
    2.22      }
    2.23 +    update_select_wakeup_events();
    2.24  }
    2.25  
    2.26  static uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr)
    2.27 @@ -492,6 +495,7 @@ static uint32_t ne2000_asic_ioport_read(
    2.28          ret = ne2000_mem_readb(s, s->rsar);
    2.29          ne2000_dma_update(s, 1);
    2.30      }
    2.31 +    update_select_wakeup_events();
    2.32  #ifdef DEBUG_NE2000
    2.33      printf("NE2000: asic read val=0x%04x\n", ret);
    2.34  #endif
    2.35 @@ -510,6 +514,7 @@ static void ne2000_asic_ioport_writel(vo
    2.36      /* 32 bit access */
    2.37      ne2000_mem_writel(s, s->rsar, val);
    2.38      ne2000_dma_update(s, 4);
    2.39 +    update_select_wakeup_events();
    2.40  }
    2.41  
    2.42  static uint32_t ne2000_asic_ioport_readl(void *opaque, uint32_t addr)
    2.43 @@ -520,6 +525,7 @@ static uint32_t ne2000_asic_ioport_readl
    2.44      /* 32 bit access */
    2.45      ret = ne2000_mem_readl(s, s->rsar);
    2.46      ne2000_dma_update(s, 4);
    2.47 +    update_select_wakeup_events();
    2.48  #ifdef DEBUG_NE2000
    2.49      printf("NE2000: asic readl val=0x%04x\n", ret);
    2.50  #endif
    2.51 @@ -535,6 +541,7 @@ static uint32_t ne2000_reset_ioport_read
    2.52  {
    2.53      NE2000State *s = opaque;
    2.54      ne2000_reset(s);
    2.55 +    update_select_wakeup_events();
    2.56      return 0;
    2.57  }
    2.58  
     3.1 --- a/tools/ioemu/hw/pcnet.c	Sun Oct 30 19:22:31 2005 +0100
     3.2 +++ b/tools/ioemu/hw/pcnet.c	Sun Oct 30 19:23:36 2005 +0100
     3.3 @@ -50,7 +50,6 @@ typedef struct PCNetState_st PCNetState;
     3.4  struct PCNetState_st {
     3.5      PCIDevice dev;
     3.6      NetDriverState *nd;
     3.7 -    QEMUTimer *poll_timer;
     3.8      int mmio_io_addr, rap, isr, lnkst;
     3.9      target_phys_addr_t rdra, tdra;
    3.10      uint8_t prom[16];
    3.11 @@ -640,8 +639,6 @@ static void pcnet_poll_timer(void *opaqu
    3.12  {
    3.13      PCNetState *s = opaque;
    3.14  
    3.15 -    qemu_del_timer(s->poll_timer);
    3.16 -
    3.17      if (CSR_TDMD(s)) {
    3.18          pcnet_transmit(s);
    3.19      }
    3.20 @@ -660,8 +657,6 @@ static void pcnet_poll_timer(void *opaqu
    3.21              } else
    3.22                  CSR_POLL(s) = t;
    3.23          }
    3.24 -        qemu_mod_timer(s->poll_timer, 
    3.25 -            pcnet_get_next_poll_time(s,qemu_get_clock(vm_clock)));
    3.26      }
    3.27  }
    3.28  
    3.29 @@ -941,6 +936,7 @@ static void pcnet_ioport_writew(void *op
    3.30          }
    3.31      }
    3.32      pcnet_update_irq(s);
    3.33 +    update_select_wakeup_events();
    3.34  }
    3.35  
    3.36  static uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr)
    3.37 @@ -966,6 +962,7 @@ static uint32_t pcnet_ioport_readw(void 
    3.38          }
    3.39      }
    3.40      pcnet_update_irq(s);
    3.41 +    update_select_wakeup_events();
    3.42  #ifdef PCNET_DEBUG_IO
    3.43      printf("pcnet_ioport_readw addr=0x%08x val=0x%04x\n", addr, val & 0xffff);
    3.44  #endif
    3.45 @@ -1000,6 +997,7 @@ static void pcnet_ioport_writel(void *op
    3.46  #endif        
    3.47      }
    3.48      pcnet_update_irq(s);
    3.49 +    update_select_wakeup_events();
    3.50  }
    3.51  
    3.52  static uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr)
    3.53 @@ -1025,6 +1023,7 @@ static uint32_t pcnet_ioport_readl(void 
    3.54          }
    3.55      }
    3.56      pcnet_update_irq(s);
    3.57 +    update_select_wakeup_events();
    3.58  #ifdef PCNET_DEBUG_IO
    3.59      printf("pcnet_ioport_readl addr=0x%08x val=0x%08x\n", addr, val);
    3.60  #endif
    3.61 @@ -1210,8 +1209,6 @@ void pci_pcnet_init(PCIBus *bus, NetDriv
    3.62      pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE, 
    3.63                             PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);
    3.64                             
    3.65 -    d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d);
    3.66 -
    3.67      d->nd = nd;
    3.68  
    3.69      pcnet_h_reset(d);
     4.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Sun Oct 30 19:22:31 2005 +0100
     4.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Sun Oct 30 19:23:36 2005 +0100
     4.3 @@ -387,12 +387,6 @@ cpu_handle_ioreq(CPUState *env)
     4.4  	}
     4.5  }
     4.6  
     4.7 -void
     4.8 -cpu_timer_handler(CPUState *env)
     4.9 -{
    4.10 -	cpu_handle_ioreq(env);
    4.11 -}
    4.12 -
    4.13  int xc_handle;
    4.14  
    4.15  static __inline__ void atomic_set_bit(long nr, volatile void *addr)
    4.16 @@ -413,6 +407,8 @@ destroy_vmx_domain(void)
    4.17          fprintf(logfile, "%s failed.!\n", destroy_cmd);
    4.18  }
    4.19  
    4.20 +fd_set wakeup_rfds;
    4.21 +int    highest_fds;
    4.22  int main_loop(void)
    4.23  {
    4.24   	fd_set rfds;
    4.25 @@ -425,8 +421,9 @@ int main_loop(void)
    4.26          extern void main_loop_wait(int);
    4.27  
    4.28   	/* Watch stdin (fd 0) to see when it has input. */
    4.29 -	FD_ZERO(&rfds);
    4.30 -
    4.31 +	FD_ZERO(&wakeup_rfds);
    4.32 +	FD_SET(evtchn_fd, &wakeup_rfds);
    4.33 +	highest_fds = evtchn_fd;
    4.34  	while (1) {
    4.35                  if (vm_running) {
    4.36                      if (shutdown_requested) {
    4.37 @@ -441,14 +438,16 @@ int main_loop(void)
    4.38  		/* Wait up to one seconds. */
    4.39  		tv.tv_sec = 0;
    4.40  		tv.tv_usec = 100000;
    4.41 -		FD_SET(evtchn_fd, &rfds);
    4.42  
    4.43  		env->send_event = 0;
    4.44 -		retval = select(evtchn_fd+1, &rfds, NULL, NULL, &tv);
    4.45 +		retval = select(highest_fds+1, &wakeup_rfds, NULL, NULL, &tv);
    4.46  		if (retval == -1) {
    4.47  			perror("select");
    4.48  			return 0;
    4.49  		}
    4.50 +        rfds = wakeup_rfds;
    4.51 +        FD_ZERO(&wakeup_rfds);
    4.52 +        FD_SET(evtchn_fd, &wakeup_rfds);
    4.53  
    4.54  #if __WORDSIZE == 32
    4.55  #define ULONGLONG_MAX   0xffffffffffffffffULL
    4.56 @@ -460,7 +459,10 @@ int main_loop(void)
    4.57  #ifdef APIC_SUPPORT
    4.58  		ioapic_update_EOI();
    4.59  #endif
    4.60 -		cpu_timer_handler(env);
    4.61 +        tun_receive_handler(&rfds);
    4.62 +        if ( FD_ISSET(evtchn_fd, &rfds) ) {
    4.63 +            cpu_handle_ioreq(env);
    4.64 +        }
    4.65  #ifdef APIC_SUPPORT
    4.66  		if (ioapic_has_intr())
    4.67                      do_ioapic();
     5.1 --- a/tools/ioemu/vl.c	Sun Oct 30 19:22:31 2005 +0100
     5.2 +++ b/tools/ioemu/vl.c	Sun Oct 30 19:23:36 2005 +0100
     5.3 @@ -1528,7 +1528,7 @@ static void tun_add_read_packet(NetDrive
     5.4                                  IOCanRWHandler *fd_can_read, 
     5.5                                  IOReadHandler *fd_read, void *opaque)
     5.6  {
     5.7 -    qemu_add_fd_read_handler(nd->fd, fd_can_read, fd_read, opaque);
     5.8 +    qemu_add_fd_event_read_handler(nd->fd, fd_can_read, fd_read, opaque);
     5.9  }
    5.10  
    5.11  static int net_tun_init(NetDriverState *nd)
    5.12 @@ -1536,11 +1536,13 @@ static int net_tun_init(NetDriverState *
    5.13      int pid, status;
    5.14      char *args[3];
    5.15      char **parg;
    5.16 +    extern int highest_fds;
    5.17  
    5.18      nd->fd = tun_open(nd->ifname, sizeof(nd->ifname));
    5.19      if (nd->fd < 0)
    5.20          return -1;
    5.21  
    5.22 +    if ( nd->fd > highest_fds ) highest_fds = nd->fd;
    5.23      /* try to launch network init script */
    5.24      pid = fork();
    5.25      if (pid >= 0) {
    5.26 @@ -1628,6 +1630,7 @@ typedef struct IOHandlerRecord {
    5.27  } IOHandlerRecord;
    5.28  
    5.29  static IOHandlerRecord *first_io_handler;
    5.30 +static IOHandlerRecord *first_eventio_handler;
    5.31  
    5.32  int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, 
    5.33                               IOReadHandler *fd_read, void *opaque)
    5.34 @@ -1646,6 +1649,23 @@ int qemu_add_fd_read_handler(int fd, IOC
    5.35      return 0;
    5.36  }
    5.37  
    5.38 +int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read, 
    5.39 +                             IOReadHandler *fd_read, void *opaque)
    5.40 +{
    5.41 +    IOHandlerRecord *ioh;
    5.42 +
    5.43 +    ioh = qemu_mallocz(sizeof(IOHandlerRecord));
    5.44 +    if (!ioh)
    5.45 +        return -1;
    5.46 +    ioh->fd = fd;
    5.47 +    ioh->fd_can_read = fd_can_read;
    5.48 +    ioh->fd_read = fd_read;
    5.49 +    ioh->opaque = opaque;
    5.50 +    ioh->next = first_eventio_handler;
    5.51 +    first_eventio_handler = ioh;
    5.52 +    return 0;
    5.53 +}
    5.54 +
    5.55  void qemu_del_fd_read_handler(int fd)
    5.56  {
    5.57      IOHandlerRecord **pioh, *ioh;
    5.58 @@ -3257,3 +3277,44 @@ int main(int argc, char **argv)
    5.59      quit_timers();
    5.60      return 0;
    5.61  }
    5.62 +
    5.63 +extern fd_set wakeup_rfds;
    5.64 +void tun_receive_handler(fd_set *rfds)
    5.65 +{
    5.66 +    IOHandlerRecord *ioh;
    5.67 +    static uint8_t buf[4096];
    5.68 +    int n, max_size;
    5.69 +
    5.70 +    for (ioh = first_eventio_handler; ioh != NULL; ioh = ioh->next) {
    5.71 +        if ( FD_ISSET(ioh->fd, rfds) ) {
    5.72 +            max_size = ioh->fd_can_read(ioh->opaque);
    5.73 +            if (max_size > 0) {
    5.74 +                if (max_size > sizeof(buf))
    5.75 +                    max_size = sizeof(buf);
    5.76 +                n = read(ioh->fd, buf, max_size);
    5.77 +                if (n >= 0) {
    5.78 +                    ioh->fd_read(ioh->opaque, buf, n);
    5.79 +                } 
    5.80 +            }
    5.81 +        }
    5.82 +    }
    5.83 +    update_select_wakeup_events();
    5.84 +}
    5.85 +
    5.86 +void update_select_wakeup_events(void)
    5.87 +{
    5.88 +    IOHandlerRecord *ioh;
    5.89 +    int max_size;
    5.90 +
    5.91 +    for(ioh = first_eventio_handler; ioh != NULL; ioh = ioh->next) {
    5.92 +        FD_CLR(ioh->fd, &wakeup_rfds);
    5.93 +        if (ioh->fd_can_read) {
    5.94 +             max_size = ioh->fd_can_read(ioh->opaque);
    5.95 +             if (max_size > 0) {
    5.96 +                 FD_SET(ioh->fd, &wakeup_rfds);
    5.97 +             }
    5.98 +        }
    5.99 +    }
   5.100 +}
   5.101 +
   5.102 +
     6.1 --- a/tools/ioemu/vl.h	Sun Oct 30 19:22:31 2005 +0100
     6.2 +++ b/tools/ioemu/vl.h	Sun Oct 30 19:23:36 2005 +0100
     6.3 @@ -178,6 +178,8 @@ typedef int IOCanRWHandler(void *opaque)
     6.4  
     6.5  int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, 
     6.6                               IOReadHandler *fd_read, void *opaque);
     6.7 +int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read, 
     6.8 +                             IOReadHandler *fd_read, void *opaque);
     6.9  void qemu_del_fd_read_handler(int fd);
    6.10  
    6.11  /* character device */
    6.12 @@ -791,5 +793,7 @@ void readline_start(const char *prompt, 
    6.13  #define DEFAULT_GDBSTUB_PORT 1234
    6.14  
    6.15  int gdbserver_start(int port);
    6.16 +void update_select_wakeup_events(void);
    6.17 +void tun_receive_handler();
    6.18  
    6.19  #endif /* VL_H */
     7.1 --- a/xen/arch/x86/shadow.c	Sun Oct 30 19:22:31 2005 +0100
     7.2 +++ b/xen/arch/x86/shadow.c	Sun Oct 30 19:23:36 2005 +0100
     7.3 @@ -1381,7 +1381,8 @@ static int resync_all(struct domain *d, 
     7.4              perfc_incrc(resync_l1);
     7.5              perfc_incr_histo(wpt_updates, changed, PT_UPDATES);
     7.6              perfc_incr_histo(l1_entries_checked, max_shadow - min_shadow + 1, PT_UPDATES);
     7.7 -            if (unshadow_l1) {
     7.8 +            if ( d->arch.ops->guest_paging_levels == PAGING_L4 &&
     7.9 +                 unshadow_l1 ) {
    7.10                  pgentry_64_t l2e;
    7.11  
    7.12                  __shadow_get_l2e(entry->v, entry->va, &l2e);
     8.1 --- a/xen/include/asm-x86/shadow.h	Sun Oct 30 19:22:31 2005 +0100
     8.2 +++ b/xen/include/asm-x86/shadow.h	Sun Oct 30 19:23:36 2005 +0100
     8.3 @@ -387,7 +387,7 @@ shadow_get_page_from_l1e(l1_pgentry_t l1
     8.4      nl1e = l1e;
     8.5      l1e_remove_flags(nl1e, _PAGE_GLOBAL);
     8.6  
     8.7 -    if ( unlikely(l1e_get_flags(l1e) & L1_DISALLOW_MASK) )
     8.8 +    if ( unlikely(l1e_get_flags(nl1e) & L1_DISALLOW_MASK) )
     8.9          return 0;
    8.10  
    8.11      res = get_page_from_l1e(nl1e, d);