diff options
author | Jan Beulich <jbeulich@suse.com> | 2012-03-07 08:53:56 +0000 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2012-03-07 08:53:56 +0000 |
commit | 12b6d9e556580c93f0026ce620e282f1cddb3674 (patch) | |
tree | 18722c2e050e13afebb9aaa68d1547ca1bc542b0 | |
parent | eff74bdeb65dd2dde2ae88dba9cc9ab34b4125a0 (diff) | |
download | xen-12b6d9e556580c93f0026ce620e282f1cddb3674.tar.gz xen-12b6d9e556580c93f0026ce620e282f1cddb3674.tar.bz2 xen-12b6d9e556580c93f0026ce620e282f1cddb3674.zip |
x86: small fixes to pcpu platform op handling
XENPF_get_cpuinfo should init the flags output field rather than only
modify it.
XENPF_cpu_online must check for the input CPU number to be in range.
XENPF_cpu_offline must also do that, and should also reject attempts
to
offline CPU 0 (this fails in cpu_down() too, but preventing this here
appears more correct given that the code here calls
continue_hypercall_on_cpu(0, ...), which would be flawed if cpu_down()
would ever allow bringing down CPU 0 (and a distinct error code is
easier to deal with when debugging issues).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24201:9c6bea25f712
xen-unstable date: Thu Nov 24 17:56:26 2011 +0100
-rw-r--r-- | xen/arch/x86/platform_hypercall.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c index 9bb952d3ff..5f1ac9085e 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -418,13 +418,14 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) if ( (g_info->xen_cpuid >= NR_CPUS) || !cpu_present(g_info->xen_cpuid) ) { - g_info->flags |= XEN_PCPU_FLAGS_INVALID; + g_info->flags = XEN_PCPU_FLAGS_INVALID; } else { g_info->apic_id = x86_cpu_to_apicid[g_info->xen_cpuid]; g_info->acpi_id = acpi_get_processor_id(g_info->xen_cpuid); ASSERT(g_info->apic_id != BAD_APICID); + g_info->flags = 0; if (cpu_online(g_info->xen_cpuid)) g_info->flags |= XEN_PCPU_FLAGS_ONLINE; } @@ -442,7 +443,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) int cpu; cpu = op->u.cpu_ol.cpuid; - if (!cpu_present(cpu)) + if (cpu >= NR_CPUS || !cpu_present(cpu)) { ret = -EINVAL; break; @@ -462,15 +463,25 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) int cpu; cpu = op->u.cpu_ol.cpuid; - if (!cpu_present(cpu)) + + if ( cpu == 0 ) + { + ret = -EOPNOTSUPP; + break; + } + + if ( cpu >= NR_CPUS || !cpu_present(cpu) ) { ret = -EINVAL; break; - } else if (!cpu_online(cpu)) + } + + if (!cpu_online(cpu)) { ret = 0; break; } + ret = continue_hypercall_on_cpu( 0, cpu_down_helper, (void *)(unsigned long)cpu); break; |