Commit 39adc483 authored by Liu Jinsong's avatar Liu Jinsong Committed by Konrad Rzeszutek Wilk

xen/acpi: ACPI cpu hotplug

This patch implement real Xen ACPI cpu hotplug driver as module.
When loaded, it replaces Xen stub driver.

For booting existed cpus, the driver enumerates them.
For hotadded cpus, which added at runtime and notify OS via
device or container event, the driver is invoked to add them,
parsing cpu information, hypercalling to Xen hypervisor to add
them, and finally setting up new /sys interface for them.
Signed-off-by: default avatarLiu Jinsong <jinsong.liu@intel.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent 40a58637
......@@ -202,6 +202,18 @@ config XEN_ACPI_HOTPLUG_MEMORY
to hot-add memory at runtime (the hot-added memory cannot be
removed until machine stop), select Y/M here, otherwise select N.
config XEN_ACPI_HOTPLUG_CPU
tristate "Xen ACPI cpu hotplug"
depends on XEN_DOM0 && XEN_STUB && ACPI
select ACPI_CONTAINER
default n
help
Xen ACPI cpu enumerating and hotplugging
For hotplugging, currently Xen only support ACPI cpu hotadd.
If you want to hotadd cpu at runtime (the hotadded cpu cannot
be removed until machine stop), select Y/M here.
config XEN_ACPI_PROCESSOR
tristate "Xen ACPI processor"
depends on XEN && X86 && ACPI_PROCESSOR && CPU_FREQ
......
......@@ -32,6 +32,7 @@ obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/
obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o
obj-$(CONFIG_XEN_STUB) += xen-stub.o
obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o
obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o
obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o
xen-evtchn-y := evtchn.o
xen-gntdev-y := gntdev.o
......
......@@ -333,6 +333,41 @@ static irqreturn_t xen_pcpu_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
/* Sync with Xen hypervisor after cpu hotadded */
void xen_pcpu_hotplug_sync(void)
{
schedule_work(&xen_pcpu_work);
}
EXPORT_SYMBOL_GPL(xen_pcpu_hotplug_sync);
/*
* For hypervisor presented cpu, return logic cpu id;
* For hypervisor non-presented cpu, return -ENODEV.
*/
int xen_pcpu_id(uint32_t acpi_id)
{
int cpu_id = 0, max_id = 0;
struct xen_platform_op op;
op.cmd = XENPF_get_cpuinfo;
while (cpu_id <= max_id) {
op.u.pcpu_info.xen_cpuid = cpu_id;
if (HYPERVISOR_dom0_op(&op)) {
cpu_id++;
continue;
}
if (acpi_id == op.u.pcpu_info.acpi_id)
return cpu_id;
if (op.u.pcpu_info.max_present > max_id)
max_id = op.u.pcpu_info.max_present;
cpu_id++;
}
return -ENODEV;
}
EXPORT_SYMBOL_GPL(xen_pcpu_id);
static int __init xen_pcpu_init(void)
{
int irq, ret;
......
This diff is collapsed.
......@@ -54,6 +54,9 @@ void xen_stub_memory_device_exit(void);
int xen_stub_processor_init(void);
void xen_stub_processor_exit(void);
void xen_pcpu_hotplug_sync(void);
int xen_pcpu_id(uint32_t acpi_id);
int xen_acpi_notify_hypervisor_state(u8 sleep_state,
u32 pm1a_cnt, u32 pm1b_cnd);
......
......@@ -324,6 +324,13 @@ struct xenpf_cpu_ol {
};
DEFINE_GUEST_HANDLE_STRUCT(xenpf_cpu_ol);
#define XENPF_cpu_hotadd 58
struct xenpf_cpu_hotadd {
uint32_t apic_id;
uint32_t acpi_id;
uint32_t pxm;
};
#define XENPF_mem_hotadd 59
struct xenpf_mem_hotadd {
uint64_t spfn;
......@@ -361,6 +368,7 @@ struct xen_platform_op {
struct xenpf_set_processor_pminfo set_pminfo;
struct xenpf_pcpuinfo pcpu_info;
struct xenpf_cpu_ol cpu_ol;
struct xenpf_cpu_hotadd cpu_add;
struct xenpf_mem_hotadd mem_add;
struct xenpf_core_parking core_parking;
uint8_t pad[128];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment