From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA742CCA47A for ; Tue, 14 Jun 2022 20:09:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357426AbiFNUJC (ORCPT ); Tue, 14 Jun 2022 16:09:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356831AbiFNUIA (ORCPT ); Tue, 14 Jun 2022 16:08:00 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A677727CEE for ; Tue, 14 Jun 2022 13:07:47 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id e1-20020a17090301c100b00168d7df157cso4030565plh.3 for ; Tue, 14 Jun 2022 13:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=6m++h1TLmwB8cNEM0gWLCTf/lVisfRn3tV3Xo5ZBF2o=; b=nWH/hVsCDdNk2ASx5jRA6o8Tna0+54SOB08YEt9isPQyB5OimOPuFRizPtguQSLNIh wM+hRGc267ThJtLhSExxvQy9S3xULfRuAhaw6p2s9Iu+bLTEpC+Y1Va6DX0+Su9jThbJ /EdkVlTgE1aZGRKWt1soyOy+IkhJrUVhwZ4BXa/qT2MwyjuD9IFuxEUPiCM1467a9Xn8 SSacTIOVEDUlgMDNZHrL3uVGJ11hu3kXiNefWHKg/HWcKPcA1I06gRBhdkww2RE5X8M2 P1SvIQQJ5Hana9l/zq+prl8PAmPyUboVk1EvCXar/b6xDzLpq1ncksE1z3wxgNPUFGOx eRmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=6m++h1TLmwB8cNEM0gWLCTf/lVisfRn3tV3Xo5ZBF2o=; b=ORUX6XFn72wAmBAaDzjWDO7tw2KDdY782h21p+mSp/u9tMwIgdsjpOTiSt7Y59c1/L OTYgwZ8FdyFil4JklAUfVmRxdRTsW01zIPVeTBoZJB/pEYzcQREYx5zmS0Ic0UaAJ625 Fpx1j7gdRugNZMZG+O79ix/hWXiRjnH5d62Jge+Ju0UPenfjUjkbkIz0b8J0WZjpzwtn bNq3ahtabvMo69lf5nMVkxWce/kWjiSH1Ops9Ao6nRGe1Z7DM+w9d3OeXfiuRgzCrEQ0 7sUqVAy/qNfRmiVfRbIktmAGYou/5dOT1hMcS3YRDm+4LTIeGOMTAUTmPWPhHxbwHyhV VAbA== X-Gm-Message-State: AJIora983JwrINicpksA0GL5w/c+UmPMCLJI8BxRPaU4aAFUDHBHlyWj H9U8w38VE0N72VFDlrS/x/UTXLw5NmA= X-Google-Smtp-Source: AGRyM1vt7V/df3fvVEWr9ejSWyNdVhY7D3OL27S/3XkGdZ4iP7evofRU8vS/rOiDkTiD5UeyK3+yiJ+yGSo= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90a:249:b0:1e0:a8a3:3c6c with SMTP id t9-20020a17090a024900b001e0a8a33c6cmr192571pje.0.1655237266602; Tue, 14 Jun 2022 13:07:46 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 14 Jun 2022 20:06:44 +0000 In-Reply-To: <20220614200707.3315957-1-seanjc@google.com> Message-Id: <20220614200707.3315957-20-seanjc@google.com> Mime-Version: 1.0 References: <20220614200707.3315957-1-seanjc@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH v2 19/42] KVM: selftests: Don't use a static local in vcpu_get_supported_hv_cpuid() From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Jim Mattson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't use a static variable for the Hyper-V supported CPUID array, the helper unconditionally reallocates the array on every invocation (and all callers free the array immediately after use). The array is intentionally recreated and refilled because the set of supported CPUID features is dependent on vCPU state, e.g. whether or not eVMCS has been enabled. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/x86_64/processor.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index 55838c603102..7c0363759864 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -1288,9 +1288,7 @@ void vcpu_set_hv_cpuid(struct kvm_vcpu *vcpu) struct kvm_cpuid2 *vcpu_get_supported_hv_cpuid(struct kvm_vcpu *vcpu) { - static struct kvm_cpuid2 *cpuid; - - cpuid = allocate_kvm_cpuid2(MAX_NR_CPUID_ENTRIES); + struct kvm_cpuid2 *cpuid = allocate_kvm_cpuid2(MAX_NR_CPUID_ENTRIES); vcpu_ioctl(vcpu, KVM_GET_SUPPORTED_HV_CPUID, cpuid); -- 2.36.1.476.g0c4daa206d-goog