coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
v2 cover coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
v2:
1.remove PIIX4_PROC_BASE operations for cpu hotplug 2.fix wrong description fo cpu-del
patch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"
EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute _Qxx method which defined
by yourself and query EC's ACPI space which can be a buffer for many purposes
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 > /sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug -- linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplugqemu::ec::sci -> kernel::ec::gpe::notifier-> kernel::cpu_physic_hotplug::handler->kernel::cpu_up
unplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460
Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for _Qxx events
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplug
default-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
RFC PATCH v2 1/8 acpi: add ACPI Embedded Controller support
this work implemented Embedded Controller chip emulation which was defined at ACPI SEPC v5 chapter 12:
"ACPI Embedded Controller Interface Specification"
commonly Embedded Controller will emulate keyboard, mouse, handle ACPI defined operations and some low-speed devices like SMbus.
--- default-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 193 ++++++++++++++++++++++++++++++++++++ include/hw/acpi/ec.h | 29 ++++++ 4 files changed, 224 insertions(+), 0 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
default-configs/x86_64-softmmu.mak +1 -0
@@ -46,3 +46,4 @@ CONFIG_APIC=y CONFIG_IOAPIC=y CONFIG_ICC_BUS=y CONFIG_PVPANIC=y +CONFIG_ACPI_EC=y
hw/acpi/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o +common-obj-$(CONFIG_ACPI_EC) += ec.o
hw/acpi/ec.c new file +193 -0
193 lines not on this page · raw message
include/hw/acpi/ec.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef __EC_H +#define __EC_H + +#include "hw/i386/pc.h" +#include "qemu/notify.h" + +#define EC_ACPI_SPACE_SIZE 0x80 + +#define EC_ACPI_CMD_PORT 0x66 +#define EC_ACPI_DATA_PORT 0x62 + +#define EC_ACPI_OBF 0x1 +#define EC_ACPI_IBF 0x2 +#define EC_ACPI_CMD 0x8 +#define EC_ACPI_BST 0x10 +#define EC_ACPI_SCI 0x20 + +#define EC_ACPI_CMD_READ 0x80 +#define EC_ACPI_CMD_WRITE 0x81 +#define EC_ACPI_BURST_EN 0x82 +#define EC_ACPI_BURST_DN 0x83 +#define EC_ACPI_CMD_QUERY 0x84 + +void qemu_register_ec_sci_notifier (Notifier *notifier); +bool qemu_ec_enabled (void ); +void ec_dev_init (ISABus *isabus); +void ec_acpi_event (uint8_t evt); + +#endif
Signature · 1 line
1.7.2.5
RFC PATCH v2 2/8 ich9: add notifer for ec to generate sci
In reply to liguang--- hw/acpi/ich9.c | 15 +++++++++++++++ include/hw/acpi/ich9.h | 1 + 2 files changed, 16 insertions(+), 0 deletions(-)
hw/acpi/ich9.c +15 -0
@@ -33,6 +33,7 @@#include "exec/address-spaces.h" #include "hw/i386/ich9.h" +#include "hw/acpi/ec.h" //#define DEBUG
@@ -43,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif +#define GPE_EC_SCI_STATUS 8 +static void pm_update_sci (ICH9LPCPMRegs *pm) {int sci_level, pm1a_sts;
@@ -202,6 +205,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)acpi_pm1_evt_power_down (&pm->acpi_regs); } +static void pm_ec_sci_req (Notifier *n,void *opaque) +{ +ICH9LPCPMRegs *pm =container_of (n, ICH9LPCPMRegs, ec_sci_notifier); +ACPIGPE *gpe = &pm->acpi_regs.gpe; + + *gpe->sts |=GPE_EC_SCI_STATUS ; +pm_update_sci (pm); +} +void ich9_pm_init (PCIDevice *lpc_pci,ICH9LPCPMRegs *pm,qemu_irq sci_irq) {
@@ -227,4 +239,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,qemu_register_reset (pm_reset, pm); pm->powerdown_notifier.notify = pm_powerdown_req;qemu_register_powerdown_notifier (&pm->powerdown_notifier); + + pm->ec_sci_notifier.notify = pm_ec_sci_req; +qemu_register_ec_sci_notifier (&pm->ec_sci_notifier); }
include/hw/acpi/ich9.h +1 -0
@@ -42,6 +42,7 @@ typedef struct ICH9LPCPMRegs {uint32_t pm_io_base;Notifier powerdown_notifier; +Notifier ec_sci_notifier; } ICH9LPCPMRegs; void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
Signature · 1 line
1.7.2.5
RFC PATCH v2 3/8 ec: add operations for _Qxx events
In reply to liguang--- hw/acpi/ec.c | 32 ++++++++++++++++++++++++++++---- include/hw/acpi/ec.h | 10 ++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-)
hw/acpi/ec.c +28 -4
@@ -22,6 +22,9 @@ typedef struct ECState {MemoryRegion io[2 ]; } ECState; +static void ec_generate_sci (ECState *); +static ECState *ecs; +static NotifierList ec_sci_notifiers =NOTIFIER_LIST_INITIALIZER (ec_sci_notifiers);void qemu_register_ec_sci_notifier (Notifier *notifier)
@@ -44,8 +47,26 @@ void ec_acpi_event(uint8_t evt) sci_event = evt; } -static void ec_generate_sci (void ) +void ec_acpi_space_poke (uint8_t idx,uint8_t val) +{ +if (idx <EC_ACPI_SPACE_SIZE ) { + ec_acpi_space[idx] = val; +ec_generate_sci (ecs); + } +} + +uint8_t ec_acpi_space_peek (uint8_t idx) { +if (idx <EC_ACPI_SPACE_SIZE ) { +return ec_acpi_space[idx]; + }else { +return 0 ; + } +} + +static void ec_generate_sci (ECState *s) +{ + s->status |=EC_ACPI_SCI ;notifier_list_notify (&ec_sci_notifiers,NULL ); }
@@ -72,12 +93,11 @@ static void acpi_data_write(void *opaque, hwaddr addr, uint64_t val, }break ;case EC_ACPI_CMD_QUERY : - s->data = sci_event;default :break ; } } -ec_generate_sci (); +ec_generate_sci (s); }static uint64_t acpi_data_read (void *opaque,hwaddr addr,unsigned size)
@@ -112,13 +132,15 @@ static void acpi_cmd_write(void *opaque, hwaddr addr, uint64_t val, is_cmd = true;break ;case EC_ACPI_CMD_QUERY : + s->data = sci_event; + s->status |=EC_ACPI_OBF ; is_cmd = true;default :break ; }if (is_cmd) { s->cmd = val &0xff ; -ec_generate_sci (); +ec_generate_sci (s); s->status |=EC_ACPI_SCI ; }else { s->cmd =0 ;
@@ -165,6 +187,8 @@ static int ec_dev_initfn(ISADevice *dev)memory_region_init_io (s->io +1 , &io66_io_ops, s,"ec-acpi-cmd" ,1 );isa_register_ioport (isadev, s->io +1 ,0x66 ); + ecs = s; +return 0 ; }
include/hw/acpi/ec.h +10 -0
@@ -21,9 +21,19 @@#define EC_ACPI_BURST_DN 0x83#define EC_ACPI_CMD_QUERY 0x84 +/* event no. */ +#define EVENT_CPU_ONLINE 0x1 +#define EVENT_CPU_OFFLINE 0x2 + +/* index of acpi space*/ +#define EC_ACPI_SPACE_CPUS 1 +#define EC_ACPI_SPACE_CPUN 2 +void qemu_register_ec_sci_notifier (Notifier *notifier);bool qemu_ec_enabled (void );void ec_dev_init (ISABus *isabus);void ec_acpi_event (uint8_t evt); +void ec_acpi_space_poke (uint8_t idx,uint8_t val); +uint8_t ec_acpi_space_peek (uint8_t idx);#endif
Signature · 1 line
1.7.2.5
RFC PATCH v2 4/8 piix4: add notifer for ec to generate sci
In reply to liguang--- hw/acpi/piix4.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
hw/acpi/piix4.c +14 -0
@@ -29,6 +29,7 @@#include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" +#include "hw/acpi/ec.h" //#define DEBUG
@@ -53,6 +54,7 @@#define PIIX4_PCI_HOTPLUG_STATUS 2#define PIIX4_CPU_HOTPLUG_STATUS 4 +#define GPE_EC_SCI_STATUS 8struct pci_status {uint32_t up;/* deprecated, maintained for migration compatibility */
@@ -94,6 +96,7 @@ typedef struct PIIX4PMState {CPUStatus gpe_cpu;Notifier cpu_added_notifier; +Notifier ec_sci_notifier; } PIIX4PMState; static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
@@ -622,6 +625,15 @@ static const MemoryRegionOps cpu_hotplug_ops = { }, }; +static void pm_ec_sci_req (Notifier *n,void *opaque) +{ +PIIX4PMState *s =container_of (n, PIIX4PMState, ec_sci_notifier); +ACPIGPE *gpe = &s->ar.gpe; + + *gpe->sts |=GPE_EC_SCI_STATUS ; +pm_update_sci (s); +} + typedef enum { PLUG, UNPLUG,
@@ -686,6 +698,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,memory_region_add_subregion (parent,PIIX4_PROC_BASE , &s->io_cpu); s->cpu_added_notifier.notify = piix4_cpu_added_req;qemu_register_cpu_added_notifier (&s->cpu_added_notifier); + s->ec_sci_notifier.notify = pm_ec_sci_req; +qemu_register_ec_sci_notifier (&s->ec_sci_notifier); }static void enable_device (PIIX4PMState *s,int slot)
Signature · 1 line
1.7.2.5
RFC PATCH v2 5/8 piix4: add events for cpu hotplug
In reply to liguang--- hw/acpi/piix4.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
hw/acpi/piix4.c +8 -0
@@ -657,6 +657,14 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, g->sts[cpu_id /8 ] &= ~(1 << (cpu_id %8 )); }pm_update_sci (s); + +if (qemu_ec_enabled ()) { +uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUS ); + +ec_acpi_event (EVENT_CPU_ONLINE ); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUS ,1 << cpu_id | cpu_sts); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUN , cpu_id); + } }static void piix4_cpu_added_req (Notifier *n,void *opaque)
Signature · 1 line
1.7.2.5
RFC PATCH v2 6/8 qmp: add 'cpu-del' command
In reply to liguangadd 'cpu-del' as complementary of 'cpu-add', cpu-del doesn't really delete a previous created cpu for it depends on CPU-QOM which it's un-finished yet to unrealize it.
cpu-del just records the cpu-id that guest want to remove to keep status of ACPI cpu hot-remove process.
--- hw/i386/pc.c | 30 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 8 files changed, 79 insertions(+), 4 deletions(-)
hw/i386/pc.c +28 -2
@@ -55,6 +55,7 @@#include "hw/acpi/acpi.h" #include "hw/cpu/icc_bus.h" #include "hw/boards.h" +#include "hw/acpi/ec.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ
@@ -926,10 +927,15 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) {DeviceState *icc_bridge;int64_t apic_id =x86_cpu_apic_id_from_index (id); +uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUS );if (cpu_exists (apic_id)) { -error_setg (errp,"Unable to add CPU: %" PRIi64 -", it already exists" , id); +if (cpu_sts &1 << id) { +error_setg (errp,"Unable to add CPU: %" PRIi64 +", it already exists" , id); + }else { +ec_acpi_space_poke (EC_ACPI_SPACE_CPUS , cpu_sts |1 << id); + }return ; }
@@ -939,11 +945,31 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)return ; } +ec_acpi_space_poke (EC_ACPI_SPACE_CPUS , cpu_sts |1 << id); icc_bridge =DEVICE (object_resolve_path_type ("icc-bridge" ,TYPE_ICC_BRIDGE ,NULL ));pc_new_cpu (current_cpu_model, apic_id, icc_bridge, errp); } +void pc_hot_del_cpu (const int64_t id,Error **errp) +{ +uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUS ); + +if (id >= max_cpus) { +error_setg (errp,"Unable to del CPU: %" PRIi64 +", max allowed: %d" , id, max_cpus -1 ); +return ; + } + +if (cpu_sts &1 << id) { +ec_acpi_space_poke (EC_ACPI_SPACE_CPUS , cpu_sts & ~(1 << id)); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUN , id); + }else { +error_setg (errp,"Unable to del CPU: %" PRIi64 +", it was not added before." , id); + } +} +void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge) {int i;
hw/i386/pc_piix.c +1 -0
@@ -333,6 +333,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = { .desc = "Standard PC (i440FX + PIIX, 1996)", .init = pc_init_pci, .hot_add_cpu = pc_hot_add_cpu, + .hot_del_cpu = pc_hot_del_cpu, .max_cpus = 255, .is_default =1 , DEFAULT_MACHINE_OPTIONS,
hw/i386/pc_q35.c +1 -0
@@ -221,6 +221,7 @@ static QEMUMachine pc_q35_machine_v1_5 = { .desc = "Standard PC (Q35 + ICH9, 2009)", .init = pc_q35_init, .hot_add_cpu = pc_hot_add_cpu, + .hot_del_cpu = pc_hot_del_cpu, .max_cpus = 255, DEFAULT_MACHINE_OPTIONS, };
include/hw/boards.h +3 -2
@@ -22,7 +22,7 @@ typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args);typedef void QEMUMachineResetFunc (void ); -typedef void QEMUMachineHotAddCPUFunc (const int64_t id,Error **errp); +typedef void QEMUMachineHotAddDelCPUFunc (const int64_t id,Error **errp); typedef struct QEMUMachine { const char *name;
@@ -30,7 +30,8 @@ typedef struct QEMUMachine {const char *desc;QEMUMachineInitFunc *init;QEMUMachineResetFunc *reset; -QEMUMachineHotAddCPUFunc *hot_add_cpu; +QEMUMachineHotAddDelCPUFunc *hot_add_cpu; +QEMUMachineHotAddDelCPUFunc *hot_del_cpu;BlockInterfaceType block_default_type;int max_cpus; unsigned int no_serial:1,
include/hw/i386/pc.h +1 -0
@@ -82,6 +82,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level);void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge);void pc_hot_add_cpu (const int64_t id,Error **errp); +void pc_hot_del_cpu (const int64_t id,Error **errp);void pc_acpi_init (const char *default_dsdt); FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename,
qapi-schema.json +13 -0
@@ -1403,6 +1403,19 @@ { 'command': 'cpu-add', 'data': {'id': 'int'} } ## +# @cpu-del +# +# Deletes CPU with specified ID +# +# @id: ID of CPU to be deleted, valid values [0..max_cpus) +# +# Returns: Nothing on success +# +# Since 1.6 +## +{ 'command': 'cpu-del', 'data': {'id': 'int'} } + +## # @memsave: # # Save a portion of guest memory to a file.
qmp-commands.hx +23 -0
@@ -408,6 +408,29 @@ Example: EQMP { + .name = "cpu-del", + .args_type = "id:i", + .mhandler.cmd_new = qmp_marshal_input_cpu_del, + }, + +SQMP +cpu-del +------- + +Deletes virtual cpu + +Arguments: + +- "id": cpu id (json-int) + +Example: + +-> { "execute": "cpu-del", "arguments": { "id": 2 } } +<- { "return": {} } + +EQMP + + { .name = "memsave", .args_type = "val:l,size:i,filename:s,cpu:i?", .mhandler.cmd_new = qmp_marshal_input_memsave,
qmp.c +9 -0
@@ -118,6 +118,15 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +void qmp_cpu_del (int64_t id,Error **errp) +{ +if (current_machine->hot_del_cpu) { + current_machine->hot_del_cpu (id, errp); + }else { +error_setg (errp,"Not supported" ); + } +} +#ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */
Signature · 1 line
1.7.2.5
RFC PATCH v2 7/8 pc: add EC qdev init for piix & q35
In reply to liguang--- hw/i386/pc_piix.c | 6 ++++++ hw/i386/pc_q35.c | 5 +++++ 2 files changed, 11 insertions(+), 0 deletions(-)
hw/i386/pc_piix.c +6 -0
@@ -46,6 +46,8 @@#include "exec/address-spaces.h" #include "hw/acpi/acpi.h" #include "cpu.h" +#include "hw/acpi/ec.h" +#ifdef CONFIG_XEN # include <xen/hvm/hvm_info_table.h> #endif
@@ -229,6 +231,10 @@ static void pc_init1(MemoryRegion *system_memory,if (has_pvpanic) {pvpanic_init (isa_bus); } + +if (qemu_ec_enabled ()) { +ec_dev_init (isa_bus); + } }static void pc_init_pci (QEMUMachineInitArgs *args)
hw/i386/pc_q35.c +5 -0
@@ -42,6 +42,7 @@#include "hw/ide/ahci.h" #include "hw/usb.h" #include "hw/cpu/icc_bus.h" +#include "hw/acpi/ec.h" /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6
@@ -206,6 +207,10 @@ static void pc_q35_init(QEMUMachineInitArgs *args)if (has_pvpanic) {pvpanic_init (isa_bus); } + +if (qemu_ec_enabled ()) { +ec_dev_init (isa_bus); + } }static void pc_q35_init_1_4 (QEMUMachineInitArgs *args)
Signature · 1 line
1.7.2.5
RFC PATCH v2 8/8 cpu-hotplug: remove memory regison for cpu hotplug
In reply to liguangoperations of memory regison(PIIX4_PROC_BASE) for cpu hostplug can be transfered to EC space naturally by adding EC support.
--- hw/acpi/piix4.c | 46 ++++++++++------------------------------------ hw/i386/pc.c | 16 ++++++++-------- include/hw/acpi/ec.h | 5 +++-- 3 files changed, 21 insertions(+), 46 deletions(-)
hw/acpi/piix4.c +10 -36
@@ -600,31 +600,6 @@ static const MemoryRegionOps piix4_pci_ops = { }, }; -static uint64_t cpu_status_read (void *opaque,hwaddr addr,unsigned int size) -{ -PIIX4PMState *s = opaque; -CPUStatus *cpus = &s->gpe_cpu; -uint64_t val = cpus->sts[addr]; - -return val; -} - -static void cpu_status_write (void *opaque,hwaddr addr,uint64_t data, -unsigned int size) -{ -/* TODO: implement VCPU removal on guest signal that CPU can be removed */ -} - -static const MemoryRegionOps cpu_hotplug_ops = { - .read = cpu_status_read, - .write = cpu_status_write, - .endianness =DEVICE_LITTLE_ENDIAN , - .valid = { - .min_access_size =1 , - .max_access_size =1 , - }, -}; -static void pm_ec_sci_req (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, ec_sci_notifier);
@@ -653,18 +628,20 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, cpu_id = k->get_arch_id (CPU (cpu));if (action ==PLUG ) { g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUM + cpu_id/8 ,1 << (cpu_id%8 )); +if (qemu_ec_enabled ()) { +ec_acpi_event (EVENT_CPU_ONLINE ); + } }else { g->sts[cpu_id /8 ] &= ~(1 << (cpu_id %8 )); +if (qemu_ec_enabled ()) { +uint8_t tmp; + tmp =ec_acpi_space_peek (EC_ACPI_SPACE_CPUM + cpu_id/8 ); + tmp &= ~(1 << (cpu_id%8 )); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUM + cpu_id/8 , tmp); + } }pm_update_sci (s); - -if (qemu_ec_enabled ()) { -uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUS ); - -ec_acpi_event (EVENT_CPU_ONLINE ); -ec_acpi_space_poke (EC_ACPI_SPACE_CPUS ,1 << cpu_id | cpu_sts); -ec_acpi_space_poke (EC_ACPI_SPACE_CPUN , cpu_id); - } }static void piix4_cpu_added_req (Notifier *n,void *opaque)
@@ -701,9 +678,6 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,pci_bus_hotplug (bus, piix4_device_hotplug, &s->dev.qdev);qemu_for_each_cpu (piix4_init_cpu_status, &s->gpe_cpu); -memory_region_init_io (&s->io_cpu, &cpu_hotplug_ops, s,"apci-cpu-hotplug" , -PIIX4_PROC_LEN ); -memory_region_add_subregion (parent,PIIX4_PROC_BASE , &s->io_cpu); s->cpu_added_notifier.notify = piix4_cpu_added_req;qemu_register_cpu_added_notifier (&s->cpu_added_notifier); s->ec_sci_notifier.notify = pm_ec_sci_req;
hw/i386/pc.c +8 -8
@@ -927,14 +927,14 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) {DeviceState *icc_bridge;int64_t apic_id =x86_cpu_apic_id_from_index (id); -uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUS ); +uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUM + apic_id/8 );if (cpu_exists (apic_id)) { -if (cpu_sts &1 << id) { +if (cpu_sts &1 << id%8 ) {error_setg (errp,"Unable to add CPU: %" PRIi64", it already exists" , id); }else { -ec_acpi_space_poke (EC_ACPI_SPACE_CPUS , cpu_sts |1 << id); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUM , cpu_sts |1 << id%8 ); }return ; }
@@ -945,7 +945,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)return ; } -ec_acpi_space_poke (EC_ACPI_SPACE_CPUS , cpu_sts |1 << id); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUM , cpu_sts |1 << id%8 ); icc_bridge =DEVICE (object_resolve_path_type ("icc-bridge" ,TYPE_ICC_BRIDGE ,NULL ));pc_new_cpu (current_cpu_model, apic_id, icc_bridge, errp);
@@ -953,7 +953,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)void pc_hot_del_cpu (const int64_t id,Error **errp) { -uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUS ); +uint8_t cpu_sts =ec_acpi_space_peek (EC_ACPI_SPACE_CPUM + id/8 );if (id >= max_cpus) { error_setg(errp, "Unable to del CPU: %" PRIi64
@@ -961,9 +961,9 @@ void pc_hot_del_cpu(const int64_t id, Error **errp)return ; } -if (cpu_sts &1 << id) { -ec_acpi_space_poke (EC_ACPI_SPACE_CPUS , cpu_sts & ~(1 << id)); -ec_acpi_space_poke (EC_ACPI_SPACE_CPUN , id); +if (cpu_sts &1 << id/8 ) { +ec_acpi_space_poke (EC_ACPI_SPACE_CPUM , cpu_sts & ~(1 << id%8 )); +ec_acpi_space_poke (EC_ACPI_SPACE_CPUI , id); }else {error_setg (errp,"Unable to del CPU: %" PRIi64", it was not added before." , id);
include/hw/acpi/ec.h +3 -2
@@ -26,8 +26,9 @@#define EVENT_CPU_OFFLINE 0x2/* index of acpi space*/ -#define EC_ACPI_SPACE_CPUS 1 -#define EC_ACPI_SPACE_CPUN 2 +#define EC_ACPI_SPACE_CCMD 2 +#define EC_ACPI_SPACE_CPUI 3 +#define EC_ACPI_SPACE_CPUM 4void qemu_register_ec_sci_notifier (Notifier *notifier);bool qemu_ec_enabled (void );
Signature · 1 line
1.7.2.5
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposes
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.
So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?
Quoted 51 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
Quoted 16 lines · 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposes
Quoted 8 lines
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?
Sorry, I'm not familiar with qemu-ga,
anyway, maybe we don't want to do things like 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")' in userspace.
BTW, Michael,
do you think if we use EC space to pass info between platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and something like it can bring some convenience?
for we can directly operate on EC space, we don't have to register memory regions and ops for them any more, and also, these regions are mostly not exist in real platforms, this a motivation that I add this device.
Quoted 52 lines
Quoted 52 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
Hi, Igor and Micheal
Quoted 31 lines · 在 2013-06-06四的 16:33 +0800,li guang写道:
Quoted 16 lines · 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposesQuoted 8 lines
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?Sorry, I'm not familiar with qemu-ga,
anyway, maybe we don't want to do things like 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")' in userspace.
Quoted 9 lines
BTW, Michael,
do you think if we use EC space to pass info between platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and something like it can bring some convenience?
for we can directly operate on EC space, we don't have to register memory regions and ops for them any more, and also, these regions are mostly not exist in real platforms, this a motivation that I add this device.
does this approach have some benefit?
Quoted 55 lines
Quoted 52 lines
Quoted 52 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
Quoted 44 lines · On Tue, 18 Jun 2013 10:47:15 +0800 li guang <[email protected]> wrote:
Hi, Igor and Micheal
Quoted 31 lines · 在 2013-06-06四的 16:33 +0800,li guang写道:
Quoted 16 lines · 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposesQuoted 8 lines
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?Sorry, I'm not familiar with qemu-ga,
anyway, maybe we don't want to do things like 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")' in userspace.Quoted 9 lines
BTW, Michael,
do you think if we use EC space to pass info between platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and something like it can bring some convenience?
for we can directly operate on EC space, we don't have to register memory regions and ops for them any more, and also, these regions are mostly not exist in real platforms, this a motivation that I add this device.
Quoted 1 line
does this approach have some benefit?
Replacing CPUs bitmap with a select window as it's done in this series could be done in PIIX4 in similar manner and would be much simpler than introducing whole new device. That however would require introducing locking in bios's ACPI code to avoid concurrent handler execution which is not needed in case of bitmap.
Quoted 59 lines
Quoted 56 lines
Quoted 53 lines
Quoted 53 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
Signature · 2 lines
Regards, Igor
Quoted 47 lines · 在 2013-06-18二的 11:14 +0200,Igor Mammedov写道:
Quoted 44 lines · On Tue, 18 Jun 2013 10:47:15 +0800 li guang <[email protected]> wrote:
Hi, Igor and Micheal
Quoted 40 lines · 在 2013-06-06四的 16:33 +0800,li guang写道:
Quoted 16 lines · 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposesQuoted 8 lines
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?Sorry, I'm not familiar with qemu-ga,
anyway, maybe we don't want to do things like 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")' in userspace.BTW, Michael,
do you think if we use EC space to pass info between platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and something like it can bring some convenience?
for we can directly operate on EC space, we don't have to register memory regions and ops for them any more, and also, these regions are mostly not exist in real platforms, this a motivation that I add this device.
Quoted 5 lines
Quoted 1 line
does this approach have some benefit?
Replacing CPUs bitmap with a select window as it's done in this series could be done in PIIX4 in similar manner and would be much simpler than introducing whole new device.
Cool! but I can't figure out the way to do that now, could you tell me a little details about this manner?
and also, as I stated before, this device is not only can be used in our cpu hotplug case, it can also be used in many other cases like pvpanic, by it, we can do pvpanic like things without introducing pvpanic like devices, isn't it an important advantage?
Quoted 4 lines
That however would require introducing
locking in bios's ACPI code to avoid concurrent handler execution which is not needed in case of bitmap.
Sorry, did not consider the lock, but for real platform, we also didn't do lock for this operation, so why it's required here?
Quoted 61 lines
Quoted 59 lines
Quoted 56 lines
Quoted 53 lines
Quoted 53 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
Quoted 16 lines · On Thu, 6 Jun 2013 11:13:29 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposes
Quoted 8 lines
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?
I believe it does.
Trying to handle 1 guest OS specific concept by introducing extra hardware and a new new linux driver to just online CPUs, doesn't look righ.
Guest already gets a cpu hot-add notification and acts on it by creating sysfs entry that can be used for onlining it. So guest knows that CPU has been hotplugged and even notifies userspace via UDEV about event. So why extra channel is needed for event that was already delivered and handled.
One can use UDEV to perform automatic online task or qemu-ga to make process less straightforward, or alternatively extend the current ACPI CPU hotplug in kernel to support automatic CPU onlining.
Quoted 53 lines
Quoted 52 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h
Quoted 27 lines · 在 2013-06-06四的 10:48 +0200,Igor Mammedov写道:
Quoted 16 lines · On Thu, 6 Jun 2013 11:13:29 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · liguang
v2:
1.removePIIX4_PROC_BASEoperations for cpu hotplug 2.fix wrong description fo cpu-delpatch 1 adds ACPI Embedded Controller (EC), refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"EC is a standard ACPI device, it plays flexible roles, especially be event carrier, it can pass events between platform and OS, so OS can execute
_Qxxmethod which defined
by yourself and query EC's ACPI space which can be a buffer for many purposesQuoted 8 lines
Quoted 5 lines
here, I want to deliver CPU online/offline event between OS and QEMU for CPU hotplug feature, then we will don't need to "echo 1 >
/sys/devices/system/cpu/cpu1/online" again after 'cpu-add' and also for offline to do real cpu removal.So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?
Quoted 9 lines
I believe it does.
Trying to handle 1 guest OS specific concept by introducing extra hardware and a new new linux driver to just online CPUs, doesn't look righ.
Guest already gets a cpu hot-add notification and acts on it by creating sysfs entry that can be used for onlining it. So guest knows that CPU has been hotplugged and even notifies userspace via UDEV about event. So why extra channel is needed for event that was already delivered and handled.
actually, there's a case in my hand to do cpu online automatically by udev, it works well.
I still can't figure out why kernel did not do cpu online directly just like the cpu ejection.
I don't have strong opinion to do cpu online in kernel space, but I think do it in user-space either by hand or script or program just not natural, that it to say, obviously cpu online is part of cpu hotplug conceptually, we'd better do the these actions together, but separate them.
Quoted 61 lines
One can use UDEV to perform automatic online task or qemu-ga to make process less straightforward, or alternatively extend the current ACPI CPU hotplug in kernel to support automatic CPU onlining.
Quoted 53 lines
Quoted 52 lines
what I am trying to do is emulated physical addition/removal (like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci-> kernel::ec::gpe::notifier->kernel::cpu_physic_hotplug::handler->kernel::cpu_upunplug kernel::cpu_down::kernel::cpu_physic_hotplug::handler-> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel, but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for_Qxxevents
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplugdefault-configs/x86_64-softmmu.mak | 1 + hw/acpi/Makefile.objs | 1 + hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 15 +++++++++++++++ hw/acpi/piix4.c | 68 ++++++++++++++ hw/i386/pc.c | 46 ++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 7 + hw/i386/pc_q35.c | 6 + include/hw/acpi/ec.h | 44 ++++++ include/hw/acpi/ich9.h | 1 + include/hw/boards.h | 5 +++-- include/hw/i386/pc.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 15 files changed, 411 insertions(+), 54 deletions(-) create mode 100644 hw/acpi/ec.c create mode 100644 include/hw/acpi/ec.h