From nobody Sun Sep 28 00:37:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561082305; cv=none; d=zoho.com; s=zohoarc; b=BlTjqGSGEuEYKpyMqy19E1ka352R8qEKl0LOrwzkwifzgTjsJZrwvIQuQ7L5X3s8nGSsAfeHjbm6zP5HJRVSuGRxGj2J+szxf78AIK0qfJzgB4IIYvgjvRYr1KjKgAyEouzCmH5IMwr0AqGeLcii6N+XkW8iBqSKOllDhRTvOUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561082305; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HAAne3y/gROX4bU2C72LMlD4mSuvEZFb/lzmz3j4hms=; b=Am0x4l3IJ/QFE9uj2jjQnPu108E3e0o7rklyFumguxMMbrfIeEoLVTE2sI5P2KmZ/TM+ZinlzFWVg8fEMIh3pzexudhaiiXfyLUWrDd+Ssu5qC8eLSzkC+/l6X/pdUUNeKMWHvLy1Y49mqaKmD3dy+hDiBRlTxGsVWk7MtpCePY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561082305754864.6975973179246; Thu, 20 Jun 2019 18:58:25 -0700 (PDT) Received: from localhost ([::1]:54090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8oo-0008HA-Qg for importer@patchew.org; Thu, 20 Jun 2019 21:58:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40856) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8Zu-0006Sc-3D for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:42:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he8Zk-0006Ky-LC for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:42:51 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:53307) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1he8Zf-0006HR-8t for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:42:45 -0400 Received: by mail-wm1-x332.google.com with SMTP id x15so4782028wmj.3 for ; Thu, 20 Jun 2019 18:42:42 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d1sm1123125wru.41.2019.06.20.18.42.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 18:42:40 -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=HAAne3y/gROX4bU2C72LMlD4mSuvEZFb/lzmz3j4hms=; b=t6X8e9aoGjaNuXUz5vrgFdUH5MRD6Irg9bcuoVeVdgRKHSqNFF44eySRc905PutG78 +i8l1jVG4ysLKawB1jxbGl0BvdIC0igdywVXO6ASLHEmhXRyOgUpYddNxvGoltsAPmBS UUMpraHWIOtza9lP3ugdLKaWYTIfk1KtwfIqyQ1fiqL/3WP6XSa5O5/EsqXKtwNN1Hw/ EtiaiuUov6bgvV4jONjS73dXTdjzB6IePmsOQ4qfj9QUNgdRS2U+axB+FNCRfQNWN10V oZ64mwKD/LpOJ6X6zJVCPMjeMbnFZOq84fshGUATS5+XMzYvV80+wHtqn9Nkl/kKvrh+ e1iA== 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=HAAne3y/gROX4bU2C72LMlD4mSuvEZFb/lzmz3j4hms=; b=gYDCkPQTNz5DnJOeN14lpM5RyvHxPtYm/rgKAYXAIXx90ylbV6ULcjWLnhuRN3NIdp Loc/dIdVqGea6hMnrmi/2xM2sI80Z/5CdPmjlT5hcBtVOpHyAt5+tjDlc3PZ/3k4NK4c I1+f1D7xQq32yWgk0gHHUeQr4TZ5v2+/cswLzyQwGHRv1PlZ3u13hDaaiYjDaQd7Ojcl G8dkgfvOkrXq368iZViRdx75eOFjOC9236ypjByr0JE/jbx3K+4d5m1bnAocqmgulkhK 1TCLp6S30thnKS1/cy9O7pJ2MS+R1E418KoCzfWzaUktpTo6oEmzG83OHrGZcTPzDok3 qOSA== X-Gm-Message-State: APjAAAXa7wODG22AEeHDlo/Xgz7Et4V9fNf+InHUN3I96seNDk0YFrMb EmfX2EcWlBvNS8q9h7HI1ZAORbAL X-Google-Smtp-Source: APXvYqxXLDrW4q+HXHwZPELe/VsJ9fU09EdN4uWvvGrCuFA06/tSimrzmLZKQlgP1mvQu8SjFVsr2g== X-Received: by 2002:a1c:f018:: with SMTP id a24mr1482527wmb.66.1561081361622; Thu, 20 Jun 2019 18:42:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2019 03:42:13 +0200 Message-Id: <1561081350-3723-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> References: <1561081350-3723-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::332 Subject: [Qemu-devel] [PULL 08/25] i386/kvm: hv-stimer requires hv-time and hv-synic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Synthetic timers operate in hv-time time and Windows won't use these without SynIC. Add .dependencies field to kvm_hyperv_properties[] and a generic mechanism to check dependencies between features. Signed-off-by: Vitaly Kuznetsov Message-Id: <20190517141924.19024-7-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 93ac6ba..58afa31 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -689,6 +689,7 @@ static struct { uint32_t fw; uint32_t bits; } flags[2]; + uint64_t dependencies; } kvm_hyperv_properties[] =3D { [HYPERV_FEAT_RELAXED] =3D { .desc =3D "relaxed timing (hv-relaxed)", @@ -756,7 +757,8 @@ static struct { .flags =3D { {.fw =3D FEAT_HYPERV_EAX, .bits =3D HV_SYNTIMERS_AVAILABLE} - } + }, + .dependencies =3D BIT(HYPERV_FEAT_SYNIC) | BIT(HYPERV_FEAT_TIME) }, [HYPERV_FEAT_FREQUENCIES] =3D { .desc =3D "frequency MSRs (hv-frequencies)", @@ -986,12 +988,25 @@ static int hv_cpuid_check_and_set(CPUState *cs, struc= t kvm_cpuid2 *cpuid, X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; uint32_t r, fw, bits; - int i; + uint64_t deps; + int i, dep_feat =3D 0; =20 if (!hyperv_feat_enabled(cpu, feature) && !cpu->hyperv_passthrough) { return 0; } =20 + deps =3D kvm_hyperv_properties[feature].dependencies; + while ((dep_feat =3D find_next_bit(&deps, 64, dep_feat)) < 64) { + if (!(hyperv_feat_enabled(cpu, dep_feat))) { + fprintf(stderr, + "Hyper-V %s requires Hyper-V %s\n", + kvm_hyperv_properties[feature].desc, + kvm_hyperv_properties[dep_feat].desc); + return 1; + } + dep_feat++; + } + for (i =3D 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i+= +) { fw =3D kvm_hyperv_properties[feature].flags[i].fw; bits =3D kvm_hyperv_properties[feature].flags[i].bits; @@ -1107,11 +1122,11 @@ static int hyperv_handle_properties(CPUState *cs, r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_EVMCS); r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_IPI); =20 - /* Dependencies */ + /* Additional dependencies not covered by kvm_hyperv_properties[] */ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC) && !cpu->hyperv_synic_kvm_only && !hyperv_feat_enabled(cpu, HYPERV_FEAT_VPINDEX)) { - fprintf(stderr, "Hyper-V %s requires %s\n", + fprintf(stderr, "Hyper-V %s requires Hyper-V %s\n", kvm_hyperv_properties[HYPERV_FEAT_SYNIC].desc, kvm_hyperv_properties[HYPERV_FEAT_VPINDEX].desc); r |=3D 1; --=20 1.8.3.1