Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2380910pxf; Sat, 20 Mar 2021 13:59:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj7DEbz1l041CTXPC2SFhmIRvqqBxc+kedIDfVwY3YHQETV8CyfK0RSTdF6GWMzUk6eDKE X-Received: by 2002:a17:906:5a8f:: with SMTP id l15mr11410705ejq.462.1616273940774; Sat, 20 Mar 2021 13:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616273940; cv=none; d=google.com; s=arc-20160816; b=Ht89XGxLdrvPMWvwJbFEXHBbCS34lGUyxJsODb4nkB6NZT0te61T5IDSjuFv+t2qSX 5kSLyR+g41nFNS2xpy9lO9mDpPd+cQUHL6Y1Vg6dnrtkcxnKS+CvlW+hNj+KWTBIsDqM WNhjYbh3DR2Pm6O9kijdlTi+WzcT3ThFgancmtyDVMCoUXleYO/Hl6rAwO24VpLN+7Cl BSVX+7jGSriWJsqQPt/MGfwJty2fhkfeQte/olivIHxbqAKXLZQTbsHmhpZWXt33O1H1 kGv/PuG+BTmE9PjKJLx4JWBRHZxrGnJ9Xi4GYEZicqKV+0ZIdjT5ME2LYmEjSCJuWMz+ 8iUA== 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=spUFCRG29h9RVqTvgsvEoyAUjRhPPLoLtv+oFUv0LF0=; b=jCL9LILwEP8qK5aSEgmxQnX6v/SBteHygLfoJT/9NVzeCyJ3fyHzsbRXhlnAneXvQz oSIVcnOdVZLbkzqT2NJVogNlWVsmPOqxtvXhmUqjLFhTA/Ldp6evjf6e2kvn2AwncmPS u6qraoC0bAW9UxEDstLcTXbY7PyJNwmAWRqAzZo73tJ0gJdIlGma/jjjb/Abx9kbmPYv xqS5dTZnfw4lQgYNtEi8hu/UVpw69C/FP3KfwlYahkt0hRcRW6rPSKL63wd1g3yo+QSA rj0FzoanOuQcFZbJGuqhZc9rgjlZemEhVEg8EWVgTmkGIB3qFEOF149rWvt09t7PnA8W 3VqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="nCwDQB/j"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si7783492ejr.208.2021.03.20.13.58.38; Sat, 20 Mar 2021 13:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="nCwDQB/j"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229840AbhCTU43 (ORCPT + 99 others); Sat, 20 Mar 2021 16:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbhCTU4J (ORCPT ); Sat, 20 Mar 2021 16:56:09 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2059C061574; Sat, 20 Mar 2021 13:56:07 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1616273765; 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=spUFCRG29h9RVqTvgsvEoyAUjRhPPLoLtv+oFUv0LF0=; b=nCwDQB/jV3yR4x0OOWDTAYdDKYZ0AardGg3IZvXQxhRR/HF39Ty9/lxv+wr3QHCQPjZTjS aUaxGxANNfs/DJDEw/kHwg9TwzQ/P+x/yU+4qFaxHUPtdiFcRA4Jx03Q1LN2hRDZN7KHtt bGjn1ziPQIBPX5S2CAzE+41lT4EuId0KW85AtOdsDP626xmzL5XRzM7NUuudowYF2y5GV7 F/vT0fVAFJiowedePWSqzwqaEqbIlmtUln3cVIOO+USMoYfzfkzpVw0Y7R06DGE1R8J3Jr PBM3bwn95Z45/u5DJm0R/kGg71BFw+sYmvVXWW0xulQh34UiOxBFtTfIJp/mUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1616273765; 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=spUFCRG29h9RVqTvgsvEoyAUjRhPPLoLtv+oFUv0LF0=; b=E8W6m/skpkxgBZ4Pka4xkdMkeW6S631dx0CDwBDYcrP3kPLPcSaqW2xkXgdJhRyp1x7OzQ SWCNCKabqcNzPFCg== To: "Chang S. Bae" , bp@suse.de, luto@kernel.org, mingo@kernel.org, x86@kernel.org Cc: len.brown@intel.com, dave.hansen@intel.com, jing2.liu@intel.com, ravi.v.shankar@intel.com, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com, linux-doc@vger.kernel.org Subject: Re: [PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support In-Reply-To: <20210221185637.19281-23-chang.seok.bae@intel.com> References: <20210221185637.19281-1-chang.seok.bae@intel.com> <20210221185637.19281-23-chang.seok.bae@intel.com> Date: Sat, 20 Mar 2021 21:56:04 +0100 Message-ID: <871rc9bl3v.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 21 2021 at 10:56, Chang S. Bae wrote: > "xstate.disable=0x60000" will disable AMX on a system that has AMX compiled > into XFEATURE_MASK_USER_ENABLED. > > "xstate.enable=0x60000" will enable AMX on a system that does NOT have AMX > compiled into XFEATURE_MASK_USER_ENABLED (assuming the kernel is new enough > to support this feature). This makes no sense at all. > Rename XFEATURE_MASK_USER_SUPPORTED to XFEATURE_MASK_USER_ENABLED to be > aligned with the new parameters. > > While this cmdline is currently enabled only for AMX, it is intended to be > easily enabled to be useful for future XSAVE-enabled features. I have a hard time to map this changelog to the actual code. > +/* All currently enabled user features */ > +#define XFEATURE_MASK_USER_ENABLED (XFEATURE_MASK_FP | \ > + XFEATURE_MASK_SSE | \ > + XFEATURE_MASK_YMM | \ > + XFEATURE_MASK_OPMASK | \ > + XFEATURE_MASK_ZMM_Hi256 | \ > + XFEATURE_MASK_Hi16_ZMM | \ > + XFEATURE_MASK_PKRU | \ > + XFEATURE_MASK_BNDREGS | \ > + XFEATURE_MASK_BNDCSR | \ > + XFEATURE_MASK_XTILE) > + > +static u64 xstate_enable; > +static u64 xstate_disable; This needs to be kept around forever because it's used where outside of __init code? > u64 __init fpu__get_supported_xfeatures_mask(void) > { > - u64 mask = XFEATURE_MASK_USER_SUPPORTED | XFEATURE_MASK_SUPERVISOR_SUPPORTED; > - > - if (!IS_ENABLED(CONFIG_X86_64)) > - mask &= ~(XFEATURE_MASK_XTILE); > + u64 mask = XFEATURE_MASK_USER_ENABLED | XFEATURE_MASK_SUPERVISOR_SUPPORTED; > + > + if (!IS_ENABLED(CONFIG_X86_64)) { > + mask &= ~(XFEATURE_MASK_XTILE); > + } else if (xstate_enable || xstate_disable) { > + u64 custom = mask; > + u64 unknown; > + > + custom |= xstate_enable; > + custom &= ~xstate_disable; > + > + unknown = custom & ~mask; > + if (unknown) { > + /* > + * User should fully understand the result of using undocumented > + * xstate component. > + */ What is to understand here? Absolutely nothing. This has been tried to be smuggled into the kernel ever so often and it's again in something which claims to do something else and the changelog is silent about it. The argument 'it allows easier testing of new features' is absolutely not true simply because the rest of the kernel knows absolutely nothing about the feature and stuff would go south anyway. We won't enable features which are unknown ever. Keep that presilicon test gunk where it belongs: In the Intel poison cabinet along with the rest of the code which nobody ever want's to see. > + } > + > + if ((custom & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE) { > + pr_warn("x86/fpu: Error in xstate.disable. Additionally disabling 0x%x components.\n", > + XFEATURE_MASK_XTILE); What? If the user added: xstate.disable=0x60000 to the command line, then the code above: > + custom &= ~xstate_disable; has cleared XFEATURE_MASK_XTILE in custom which makes that check true, the warning emitted and then > + custom &= ~(XFEATURE_MASK_XTILE); this part clears out XFEATURE_MASK_XTILE once more. > + } What the heck. > +/* > + * Longest parameter of 'xstate.enable=' is 22 octal number characters with '0' prefix and > + * an extra '\0' for termination. > + */ > +#define MAX_XSTATE_MASK_CHARS 24 > +/* > + * We parse xstate parameters early because fpu__init_system() is executed before > + * parse_early_param(). > + */ > +static void __init fpu__init_parse_early_param(void) > +{ > + char arg[MAX_XSTATE_MASK_CHARS]; > + > + if (cmdline_find_option(boot_command_line, "xstate.enable", arg, sizeof(arg)) && > + !kstrtoull(arg, 0, &xstate_enable)) > + xstate_enable &= XFEATURE_MASK_CONFIGURABLE; This enable thing is not going to happen. > + if (cmdline_find_option(boot_command_line, "xstate.disable", arg, sizeof(arg)) && > + !kstrtoull(arg, 0, &xstate_disable)) > + xstate_disable &= XFEATURE_MASK_CONFIGURABLE; > +} > + This parser needs to be called for X86_32 because? Thanks, tglx