From: Jan Beulich Date: Wed, 15 Jul 2015 16:04:00 +0000 (+0200) Subject: sysctl: adjust XEN_SYSCTL_cputopoinfo behavior X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2773 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=05970d10bdeae6979b6ec053f9286a3d206acc50;p=xen.git sysctl: adjust XEN_SYSCTL_cputopoinfo behavior The new function's implementation, unlike the original one of XEN_SYSCTL_topologyinfo, didn't allow the caller to get what it needs (if e.g. it's after the data for just one specific CPU) with just one hypercall, without caring about the total number of CPUs in the system. Signed-off-by: Jan Beulich Reviewed-by: Boris Ostrovsky Acked-by: Ian Campbell --- diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 601dd09130..5f9af2b294 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -358,15 +358,9 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { xen_sysctl_cputopo_t cputopo = { 0 }; - if ( ti->num_cpus < num_cpus ) - { - ret = -ENOBUFS; - i = num_cpus; - } - else - i = 0; - - for ( ; i < num_cpus; i++ ) + if ( num_cpus > ti->num_cpus ) + num_cpus = ti->num_cpus; + for ( i = 0; i < num_cpus; ++i ) { if ( cpu_present(i) ) { @@ -393,7 +387,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) else i = num_cpus; - if ( (!ret || (ret == -ENOBUFS)) && (ti->num_cpus != i) ) + if ( !ret && (ti->num_cpus != i) ) { ti->num_cpus = i; if ( __copy_field_to_guest(u_sysctl, op, diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index cd544c0ef4..86de43807a 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -482,10 +482,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cputopo_t); * - otherwise it's the number of entries in 'cputopo' * * OUT: - * - If 'num_cpus' is less than the number Xen needs to write, -ENOBUFS shall - * be returned and 'num_cpus' updated to reflect the intended number. - * - On success, 'num_cpus' shall indicate the number of entries written, which - * may be less than the maximum. + * - If 'num_cpus' is less than the number Xen wants to write but the handle + * handle is not a NULL one, partial data gets returned and 'num_cpus' gets + * updated to reflect the intended number. + * - Otherwise, 'num_cpus' shall indicate the number of entries written, which + * may be less than the input value. */ struct xen_sysctl_cputopoinfo { uint32_t num_cpus;