Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp581498imm; Wed, 25 Jul 2018 02:28:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcfRMxhmvwNXmHjPM9aoLNRYvWUiL/wk5AgsHeuu2tAlt8ht2xlX0ndbmCAGrgpsnj6IG2H X-Received: by 2002:a62:5486:: with SMTP id i128-v6mr21087670pfb.166.1532510927078; Wed, 25 Jul 2018 02:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532510927; cv=none; d=google.com; s=arc-20160816; b=eqwo23riZ1w610hMGRb4seal8vvfvfCcvMMCsjfMQh22Jc7qONcL6okAYS9YfeNOO5 AY0uegGhu7WVT7QIRYynqMFCmxJqSGIHAqLS7nkVTMvN/hhgRrGTwkReAgBBkrzeJyO/ mNI2LaOL3Iw86E8JcdBX1yNloXmhlGcxKNPpWwUwswoE8VoFVlWImEQ1bDWCsGwc9fRk PPz55bc79Pdv/Br/oHLfl05aNwunGxN4+OScJul5J2iPmsf8Mhsmv2VVhzQzOfCi3VJs 8jzBIU7XHYLPPKHOMno35D9WT5M3XsiZoys+5xoRMY7IXQo9F+OoVxp9b0AX0XoaHIN4 rJjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=PaLVbunzyxy37uLttWhTKJ8yQUctrbpogLwYMqooXfc=; b=lYVEHVavkZSx1Jvk/HlIRkYvwnAUelfi/eWjkj4yaZvnJy8uCG/pdHyAycvQIk3lvf DhaVXOSGllYpe4xbqrjMEbO/UvIe+du60qCAzqmpSNnbQHrLI8PNSq/JghNdhEdV2XkL ipZVvcNRNajIx3+qI1PDgmJ1pmoTZXMSPgb4XC/3HmCh5lzTi7XPFn2Qq7cR6H6NYeZT IUcRQrpcvmudcpOQmlqftB316Ky1L1L3scEV64ptAqqfD76K6pQpyKFKK9BVxVlLiqx1 S+3N66zUd8NGPznGqSPjJknyqghiMkdeHY90bEIRd496FqoNvCovyl413ZJ+Npv20iYX D4Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si13743287plk.97.2018.07.25.02.28.31; Wed, 25 Jul 2018 02:28:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728653AbeGYKif (ORCPT + 99 others); Wed, 25 Jul 2018 06:38:35 -0400 Received: from foss.arm.com ([217.140.101.70]:34854 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbeGYKif (ORCPT ); Wed, 25 Jul 2018 06:38:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 82C9480D; Wed, 25 Jul 2018 02:27:45 -0700 (PDT) Received: from [10.37.10.30] (unknown [10.37.10.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B4B7E3F237; Wed, 25 Jul 2018 02:27:43 -0700 (PDT) Subject: Re: [PATCH] arm64: Check for errata before evaluating cpu features To: Dave Martin Cc: Dirk Mueller , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Alex Graf References: <20180725083504.25836-1-dmueller@suse.com> <20180725085604.GB4240@e103592.cambridge.arm.com> From: Suzuki K Poulose Message-ID: <3d26391a-afbe-621e-90d0-80c4dbc4e2f6@arm.com> Date: Wed, 25 Jul 2018 10:28:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180725085604.GB4240@e103592.cambridge.arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dave, On 07/25/2018 09:56 AM, Dave Martin wrote: > On Wed, Jul 25, 2018 at 09:51:53AM +0100, Suzuki K Poulose wrote: >> On 07/25/2018 09:35 AM, Dirk Mueller wrote: >>> Since commit d3aec8a28be3b8 ("arm64: capabilities: Restrict KPTI >>> detection to boot-time CPUs") we rely on errata flags being already >>> populated during feature enumeration. The order of errata and >>> features was flipped as part of commit ed478b3f9e4a ("arm64: >>> capabilities: Group handling of features and errata workarounds"). >>> >>> Return to the orginal order of errata and feature evaluation to >>> ensure errata flags are present during feature evaluation. >>> >>> Fixes: d3aec8a28be3b8 ("arm64: capabilities: Restrict KPTI >>> detection to boot-time CPUs") >>> CC: Suzuki K Poulose >>> CC: Marc Zyngier >>> Signed-off-by: Dirk Mueller >> >> It would be good to add "Fixes: ed478b3f9e4a" (instead), just to make >> sure this gets fixed everywhere the original problem appears. >> > > I forget why these were originally reordered in ed478b3f9e4a. > Was there any real reason for it? No, there was no real reason for it. We have always detected the cpu local errata first and all features were system wide. So that ensured that the errata are detected before features. With the introduction of cpu local features, it was a random order until we realised this issue. That said, this exposes a problem with the current infrastructure where, if there are local capabilities that depend on other local capabilities. On a heterogeneous system, there is no guarantee on the order in which the CPUs turn up and thus detect the capabilities. In this case, this patch wouldn't work if we were dealing with a heterogeneous system. The solution would be to use cpu local and system wide versions of the same capability and use the cpu-local capabilities to decide the system capability. i.e, here KPTI needs two caps : a) CPU_NEEDS_KPTI - Local CPU capability to detect the local CPU which needs KPTRI b) SYSTEM_NEEDS_KPTI - System wide capability, which can be turned on iff we have CPU_NEEDS_KPTI && !CAVIUM_ERRATA. > > I also notice in that commit that after the detection pass, we set > things up (in update_cpu_capabilities(), enable_cpu_capabilities()) in > the order errata, features. Does this matter for anything? None that I am aware of. But logically that sounds like a better option. Suzuki