kvm: Create kvm_arch_vcpu_id() function
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 6/37 kvm: Create kvm_arch_vcpu_id() function
From: Eduardo Habkost <[email protected]>
This will allow each architecture to define how the VCPU ID is set on the KVM_CREATE_VCPU ioctl call.
--- include/sysemu/kvm.h | 3 +++ kvm-all.c | 2 +- target-i386/kvm.c | 5 +++++ target-ppc/kvm.c | 5 +++++ target-s390x/kvm.c | 5 +++++
5 Dateien geändert, 19 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
include/sysemu/kvm.h +3 -0
@@ -196,6 +196,9 @@ int kvm_arch_init(KVMState *s);int kvm_arch_init_vcpu (CPUState *cpu); +/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */ +unsigned long kvm_arch_vcpu_id (CPUState *cpu); +void kvm_arch_reset_vcpu (CPUState *cpu);int kvm_arch_on_sigbus_vcpu (CPUState *cpu,int code,void *addr);
kvm-all.c +1 -1
@@ -222,7 +222,7 @@ int kvm_init_vcpu(CPUState *cpu)DPRINTF ("kvm_init_vcpu\n" ); - ret =kvm_vm_ioctl (s,KVM_CREATE_VCPU , cpu->cpu_index); + ret =kvm_vm_ioctl (s,KVM_CREATE_VCPU , (void *)kvm_arch_vcpu_id (cpu));if (ret <0 ) {DPRINTF ("kvm_create_vcpu failed\n" ); goto err;
target-i386/kvm.c +5 -0
@@ -411,6 +411,11 @@ static void cpu_update_state(void *opaque, int running, RunState state) } } +unsigned long kvm_arch_vcpu_id (CPUState *cpu) +{ +return cpu->cpu_index; +} +int kvm_arch_init_vcpu (CPUState *cs) {struct {
target-ppc/kvm.c +5 -0
@@ -384,6 +384,11 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu)#endif /* !defined (TARGET_PPC64) */ +unsigned long kvm_arch_vcpu_id (CPUState *cpu) +{ +return cpu->cpu_index; +} +int kvm_arch_init_vcpu (CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);
target-s390x/kvm.c +5 -0
@@ -76,6 +76,11 @@ int kvm_arch_init(KVMState *s)return 0 ; } +unsigned long kvm_arch_vcpu_id (CPUState *cpu) +{ +return cpu->cpu_index; +} +int kvm_arch_init_vcpu (CPUState *cpu) {int ret =0 ;
Signature · 1 line
1.7.10.4
PATCH 7/37 target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
In reply to a message not in the archiveFrom: Eduardo Habkost <[email protected]>
The CPU ID in KVM is supposed to be the APIC ID, so change the KVM_CREATE_VCPU call to match it. The current behavior didn't break anything yet because today the APIC ID is assumed to be equal to the CPU index, but this won't be true in the future.
--- target-i386/kvm.c | 5 +++--
1 Datei geändert, 3 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
target-i386/kvm.c +3 -2
@@ -411,9 +411,10 @@ static void cpu_update_state(void *opaque, int running, RunState state) } } -unsigned long kvm_arch_vcpu_id (CPUState *cpu) +unsigned long kvm_arch_vcpu_id (CPUState *cs) { -return cpu->cpu_index; +X86CPU *cpu =X86_CPU (cs); +return cpu->env.cpuid_apic_id; }int kvm_arch_init_vcpu (CPUState *cs)
Signature · 1 line
1.7.10.4
PATCH 37/37 kvm: Pass CPUState to kvm_on_sigbus_vcpu()
In reply to a message not in the archiveSince commit 20d695a9254c1b086a456d3b79a3c311236643ba (kvm: Pass CPUState to kvm_arch_*) CPUArchState is no longer needed.
Allows to change qemu_kvm_eat_signals() argument as well.
--- cpus.c | 8 ++++---- include/sysemu/kvm.h | 2 +- kvm-all.c | 3 +-- kvm-stub.c | 2 +-
4 Dateien geändert, 7 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)
cpus.c +4 -4
@@ -517,7 +517,7 @@ static void qemu_init_sigbus(void)prctl (PR_MCE_KILL ,PR_MCE_KILL_SET ,PR_MCE_KILL_EARLY ,0 ,0 ); } -static void qemu_kvm_eat_signals (CPUArchState *env) +static void qemu_kvm_eat_signals (CPUState *cpu) {struct timespec ts = {0 ,0 };siginfo_t siginfo;
@@ -538,7 +538,7 @@ static void qemu_kvm_eat_signals(CPUArchState *env)switch (r) {case SIGBUS : -if (kvm_on_sigbus_vcpu (env, siginfo.si_code, siginfo.si_addr)) { +if (kvm_on_sigbus_vcpu (cpu, siginfo.si_code, siginfo.si_addr)) {sigbus_reraise (); }break ;
@@ -560,7 +560,7 @@ static void qemu_init_sigbus(void) { } -static void qemu_kvm_eat_signals (CPUArchState *env) +static void qemu_kvm_eat_signals (CPUState *cpu) { }#endif /* !CONFIG_LINUX */
@@ -727,7 +727,7 @@ static void qemu_kvm_wait_io_event(CPUArchState *env)qemu_cond_wait (cpu->halt_cond, &qemu_global_mutex); } -qemu_kvm_eat_signals (env); +qemu_kvm_eat_signals (cpu);qemu_wait_io_event_common (cpu); }
include/sysemu/kvm.h +1 -1
@@ -159,7 +159,7 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap);int kvm_set_signal_mask (CPUArchState *env,const sigset_t *sigset);#endif -int kvm_on_sigbus_vcpu (CPUArchState *env,int code,void *addr); +int kvm_on_sigbus_vcpu (CPUState *cpu,int code,void *addr);int kvm_on_sigbus (int code,void *addr);/* internal API */
kvm-all.c +1 -2
@@ -2026,9 +2026,8 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign)return 0 ; } -int kvm_on_sigbus_vcpu (CPUArchState *env,int code,void *addr) +int kvm_on_sigbus_vcpu (CPUState *cpu,int code,void *addr) { -CPUState *cpu =ENV_GET_CPU (env);return kvm_arch_on_sigbus_vcpu (cpu, code, addr); }
kvm-stub.c +1 -1
@@ -112,7 +112,7 @@ int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign, uintreturn -ENOSYS ; } -int kvm_on_sigbus_vcpu (CPUArchState *env,int code,void *addr) +int kvm_on_sigbus_vcpu (CPUState *cpu,int code,void *addr) {return 1 ; }
Signature · 1 line
1.7.10.4