x86: add platform hypercall to retrieve pCPU-s' family, model, and stepping With the recent hotplug changes to the Xen part of the microcode loading, this allows the kernel driver to avoid unnecessary calls into the hypervisor during pCPU hot-enabling: Knowing that the hypervisor retains the data for already booted CPUs, only data for CPUs with a different signature needs to be passed down. Since the microcode loading code can be pretty verbose, avoiding to invoke it can make the log much easier to look at in case of problems. Signed-off-by: Jan Beulich --- 2011-11-23.orig/xen/arch/x86/platform_hypercall.c 2011-12-01 12:06:55.000000000 +0100 +++ 2011-11-23/xen/arch/x86/platform_hypercall.c 2011-12-09 17:39:04.000000000 +0100 @@ -469,6 +469,42 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe } break; + case XENPF_get_cpu_version: + { + struct xenpf_pcpu_version *ver = &op->u.pcpu_version; + + if ( !get_cpu_maps() ) + { + ret = -EBUSY; + break; + } + + if ( (ver->xen_cpuid >= nr_cpu_ids) || !cpu_online(ver->xen_cpuid) ) + { + memset(ver->vendor_id, 0, sizeof(ver->vendor_id)); + ver->family = 0; + ver->model = 0; + ver->stepping = 0; + } + else + { + const struct cpuinfo_x86 *c = &cpu_data[ver->xen_cpuid]; + + memcpy(ver->vendor_id, c->x86_vendor_id, sizeof(ver->vendor_id)); + ver->family = c->x86; + ver->model = c->x86_model; + ver->stepping = c->x86_mask; + } + + ver->max_present = cpumask_last(&cpu_present_map); + + put_cpu_maps(); + + if ( copy_field_to_guest(u_xenpf_op, op, u.pcpu_version) ) + ret = -EFAULT; + } + break; + case XENPF_cpu_online: { int cpu = op->u.cpu_ol.cpuid; --- 2011-11-23.orig/xen/arch/x86/x86_64/platform_hypercall.c 2011-12-09 17:40:49.000000000 +0100 +++ 2011-11-23/xen/arch/x86/x86_64/platform_hypercall.c 2011-12-01 16:04:28.000000000 +0100 @@ -3,7 +3,7 @@ */ #include -#include +#include #include DEFINE_XEN_GUEST_HANDLE(compat_platform_op_t); @@ -26,8 +26,13 @@ DEFINE_XEN_GUEST_HANDLE(compat_platform_ #define xen_processor_power_t compat_processor_power_t #define set_cx_pminfo compat_set_cx_pminfo -#define xenpf_pcpuinfo compat_pf_pcpuinfo -#define xenpf_pcpuinfo_t compat_pf_pcpuinfo_t +#define xen_pf_pcpuinfo xenpf_pcpuinfo +CHECK_pf_pcpuinfo; +#undef xen_pf_pcpuinfo + +#define xen_pf_pcpu_version xenpf_pcpu_version +CHECK_pf_pcpu_version; +#undef xen_pf_pcpu_version #define xenpf_enter_acpi_sleep compat_pf_enter_acpi_sleep --- 2011-11-23.orig/xen/include/public/platform.h 2011-12-09 17:40:49.000000000 +0100 +++ 2011-11-23/xen/include/public/platform.h 2011-12-09 17:39:17.000000000 +0100 @@ -449,6 +449,21 @@ struct xenpf_pcpuinfo { typedef struct xenpf_pcpuinfo xenpf_pcpuinfo_t; DEFINE_XEN_GUEST_HANDLE(xenpf_pcpuinfo_t); +#define XENPF_get_cpu_version 48 +struct xenpf_pcpu_version { + /* IN */ + uint32_t xen_cpuid; + /* OUT */ + /* The maxium cpu_id that is present */ + uint32_t max_present; + char vendor_id[12]; + uint32_t family; + uint32_t model; + uint32_t stepping; +}; +typedef struct xenpf_pcpu_version xenpf_pcpu_version_t; +DEFINE_XEN_GUEST_HANDLE(xenpf_pcpu_version_t); + #define XENPF_cpu_online 56 #define XENPF_cpu_offline 57 struct xenpf_cpu_ol @@ -492,6 +507,7 @@ struct xen_platform_op { struct xenpf_getidletime getidletime; struct xenpf_set_processor_pminfo set_pminfo; struct xenpf_pcpuinfo pcpu_info; + struct xenpf_pcpu_version pcpu_version; struct xenpf_cpu_ol cpu_ol; struct xenpf_cpu_hotadd cpu_add; struct xenpf_mem_hotadd mem_add; --- 2011-11-23.orig/xen/include/xlat.lst 2011-12-09 17:40:49.000000000 +0100 +++ 2011-11-23/xen/include/xlat.lst 2011-12-01 15:46:31.000000000 +0100 @@ -72,6 +72,17 @@ ? physdev_restore_msi physdev.h ? physdev_set_iopl physdev.h ? physdev_setup_gsi physdev.h +! pct_register platform.h +! power_register platform.h +? processor_csd platform.h +! processor_cx platform.h +! processor_flags platform.h +! processor_performance platform.h +! processor_power platform.h +? processor_px platform.h +! psd_package platform.h +? xenpf_pcpuinfo platform.h +? xenpf_pcpu_version platform.h ! sched_poll sched.h ? sched_remote_shutdown sched.h ? sched_shutdown sched.h @@ -84,12 +95,3 @@ ! vcpu_set_singleshot_timer vcpu.h ? xenoprof_init xenoprof.h ? xenoprof_passive xenoprof.h -! power_register platform.h -? processor_csd platform.h -! processor_cx platform.h -! processor_flags platform.h -! processor_power platform.h -! pct_register platform.h -? processor_px platform.h -! psd_package platform.h -! processor_performance platform.h