Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5728013rwd; Mon, 12 Jun 2023 08:54:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xUhwPCMpzowOryAFHJbuWbdnBP6zwOmX/kax9LxpovsVhZ1gzQG5+z4q+1x3BsW7j41Ei X-Received: by 2002:a05:6a21:6709:b0:118:a48:8970 with SMTP id wh9-20020a056a21670900b001180a488970mr7807797pzb.31.1686585242975; Mon, 12 Jun 2023 08:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686585242; cv=none; d=google.com; s=arc-20160816; b=o+TQ1hzddHtJBUD3xBaMbIXQIipCYNFRJhqqp2HwMsTgyLjjTcxz2+MFwVw2zJUK23 1HHqF0dsLx/2pTY1rirsPq8HZ3L1UnJabDtsUgasUiuWsGr797yWYYvuiZ+AewPCuf/t TnOoCFrS9xSwSFLpPu0kBRy1KRRLa1axK6Oe7erW+b2gIUZ1OE4ZnveR8BfWOYMtcx2I 5kJIgeRghJxSYXazjT1N60Gj7RltDnRc/DWGa05ZO7g4xPmpAYjOHSVoUs4zzqKNLKZB WeeErRDZ7WKvKsrfUG9wUw8lSpqvifnWrtZs9VpQvfk8ngdgeDzk+woRPllbyVCK7OHc G71Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=+bqt2DJTBIwNA4YUB3UD0Uqa0lFwB4F8gQo7oR65+qI=; b=kNp2mR77BZyCpcpbMA27VvohnUoHxKvsqmbWokoloxRFRqN6Ha5ScrcFl+dE8WXURf ur9FVFyltGzy0/YHiV++TyxzSHYH+XE/lAK3DixAOV6rMVSShiQ+z73S2WW+8XcE21SP /bIr9CrWJYZC8D5UJj9mWR7vFJQNyxOf9B9PX2mGKrSh2rknD20Bl826SbFKf2qXcpMC BvvpYxVWCT7zQJOlVJUaR94AnI8+4ItKSXrv0GsYc4jR9aqd0xI0qQg1pZ+5DgFWNeP7 fEcsNcOLptY4mg2eGYfahcmJlm27i+QAI2JxjtRFRABA7wwSF3BzesK+dZcG7ucfeRGq tV7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HXFkb3ca; dkim=neutral (no key) header.i=@linutronix.de; 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=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h184-20020a6383c1000000b00543c1b2a326si4128035pge.177.2023.06.12.08.53.48; Mon, 12 Jun 2023 08:54:02 -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=@linutronix.de header.s=2020 header.b=HXFkb3ca; dkim=neutral (no key) header.i=@linutronix.de; 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=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236365AbjFLP0e (ORCPT + 99 others); Mon, 12 Jun 2023 11:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236807AbjFLP0c (ORCPT ); Mon, 12 Jun 2023 11:26:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0653E57 for ; Mon, 12 Jun 2023 08:26:30 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686583589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+bqt2DJTBIwNA4YUB3UD0Uqa0lFwB4F8gQo7oR65+qI=; b=HXFkb3ca0s8WRAW4B4wWT7d9QsMnyQUm4g6c5YBISjuzcQjFOuh4QMidTE3rBlvLECtns+ nSXXTrbxmVuSeq/buyJSg1+Hnz/gwDiPEWMYuy2i7ZoF6k9bJsEHzncgA8GwWYQgY3jd4/ gwBg+CqYnRmFuIhBQXh8Ke26rwmO8oEck1PW2Dr5JQtZXItl+tKlZdRs16JfHyzJ5Y0KB1 hV3LVHb1wLlqb6DfAgG8G2P4HxndBf8Vh9LqOU1kzEv7h56UYZ6m0ilIkgqvc3PSbc7G7O nDdcnDarVIjVCgJsv5w9agrTexR5QWxCmrjXNyODIdmhFxHwpOhg3SmdXV8tKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686583589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+bqt2DJTBIwNA4YUB3UD0Uqa0lFwB4F8gQo7oR65+qI=; b=XUtHFu71MVEZaLAgGqPVrPHfWJDjNf7aRiIJgH4Cg1xZcLWc03Z6IHm1zhNQa1b3qbsMrQ Jc9VKMXU17VMaIBg== To: Borislav Petkov , X86 ML Cc: LKML Subject: Re: [PATCH 2/2] x86/microcode: Add a "microcode=" command line option In-Reply-To: <20230605141332.25948-2-bp@alien8.de> References: <20230605141332.25948-1-bp@alien8.de> <20230605141332.25948-2-bp@alien8.de> Date: Mon, 12 Jun 2023 17:26:28 +0200 Message-ID: <87ilbs7lcr.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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, Jun 05 2023 at 16:13, Borislav Petkov wrote: > From: "Borislav Petkov (AMD)" > > It will be used to control microcode loader behavior. Add the first > chicken bit: to control whether the AMD side should load microcode late > on all logical SMT threads. This has a distinct void of information here. Why is it suddenly required to prevent late loading on SMT threads? That's the exact opposite of what e7ad18d1169c ("x86/microcode/AMD: Apply the patch early on every logical thread") is doing. I'm seriously confused. > > + microcode= [X86] Control the behavior of the microcode > + loader. Available options: > + > + no_late_all - do not load on all SMT threads on > + AMD. Loading on all logical threads is enabled by > + default. no_late_all is a horrible option name. Also the explanation is not mentioning that this is only relevant for late loading. Aside of that why is this a kernel side chicken bit and not communicated by the microcode header? How should an administrator know which microcode versions need this treatment and which do not? How is that supposed to work on a fleet? > --- a/arch/x86/kernel/cpu/microcode/core.c > +++ b/arch/x86/kernel/cpu/microcode/core.c > @@ -40,11 +40,15 @@ > #include > #include > > +#include "internal.h" > + > #define DRIVER_VERSION "2.2" > > static struct microcode_ops *microcode_ops; > static bool dis_ucode_ldr = true; > > +unsigned long control = LATE_ALL_THREADS; global variable name without a proper prefix. Moo. > +static ssize_t control_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + return sprintf(buf, "0x%lx\n", control); > +} > + > +static ssize_t control_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + unsigned long val; > + > + if (kstrtoul(buf, 0, &val) < 0) > + return -ERANGE; > + > + if (val & CONTROL_FLAGS_MASK) > + return -EINVAL; > + > + control = val; > + > + return count; > +} Where is the documentation which tells me what I'm supposed to write into this file? Also this is a generic file, right? So what's the meaning for non AMD? I can write this bit into it successfully and nothing happens, right? > +++ b/arch/x86/kernel/cpu/microcode/internal.h > @@ -0,0 +1,16 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __X86_MICROCODE_INTERNAL_H__ > +#define __X86_MICROCODE_INTERNAL_H__ > + > +extern unsigned long control; > + > +/* Loader control flags. */ > +enum control_flags { > + __LATE_ALL_THREADS = 0, > + __CONTROL_FLAGS_NUM, > +}; > + > +#define LATE_ALL_THREADS BIT_ULL(__LATE_ALL_THREADS) > +#define CONTROL_FLAGS_MASK ~(BIT_ULL(__CONTROL_FLAGS_NUM) - 1) Why ULL bits for a unsigned long variable? Thanks, tglx