Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5472543rwl; Tue, 11 Apr 2023 06:05:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ZnUbY33VF71d+w0Un6BXOyiv9hTQzDQqZYonOM2nBrIBWF9+nN0fkflBk23WOyzm4q0JhN X-Received: by 2002:aa7:cd96:0:b0:502:70e9:2c14 with SMTP id x22-20020aa7cd96000000b0050270e92c14mr2088551edv.29.1681218355040; Tue, 11 Apr 2023 06:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681218355; cv=none; d=google.com; s=arc-20160816; b=awF86FxvDMF0LuOG3jo4J3+8/Gb+S0nRcz0Z2nVw6u8VashN5OSmnDFSbbz1f59WI6 5uPo7Zsnq2KS2W6TRoSJS3h8HnHIYXfyJXIpVhtMajzcNKkv83JjkeT904RuBPmE8dfh O/0YdaTXxiCcXE+ULOwr5AczYPdgX7polUA+q0juEeCYDLZYdBKzhPCJY5fPkc9MCPru e32wf1X3MHy2z2uSF4qL0cGtrLyHs5UhNRQVa+NY/XVf5PDHv7s7u9VHvbEAthv8OnBA ZVu53RnLG1D5527pqikpjOBDAJEayjfEk80rKM1EdebcZpFWOkq3SMAyXWYgHucs/oM3 uqyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DGPsZgWveJxj8Dn+JY/R3MDE1ywwia78QYoiL5Lim/Y=; b=xAyDklDmOpBob5LroXqi4QQY5Eb4jQWX07gT611E8EQL91QArktWxX9j+3IgW4S0Nm 7aiSX8zBVF1NQ/qnz8vPZ9jBoXhfKm8jf/sjfi8lZL12iEqVUPmpHCbZzjXav/N2YJIt Cxn8Efjqc+LYAWicJhnqOxLoER0372w+6bh63wIdPLRui3E0ejgxltI/6dY3K7WhnCMA dZUxJhcrOZux/dxtnKgJhT+6O//7mQMxplwA5OONCakUq/280pq+BOtn3MCttKZckh0c LWusmxAyh40Vpm/yUE+mPoi05UtEuC4qguRYtySjMrJeNagkLzJ0YKKSBIU3zcd7SQUB WPtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dnHqZC/0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a056402161100b005005c61fdf8si4235283edv.372.2023.04.11.06.05.14; Tue, 11 Apr 2023 06:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dnHqZC/0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbjDKNET (ORCPT + 99 others); Tue, 11 Apr 2023 09:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbjDKNEM (ORCPT ); Tue, 11 Apr 2023 09:04:12 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48F625273; Tue, 11 Apr 2023 06:03:50 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id e18-20020a17090ac21200b00246952d917fso6316050pjt.4; Tue, 11 Apr 2023 06:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681218229; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DGPsZgWveJxj8Dn+JY/R3MDE1ywwia78QYoiL5Lim/Y=; b=dnHqZC/0oeXGXGbNKCR7IbA/S6vUmwRZaRKhzBcG1vfikiAjudQRVgFqtxioPYu1LL WGeLVQQPYB7XI410D0VdxKEUvJcokUk6KuphqI7LS/AeTPcgFAapd1wh2Q1njd+AYev0 CY6Bk+csVKlHGKjPDjUD/5C8Nbj5Viu47keO9ZP5lJs68c1QBbVdGglhHGZF0YkGm8tr T2+JSgOUzM/8lo+He0SfgLmKdd9lgqMObh0fIyEhuI8Sk2F1DPB7vzt9Svf4OHzPvC+X gAhWNgL1ibAumkfqrHR1nEKD7/AgiZgJpurznrCVQ5ctKxIXUj1hHr5FRhWraGFS6EHy frkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681218229; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DGPsZgWveJxj8Dn+JY/R3MDE1ywwia78QYoiL5Lim/Y=; b=QjwVZmzti056NgNZNYtZjCF1qSw0ZP1FTeSdEIVOVSGTOkW8davqjXMMruozJoi9R4 buf3ylZIhQ70ii5/OqAUtj+Klo9tYzS0n68q6jthGNrBac2LbGzxxhk7WA4oOK1TdeqS a8SknJ1kK6ZmDVdfLqSHJeTKm+HxNat99aQhY+VnE3Ugd+/RapGX5szS34n+CDpBom+N mOpc8fSP55uztGuv9WxExi+VGxhZ5L9yxq4argUu9z4bTvP+H+lR7pIsK0iBeZSDV0xL /0/5fxlp4paAHzdj28OMLSETFCVslsdMJWNxxXj90w6RJLcSenHxqpqwkTX2GLW1PdcN 75yQ== X-Gm-Message-State: AAQBX9dhHZS10ggi57rTjT9HrFMC0qdyrV4UWXEVp2i9gmgPk2ZFQAk+ cu4bjbY7dfkJWh/ZvSzo7C8= X-Received: by 2002:a17:902:d40d:b0:1a6:4b2f:9a2f with SMTP id b13-20020a170902d40d00b001a64b2f9a2fmr4470258ple.59.1681218229492; Tue, 11 Apr 2023 06:03:49 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id c9-20020a170902724900b001a060007fcbsm9598506pll.213.2023.04.11.06.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 06:03:49 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson , Like Xu Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Wanpeng Li , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: x86/pmu: Remove redundant check for MSR_IA32_DS_AREA set handler Date: Tue, 11 Apr 2023 21:03:38 +0800 Message-Id: <20230411130338.8592-1-cloudliang@tencent.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jinrong Liang After commit 2de154f541fc ("KVM: x86/pmu: Provide "error" semantics for unsupported-but-known PMU MSRs"), the guest_cpuid_has(DS) check is not necessary any more since if the guest supports X86_FEATURE_DS, it never returns 1. And if the guest does not support this feature, the set_msr handler will get false from kvm_pmu_is_valid_msr() before reaching this point. Therefore, the check will not be true in all cases and can be safely removed, which also simplifies the code and improves its readability. Signed-off-by: Jinrong Liang --- arch/x86/kvm/vmx/pmu_intel.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index e8a3be0b9df9..b0d70a8b7613 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -443,8 +443,6 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) } break; case MSR_IA32_DS_AREA: - if (msr_info->host_initiated && data && !guest_cpuid_has(vcpu, X86_FEATURE_DS)) - return 1; if (is_noncanonical_address(data, vcpu)) return 1; pmu->ds_area = data; -- 2.31.1