ia64/xen-unstable

changeset 1546:c4b72645fb6b

bitkeeper revision 1.1002 (40d88177J1ZwWwtviFnQ0ek2z1hFVw)

Cleanups
author kaf24@scramble.cl.cam.ac.uk
date Tue Jun 22 18:59:03 2004 +0000 (2004-06-22)
parents aeb5e98fd252
children f9d7fa707de4
files xen/common/ac_timer.c xen/common/keyhandler.c xen/common/memory.c xen/common/physdev.c
line diff
     1.1 --- a/xen/common/ac_timer.c	Tue Jun 22 16:49:45 2004 +0000
     1.2 +++ b/xen/common/ac_timer.c	Tue Jun 22 18:59:03 2004 +0000
     1.3 @@ -275,8 +275,6 @@ void __init ac_timer_init(void)
     1.4  {
     1.5      int i;
     1.6  
     1.7 -    printk ("ACT: Initialising Accurate timers\n");
     1.8 -
     1.9      open_softirq(AC_TIMER_SOFTIRQ, ac_timer_softirq_action);
    1.10  
    1.11      for ( i = 0; i < smp_num_cpus; i++ )
     2.1 --- a/xen/common/keyhandler.c	Tue Jun 22 16:49:45 2004 +0000
     2.2 +++ b/xen/common/keyhandler.c	Tue Jun 22 18:59:03 2004 +0000
     2.3 @@ -9,45 +9,28 @@
     2.4  #define KEY_MAX 256
     2.5  #define STR_MAX  64
     2.6  
     2.7 -typedef struct _key_te { 
     2.8 +static struct { 
     2.9      key_handler *handler; 
    2.10      char         desc[STR_MAX]; 
    2.11 -} key_te_t; 
    2.12 -
    2.13 -static key_te_t key_table[KEY_MAX]; 
    2.14 -    
    2.15 -void add_key_handler(u_char key, key_handler *handler, char *desc) 
    2.16 -{
    2.17 -    int i; 
    2.18 -    char *str; 
    2.19 -
    2.20 -    if ( key_table[key].handler != NULL ) 
    2.21 -        printk("Warning: overwriting handler for key 0x%x\n", key); 
    2.22 +} key_table[KEY_MAX]; 
    2.23  
    2.24 +void add_key_handler(unsigned char key, key_handler *handler, char *desc)
    2.25 +{
    2.26      key_table[key].handler = handler; 
    2.27 -
    2.28 -    str = key_table[key].desc; 
    2.29 -    for ( i = 0; i < STR_MAX; i++ )
    2.30 -    {
    2.31 -        if ( *desc != '\0' ) 
    2.32 -            *str++ = *desc++; 
    2.33 -        else
    2.34 -            break; 
    2.35 -    }
    2.36 -    if ( i == STR_MAX ) 
    2.37 -        key_table[key].desc[STR_MAX-1] = '\0'; 
    2.38 +    strncpy(key_table[key].desc, desc, STR_MAX);
    2.39 +    key_table[key].desc[STR_MAX-1] = '\0'; 
    2.40  }
    2.41  
    2.42 -key_handler *get_key_handler(u_char key)
    2.43 +key_handler *get_key_handler(unsigned char key)
    2.44  {
    2.45      return key_table[key].handler; 
    2.46  }
    2.47  
    2.48 -static void show_handlers(u_char key, void *dev_id, struct pt_regs *regs) 
    2.49 +static void show_handlers(unsigned char key, void *dev_id,
    2.50 +                          struct pt_regs *regs)
    2.51  {
    2.52      int i; 
    2.53 -
    2.54 -    printk("'%c' pressed -> showing installed handlers\n", key); 
    2.55 +    printk("'%c' pressed -> showing installed handlers\n", key);
    2.56      for ( i = 0; i < KEY_MAX; i++ ) 
    2.57          if ( key_table[i].handler != NULL ) 
    2.58              printk(" key '%c' (ascii '%02x') => %s\n", 
    2.59 @@ -56,24 +39,26 @@ static void show_handlers(u_char key, vo
    2.60  }
    2.61  
    2.62  
    2.63 -static void dump_registers(u_char key, void *dev_id, struct pt_regs *regs) 
    2.64 +static void dump_registers(unsigned char key, void *dev_id,
    2.65 +                           struct pt_regs *regs)
    2.66  {
    2.67      extern void show_registers(struct pt_regs *regs); 
    2.68      printk("'%c' pressed -> dumping registers\n", key); 
    2.69      show_registers(regs); 
    2.70  }
    2.71  
    2.72 -static void halt_machine(u_char key, void *dev_id, struct pt_regs *regs) 
    2.73 +static void halt_machine(unsigned char key, void *dev_id,
    2.74 +                         struct pt_regs *regs) 
    2.75  {
    2.76      printk("'%c' pressed -> rebooting machine\n", key); 
    2.77      machine_restart(NULL); 
    2.78  }
    2.79  
    2.80 -void do_task_queues(u_char key, void *dev_id, struct pt_regs *regs) 
    2.81 +void do_task_queues(unsigned char key, void *dev_id,
    2.82 +                    struct pt_regs *regs) 
    2.83  {
    2.84      unsigned long  flags;
    2.85 -    struct domain *d; 
    2.86 -    shared_info_t *s; 
    2.87 +    struct domain *d;
    2.88      s_time_t       now = NOW();
    2.89  
    2.90      printk("'%c' pressed -> dumping task queues (now=0x%X:%08X)\n", key,
    2.91 @@ -87,10 +72,9 @@ void do_task_queues(u_char key, void *de
    2.92                 d->domain, d->processor, 
    2.93                 test_bit(DF_RUNNING, &d->flags) ? 'T':'F',
    2.94                 atomic_read(&d->refcnt), d->tot_pages);
    2.95 -        s = d->shared_info; 
    2.96          printk("Guest: upcall_pend = %02x, upcall_mask = %02x\n", 
    2.97 -               s->vcpu_data[0].evtchn_upcall_pending, 
    2.98 -               s->vcpu_data[0].evtchn_upcall_mask);
    2.99 +               d->shared_info->vcpu_data[0].evtchn_upcall_pending, 
   2.100 +               d->shared_info->vcpu_data[0].evtchn_upcall_mask);
   2.101          printk("Notifying guest...\n"); 
   2.102          send_guest_virq(d, VIRQ_DEBUG);
   2.103      }
   2.104 @@ -98,28 +82,21 @@ void do_task_queues(u_char key, void *de
   2.105      read_unlock_irqrestore(&tasklist_lock, flags); 
   2.106  }
   2.107  
   2.108 -extern void dump_runq(u_char key, void *dev_id, struct pt_regs *regs);
   2.109 -extern void print_sched_histo(u_char key, void *dev_id, struct pt_regs *regs);
   2.110 -extern void reset_sched_histo(u_char key, void *dev_id, struct pt_regs *regs);
   2.111 +extern void dump_runq(unsigned char key, void *dev_id, 
   2.112 +                      struct pt_regs *regs);
   2.113 +extern void print_sched_histo(unsigned char key, void *dev_id, 
   2.114 +                              struct pt_regs *regs);
   2.115 +extern void reset_sched_histo(unsigned char key, void *dev_id, 
   2.116 +                              struct pt_regs *regs);
   2.117  #ifdef PERF_COUNTERS
   2.118 -extern void perfc_printall (u_char key, void *dev_id, struct pt_regs *regs);
   2.119 -extern void perfc_reset (u_char key, void *dev_id, struct pt_regs *regs);
   2.120 +extern void perfc_printall(unsigned char key, void *dev_id,
   2.121 +                           struct pt_regs *regs);
   2.122 +extern void perfc_reset(unsigned char key, void *dev_id,
   2.123 +                        struct pt_regs *regs);
   2.124  #endif
   2.125 -#ifndef NDEBUG
   2.126 -void reaudit_pages(u_char key, void *dev_id, struct pt_regs *regs);
   2.127 -void audit_all_pages(u_char key, void *dev_id, struct pt_regs *regs);
   2.128 -#endif
   2.129 -
   2.130  
   2.131  void initialize_keytable(void)
   2.132  {
   2.133 -    int i; 
   2.134 -
   2.135 -    /* first initialize key handler table */
   2.136 -    for ( i = 0; i < KEY_MAX; i++ ) 
   2.137 -        key_table[i].handler = (key_handler *)NULL; 
   2.138 -
   2.139 -    /* setup own handlers */
   2.140      add_key_handler('d', dump_registers, "dump registers"); 
   2.141      add_key_handler('h', show_handlers, "show this message");
   2.142      add_key_handler('l', print_sched_histo, "print sched latency histogram");
   2.143 @@ -131,8 +108,4 @@ void initialize_keytable(void)
   2.144      add_key_handler('p', perfc_printall, "print performance counters"); 
   2.145      add_key_handler('P', perfc_reset,    "reset performance counters"); 
   2.146  #endif
   2.147 -#ifndef NDEBUG
   2.148 -    add_key_handler('m', reaudit_pages, "re-audit pages");
   2.149 -    add_key_handler('M', audit_all_pages, "audit all pages");
   2.150 -#endif
   2.151  }
     3.1 --- a/xen/common/memory.c	Tue Jun 22 16:49:45 2004 +0000
     3.2 +++ b/xen/common/memory.c	Tue Jun 22 18:59:03 2004 +0000
     3.3 @@ -1297,177 +1297,3 @@ int do_update_va_mapping_otherdomain(uns
     3.4  
     3.5      return rc;
     3.6  }
     3.7 -
     3.8 -
     3.9 -#ifndef NDEBUG
    3.10 -/*
    3.11 - * below are various memory debugging functions: 
    3.12 - * __audit_page():    prints out all the ptes a pages is listed in
    3.13 - * audit_page():      in addition maintains a history of audited pages
    3.14 - * reaudit_pages():   re-audit previously audited pages
    3.15 - * audit_all_pages(): check the ref-count for all leaf pages
    3.16 - * reaudit_page() and audit_all_pages() are designed to be
    3.17 - * keyhandler functions so that they can be easily invoked from the console.
    3.18 - */
    3.19 -
    3.20 -
    3.21 -/*
    3.22 - * prints out all the pt's a page is listed in
    3.23 - */
    3.24 -void __audit_page(unsigned long pfn) {
    3.25 -    unsigned long     i, j;
    3.26 -    struct pfn_info  *page;
    3.27 -    unsigned long     page_addr;
    3.28 -    l1_pgentry_t     *pl1e, l1e;
    3.29 -    
    3.30 -    page = &frame_table[pfn];
    3.31 -    page_addr = pfn << PAGE_SHIFT;
    3.32 -
    3.33 -    printk("audit page: pfn=%lx info: cf=%x tf=%x ts=%x dom=%lx\n", pfn,
    3.34 -           page->count_and_flags, page->type_and_flags,
    3.35 -           page->tlbflush_timestamp, (unsigned long)page->u.domain);
    3.36 -
    3.37 -    /* walk the frame table */
    3.38 -    for ( i = 0; i < max_page; i++ )
    3.39 -    {
    3.40 -        if ( (frame_table[i].count_and_flags & PGC_count_mask) == 0 )
    3.41 -            continue;
    3.42 -
    3.43 -        /* check if entry is a page table (L1 page table) and in use */
    3.44 -        if ( ((frame_table[i].type_and_flags & PGT_type_mask) ==
    3.45 -              PGT_l1_page_table) &&
    3.46 -             ((frame_table[i].type_and_flags & PGT_count_mask) != 0) )
    3.47 -        {
    3.48 -            pl1e = map_domain_mem(i << PAGE_SHIFT);
    3.49 -
    3.50 -            /* scan page table for page to audit */
    3.51 -            for ( j=0; j < ENTRIES_PER_L1_PAGETABLE; j++  )
    3.52 -            {
    3.53 -                l1e = pl1e[j];
    3.54 -                if ( l1_pgentry_empty(l1e) )
    3.55 -                    continue;
    3.56 -                if ( l1_pgentry_to_pagenr(l1e) == pfn )
    3.57 -                {
    3.58 -                    printk("  pte_pfn=%06lx cf=%08x tf=%08x dom=%08lx\n", 
    3.59 -                           i, frame_table[i].count_and_flags,
    3.60 -                           frame_table[i].type_and_flags,
    3.61 -                           (unsigned long)frame_table[i].u.domain);
    3.62 -                    printk("    pte_idx=%03lx *pte_idx=%08lx\n", 
    3.63 -                           j, l1_pgentry_val(l1e));
    3.64 -                }
    3.65 -            }
    3.66 -            unmap_domain_mem(pl1e);
    3.67 -        }
    3.68 -    }
    3.69 -
    3.70 -}
    3.71 -
    3.72 -/*
    3.73 - * audit a page and keep a history of audited pfns
    3.74 - */
    3.75 -#define LASTPAGES_SIZE 128
    3.76 -static long last_pages[LASTPAGES_SIZE];
    3.77 -static int  last_pages_idx = 0;
    3.78 -void audit_page(unsigned long pfn)
    3.79 -{
    3.80 -    unsigned long     i;
    3.81 -
    3.82 -    __cli();
    3.83 -    __audit_page(pfn);
    3.84 -    __sti();
    3.85 -    /* add pfn to last_pages cache if is not already present */
    3.86 -    for ( i = 0; i < LASTPAGES_SIZE; i++ )
    3.87 -        if ( last_pages[i] == pfn )
    3.88 -            return;
    3.89 -
    3.90 -    /* new entry */
    3.91 -    last_pages[last_pages_idx++] = pfn;
    3.92 -    if ( last_pages_idx >= LASTPAGES_SIZE ) 
    3.93 -        last_pages_idx = 0;
    3.94 -
    3.95 -}
    3.96 -
    3.97 -/*
    3.98 - * re-audit previously audited pages
    3.99 - */
   3.100 -void reaudit_pages(u_char key, void *dev_id, struct pt_regs *regs)
   3.101 -{
   3.102 -    int i;
   3.103 -
   3.104 -    printk("Dumping audited pages\n");
   3.105 -
   3.106 -    for ( i = 0; i < LASTPAGES_SIZE; i++ )
   3.107 -        if ( last_pages[i] != 0 )
   3.108 -            __audit_page(last_pages[i]);
   3.109 -}
   3.110 -
   3.111 -/*
   3.112 - * do various checks on all pages.
   3.113 - * Currently:
   3.114 - * - check for pages with corrupt ref-count
   3.115 - * Interrupts are diabled completely. use with care.
   3.116 - */
   3.117 -void audit_all_pages(u_char key, void *dev_id, struct pt_regs *regs)
   3.118 -{
   3.119 -    unsigned long     i, j, k;
   3.120 -    unsigned long     ref_count;
   3.121 -    l1_pgentry_t     *pl1e, l1e;
   3.122 -
   3.123 -    printk("audit_all_pages\n");
   3.124 -
   3.125 -    __cli();
   3.126 -    
   3.127 -    /* walk the frame table */
   3.128 -    for ( i = 0; i < max_page; i++ )
   3.129 -    {
   3.130 -        /* check ref count for leaf pages */
   3.131 -        if ( ((frame_table[i].type_and_flags & PGT_type_mask) ==
   3.132 -              PGT_writeable_page) )
   3.133 -        {
   3.134 -            ref_count = 0;
   3.135 -
   3.136 -            /* find page tables */
   3.137 -            for ( j = 0; j < max_page; j++ )
   3.138 -            {
   3.139 -                if ( ((frame_table[j].type_and_flags & PGT_type_mask) ==
   3.140 -                      PGT_l1_page_table) &&
   3.141 -                     ((frame_table[j].type_and_flags & PGT_count_mask) != 0) )
   3.142 -                {
   3.143 -                    pl1e = map_domain_mem(j << PAGE_SHIFT);
   3.144 -
   3.145 -                    /* scan page table for page to audit */
   3.146 -                    for ( k=0; k < ENTRIES_PER_L1_PAGETABLE; k++  )
   3.147 -                    {
   3.148 -                        l1e = pl1e[k];
   3.149 -                        if ( l1_pgentry_empty(l1e) )
   3.150 -                            continue;
   3.151 -                        if ( l1_pgentry_to_pagenr(l1e) == i )
   3.152 -                        {
   3.153 -                            ref_count++;
   3.154 -                            /* page is in pagetable */
   3.155 -                        }
   3.156 -                    }
   3.157 -                    unmap_domain_mem(pl1e);
   3.158 -                }
   3.159 -
   3.160 -            }
   3.161 -
   3.162 -            /* check for PGC_ALLOCATED */
   3.163 -            if ( (frame_table[i].count_and_flags & PGC_allocated) != 0 )
   3.164 -                ref_count++;
   3.165 -
   3.166 -            if ( (frame_table[i].count_and_flags & PGC_count_mask) 
   3.167 -                 != ref_count )
   3.168 -            {
   3.169 -                printk("refcount error: pfn=%06lx cf=%08x refcount=%lx\n",
   3.170 -                       i, frame_table[i].count_and_flags, ref_count);
   3.171 -                __audit_page(i);
   3.172 -                printk("\n");
   3.173 -            }
   3.174 -        } /* ref count error */
   3.175 -    }
   3.176 -    __sti();
   3.177 -    
   3.178 -}
   3.179 -
   3.180 -#endif /* NDEBUG */
     4.1 --- a/xen/common/physdev.c	Tue Jun 22 16:49:45 2004 +0000
     4.2 +++ b/xen/common/physdev.c	Tue Jun 22 18:59:03 2004 +0000
     4.3 @@ -38,7 +38,7 @@ extern void pcibios_enable_irq(struct pc
     4.4  #define VERBOSE_INFO(_f, _a...) ((void)0)
     4.5  #endif
     4.6  
     4.7 -#if 1 || !defined(NDEBUG)
     4.8 +#ifndef NDEBUG
     4.9  #define INFO(_f, _a...) printk( _f, ## _a )
    4.10  #else
    4.11  #define INFO(_f, _a...) ((void)0)
    4.12 @@ -331,8 +331,8 @@ static int do_base_address_access(phys_d
    4.13          /* We could set *val to some value but the guest may well be in trouble
    4.14           * anyway if this write fails.  Hopefully the printk will give us a
    4.15           * clue what went wrong. */
    4.16 -        printk("Guest %u attempting sub-dword %s to BASE_ADDRESS %d\n",
    4.17 -               pdev->owner->domain, (acc == ACC_READ) ? "read" : "write", idx);
    4.18 +        INFO("Guest %u attempting sub-dword %s to BASE_ADDRESS %d\n",
    4.19 +             pdev->owner->domain, (acc == ACC_READ) ? "read" : "write", idx);
    4.20          
    4.21          return -EPERM;
    4.22      }
    4.23 @@ -729,22 +729,21 @@ void physdev_init_dom0(struct domain *p)
    4.24  
    4.25      pci_for_each_dev(dev)
    4.26      {
    4.27 -        if ( !pcidev_dom0_hidden(dev) )
    4.28 +        if ( pcidev_dom0_hidden(dev) )
    4.29          {            
    4.30 -            /* Skip bridges and other peculiarities for now. */
    4.31 -            if ( dev->hdr_type != PCI_HEADER_TYPE_NORMAL )
    4.32 -                continue;
    4.33 -            pdev = kmalloc(sizeof(phys_dev_t), GFP_KERNEL);
    4.34 -            pdev->dev = dev;
    4.35 -            pdev->flags = ACC_WRITE;
    4.36 -            pdev->state = 0;
    4.37 -            pdev->owner = p;
    4.38 -            list_add(&pdev->node, &p->pcidev_list);
    4.39 +            printk("Hiding PCI device %s from DOM0\n", dev->slot_name);
    4.40 +            continue;
    4.41          }
    4.42 -        else
    4.43 -        {
    4.44 -            printk("Hiding PCI device %s from DOM0\n", dev->slot_name);
    4.45 -        }
    4.46 +
    4.47 +        /* Skip bridges and other peculiarities for now. */
    4.48 +        if ( dev->hdr_type != PCI_HEADER_TYPE_NORMAL )
    4.49 +            continue;
    4.50 +        pdev = kmalloc(sizeof(phys_dev_t), GFP_KERNEL);
    4.51 +        pdev->dev = dev;
    4.52 +        pdev->flags = ACC_WRITE;
    4.53 +        pdev->state = 0;
    4.54 +        pdev->owner = p;
    4.55 +        list_add(&pdev->node, &p->pcidev_list);
    4.56      }
    4.57  
    4.58      set_bit(DF_PHYSDEV, &p->flags);