From nobody Wed Jul 1 21:44:49 2026 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 BA577C433EF for ; Wed, 15 Dec 2021 16:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244735AbhLOQQz (ORCPT ); Wed, 15 Dec 2021 11:16:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40015 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244743AbhLOQQl (ORCPT ); Wed, 15 Dec 2021 11:16:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639585000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8NJRR+a9hlTKwcYiYBaZVulZ3Qw4EA1LMUIGcFZHriw=; b=eB1rOPwStCT8ZKRYOIICL2Zil+4ZHJRMcfvyEFdQFVN4WsUshmcAgG+fdvUgXk13+mIOCj kg0wjZC27OsNbkh5GtxeKwkVIP6f45IMHPxOzjDPQHTVJcL7jKZuysRrbkjJQtxKTJ844p Ev5phRKfh9ppwMaKnY0/cJ6wvHf5UAk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-op_bkYODMPCejNi40MvNyg-1; Wed, 15 Dec 2021 11:16:39 -0500 X-MC-Unique: op_bkYODMPCejNi40MvNyg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA4CD64141; Wed, 15 Dec 2021 16:16:37 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.195.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id E46405E26D; Wed, 15 Dec 2021 16:16:18 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , oliver.sang@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: selftests: Avoid KVM_SET_CPUID2 after KVM_RUN in vmx_pmu_msrs_test Date: Wed, 15 Dec 2021 17:16:17 +0100 Message-Id: <20211215161617.246563-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit feb627e8d6f6 ("KVM: x86: Forbid KVM_SET_CPUID{,2} after KVM_RUN") forbade chaning vCPU's CPUID data after the first KVM_RUN but vmx_pmu_msrs_test does exactly that. Test VM needs to be re-created after vcpu_run(). Reported-by: kernel test robot Fixes: feb627e8d6f6 ("KVM: x86: Forbid KVM_SET_CPUID{,2} after KVM_RUN") Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c b/tools= /testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c index 23051d84b907..17882f79deed 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c @@ -99,6 +99,11 @@ int main(int argc, char *argv[]) vcpu_run(vm, VCPU_ID); ASSERT_EQ(vcpu_get_msr(vm, VCPU_ID, MSR_IA32_PERF_CAPABILITIES), PMU_CAP_= FW_WRITES); =20 + /* Re-create guest VM after KVM_RUN so CPUID can be changed */ + kvm_vm_free(vm); + vm =3D vm_create_default(VCPU_ID, 0, guest_code); + vcpu_set_cpuid(vm, VCPU_ID, cpuid); + /* testcase 2, check valid LBR formats are accepted */ vcpu_set_msr(vm, 0, MSR_IA32_PERF_CAPABILITIES, 0); ASSERT_EQ(vcpu_get_msr(vm, VCPU_ID, MSR_IA32_PERF_CAPABILITIES), 0); --=20 2.33.1