ia64/xen-unstable
changeset 2577:4ecd18756ef8
bitkeeper revision 1.1159.1.192 (415c7082v4eKZkH-NXLbAR9bU6B8hg)
Merge ssh://srg//auto/groups/xeno/BK/xeno-unstable.bk
into equilibrium.research:/export/scratch/xeno-blkscripts.bk
Merge ssh://srg//auto/groups/xeno/BK/xeno-unstable.bk
into equilibrium.research:/export/scratch/xeno-blkscripts.bk
author | mwilli2@equilibrium.research |
---|---|
date | Thu Sep 30 20:45:54 2004 +0000 (2004-09-30) |
parents | 82cab392896d 1293cc819fed |
children | 3eebdef21285 |
files | linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/time.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 xen/arch/x86/traps.c |
line diff
1.1 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/time.c Tue Sep 28 14:47:51 2004 +0000 1.2 +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/kernel/time.c Thu Sep 30 20:45:54 2004 +0000 1.3 @@ -126,14 +126,14 @@ u64 processed_system_time; /* System t 1.4 (_tv).tv_sec++; \ 1.5 } \ 1.6 } while (0) 1.7 -static inline void __normalize_time(time_t *sec, s64 *usec) 1.8 +static inline void __normalize_time(time_t *sec, s64 *nsec) 1.9 { 1.10 - while (*usec >= NSEC_PER_SEC) { 1.11 - (*usec) -= NSEC_PER_SEC; 1.12 + while (*nsec >= NSEC_PER_SEC) { 1.13 + (*nsec) -= NSEC_PER_SEC; 1.14 (*sec)++; 1.15 } 1.16 - while (*usec < NSEC_PER_SEC) { 1.17 - (*usec) += NSEC_PER_SEC; 1.18 + while (*nsec < 0) { 1.19 + (*nsec) += NSEC_PER_SEC; 1.20 (*sec)--; 1.21 } 1.22 }
2.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c Tue Sep 28 14:47:51 2004 +0000 2.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c Thu Sep 30 20:45:54 2004 +0000 2.3 @@ -554,6 +554,8 @@ int blkif_ioctl(struct inode *inode, str 2.4 struct gendisk *gd; 2.5 struct hd_struct *part; 2.6 int i; 2.7 + unsigned short cylinders; 2.8 + byte heads, sectors; 2.9 2.10 /* NB. No need to check permissions. That is done for us. */ 2.11 2.12 @@ -598,23 +600,39 @@ int blkif_ioctl(struct inode *inode, str 2.13 break; 2.14 2.15 case HDIO_GETGEO: 2.16 - /* note: these values are complete garbage */ 2.17 DPRINTK_IOCTL(" HDIO_GETGEO: %x\n", HDIO_GETGEO); 2.18 if (!argument) return -EINVAL; 2.19 + 2.20 + /* We don't have real geometry info, but let's at least return 2.21 + values consistent with the size of the device */ 2.22 + 2.23 + heads = 0xff; 2.24 + sectors = 0x3f; 2.25 + cylinders = part->nr_sects / (heads * sectors); 2.26 + 2.27 if (put_user(0x00, (unsigned long *) &geo->start)) return -EFAULT; 2.28 - if (put_user(0xff, (byte *)&geo->heads)) return -EFAULT; 2.29 - if (put_user(0x3f, (byte *)&geo->sectors)) return -EFAULT; 2.30 - if (put_user(0x106, (unsigned short *)&geo->cylinders)) return -EFAULT; 2.31 + if (put_user(heads, (byte *)&geo->heads)) return -EFAULT; 2.32 + if (put_user(sectors, (byte *)&geo->sectors)) return -EFAULT; 2.33 + if (put_user(cylinders, (unsigned short *)&geo->cylinders)) return -EFAULT; 2.34 + 2.35 return 0; 2.36 2.37 case HDIO_GETGEO_BIG: 2.38 - /* note: these values are complete garbage */ 2.39 DPRINTK_IOCTL(" HDIO_GETGEO_BIG: %x\n", HDIO_GETGEO_BIG); 2.40 if (!argument) return -EINVAL; 2.41 + 2.42 + /* We don't have real geometry info, but let's at least return 2.43 + values consistent with the size of the device */ 2.44 + 2.45 + heads = 0xff; 2.46 + sectors = 0x3f; 2.47 + cylinders = part->nr_sects / (heads * sectors); 2.48 + 2.49 if (put_user(0x00, (unsigned long *) &geo->start)) return -EFAULT; 2.50 - if (put_user(0xff, (byte *)&geo->heads)) return -EFAULT; 2.51 - if (put_user(0x3f, (byte *)&geo->sectors)) return -EFAULT; 2.52 - if (put_user(0x106, (unsigned int *) &geo->cylinders)) return -EFAULT; 2.53 + if (put_user(heads, (byte *)&geo->heads)) return -EFAULT; 2.54 + if (put_user(sectors, (byte *)&geo->sectors)) return -EFAULT; 2.55 + if (put_user(cylinders, (unsigned int *) &geo->cylinders)) return -EFAULT; 2.56 + 2.57 return 0; 2.58 2.59 case CDROMMULTISESSION:
3.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c Tue Sep 28 14:47:51 2004 +0000 3.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c Thu Sep 30 20:45:54 2004 +0000 3.3 @@ -31,22 +31,6 @@ 3.4 3.5 #define DEBUG 0 3.6 3.7 -#if DEBUG 3.8 -#define DPRINTK(fmt, args...) \ 3.9 - printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args) 3.10 -#else 3.11 -#define DPRINTK(fmt, args...) ((void)0) 3.12 -#endif 3.13 - 3.14 -#define IPRINTK(fmt, args...) \ 3.15 - printk(KERN_INFO "[XEN]" fmt, ##args) 3.16 - 3.17 -#define WPRINTK(fmt, args...) \ 3.18 - printk(KERN_WARNING "[XEN]" fmt, ##args) 3.19 - 3.20 -#define EPRINTK(fmt, args...) \ 3.21 - printk(KERN_ERROR "[XEN]" fmt, ##args) 3.22 - 3.23 #ifndef __GFP_NOWARN 3.24 #define __GFP_NOWARN 0 3.25 #endif 3.26 @@ -114,6 +98,12 @@ struct net_private 3.27 #define UST_OPEN 1 3.28 unsigned int user_state; 3.29 3.30 + /* Receive-ring batched refills. */ 3.31 +#define RX_MIN_TARGET 8 3.32 +#define RX_MAX_TARGET NETIF_RX_RING_SIZE 3.33 + int rx_target; 3.34 + struct sk_buff_head rx_batch; 3.35 + 3.36 /* 3.37 * {tx,rx}_skbs store outstanding skbuffs. The first entry in each 3.38 * array is an index into a chain of free entries. 3.39 @@ -122,24 +112,6 @@ struct net_private 3.40 struct sk_buff *rx_skbs[NETIF_RX_RING_SIZE+1]; 3.41 }; 3.42 3.43 -char * status_name[] = { 3.44 - [NETIF_INTERFACE_STATUS_CLOSED] = "closed", 3.45 - [NETIF_INTERFACE_STATUS_DISCONNECTED] = "disconnected", 3.46 - [NETIF_INTERFACE_STATUS_CONNECTED] = "connected", 3.47 - [NETIF_INTERFACE_STATUS_CHANGED] = "changed", 3.48 -}; 3.49 - 3.50 -char * be_state_name[] = { 3.51 - [BEST_CLOSED] = "closed", 3.52 - [BEST_DISCONNECTED] = "disconnected", 3.53 - [BEST_CONNECTED] = "connected", 3.54 -}; 3.55 - 3.56 -char * user_state_name[] = { 3.57 - [UST_CLOSED] = "closed", 3.58 - [UST_OPEN] = "open", 3.59 -}; 3.60 - 3.61 /* Access macros for acquiring freeing slots in {tx,rx}_skbs[]. */ 3.62 #define ADD_ID_TO_FREELIST(_list, _id) \ 3.63 (_list)[(_id)] = (_list)[0]; \ 3.64 @@ -149,6 +121,30 @@ char * user_state_name[] = { 3.65 (_list)[0] = (_list)[_id]; \ 3.66 (unsigned short)_id; }) 3.67 3.68 +static char *status_name[] = { 3.69 + [NETIF_INTERFACE_STATUS_CLOSED] = "closed", 3.70 + [NETIF_INTERFACE_STATUS_DISCONNECTED] = "disconnected", 3.71 + [NETIF_INTERFACE_STATUS_CONNECTED] = "connected", 3.72 + [NETIF_INTERFACE_STATUS_CHANGED] = "changed", 3.73 +}; 3.74 + 3.75 +static char *be_state_name[] = { 3.76 + [BEST_CLOSED] = "closed", 3.77 + [BEST_DISCONNECTED] = "disconnected", 3.78 + [BEST_CONNECTED] = "connected", 3.79 +}; 3.80 + 3.81 +#if DEBUG 3.82 +#define DPRINTK(fmt, args...) \ 3.83 + printk(KERN_ALERT "[XEN] (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args) 3.84 +#else 3.85 +#define DPRINTK(fmt, args...) ((void)0) 3.86 +#endif 3.87 +#define IPRINTK(fmt, args...) \ 3.88 + printk(KERN_INFO "[XEN] " fmt, ##args) 3.89 +#define WPRINTK(fmt, args...) \ 3.90 + printk(KERN_WARNING "[XEN] " fmt, ##args) 3.91 + 3.92 static struct net_device *find_dev_by_handle(unsigned int handle) 3.93 { 3.94 struct list_head *ent; 3.95 @@ -185,9 +181,8 @@ static void netctrl_init(void) 3.96 */ 3.97 static int netctrl_err(int err) 3.98 { 3.99 - if ( (err < 0) && !netctrl.err ){ 3.100 + if ( (err < 0) && !netctrl.err ) 3.101 netctrl.err = err; 3.102 - } 3.103 return netctrl.err; 3.104 } 3.105 3.106 @@ -197,13 +192,15 @@ static int netctrl_err(int err) 3.107 */ 3.108 static int netctrl_connected(void) 3.109 { 3.110 - int ok = 0; 3.111 + int ok; 3.112 3.113 - if(netctrl.err){ 3.114 + if ( netctrl.err ) 3.115 ok = netctrl.err; 3.116 - } else if(netctrl.up == NETIF_DRIVER_STATUS_UP){ 3.117 + else if ( netctrl.up == NETIF_DRIVER_STATUS_UP ) 3.118 ok = (netctrl.connected_n == netctrl.interface_n); 3.119 - } 3.120 + else 3.121 + ok = 0; 3.122 + 3.123 return ok; 3.124 } 3.125 3.126 @@ -222,9 +219,8 @@ static int netctrl_connected_count(void) 3.127 3.128 list_for_each(ent, &dev_list) { 3.129 np = list_entry(ent, struct net_private, list); 3.130 - if (np->backend_state == BEST_CONNECTED){ 3.131 + if (np->backend_state == BEST_CONNECTED) 3.132 connected++; 3.133 - } 3.134 } 3.135 3.136 netctrl.connected_n = connected; 3.137 @@ -326,17 +322,34 @@ static void network_alloc_rx_buffers(str 3.138 unsigned short id; 3.139 struct net_private *np = dev->priv; 3.140 struct sk_buff *skb; 3.141 - NETIF_RING_IDX i = np->rx->req_prod; 3.142 - int nr_pfns = 0; 3.143 + int i, batch_target; 3.144 + NETIF_RING_IDX req_prod = np->rx->req_prod; 3.145 3.146 - /* Make sure the batch is large enough to be worthwhile (1/2 ring). */ 3.147 - if ( unlikely((i - np->rx_resp_cons) > (NETIF_RX_RING_SIZE/2)) || 3.148 - unlikely(np->backend_state != BEST_CONNECTED) ) 3.149 + if ( unlikely(np->backend_state != BEST_CONNECTED) ) 3.150 return; 3.151 3.152 - do { 3.153 + /* 3.154 + * Allocate skbuffs greedily, even though we batch updates to the 3.155 + * receive ring. This creates a less bursty demand on the memory allocator, 3.156 + * so should reduce the chance of failed allocation requests both for 3.157 + * ourself and for other kernel subsystems. 3.158 + */ 3.159 + batch_target = np->rx_target - (req_prod - np->rx_resp_cons); 3.160 + for ( i = skb_queue_len(&np->rx_batch); i < batch_target; i++ ) 3.161 + { 3.162 if ( unlikely((skb = alloc_xen_skb(dev->mtu + RX_HEADROOM)) == NULL) ) 3.163 break; 3.164 + __skb_queue_tail(&np->rx_batch, skb); 3.165 + } 3.166 + 3.167 + /* Is the batch large enough to be worthwhile? */ 3.168 + if ( i < (np->rx_target/2) ) 3.169 + return; 3.170 + 3.171 + for ( i = 0; ; i++ ) 3.172 + { 3.173 + if ( (skb = __skb_dequeue(&np->rx_batch)) == NULL ) 3.174 + break; 3.175 3.176 skb->dev = dev; 3.177 3.178 @@ -344,25 +357,19 @@ static void network_alloc_rx_buffers(str 3.179 3.180 np->rx_skbs[id] = skb; 3.181 3.182 - np->rx->ring[MASK_NETIF_RX_IDX(i)].req.id = id; 3.183 + np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.id = id; 3.184 3.185 - rx_pfn_array[nr_pfns] = virt_to_machine(skb->head) >> PAGE_SHIFT; 3.186 + rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT; 3.187 3.188 /* Remove this page from pseudo phys map before passing back to Xen. */ 3.189 phys_to_machine_mapping[virt_to_phys(skb->head) >> PAGE_SHIFT] 3.190 = INVALID_P2M_ENTRY; 3.191 3.192 - rx_mcl[nr_pfns].op = __HYPERVISOR_update_va_mapping; 3.193 - rx_mcl[nr_pfns].args[0] = (unsigned long)skb->head >> PAGE_SHIFT; 3.194 - rx_mcl[nr_pfns].args[1] = 0; 3.195 - rx_mcl[nr_pfns].args[2] = 0; 3.196 - 3.197 - nr_pfns++; 3.198 + rx_mcl[i].op = __HYPERVISOR_update_va_mapping; 3.199 + rx_mcl[i].args[0] = (unsigned long)skb->head >> PAGE_SHIFT; 3.200 + rx_mcl[i].args[1] = 0; 3.201 + rx_mcl[i].args[2] = 0; 3.202 } 3.203 - while ( (++i - np->rx_resp_cons) != NETIF_RX_RING_SIZE ); 3.204 - 3.205 - if ( unlikely(nr_pfns == 0) ) 3.206 - return; 3.207 3.208 /* 3.209 * We may have allocated buffers which have entries outstanding in the page 3.210 @@ -371,25 +378,30 @@ static void network_alloc_rx_buffers(str 3.211 flush_page_update_queue(); 3.212 3.213 /* After all PTEs have been zapped we blow away stale TLB entries. */ 3.214 - rx_mcl[nr_pfns-1].args[2] = UVMF_FLUSH_TLB; 3.215 + rx_mcl[i-1].args[2] = UVMF_FLUSH_TLB; 3.216 3.217 /* Give away a batch of pages. */ 3.218 - rx_mcl[nr_pfns].op = __HYPERVISOR_dom_mem_op; 3.219 - rx_mcl[nr_pfns].args[0] = MEMOP_decrease_reservation; 3.220 - rx_mcl[nr_pfns].args[1] = (unsigned long)rx_pfn_array; 3.221 - rx_mcl[nr_pfns].args[2] = (unsigned long)nr_pfns; 3.222 - rx_mcl[nr_pfns].args[3] = 0; 3.223 - rx_mcl[nr_pfns].args[4] = DOMID_SELF; 3.224 + rx_mcl[i].op = __HYPERVISOR_dom_mem_op; 3.225 + rx_mcl[i].args[0] = MEMOP_decrease_reservation; 3.226 + rx_mcl[i].args[1] = (unsigned long)rx_pfn_array; 3.227 + rx_mcl[i].args[2] = (unsigned long)i; 3.228 + rx_mcl[i].args[3] = 0; 3.229 + rx_mcl[i].args[4] = DOMID_SELF; 3.230 3.231 /* Zap PTEs and give away pages in one big multicall. */ 3.232 - (void)HYPERVISOR_multicall(rx_mcl, nr_pfns+1); 3.233 + (void)HYPERVISOR_multicall(rx_mcl, i+1); 3.234 3.235 /* Check return status of HYPERVISOR_dom_mem_op(). */ 3.236 - if ( rx_mcl[nr_pfns].args[5] != nr_pfns ) 3.237 + if ( unlikely(rx_mcl[i].args[5] != i) ) 3.238 panic("Unable to reduce memory reservation\n"); 3.239 3.240 /* Above is a suitable barrier to ensure backend will see requests. */ 3.241 - np->rx->req_prod = i; 3.242 + np->rx->req_prod = req_prod + i; 3.243 + 3.244 + /* Adjust our floating fill target if we risked running out of buffers. */ 3.245 + if ( ((req_prod - np->rx->resp_prod) < (np->rx_target / 4)) && 3.246 + ((np->rx_target *= 2) > RX_MAX_TARGET) ) 3.247 + np->rx_target = RX_MAX_TARGET; 3.248 } 3.249 3.250 3.251 @@ -627,6 +639,12 @@ static int netif_poll(struct net_device 3.252 3.253 np->rx_resp_cons = i; 3.254 3.255 + /* If we get a callback with very few responses, reduce fill target. */ 3.256 + /* NB. Note exponential increase, linear decrease. */ 3.257 + if ( ((np->rx->req_prod - np->rx->resp_prod) > ((3*np->rx_target) / 4)) && 3.258 + (--np->rx_target < RX_MIN_TARGET) ) 3.259 + np->rx_target = RX_MIN_TARGET; 3.260 + 3.261 network_alloc_rx_buffers(dev); 3.262 3.263 *pbudget -= work_done; 3.264 @@ -755,10 +773,10 @@ static void vif_show(struct net_private 3.265 { 3.266 #if DEBUG 3.267 if (np) { 3.268 - IPRINTK(" <vif handle=%u %s(%s) evtchn=%u irq=%u tx=%p rx=%p>\n", 3.269 + IPRINTK("<vif handle=%u %s(%s) evtchn=%u irq=%u tx=%p rx=%p>\n", 3.270 np->handle, 3.271 be_state_name[np->backend_state], 3.272 - user_state_name[np->user_state], 3.273 + np->user_state ? "open" : "closed", 3.274 np->evtchn, 3.275 np->irq, 3.276 np->tx, 3.277 @@ -806,13 +824,13 @@ static int send_driver_status(int ok) 3.278 3.279 /* Stop network device and free tx/rx queues and irq. 3.280 */ 3.281 -static void vif_release(struct net_private *np){ 3.282 - 3.283 +static void vif_release(struct net_private *np) 3.284 +{ 3.285 /* Stop old i/f to prevent errors whilst we rebuild the state. */ 3.286 spin_lock_irq(&np->tx_lock); 3.287 spin_lock(&np->rx_lock); 3.288 netif_stop_queue(np->dev); 3.289 - //np->backend_state = BEST_DISCONNECTED; 3.290 + /* np->backend_state = BEST_DISCONNECTED; */ 3.291 spin_unlock(&np->rx_lock); 3.292 spin_unlock_irq(&np->tx_lock); 3.293 3.294 @@ -827,18 +845,18 @@ static void vif_release(struct net_priva 3.295 np->tx = NULL; 3.296 np->rx = NULL; 3.297 } 3.298 - 3.299 } 3.300 3.301 /* Release vif resources and close it down completely. 3.302 */ 3.303 -static void vif_close(struct net_private *np){ 3.304 +static void vif_close(struct net_private *np) 3.305 +{ 3.306 DPRINTK(">\n"); vif_show(np); 3.307 - WPRINTK(" Unexpected netif-CLOSED message in state %s\n", 3.308 + WPRINTK("Unexpected netif-CLOSED message in state %s\n", 3.309 be_state_name[np->backend_state]); 3.310 vif_release(np); 3.311 np->backend_state = BEST_CLOSED; 3.312 - //todo: take dev down and free. 3.313 + /* todo: take dev down and free. */ 3.314 vif_show(np); DPRINTK("<\n"); 3.315 } 3.316 3.317 @@ -873,11 +891,13 @@ static void vif_disconnect(struct net_pr 3.318 * is initiated by a special "RESET" message - disconnect could 3.319 * just mean we're not allowed to use this interface any more. 3.320 */ 3.321 -static void vif_reset(struct net_private *np){ 3.322 +static void 3.323 +vif_reset( 3.324 + struct net_private *np) 3.325 +{ 3.326 DPRINTK(">\n"); 3.327 - IPRINTK(" Attempting to reconnect network interface: handle=%u\n", 3.328 - np->handle); 3.329 - 3.330 + IPRINTK("Attempting to reconnect network interface: handle=%u\n", 3.331 + np->handle); 3.332 vif_release(np); 3.333 vif_disconnect(np); 3.334 vif_show(np); DPRINTK("<\n"); 3.335 @@ -887,7 +907,10 @@ static void vif_reset(struct net_private 3.336 * Sets the mac and event channel from the message. 3.337 * Binds the irq to the event channel. 3.338 */ 3.339 -static void vif_connect(struct net_private *np, netif_fe_interface_status_t *status){ 3.340 +static void 3.341 +vif_connect( 3.342 + struct net_private *np, netif_fe_interface_status_t *status) 3.343 +{ 3.344 struct net_device *dev = np->dev; 3.345 DPRINTK(">\n"); 3.346 memcpy(dev->dev_addr, status->mac, ETH_ALEN); 3.347 @@ -927,13 +950,14 @@ static int create_netdev(int handle, str 3.348 spin_lock_init(&np->tx_lock); 3.349 spin_lock_init(&np->rx_lock); 3.350 3.351 + skb_queue_head_init(&np->rx_batch); 3.352 + np->rx_target = RX_MIN_TARGET; 3.353 + 3.354 /* Initialise {tx,rx}_skbs to be a free chain containing every entry. */ 3.355 - for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ ){ 3.356 + for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ ) 3.357 np->tx_skbs[i] = (void *)(i+1); 3.358 - } 3.359 - for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ ){ 3.360 + for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ ) 3.361 np->rx_skbs[i] = (void *)(i+1); 3.362 - } 3.363 3.364 dev->open = network_open; 3.365 dev->hard_start_xmit = network_start_xmit; 3.366 @@ -951,11 +975,10 @@ static int create_netdev(int handle, str 3.367 list_add(&np->list, &dev_list); 3.368 3.369 exit: 3.370 - if ( (err != 0) && (dev != NULL ) ){ 3.371 + if ( (err != 0) && (dev != NULL ) ) 3.372 kfree(dev); 3.373 - } else if ( val != NULL ) { 3.374 + else if ( val != NULL ) 3.375 *val = dev; 3.376 - } 3.377 return err; 3.378 } 3.379 3.380 @@ -967,44 +990,42 @@ static int create_netdev(int handle, str 3.381 * @param np return parameter for interface state 3.382 * @return 0 on success, error code otherwise 3.383 */ 3.384 -static int target_vif(netif_fe_interface_status_t *status, struct net_private **np) 3.385 +static int 3.386 +target_vif( 3.387 + netif_fe_interface_status_t *status, struct net_private **np) 3.388 { 3.389 int err = 0; 3.390 struct net_device *dev; 3.391 3.392 DPRINTK("> handle=%d\n", status->handle); 3.393 - if(status->handle < 0) { 3.394 + if ( status->handle < 0 ) 3.395 + { 3.396 err = -EINVAL; 3.397 goto exit; 3.398 } 3.399 - dev = find_dev_by_handle(status->handle); 3.400 - DPRINTK("> dev=%p\n", dev); 3.401 - if(dev) goto exit; 3.402 - // No good - give up. 3.403 - if(status->status == NETIF_INTERFACE_STATUS_CLOSED) goto exit; 3.404 - if(status->status == NETIF_INTERFACE_STATUS_CHANGED) goto exit; 3.405 - // It's a new interface in a good state - create it. 3.406 + 3.407 + if ( (dev = find_dev_by_handle(status->handle)) != NULL ) 3.408 + goto exit; 3.409 + 3.410 + if ( status->status == NETIF_INTERFACE_STATUS_CLOSED ) 3.411 + goto exit; 3.412 + if ( status->status == NETIF_INTERFACE_STATUS_CHANGED ) 3.413 + goto exit; 3.414 + 3.415 + /* It's a new interface in a good state - create it. */ 3.416 DPRINTK("> create device...\n"); 3.417 - err = create_netdev(status->handle, &dev); 3.418 - if(err) goto exit; 3.419 + if ( (err = create_netdev(status->handle, &dev)) != 0 ) 3.420 + goto exit; 3.421 + 3.422 netctrl.interface_n++; 3.423 + 3.424 exit: 3.425 - if(np){ 3.426 + if ( np != NULL ) 3.427 *np = ((dev && !err) ? dev->priv : NULL); 3.428 - } 3.429 DPRINTK("< err=%d\n", err); 3.430 return err; 3.431 } 3.432 3.433 -/* Warn about an unexpected status. */ 3.434 -static void unexpected(struct net_private *np, 3.435 - netif_fe_interface_status_t *status) 3.436 -{ 3.437 - WPRINTK(" Unexpected netif status %s in state %s\n", 3.438 - status_name[status->status], 3.439 - be_state_name[np->backend_state]); 3.440 -} 3.441 - 3.442 /* Handle an interface status message. */ 3.443 static void netif_interface_status(netif_fe_interface_status_t *status) 3.444 { 3.445 @@ -1012,22 +1033,25 @@ static void netif_interface_status(netif 3.446 struct net_private *np = NULL; 3.447 3.448 DPRINTK(">\n"); 3.449 - DPRINTK("> status=%s handle=%d\n", status_name[status->status], status->handle); 3.450 + DPRINTK("> status=%s handle=%d\n", 3.451 + status_name[status->status], status->handle); 3.452 3.453 - err = target_vif(status, &np); 3.454 - if(err){ 3.455 - WPRINTK(" Invalid netif: handle=%u\n", status->handle); 3.456 + if ( (err = target_vif(status, &np)) != 0 ) 3.457 + { 3.458 + WPRINTK("Invalid netif: handle=%u\n", status->handle); 3.459 return; 3.460 } 3.461 - if(np == NULL){ 3.462 + 3.463 + if ( np == NULL ) 3.464 + { 3.465 DPRINTK("> no vif\n"); 3.466 return; 3.467 } 3.468 3.469 DPRINTK(">\n"); vif_show(np); 3.470 3.471 - switch (status->status) { 3.472 - 3.473 + switch ( status->status ) 3.474 + { 3.475 case NETIF_INTERFACE_STATUS_CLOSED: 3.476 switch ( np->backend_state ) 3.477 { 3.478 @@ -1056,7 +1080,9 @@ static void netif_interface_status(netif 3.479 switch ( np->backend_state ) 3.480 { 3.481 case BEST_CLOSED: 3.482 - unexpected(np, status); 3.483 + WPRINTK("Unexpected netif status %s in state %s\n", 3.484 + status_name[status->status], 3.485 + be_state_name[np->backend_state]); 3.486 vif_disconnect(np); 3.487 vif_connect(np, status); 3.488 break; 3.489 @@ -1074,7 +1100,7 @@ static void netif_interface_status(netif 3.490 break; 3.491 3.492 default: 3.493 - WPRINTK(" Invalid netif status code %d\n", status->status); 3.494 + WPRINTK("Invalid netif status code %d\n", status->status); 3.495 break; 3.496 } 3.497 vif_show(np); 3.498 @@ -1135,7 +1161,8 @@ static int probe_interfaces(void) 3.499 3.500 DPRINTK(">\n"); 3.501 3.502 - for ( wait_i = 0; wait_i < wait_n; wait_i++) { 3.503 + for ( wait_i = 0; wait_i < wait_n; wait_i++) 3.504 + { 3.505 DPRINTK("> wait_i=%d\n", wait_i); 3.506 conn = netctrl_connected(); 3.507 if(conn) break; 3.508 @@ -1145,9 +1172,10 @@ static int probe_interfaces(void) 3.509 } 3.510 3.511 DPRINTK("> wait finished...\n"); 3.512 - if ( conn <= 0 ) { 3.513 + if ( conn <= 0 ) 3.514 + { 3.515 err = netctrl_err(-ENETDOWN); 3.516 - WPRINTK(" Failed to connect all virtual interfaces: err=%d\n", err); 3.517 + WPRINTK("Failed to connect all virtual interfaces: err=%d\n", err); 3.518 } 3.519 3.520 DPRINTK("< err=%d\n", err); 3.521 @@ -1177,7 +1205,8 @@ static int probe_interfaces(void) 3.522 DPRINTK(">\n"); 3.523 3.524 netctrl.interface_n = 0; 3.525 - for (wait_i = 0; wait_i < wait_n; wait_i++) { 3.526 + for ( wait_i = 0; wait_i < wait_n; wait_i++ ) 3.527 + { 3.528 DPRINTK("> wait_i=%d query=%d\n", wait_i, query); 3.529 msg.handle = query; 3.530 memcpy(cmsg.msg, &msg, sizeof(msg)); 3.531 @@ -1199,9 +1228,10 @@ static int probe_interfaces(void) 3.532 } 3.533 3.534 exit: 3.535 - if (err) { 3.536 + if ( err ) 3.537 + { 3.538 err = netctrl_err(-ENETDOWN); 3.539 - WPRINTK(" Connecting virtual network interfaces failed: err=%d\n", err); 3.540 + WPRINTK("Connecting virtual network interfaces failed: err=%d\n", err); 3.541 } 3.542 3.543 DPRINTK("< err=%d\n", err); 3.544 @@ -1218,7 +1248,7 @@ static int __init netif_init(void) 3.545 (start_info.flags & SIF_NET_BE_DOMAIN) ) 3.546 return 0; 3.547 3.548 - IPRINTK(" Initialising virtual ethernet driver.\n"); 3.549 + IPRINTK("Initialising virtual ethernet driver.\n"); 3.550 INIT_LIST_HEAD(&dev_list); 3.551 netctrl_init(); 3.552 (void)ctrl_if_register_receiver(CMSG_NETIF_FE, netif_ctrlif_rx, 3.553 @@ -1277,7 +1307,8 @@ void netif_resume(void) 3.554 struct net_private *np; 3.555 3.556 DPRINTK(">\n"); 3.557 - list_for_each(ent, &dev_list){ 3.558 + list_for_each ( ent, &dev_list ) 3.559 + { 3.560 np = list_entry(ent, struct net_private, list); 3.561 vif_resume(np); 3.562 }
4.1 --- a/xen/arch/x86/traps.c Tue Sep 28 14:47:51 2004 +0000 4.2 +++ b/xen/arch/x86/traps.c Thu Sep 30 20:45:54 2004 +0000 4.3 @@ -344,18 +344,6 @@ asmlinkage void do_page_fault(struct pt_ 4.4 4.5 ASSERT_no_criticalregion(); 4.6 4.7 - if ( unlikely(addr >= LDT_VIRT_START) && 4.8 - (addr < (LDT_VIRT_START + (d->mm.ldt_ents*LDT_ENTRY_SIZE))) ) 4.9 - { 4.10 - /* 4.11 - * Copy a mapping from the guest's LDT, if it is valid. Otherwise we 4.12 - * send the fault up to the guest OS to be handled. 4.13 - */ 4.14 - off = addr - LDT_VIRT_START; 4.15 - addr = d->mm.ldt_base + off; 4.16 - if ( likely(map_ldt_shadow_page(off >> PAGE_SHIFT)) ) 4.17 - return; /* successfully copied the mapping */ 4.18 - } 4.19 4.20 if ( likely(VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) ) 4.21 { 4.22 @@ -377,6 +365,19 @@ asmlinkage void do_page_fault(struct pt_ 4.23 (addr < PAGE_OFFSET) && shadow_fault(addr, error_code) ) 4.24 return; /* Returns TRUE if fault was handled. */ 4.25 4.26 + if ( unlikely(addr >= LDT_VIRT_START) && 4.27 + (addr < (LDT_VIRT_START + (d->mm.ldt_ents*LDT_ENTRY_SIZE))) ) 4.28 + { 4.29 + /* 4.30 + * Copy a mapping from the guest's LDT, if it is valid. Otherwise we 4.31 + * send the fault up to the guest OS to be handled. 4.32 + */ 4.33 + off = addr - LDT_VIRT_START; 4.34 + addr = d->mm.ldt_base + off; 4.35 + if ( likely(map_ldt_shadow_page(off >> PAGE_SHIFT)) ) 4.36 + return; /* successfully copied the mapping */ 4.37 + } 4.38 + 4.39 if ( unlikely(!(regs->xcs & 3)) ) 4.40 goto xen_fault; 4.41