diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-12-17 18:53:36 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-12-17 18:53:36 +0000 |
| commit | 75ee62ac606bfc9eb59310b9446df3434bf6e8c2 (patch) | |
| tree | d805ddd0a70555b50d6fbcfe57750618bb3c4271 /target/i386/kvm/hyperv.c | |
| parent | af3f37319cb1e1ca0c42842ecdbd1bcfc64a4b6f (diff) | |
| parent | 9fb75013d864489a91ba05e6009ed79c250d4064 (diff) | |
| download | focaccia-qemu-75ee62ac606bfc9eb59310b9446df3434bf6e8c2.tar.gz focaccia-qemu-75ee62ac606bfc9eb59310b9446df3434bf6e8c2.zip | |
Merge remote-tracking branch 'remotes/ehabkost-gl/tags/x86-next-pull-request' into staging
x86 queue, 2020-12-17
Features:
* AVX512_FP16 feature (Cathy Zhang)
Cleanups:
* accel code cleanup (Claudio Fontana)
* hyperv initialization cleanup (Vitaly Kuznetsov)
# gpg: Signature made Thu 17 Dec 2020 18:44:45 GMT
# gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6
# gpg: issuer "ehabkost@redhat.com"
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full]
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost-gl/tags/x86-next-pull-request:
cpu: Remove unnecessary noop methods
tcg: Make CPUClass.debug_excp_handler optional
tcg: make CPUClass.cpu_exec_* optional
tcg: cpu_exec_{enter,exit} helpers
i386: tcg: remove inline from cpu_load_eflags
i386: move TCG cpu class initialization to tcg/
x86/cpu: Add AVX512_FP16 cpu feature
i386: move hyperv_limits initialization to x86_cpu_realizefn()
i386: move hyperv_version_id initialization to x86_cpu_realizefn()
i386: move hyperv_interface_id initialization to x86_cpu_realizefn()
i386: move hyperv_vendor_id initialization to x86_cpu_realizefn()
i386: move cpu dump out of helper.c into cpu-dump.c
i386: move TCG accel files into tcg/
i386: hvf: remove stale MAINTAINERS entry for old hvf stubs
i386: move hax accel files into hax/
i386: move whpx accel files into whpx/
i386: move kvm accel files into kvm/
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target/i386/kvm/hyperv.c')
| -rw-r--r-- | target/i386/kvm/hyperv.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c new file mode 100644 index 0000000000..26efc1e0e6 --- /dev/null +++ b/target/i386/kvm/hyperv.c @@ -0,0 +1,101 @@ +/* + * QEMU KVM Hyper-V support + * + * Copyright (C) 2015 Andrey Smetanin <asmetanin@virtuozzo.com> + * + * Authors: + * Andrey Smetanin <asmetanin@virtuozzo.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "hyperv.h" +#include "hw/hyperv/hyperv.h" +#include "hyperv-proto.h" + +int hyperv_x86_synic_add(X86CPU *cpu) +{ + hyperv_synic_add(CPU(cpu)); + return 0; +} + +void hyperv_x86_synic_reset(X86CPU *cpu) +{ + hyperv_synic_reset(CPU(cpu)); +} + +void hyperv_x86_synic_update(X86CPU *cpu) +{ + CPUX86State *env = &cpu->env; + bool enable = env->msr_hv_synic_control & HV_SYNIC_ENABLE; + hwaddr msg_page_addr = (env->msr_hv_synic_msg_page & HV_SIMP_ENABLE) ? + (env->msr_hv_synic_msg_page & TARGET_PAGE_MASK) : 0; + hwaddr event_page_addr = (env->msr_hv_synic_evt_page & HV_SIEFP_ENABLE) ? + (env->msr_hv_synic_evt_page & TARGET_PAGE_MASK) : 0; + hyperv_synic_update(CPU(cpu), enable, msg_page_addr, event_page_addr); +} + +static void async_synic_update(CPUState *cs, run_on_cpu_data data) +{ + qemu_mutex_lock_iothread(); + hyperv_x86_synic_update(X86_CPU(cs)); + qemu_mutex_unlock_iothread(); +} + +int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) +{ + CPUX86State *env = &cpu->env; + + switch (exit->type) { + case KVM_EXIT_HYPERV_SYNIC: + if (!hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC)) { + return -1; + } + + switch (exit->u.synic.msr) { + case HV_X64_MSR_SCONTROL: + env->msr_hv_synic_control = exit->u.synic.control; + break; + case HV_X64_MSR_SIMP: + env->msr_hv_synic_msg_page = exit->u.synic.msg_page; + break; + case HV_X64_MSR_SIEFP: + env->msr_hv_synic_evt_page = exit->u.synic.evt_page; + break; + default: + return -1; + } + + /* + * this will run in this cpu thread before it returns to KVM, but in a + * safe environment (i.e. when all cpus are quiescent) -- this is + * necessary because memory hierarchy is being changed + */ + async_safe_run_on_cpu(CPU(cpu), async_synic_update, RUN_ON_CPU_NULL); + + return 0; + case KVM_EXIT_HYPERV_HCALL: { + uint16_t code = exit->u.hcall.input & 0xffff; + bool fast = exit->u.hcall.input & HV_HYPERCALL_FAST; + uint64_t param = exit->u.hcall.params[0]; + + switch (code) { + case HV_POST_MESSAGE: + exit->u.hcall.result = hyperv_hcall_post_message(param, fast); + break; + case HV_SIGNAL_EVENT: + exit->u.hcall.result = hyperv_hcall_signal_event(param, fast); + break; + default: + exit->u.hcall.result = HV_STATUS_INVALID_HYPERCALL_CODE; + } + return 0; + } + default: + return -1; + } +} |