From nobody Mon Feb 9 20:10:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539898431079587.3615804823955; Thu, 18 Oct 2018 14:33:51 -0700 (PDT) Received: from localhost ([::1]:44859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDFvR-0001Yb-Pd for importer@patchew.org; Thu, 18 Oct 2018 17:33:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDEyc-0007i7-ES for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDEyZ-0006ax-7R for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:02 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35669) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDEyY-0006a4-VZ for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:32:59 -0400 Received: by mail-wm1-x343.google.com with SMTP id o17-v6so901194wmh.0 for ; Thu, 18 Oct 2018 13:32:58 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-231-174.clienti.tiscali.it. [78.12.231.174]) by smtp.gmail.com with ESMTPSA id a12-v6sm14270952wrr.71.2018.10.18.13.32.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 13:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RTaoNuPKdzLJ7KrlehIQDYmZBJKalYiNnbQZ/vXcdzU=; b=M5gvlmn6e+Tomdu9pNVg+j4+suYmRhnNcSdS3JYaji4WvapNNHWXzAl+aoGkm6zMZv dDquEsqCKvZAlZR3I6pa8C8PR0Nx2ml8CNffKYxMwvSoOtjKAqfMJh39FXeboDcjFVgb YJyJL/ZBLxp+Q2g0vMOQmwzQTKT5IU2FcOwsf6Gozn2uvd4VbI4zeokGv6nkLkvsRebk d9d1yar9UPHjmIcOuBPTP49u8HE+oQ/QBPPdhd7QVFNTFFG3husVkKiMPBk4JwrhieVB J4WGdhbr1pMZMRa3X6oSHiTDlQPyZo6LfGxYfXIQTiJGYG/zTi4oVVafnh1YhIMlOtAF 1NVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=RTaoNuPKdzLJ7KrlehIQDYmZBJKalYiNnbQZ/vXcdzU=; b=QMMBSPwNN54Xw3l0cOKv8wnQKKFpqbv493GsgD1L3acAXTs4kG2GQLZC5e0OdGKtGb 3uMiT4cOPv1aBPe0Usxec89X46upSdNkScy7j4OeKivTntz9WIJeWUf0TUVX7jr0Ms51 TGXrTRGpCIYgHDxvn3pYDhW2nJe6jqE3lbd7GDa+cotwO/besnU5nUwAgvxOmssff4+r R9oV3Bqf3LSN8eRj1TrVVb42+ljqycEDxgPgKi2mXoQUyCPxkufWoIQ+hJefVzWxyHIS T6iGr6yaqP5TIFpM+r3hsDoGoE5OBD2PxjT0M9fv501Li5KQrJPvfzkhrPQGObkg9sDP V9ag== X-Gm-Message-State: ABuFfoh/4NwURv4SGM58Y+DVRwAGASjddVmcZo5WAWFKH517r0pfXvj5 4o/vP/f5O3DGaoP37O3aTdvrG2vg X-Google-Smtp-Source: ACcGV63X+xFRPI2H6IFKcwfu+LdLxVXDYW9PaNMsLrDRYZTue+NtUK+drWRIncBpeFblMuDmEMuuKQ== X-Received: by 2002:a1c:544d:: with SMTP id p13-v6mr1814124wmi.144.1539894777700; Thu, 18 Oct 2018 13:32:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 22:32:04 +0200 Message-Id: <1539894735-14232-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539894735-14232-1-git-send-email-pbonzini@redhat.com> References: <1539894735-14232-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 37/48] hyperv:synic: split capability testing and setting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan Put a bit more consistency into handling KVM_CAP_HYPERV_SYNIC capability, by checking its availability and determining the feasibility of hv-synic property first, and enabling it later. Signed-off-by: Roman Kagan Message-Id: <20180921082217.29481-2-rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b0b42d2..2e5b9f6 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -735,8 +735,9 @@ static int hyperv_handle_properties(CPUState *cs) } if (cpu->hyperv_synic) { if (!has_msr_hv_synic || - kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_SYNIC, 0)) { - fprintf(stderr, "Hyper-V SynIC is not supported by kernel\n"); + !kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_SYNIC)) { + fprintf(stderr, "Hyper-V SynIC (requested by 'hv-synic' cpu fl= ag) " + "is not supported by kernel\n"); return -ENOSYS; } =20 @@ -754,12 +755,14 @@ static int hyperv_handle_properties(CPUState *cs) =20 static int hyperv_init_vcpu(X86CPU *cpu) { + CPUState *cs =3D CPU(cpu); + int ret; + if (cpu->hyperv_vpindex && !hv_vpindex_settable) { /* * the kernel doesn't support setting vp_index; assert that its va= lue * is in sync */ - int ret; struct { struct kvm_msrs info; struct kvm_msr_entry entries[1]; @@ -768,7 +771,7 @@ static int hyperv_init_vcpu(X86CPU *cpu) .entries[0].index =3D HV_X64_MSR_VP_INDEX, }; =20 - ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data); + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_MSRS, &msr_data); if (ret < 0) { return ret; } @@ -780,6 +783,15 @@ static int hyperv_init_vcpu(X86CPU *cpu) } } =20 + if (cpu->hyperv_synic) { + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_SYNIC, 0); + if (ret < 0) { + error_report("failed to turn on HyperV SynIC in KVM: %s", + strerror(-ret)); + return ret; + } + } + return 0; } =20 --=20 1.8.3.1