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 +static long do_microcode_update(void *_info)
    1.47  {
    1.48 -    int error = microcode_update_cpu(
    1.49 -        smp_processor_id(), microcode_buffer.buf, microcode_buffer.size);
    1.50 -    if ( error )
    1.51 -        microcode_error = error;
    1.52 -}
    1.53 +    struct microcode_info *info = _info;
    1.54 +    int error;
    1.55  
    1.56 -static int do_microcode_update(void)
    1.57 -{
    1.58 -    microcode_error = 0;
    1.59 +    BUG_ON(info->cpu != smp_processor_id());
    1.60  
    1.61 -    if ( on_each_cpu(do_microcode_update_one, NULL, 1, 1) != 0 )
    1.62 -    {
    1.63 -        printk(KERN_ERR "microcode: Error! Could not run on all processors\n");
    1.64 -        return -EIO;
    1.65 -    }
    1.66 +    error = microcode_update_cpu(info->buffer, info->buffer_size);
    1.67 +    if ( error )
    1.68 +        info->error = error;
    1.69  
    1.70 -    return microcode_error;
    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 +    error = info->error;
    1.76 +    xfree(info);
    1.77 +    return error;
    1.78 +
    1.79  }
    1.80  
    1.81  int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len)
    1.82  {
    1.83      int ret;
    1.84 -
    1.85 -    /* XXX FIXME: No allocations in interrupt context. */
    1.86 -    return -EINVAL;
    1.87 +    struct microcode_info *info;
    1.88  
    1.89 -    if ( len != (typeof(microcode_buffer.size))len )
    1.90 -    {
    1.91 -        printk(KERN_ERR "microcode: too much data\n");
    1.92 +    if ( len != (uint32_t)len )
    1.93          return -E2BIG;
    1.94 -    }
    1.95  
    1.96      if ( microcode_ops == NULL )
    1.97          return -EINVAL;
    1.98  
    1.99 -    microcode_buffer.buf = xmalloc_array(uint8_t, len);
   1.100 -    if ( microcode_buffer.buf == NULL )
   1.101 +    info = xmalloc_bytes(sizeof(*info) + len);
   1.102 +    if ( info == NULL )
   1.103          return -ENOMEM;
   1.104  
   1.105 -    ret = copy_from_guest(microcode_buffer.buf, buf, len);
   1.106 +    ret = copy_from_guest(info->buffer, buf, len);
   1.107      if ( ret != 0 )
   1.108 +    {
   1.109 +        xfree(info);
   1.110          return ret;
   1.111 -
   1.112 -    microcode_buffer.size = len;
   1.113 -    wmb();
   1.114 +    }
   1.115  
   1.116 -    ret = do_microcode_update();
   1.117 +    info->buffer_size = len;
   1.118 +    info->error = 0;
   1.119 +    info->cpu = first_cpu(cpu_online_map);
   1.120  
   1.121 -    xfree(microcode_buffer.buf);
   1.122 -    microcode_buffer.buf = NULL;
   1.123 -    microcode_buffer.size = 0;
   1.124 -
   1.125 -    return ret;
   1.126 +    return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info);
   1.127  }
     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              {