ia64/xen-unstable

changeset 18507:d7be37824fe0

Merge with IA64 tree.
author Keir Fraser <keir.fraser@citrix.com>
date Tue Sep 16 13:53:47 2008 +0100 (2008-09-16)
parents 4a381ddc764a f163138e3340
children 15efb62ecf09
files
line diff
     1.1 --- a/xen/arch/x86/microcode.c	Tue Sep 16 21:25:30 2008 +0900
     1.2 +++ b/xen/arch/x86/microcode.c	Tue Sep 16 13:53:47 2008 +0100
     1.3 @@ -42,14 +42,13 @@ static DEFINE_SPINLOCK(microcode_mutex);
     1.4  
     1.5  struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
     1.6  
     1.7 -struct microcode_buffer {
     1.8 -    void *buf;
     1.9 -    size_t size;
    1.10 +struct microcode_info {
    1.11 +    unsigned int cpu;
    1.12 +    uint32_t buffer_size;
    1.13 +    int error;
    1.14 +    char buffer[1];
    1.15  };
    1.16  
    1.17 -static struct microcode_buffer microcode_buffer;
    1.18 -static bool_t microcode_error;
    1.19 -
    1.20  static void microcode_fini_cpu(int cpu)
    1.21  {
    1.22      struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    1.23 @@ -108,14 +107,12 @@ static int microcode_resume_cpu(int cpu)
    1.24      return err;
    1.25  }
    1.26  
    1.27 -static int microcode_update_cpu(int cpu, const void *buf, size_t size)
    1.28 +static int microcode_update_cpu(const void *buf, size_t size)
    1.29  {
    1.30 -    int err = 0;
    1.31 +    int err;
    1.32 +    unsigned int cpu = smp_processor_id();
    1.33      struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    1.34  
    1.35 -    /* We should bind the task to the CPU */
    1.36 -    BUG_ON(raw_smp_processor_id() != cpu);
    1.37 -
    1.38      spin_lock(&microcode_mutex);
    1.39  
    1.40      /*
    1.41 @@ -138,59 +135,52 @@ static int microcode_update_cpu(int cpu,
    1.42      return err;
    1.43  }
    1.44  
    1.45 -static void do_microcode_update_one(void *info)
    1.46 -{
    1.47 -    int error = microcode_update_cpu(
    1.48 -        smp_processor_id(), microcode_buffer.buf, microcode_buffer.size);
    1.49 -    if ( error )
    1.50 -        microcode_error = error;
    1.51 -}
    1.52 -
    1.53 -static int do_microcode_update(void)
    1.54 +static long do_microcode_update(void *_info)
    1.55  {
    1.56 -    microcode_error = 0;
    1.57 +    struct microcode_info *info = _info;
    1.58 +    int error;
    1.59 +
    1.60 +    BUG_ON(info->cpu != smp_processor_id());
    1.61 +
    1.62 +    error = microcode_update_cpu(info->buffer, info->buffer_size);
    1.63 +    if ( error )
    1.64 +        info->error = error;
    1.65  
    1.66 -    if ( on_each_cpu(do_microcode_update_one, NULL, 1, 1) != 0 )
    1.67 -    {
    1.68 -        printk(KERN_ERR "microcode: Error! Could not run on all processors\n");
    1.69 -        return -EIO;
    1.70 -    }
    1.71 +    info->cpu = next_cpu(info->cpu, cpu_online_map);
    1.72 +    if ( info->cpu < NR_CPUS )
    1.73 +        return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info);
    1.74  
    1.75 -    return microcode_error;
    1.76 +    error = info->error;
    1.77 +    xfree(info);
    1.78 +    return error;
    1.79 +
    1.80  }
    1.81  
    1.82  int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len)
    1.83  {
    1.84      int ret;
    1.85 -
    1.86 -    /* XXX FIXME: No allocations in interrupt context. */
    1.87 -    return -EINVAL;
    1.88 +    struct microcode_info *info;
    1.89  
    1.90 -    if ( len != (typeof(microcode_buffer.size))len )
    1.91 -    {
    1.92 -        printk(KERN_ERR "microcode: too much data\n");
    1.93 +    if ( len != (uint32_t)len )
    1.94          return -E2BIG;
    1.95 -    }
    1.96  
    1.97      if ( microcode_ops == NULL )
    1.98          return -EINVAL;
    1.99  
   1.100 -    microcode_buffer.buf = xmalloc_array(uint8_t, len);
   1.101 -    if ( microcode_buffer.buf == NULL )
   1.102 +    info = xmalloc_bytes(sizeof(*info) + len);
   1.103 +    if ( info == NULL )
   1.104          return -ENOMEM;
   1.105  
   1.106 -    ret = copy_from_guest(microcode_buffer.buf, buf, len);
   1.107 +    ret = copy_from_guest(info->buffer, buf, len);
   1.108      if ( ret != 0 )
   1.109 +    {
   1.110 +        xfree(info);
   1.111          return ret;
   1.112 -
   1.113 -    microcode_buffer.size = len;
   1.114 -    wmb();
   1.115 +    }
   1.116  
   1.117 -    ret = do_microcode_update();
   1.118 +    info->buffer_size = len;
   1.119 +    info->error = 0;
   1.120 +    info->cpu = first_cpu(cpu_online_map);
   1.121  
   1.122 -    xfree(microcode_buffer.buf);
   1.123 -    microcode_buffer.buf = NULL;
   1.124 -    microcode_buffer.size = 0;
   1.125 -
   1.126 -    return ret;
   1.127 +    return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info);
   1.128  }
     2.1 --- a/xen/arch/x86/traps.c	Tue Sep 16 21:25:30 2008 +0900
     2.2 +++ b/xen/arch/x86/traps.c	Tue Sep 16 13:53:47 2008 +0100
     2.3 @@ -2223,10 +2223,6 @@ static int emulate_privileged_op(struct 
     2.4              if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) != 0 )
     2.5                  goto fail;
     2.6              break;
     2.7 -        case MSR_EFER:
     2.8 -            if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) )
     2.9 -                goto fail;
    2.10 -            break;
    2.11          case MSR_IA32_MISC_ENABLE:
    2.12              if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) )
    2.13                  goto fail;
    2.14 @@ -2236,12 +2232,9 @@ static int emulate_privileged_op(struct 
    2.15                           MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL |
    2.16                           MSR_IA32_MISC_ENABLE_XTPR_DISABLE;
    2.17              break;
    2.18 +        case MSR_EFER:
    2.19          case MSR_IA32_THERM_CONTROL:
    2.20 -            if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
    2.21 -                goto fail;
    2.22 -            if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) )
    2.23 -                goto fail;
    2.24 -            break;
    2.25 +        case MSR_AMD_PATCHLEVEL:
    2.26          default:
    2.27              if ( rdmsr_hypervisor_regs(regs->ecx, &l, &h) )
    2.28              {