From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FFE6C433DB for ; Fri, 26 Mar 2021 10:58:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DD2E61A1E for ; Fri, 26 Mar 2021 10:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DD2E61A1E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:Cc:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m1acH4XAwfIrCZgQn6oyiVLF6rVP2CSykvQfqMqHnbs=; b=UAVpS9x3okD7RGn142dwqmkdB XlA1yAagUW2+ew+DnyKXoOyK3vNXV6ARhschN0HeusT3QgH81fEKg8HHHPwM5ZTRCNyg7HH5w3seq viFB9LFmRsVj/v4QWjN6VtqKbqXA7xVtbOqHtJKarzdgsvKHl0nTVLipL/K3QDdyyJbiV0O+jQero J5HD3ZX2yveTtDI1bg6sJt0VGJY7NH8mtIHxvSPIvE5/4Djvd5T/Yh48LY3ifnVNlWHTxSY41hHh+ N2xplzEZjvk6cB+TnC6KWgdQxx3I4x3fcXhIjSAr+eJl0NozpS8l/txB4gAYIhzvXaCYZnoCAghBe 7m2SgBtnw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPk8p-003MGJ-OZ; Fri, 26 Mar 2021 10:56:35 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lPk8l-003MEn-6L for linux-arm-kernel@lists.infradead.org; Fri, 26 Mar 2021 10:56:33 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2E2E619C9; Fri, 26 Mar 2021 10:56:26 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lPk8e-003xna-EX; Fri, 26 Mar 2021 10:56:24 +0000 Date: Fri, 26 Mar 2021 10:56:23 +0000 Message-ID: <87tuoyfajs.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Hector Martin , Arnd Bergmann , Mark Rutland , Catalin Marinas , kernel-team@android.com Subject: Re: [PATCH 1/2] arm64: cpufeature: Allow early filtering of feature override In-Reply-To: <20210325192759.GA16123@willie-the-truck> References: <20210325124721.941182-1-maz@kernel.org> <20210325124721.941182-2-maz@kernel.org> <20210325192759.GA16123@willie-the-truck> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: will@kernel.org, linux-arm-kernel@lists.infradead.org, marcan@marcan.st, arnd@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210326_105631_621404_824096D9 X-CRM114-Status: GOOD ( 30.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 25 Mar 2021 19:27:59 +0000, Will Deacon wrote: > > On Thu, Mar 25, 2021 at 12:47:20PM +0000, Marc Zyngier wrote: > > Some CPUs are broken enough that some overrides need to be rejected > > at the earliest opportunity. In some cases, that's right at cpu > > feature override time. > > > > Provide the necessary infrastructure to filter out overrides, > > and to report such filtered out overrides to the core cpufeature code. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kernel/cpufeature.c | 6 ++++++ > > arch/arm64/kernel/idreg-override.c | 13 +++++++++++++ > > 2 files changed, 19 insertions(+) > > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > index 066030717a4c..6de15deaa912 100644 > > --- a/arch/arm64/kernel/cpufeature.c > > +++ b/arch/arm64/kernel/cpufeature.c > > @@ -809,6 +809,12 @@ static void __init init_cpu_ftr_reg(u32 sys_reg, u64 new) > > reg->name, > > ftrp->shift + ftrp->width - 1, > > ftrp->shift, str, tmp); > > + } else if ((ftr_mask & reg->override->val) == ftr_mask) { > > This seems to rely on 'val == mask' being invalid, but I'm not sure why > that's generally true. This is really 'ovr->val == mask && ovr->mask != mask', thanks to being on the 'else' branch. The encoding rules of val/mask are, for a given field: - no override set: mask = 0, val = 0 - valid override set: mask = 0xf, val = (override value) - invalid override set: mask = 0, val = 0xf I don't see where the ambiguity could be (though the above could figure in a comment to make things clearer). > Can we just invoke the filter function again here to figure out if > the field has been ignored? Then in match_options, we can just clear > the override val/mask to zero. The filter function isn't available outside of idreg-override.c: that's where the per-field override structures are defined, and I'd rather not expose that to the rest of the kernel. Also, calling the filter implies that you parse the whole command-line again, and you get into a real mess because the invalid override can come from the expansion of an alias (e.g. 'kvm-arm.mode=nvhe'). Seems totally overkill to me. If, for some reason that I can't see at the moment, we need an extra u64 to communicate that there is an invalid option, we can add that to the override structure. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel