Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3788884iob; Tue, 17 May 2022 07:16:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdirYoWVDlxbRAcPaE8JSvHMSnCBaxQPo4k9iAI+2DVvpR601HefRFiKzs9BBlQ+WrwxYN X-Received: by 2002:a17:903:1c9:b0:161:89e8:229 with SMTP id e9-20020a17090301c900b0016189e80229mr8121530plh.106.1652797017123; Tue, 17 May 2022 07:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652797017; cv=none; d=google.com; s=arc-20160816; b=S5ZWv4GYukAmyAif5ydRck+3zPKfBJs/S7uuQLReq7lv0ei9a6rOKF4psVG+BNG1yg BnAcRXmW484iPvZfVLsCnIIC76uzQ9defyCn3XxxJ+mvkvvss1R5SPOwg4MeC+HVE+4P GpHyFJE1Mf9JG/138A0NZ5NxRvVgwyUGdsVt7ADp9Nmb6FLuls0LQFxnvUFgYheBnRR2 yEqM2kn4nUQmYBEO2VNn9sWigGOOitnEHTn63Y69rSN3I0O0+845LNgUgK8Wq9OSfE7O WDMyD3bzMZZvoYV+edjxJrHPk3MyaPGeaq5KepJOrYXGUwA0jBkwkfOUioc45Y/524fE N3oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dOFwWvCzKdZRiDREe2Yw7hYWmMD5WfY21+v62r2lSAQ=; b=hIaVRlzsLyifqWFEKH2pHvS9n9MsPbrLznMh5IPnbcgmvrQwBLGXUlpJUJhLfWIkUv lZjINg6s+dDq4AA0qa/QqfbYzxL98qOLkXtYyPvnLUAWqYRPvX1FbY21coKZcaZiLrKF Jyu+a1Q9JFBfD5xlgJOpzRzzORO0V1uRy9Ytz0cXTVId/dQRNHStOfTT8lMd0jab0CRV 6TkBAO8ao8sXEqgFnu0ulFV+28rEziaXuOra9mYP1oJZYxrSRIkjNzgpWk4hrkYQU8vV WVrlcku4pfSlARym4gHE9kTOf9x8TLz/XyXL3ZbEvx5QWyugx+X6BZuHck0j64azbnsw S9WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NTVAN5Oe; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a170902bcc700b00153b2d164bcsi15274329pls.196.2022.05.17.07.16.41; Tue, 17 May 2022 07:16:57 -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=@google.com header.s=20210112 header.b=NTVAN5Oe; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241917AbiEQA75 (ORCPT + 99 others); Mon, 16 May 2022 20:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240711AbiEQA7m (ORCPT ); Mon, 16 May 2022 20:59:42 -0400 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B1A46165 for ; Mon, 16 May 2022 17:59:39 -0700 (PDT) Received: by mail-ua1-x930.google.com with SMTP id f13so6459076uax.11 for ; Mon, 16 May 2022 17:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dOFwWvCzKdZRiDREe2Yw7hYWmMD5WfY21+v62r2lSAQ=; b=NTVAN5OeH9zigQ0ls1wYbMQdNrPMZcFb9eIgEhfEZr2WW26Rik9MXZfufZOyienHwS EtCJYc9E3eLm7MDJG7hZXuyEeCr40N7ediAdDIWhArm2cAg9D7Kr4e032+E1U32YWc0G /U2iI4O3u6CXHMWIP5u6U1Xv8y+Q6zs+nQg7Jq0QVXIkrjokFICe/7s/jVdSPh+5/qWY 70LTFRRCGbO7ofPPDFdPz1f0TJw+0iS0eHH+3Cjqt7Baa1sF7vuwm3w1pMHst+p+nxP2 SVvvtyCQq4Gw03JOqXql1xUiJoPxveThLJHhVFiOWQOTyNE5bN9q8KE9ns01rX5MbfHb TXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dOFwWvCzKdZRiDREe2Yw7hYWmMD5WfY21+v62r2lSAQ=; b=PellfF91FTeK1PRBK19MuOdugnfFkqisIBpoPot0euf2tICjtgqebHpAJH2J3QRbsp I/3AF6ZlfK0rBOf0bviH1mm+GTDu79/dcFq35zHg2lmNh7d9XcH7WQLnv5l63YqQ2l+8 N+wB9RJjG23ClzaqkehHVfjBj/wXQd4LAGj37jmziggzMp60E+7ojMW+QWFt1DxGbj4h rCTmG0tSF66SMXdoee8OFO3HFZl9rAZPZh6jyddyXkWjEidJnXcpiDIC0pQNc5XMYQ3L BhQoTB9reu54phElIRozh7Gjnm8YEfOnm/AKSitTSnuo4StA1bJEv5XVL2iThm1kIwhT 8GCg== X-Gm-Message-State: AOAM531gmSn+C4xq/qNX+P06eqPePHJc/uGbnGaM0Ma0DHUGp1ZI6E0s vEcOp47ISXQzRw4Hs7omS6luYLCaUUBZYrxjXwttIH9VovM= X-Received: by 2002:ab0:1525:0:b0:365:95fa:4e51 with SMTP id o34-20020ab01525000000b0036595fa4e51mr7147536uae.121.1652749178730; Mon, 16 May 2022 17:59:38 -0700 (PDT) MIME-Version: 1.0 References: <20220516154838.7044-1-bp@alien8.de> In-Reply-To: <20220516154838.7044-1-bp@alien8.de> From: Stephane Eranian Date: Mon, 16 May 2022 17:59:27 -0700 Message-ID: Subject: Re: [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw To: Borislav Petkov Cc: Peter Zijlstra , X86 ML , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Mon, May 16, 2022 at 8:48 AM Borislav Petkov wrote: > > From: Borislav Petkov > > This fires on a Fam16h machine here: > > unchecked MSR access error: WRMSR to 0xc000010f (tried to write 0x0000000000000018) \ > at rIP: 0xffffffff81007db1 (amd_brs_reset+0x11/0x50) > Call Trace: > > amd_pmu_cpu_starting > ? x86_pmu_dead_cpu > x86_pmu_starting_cpu > cpuhp_invoke_callback > ? x86_pmu_starting_cpu > ? x86_pmu_dead_cpu > cpuhp_issue_call > ? x86_pmu_starting_cpu > __cpuhp_setup_state_cpuslocked > ? x86_pmu_dead_cpu > ? x86_pmu_starting_cpu > __cpuhp_setup_state > ? map_vsyscall > init_hw_perf_events > ? map_vsyscall > do_one_initcall > ? _raw_spin_unlock_irqrestore > ? try_to_wake_up > kernel_init_freeable > ? rest_init > kernel_init > ret_from_fork > > because that CPU hotplug callback gets executed on any AMD CPU - not > only on the BRS-enabled ones. Check the BRS feature bit properly. > Thanks for catching this. I tested on Zen2 (Fam17h) and it did not trigger the problem, yet I think the problem in amd_brs_reset() is there. > Signed-off-by: Borislav Petkov Acked-By: Stephane Eranian > --- > arch/x86/events/amd/brs.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/events/amd/brs.c b/arch/x86/events/amd/brs.c > index 895c82165d85..bee8765a1e9b 100644 > --- a/arch/x86/events/amd/brs.c > +++ b/arch/x86/events/amd/brs.c > @@ -57,7 +57,7 @@ static inline u64 get_debug_extn_cfg(void) > > static bool __init amd_brs_detect(void) > { > - if (!boot_cpu_has(X86_FEATURE_BRS)) > + if (!cpu_feature_enabled(X86_FEATURE_BRS)) > return false; > > switch (boot_cpu_data.x86) { > @@ -112,6 +112,9 @@ static inline int amd_brs_get_tos(union amd_debug_extn_cfg *cfg) > */ > void amd_brs_reset(void) > { > + if (!cpu_feature_enabled(X86_FEATURE_BRS)) > + return; > + > /* > * Reset config > */ > -- > 2.35.1 >