diff --git a/target/i386/nvmm-all.c b/target/i386/nvmm-all.c index a21908f46a..af44a97c2a 100644 --- a/target/i386/nvmm-all.c +++ b/target/i386/nvmm-all.c @@ -26,6 +26,9 @@ #include +//#undef NVMM_USER_VERSION +//#define NVMM_USER_VERSION 1 + struct qemu_vcpu { struct nvmm_vcpu vcpu; uint8_t tpr; @@ -63,6 +66,18 @@ get_nvmm_mach(void) /* -------------------------------------------------------------------------- */ +#if NVMM_USER_VERSION >= 2 +static void nvmm_cpu_kick_self(void) +{ + struct qemu_vcpu *qcpu = get_qemu_vcpu(current_cpu); + struct nvmm_vcpu *vcpu = &qcpu->vcpu; + + nvmm_vcpu_stop(vcpu); +} +#endif + +/* -------------------------------------------------------------------------- */ + static void nvmm_set_segment(struct nvmm_x64_state_seg *nseg, const SegmentCache *qseg) { @@ -749,7 +764,11 @@ nvmm_vcpu_loop(CPUState *cpu) nvmm_vcpu_pre_run(cpu); if (atomic_read(&cpu->exit_request)) { +#if NVMM_USER_VERSION >= 2 + nvmm_cpu_kick_self(); +#else qemu_cpu_kick_self(); +#endif } ret = nvmm_vcpu_run(mach, vcpu); @@ -764,6 +783,11 @@ nvmm_vcpu_loop(CPUState *cpu) switch (exit->reason) { case NVMM_VCPU_EXIT_NONE: break; +#if NVMM_USER_VERSION >= 2 + case NVMM_VCPU_EXIT_STOPPED: + qcpu->stop = true; + break; +#endif case NVMM_VCPU_EXIT_MEMORY: ret = nvmm_handle_mem(mach, vcpu); break; @@ -871,11 +895,13 @@ static Error *nvmm_migration_blocker; static void nvmm_ipi_signal(int sigcpu) { - struct qemu_vcpu *qcpu; - if (current_cpu) { - qcpu = get_qemu_vcpu(current_cpu); +#if NVMM_USER_VERSION >= 2 + nvmm_cpu_kick_self(); +#else + struct qemu_vcpu *qcpu = get_qemu_vcpu(current_cpu); qcpu->stop = true; +#endif } } @@ -1171,7 +1197,7 @@ nvmm_accel_init(MachineState *ms) error_report("NVMM: Unable to fetch capability, error=%d", errno); return -err; } - if (qemu_mach.cap.version != 1) { + if (qemu_mach.cap.version != NVMM_KERN_VERSION) { error_report("NVMM: Unsupported version %u", qemu_mach.cap.version); return -EPROGMISMATCH; }