From 9dc83cd9c3cd766263a7180bccaf67afe970d816 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 24 Jun 2019 21:39:13 +0200 Subject: i386/kvm: Fix build with -m32 find_next_bit() takes a pointer of type "const unsigned long *", but the first argument passed here is a "uint64_t *". These types are incompatible when compiling qemu with -m32. Just use ctz64() instead. Fixes: c686193072a47032d83cb4e131dc49ae30f9e5d Signed-off-by: Max Reitz Reviewed-by: Eduardo Habkost Message-Id: <20190624193913.28343-1-mreitz@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'target/i386') diff --git a/target/i386/kvm.c b/target/i386/kvm.c index e4b4f5756a..31490bf8b5 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1043,14 +1043,15 @@ static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid, CPUX86State *env = &cpu->env; uint32_t r, fw, bits; uint64_t deps; - int i, dep_feat = 0; + int i, dep_feat; if (!hyperv_feat_enabled(cpu, feature) && !cpu->hyperv_passthrough) { return 0; } deps = kvm_hyperv_properties[feature].dependencies; - while ((dep_feat = find_next_bit(&deps, 64, dep_feat)) < 64) { + while (deps) { + dep_feat = ctz64(deps); if (!(hyperv_feat_enabled(cpu, dep_feat))) { fprintf(stderr, "Hyper-V %s requires Hyper-V %s\n", @@ -1058,7 +1059,7 @@ static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid, kvm_hyperv_properties[dep_feat].desc); return 1; } - dep_feat++; + deps &= ~(1ull << dep_feat); } for (i = 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i++) { -- cgit v1.2.3 From 4b03403f7684ef2dc2af5f8ab8ab52515562e3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 24 Jun 2019 13:38:35 +0100 Subject: target/i386: fix feature check in hyperv-stub.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 2d384d7c8 broken the build when built with: configure --without-default-devices --disable-user The reason was the conversion of cpu->hyperv_synic to cpu->hyperv_synic_kvm_only although the rest of the patch introduces a feature checking mechanism. So I've fixed the KVM_EXIT_HYPERV_SYNIC in hyperv-stub to do the same feature check as in the real hyperv.c Signed-off-by: Alex Bennée Cc: Vitaly Kuznetsov Cc: Paolo Bonzini Cc: Roman Kagan Message-Id: <20190624123835.28869-1-alex.bennee@linaro.org> Reviewed-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini --- target/i386/hyperv-stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'target/i386') diff --git a/target/i386/hyperv-stub.c b/target/i386/hyperv-stub.c index fe548cbae2..0028527e79 100644 --- a/target/i386/hyperv-stub.c +++ b/target/i386/hyperv-stub.c @@ -15,7 +15,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) { switch (exit->type) { case KVM_EXIT_HYPERV_SYNIC: - if (!cpu->hyperv_synic) { + if (!hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC)) { return -1; } -- cgit v1.2.3 From ec7b1bbd2c470d8766b61617bd4d8ba46aa2056b Mon Sep 17 00:00:00 2001 From: Liran Alon Date: Tue, 25 Jun 2019 02:05:14 +0300 Subject: target/i386: kvm: Fix when nested state is needed for migration When vCPU is in VMX operation and enters SMM mode, it temporarily exits VMX operation but KVM maintained nested-state still stores the VMXON region physical address, i.e. even when the vCPU is in SMM mode then (nested_state->hdr.vmx.vmxon_pa != -1ull). Therefore, there is no need to explicitly check for KVM_STATE_NESTED_SMM_VMXON to determine if it is necessary to save nested-state as part of migration stream. Reviewed-by: Karl Heubaum Signed-off-by: Liran Alon Message-Id: <20190624230514.53326-1-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- target/i386/machine.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'target/i386') diff --git a/target/i386/machine.c b/target/i386/machine.c index 851b249d1a..704ba6de46 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -997,9 +997,8 @@ static bool vmx_nested_state_needed(void *opaque) { struct kvm_nested_state *nested_state = opaque; - return ((nested_state->format == KVM_STATE_NESTED_FORMAT_VMX) && - ((nested_state->hdr.vmx.vmxon_pa != -1ull) || - (nested_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_VMXON))); + return (nested_state->format == KVM_STATE_NESTED_FORMAT_VMX && + nested_state->hdr.vmx.vmxon_pa != -1ull); } static const VMStateDescription vmstate_vmx_nested_state = { -- cgit v1.2.3