From nobody Tue Feb 10 00:59:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653508177; cv=none; d=zohomail.com; s=zohoarc; b=aNiWTKmgY1mAJ6J9nOTBVMgacJ5bFdGc3y/OS2NPQ7ASKKjddiC0WAeoXRE+dp32DqsWu1Tvn46JPfEZrGllWNak59XKlOfGOQqPRre8i2m6qZ7yC96islytIQx+8zJSZGQMsiZ+nSP8TzHUhhIeSYCS+Z2uO45uSOQfo1BnmmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653508177; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gG9nneWWyjnupUUg6wVGpKu/gWNRRTAvNAqk45p9EZU=; b=Ea/yZAUloroYgTbFzuypPmhVVvgC29QFqd4qSuGzxCE4l5/1JykurnDEVX0DY4f+Y0OdOL/MdHj0UYot2Ui8jNZtchV2XT3F9eEQDOxELBkQrPL5EpElg/+/yfxxdPDJO0GyhyZ4fUmTDr5RoM216JLCGPMDRouP9j6hAPkTWlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653508177236982.539217213692; Wed, 25 May 2022 12:49:37 -0700 (PDT) Received: from localhost ([::1]:50664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntx0h-0007IU-Mc for importer@patchew.org; Wed, 25 May 2022 15:49:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhH-0005YV-1p for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhF-0003sA-9t for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:30 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-Hqt4PTxbNA69lrG8KqwAmA-1; Wed, 25 May 2022 15:29:27 -0400 Received: by mail-ej1-f72.google.com with SMTP id k7-20020a1709062a4700b006fe92440164so9212772eje.23 for ; Wed, 25 May 2022 12:29:27 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id ej23-20020a056402369700b0042a2d9af0f8sm11268052edb.79.2022.05.25.12.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gG9nneWWyjnupUUg6wVGpKu/gWNRRTAvNAqk45p9EZU=; b=datWObJ9ynHuEV7Yg0bi/cpkkPgZvt8rV5Yi1joj3IMzHBsrLVBT6MuWXJvw6TzZI3a+xG e4hIYtJZetcVFfNzjGN2ZQiv4cKXZSO5w0WTFbTv/9lZzWT0j57Ha19JKORTyZqTFDeu8t yxBLxjU1M1839fmMevRkZBJ4f6p8ztg= X-MC-Unique: Hqt4PTxbNA69lrG8KqwAmA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gG9nneWWyjnupUUg6wVGpKu/gWNRRTAvNAqk45p9EZU=; b=WfFvOM7QGIzw7t/TmSM/pEyo/7xk/0d9+5J41YSeGWncAyuomdxautwku7gr0fjJI/ TbmVbKDsGjjCKWblCe8GSH7jUpRib8AvoSrA7ZVH1BbrCDc5wFNXBLFJhsB8z37DmMzN XlHLUKyCMXAlKuBh+mf663wC6PDa6ggAFXrwdAfN3JBhV3sObIaPd5Ccrh8018/KnXEF p1uSxJEq+8ma2HiMNB1g9wTV1zwFqgwViIYhZtlO/L0ZWkFdyw/jV0qp8l9HMUfFJTkm qJnm+QntQvuvV3bQzyTHFwVG6daZok7ImoRdyrCbg7PB2+QHky3R9dqEp8sLCdFgdvqP lyRw== X-Gm-Message-State: AOAM531E3iJzsdbCyDy3UDonCJNJKC05cF4MkktyopjN5NWOQY6SPoOY iBzxKMEdylt1yNtHUbJZYjsX9EMeClkSpB9YRdXJWlrSx0qrskxv6RXbbjUO80ZElVNa2wOMpal TZK3D/ygH7pY2JQxebdjd2btWccLQTuv8ossRgNpL1wr6g/0NLvYv8oypJEoRz9FdX5o= X-Received: by 2002:a17:906:478b:b0:6f8:5850:4da9 with SMTP id cw11-20020a170906478b00b006f858504da9mr30080741ejc.619.1653506965690; Wed, 25 May 2022 12:29:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyhLSCDttMfLvkvrQaYCw6iwBU9fRaZX/Whp06iIRxQhr/KBB/qWOTt6MT+29oqDec8sgGOg== X-Received: by 2002:a17:906:478b:b0:6f8:5850:4da9 with SMTP id cw11-20020a170906478b00b006f858504da9mr30080714ejc.619.1653506965345; Wed, 25 May 2022 12:29:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 12/17] i386: Use hv_build_cpuid_leaf() for HV_CPUID_NESTED_FEATURES Date: Wed, 25 May 2022 21:28:47 +0200 Message-Id: <20220525192852.301633-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653508178977100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Previously, HV_CPUID_NESTED_FEATURES.EAX CPUID leaf was handled differently as it was only used to encode the supported eVMCS version range. In fact, there are also feature (e.g. Enlightened MSR-Bitmap) bits there. In preparation to adding these features, move HV_CPUID_NESTED_FEATURES leaf handling to hv_build_cpuid_leaf() and drop now-unneeded 'hyperv_nested'. No functional change intended. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-2-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 - target/i386/kvm/kvm.c | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0d528ac58f..2e918daf6b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1804,7 +1804,6 @@ struct ArchCPU { uint32_t hyperv_vendor_id[3]; uint32_t hyperv_interface_id[4]; uint32_t hyperv_limits[3]; - uint32_t hyperv_nested[4]; bool hyperv_enforce_cpuid; uint32_t hyperv_ver_id_build; uint16_t hyperv_ver_id_major; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e2d675115b..38af0e4f04 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -831,6 +831,8 @@ static bool tsc_is_stable_and_known(CPUX86State *env) || env->user_tsc_khz; } =20 +#define DEFAULT_EVMCS_VERSION ((1 << 8) | 1) + static struct { const char *desc; struct { @@ -1254,6 +1256,13 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs, ui= nt32_t func, int reg) } } =20 + /* HV_CPUID_NESTED_FEATURES.EAX also encodes the supported eVMCS range= */ + if (func =3D=3D HV_CPUID_NESTED_FEATURES && reg =3D=3D R_EAX) { + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { + r |=3D DEFAULT_EVMCS_VERSION; + } + } + return r; } =20 @@ -1384,11 +1393,11 @@ static int hyperv_fill_cpuids(CPUState *cs, struct kvm_cpuid_entry2 *c; uint32_t signature[3]; uint32_t cpuid_i =3D 0, max_cpuid_leaf =3D 0; + uint32_t nested_eax =3D + hv_build_cpuid_leaf(cs, HV_CPUID_NESTED_FEATURES, R_EAX); =20 - max_cpuid_leaf =3D HV_CPUID_IMPLEMENT_LIMITS; - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { - max_cpuid_leaf =3D MAX(max_cpuid_leaf, HV_CPUID_NESTED_FEATURES); - } + max_cpuid_leaf =3D nested_eax ? HV_CPUID_NESTED_FEATURES : + HV_CPUID_IMPLEMENT_LIMITS; =20 if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG)) { max_cpuid_leaf =3D @@ -1461,7 +1470,7 @@ static int hyperv_fill_cpuids(CPUState *cs, c->ecx =3D cpu->hyperv_limits[1]; c->edx =3D cpu->hyperv_limits[2]; =20 - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { + if (nested_eax) { uint32_t function; =20 /* Create zeroed 0x40000006..0x40000009 leaves */ @@ -1473,7 +1482,7 @@ static int hyperv_fill_cpuids(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_NESTED_FEATURES; - c->eax =3D cpu->hyperv_nested[0]; + c->eax =3D nested_eax; } =20 if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG)) { @@ -1522,8 +1531,6 @@ static bool evmcs_version_supported(uint16_t evmcs_ve= rsion, (max_version <=3D max_supported_version); } =20 -#define DEFAULT_EVMCS_VERSION ((1 << 8) | 1) - static int hyperv_init_vcpu(X86CPU *cpu) { CPUState *cs =3D CPU(cpu); @@ -1620,8 +1627,6 @@ static int hyperv_init_vcpu(X86CPU *cpu) supported_evmcs_version >> 8); return -ENOTSUP; } - - cpu->hyperv_nested[0] =3D evmcs_version; } =20 if (cpu->hyperv_enforce_cpuid) { --=20 2.36.1