Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1404897rdb; Fri, 1 Dec 2023 16:05:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgKm8DZQpPph5TZpyCn0ctIMPd9UEaqJGdKMxRzV2hdJ8Pht2gfxFUXt3krlNu0eGo11/j X-Received: by 2002:a92:c985:0:b0:35d:5995:1d78 with SMTP id y5-20020a92c985000000b0035d59951d78mr369158iln.61.1701475506896; Fri, 01 Dec 2023 16:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701475506; cv=none; d=google.com; s=arc-20160816; b=Z5quFFFVX9sCKj5TAkTWiUvsO9lW12SmE+Kr9339BSFb1znh4ARER8hsvqLeKKxb3o 0QoywHkVhGV6nHpIsXh/hcXR7K7UeR7IqlcNPH9+K2DA016fSvkXaHFc4UqrWhfEO/s0 LxWVLjidt6sOZIpIo+oavJu0MTLz55d3VqUHcvL42yr/CqC7GxMxga2PZjvhgw0nP/yQ Kt1XPO3Q8d58raX6BUCVoanOrBGH5o76XJE4POVp9U//YLfK1/2rWgvpKb4L6HFeW8Ge +hbiVXjXwEwof57+enaPLvqL5s+Cds0Qc1x6Qzj+uiIJuhZQrqNDx5995lho9gty1SH3 hQ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=MdN/fXe06mNI/rx7xpLhmxtX8yoQrkzTbIXLwt/4RE8=; fh=gm96CM+cG0KJxn7vnhn0c1c98ILNP1HHUrKfrGecw3M=; b=L+3pvo+XIM5kH+LeqszvUxNdA7KHn/nu3w38TxhsMR8gd0pQ0+lGssYXASjQmM/q72 JjZJafwETTI2KpVR//qlFJO0mzjxeHCTVuoeXs0Qc93k5XUFOA2vE7g2L5uaMix0Dagr +hKU2bNdoWOO9+4gcgdg8V7kgfNuV+k7/SHVu4EeqHnM6J9UYU4Hv1RhutuqzVJ/aVt9 LOkGBUK5+zD1LKc9BsrxZJXvX/3rNx8f5CvDjPGaewxRyeC8jvSUNLQadZVmSM8lMITK yGbAYHI3PYN3U8Ud+W+7HAcvp3uG2zqDMcULTXc2kT1bFgL3ZYby/iLNtLOvxN23dNsL 7eeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L1h7Y1D7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id y21-20020a656c15000000b005c278e32054si4369873pgu.677.2023.12.01.16.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 16:05:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L1h7Y1D7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 837A08163C12; Fri, 1 Dec 2023 16:05:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235314AbjLBAEm (ORCPT + 99 others); Fri, 1 Dec 2023 19:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441939AbjLBAEh (ORCPT ); Fri, 1 Dec 2023 19:04:37 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F1B8DD for ; Fri, 1 Dec 2023 16:04:33 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5d3aa625542so17208697b3.1 for ; Fri, 01 Dec 2023 16:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701475472; x=1702080272; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=MdN/fXe06mNI/rx7xpLhmxtX8yoQrkzTbIXLwt/4RE8=; b=L1h7Y1D7+jirALHlwpBx/C8UuKNR0EiPyYpBUkcuZBOENFFXt7jwGMTnZH0naccBf6 p1g48ya97PKgoKcF2L4G70TDMx1beW5yKGPYIUwtBnmPKs4bbJE0lXAMKderZ4bVfCk+ 05IcD9lBhSiS2zmS2zHvYlCe/pO093Wry9/qCAZ85WFMNxP+Q+H7A9CkKkWZ1gMJVWnx HCGij+VmFvd3fldpdHHLXZG1H2t8m1PkcgAi95ADHmHOmdn1pEtR6yWycowWDWHeqDG8 WdBbGvKcJZzmyqYZl/62m1x0ybsioTKPTPIypga6Lh1BN/sqBVoC10cNMeWRrwwwHZxh tYYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701475472; x=1702080272; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MdN/fXe06mNI/rx7xpLhmxtX8yoQrkzTbIXLwt/4RE8=; b=uF9MRhht7x+gWoblZ+p3u5EJQ+ofXIKz5/2bRnLBtovJOvCLHuRvsu4AfvVVLvvH/5 HbIuBwAcrCAMTEQfxcEBDM9o/WjpP4ZTWeVIF4bGnzwqgn/xfiSinzkGyD91tbol4kS7 QtfQgK5Nk8Y83wO/KmrJLbhXIpGizLzSBqWlLaIAPcc2d+2/KjoxY1OZZUucpon+SQTu frYQQYiGjevBHVx/3UmCm9zzH766WgJpUUuj9YWT2ZXaonjpdlyyBzdnFFSE09oQ/E5i O0jLGX++WroOhrj++f4dnHDJBmopdRnbcY+gmOGOVtUNfZKw7s2OCMS4nUu4xhhY7w1v pwDQ== X-Gm-Message-State: AOJu0YzKmNAHwR5WGe2/pvPWaW/9KGEAJY6azVW0IQhiExQIW6qWnOiY DrEuR4nfLhhADCS+uUJb0hFGWklZdFU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:3692:b0:5d1:6732:25a0 with SMTP id fu18-20020a05690c369200b005d1673225a0mr674144ywb.4.1701475472351; Fri, 01 Dec 2023 16:04:32 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 1 Dec 2023 16:03:55 -0800 In-Reply-To: <20231202000417.922113-1-seanjc@google.com> Mime-Version: 1.0 References: <20231202000417.922113-1-seanjc@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231202000417.922113-7-seanjc@google.com> Subject: [PATCH v9 06/28] KVM: x86/pmu: Don't ignore bits 31:30 for RDPMC index on AMD From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kan Liang , Dapeng Mi , Jim Mattson , Jinrong Liang , Aaron Lewis , Like Xu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 01 Dec 2023 16:05:03 -0800 (PST) Stop stripping bits 31:30 prior to validating/consuming the RDPMC index on AMD. Per the APM's documentation of RDPMC, *values* greater than 27 are reserved. The behavior of upper bits being flags is firmly Intel-only. Fixes: ca724305a2b0 ("KVM: x86/vPMU: Implement AMD vPMU code for KVM") Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/pmu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c index 1475d47c821c..1fafc46f61c9 100644 --- a/arch/x86/kvm/svm/pmu.c +++ b/arch/x86/kvm/svm/pmu.c @@ -77,8 +77,6 @@ static bool amd_is_valid_rdpmc_ecx(struct kvm_vcpu *vcpu, unsigned int idx) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); - idx &= ~(3u << 30); - return idx < pmu->nr_arch_gp_counters; } @@ -86,7 +84,7 @@ static bool amd_is_valid_rdpmc_ecx(struct kvm_vcpu *vcpu, unsigned int idx) static struct kvm_pmc *amd_rdpmc_ecx_to_pmc(struct kvm_vcpu *vcpu, unsigned int idx, u64 *mask) { - return amd_pmc_idx_to_pmc(vcpu_to_pmu(vcpu), idx & ~(3u << 30)); + return amd_pmc_idx_to_pmc(vcpu_to_pmu(vcpu), idx); } static struct kvm_pmc *amd_msr_idx_to_pmc(struct kvm_vcpu *vcpu, u32 msr) -- 2.43.0.rc2.451.g8631bc7472-goog