From patchwork Tue Apr 11 13:03:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinrong Liang X-Patchwork-Id: 13207561 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 0962DC76196 for ; Tue, 11 Apr 2023 13:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbjDKNET (ORCPT ); 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-Google-Smtp-Source: AKy350aKCsAD2r5D8fmvW4B6NhiTUAp74QYcGu/SmHvcLWzuncyduCGC2UAXTfkU4oNJbZ1KI8Q6UQ== 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 Precedence: bulk List-ID: X-Mailing-List: kvm@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;