Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3281013imm; Fri, 25 May 2018 03:01:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrupSfWfNWjO3y367cZepoMnbsfkVFL4l+fwUOq4jNCPurAk8XvtYB6FGx2lY0QgyrDl7eH X-Received: by 2002:a62:4086:: with SMTP id f6-v6mr1850496pfd.194.1527242489344; Fri, 25 May 2018 03:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527242489; cv=none; d=google.com; s=arc-20160816; b=vvf4wbNA1f0YZZkVkg82/g6tJB4M8hEoCG9rGcExvFJde2w6nmg3sZOuDLUqlCCera s2ATDiVgxUQErQzVIQO1QsvKBMeAg6YUBh31uHfPxu4BBI8WAhwp6XTqvmIgg53tbA3w dGDCOalUtPTgs77o/SJmuAXHu6ZLkJVlHgc3kPv+Kln8/C/CwxVEVxwazoHgcDAWZsg6 2HReb7AUwsiYIKotbYEEVH/FnmBZZr/sdAlQ4oXtMs5B/gsOi1TaZl4Wl+08fTSsT3n5 jtcX60pAT1guW7BmujFxw5v1VjjVtdplyZ8n7X0rzrS7XJWyAKn18NWApPcYXqWLa1F8 +ZvQ== 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=P/ASBL0PbugyrSnAQtJpDR3GJC3vsq3CbP0UKAEWJkM=; b=xndPc0qswa9pSfkz5KvN5tgHjhdHBeAZ2MaDpXWh/0cuCQPJRPWRVMGNOnBfJ9NIig VyR8Xily2jsZvAqb9oKzqDE3IcCjWxFZJ6/a3M8aAKQfsF/MiaNfVru+N73ImZU7XWrO Uz9ufoJDm3uPMSbuRJQNdOnYjvAYnyYKfA6xnn1x+OVZYq/NqqmRHxkeie9Xd3VVhD29 w2Z5LnTLZuyqFUPujOOpm8Mft+ktkag4RixxzHmD9WVMpBrDPYHBcSBtuCmmY17Eoom8 RPJEvbdgzaMDP79JcDW1xeukF3sA/PrxbP0pr6f3kitZ4fSbICv3t/hE0OAS89zwafNi imuQ== 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 s13-v6si22441865plq.464.2018.05.25.03.01.14; Fri, 25 May 2018 03:01:29 -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 S965539AbeEYKBD (ORCPT + 99 others); Fri, 25 May 2018 06:01:03 -0400 Received: from foss.arm.com ([217.140.101.70]:58158 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965291AbeEYKBC (ORCPT ); Fri, 25 May 2018 06:01:02 -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 69DA580D; Fri, 25 May 2018 03:01:02 -0700 (PDT) Received: from [10.1.206.73] (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C3B13F25D; Fri, 25 May 2018 03:01:00 -0700 (PDT) Subject: Re: [PATCH v4 04/26] arm64: alternative: Apply alternatives early in boot process To: Julien Thierry , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, mark.rutland@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Christoffer Dall References: <1527241772-48007-1-git-send-email-julien.thierry@arm.com> <1527241772-48007-5-git-send-email-julien.thierry@arm.com> From: Suzuki K Poulose Message-ID: <89769f8d-2ed0-1eb7-0373-09fc25f8071a@arm.com> Date: Fri, 25 May 2018 11:00:58 +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: <1527241772-48007-5-git-send-email-julien.thierry@arm.com> Content-Type: text/plain; charset=us-ascii; 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 On 25/05/18 10:49, Julien Thierry wrote: > From: Daniel Thompson > > Currently alternatives are applied very late in the boot process (and > a long time after we enable scheduling). Some alternative sequences, > such as those that alter the way CPU context is stored, must be applied > much earlier in the boot sequence. > > Introduce apply_boot_alternatives() to allow some alternatives to be > applied immediately after we detect the CPU features of the boot CPU. > > Signed-off-by: Daniel Thompson > [julien.thierry@arm.com: rename to fit new cpufeature framework better, > apply BOOT_SCOPE feature early in boot] > Signed-off-by: Julien Thierry > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Christoffer Dall > Cc: Suzuki K Poulose > --- > arch/arm64/include/asm/alternative.h | 3 +-- > arch/arm64/include/asm/cpufeature.h | 2 ++ > arch/arm64/kernel/alternative.c | 30 +++++++++++++++++++++++++++--- > arch/arm64/kernel/cpufeature.c | 5 +++++ > arch/arm64/kernel/smp.c | 7 +++++++ > 5 files changed, 42 insertions(+), 5 deletions(-) > ... > > +unsigned long boot_capabilities; > + > /* > * Flag to indicate if we have computed the system wide > * capabilities based on the boot time active CPUs. This > @@ -1370,6 +1372,9 @@ static void __update_cpu_capabilities(const struct arm64_cpu_capabilities *caps, > if (!cpus_have_cap(caps->capability) && caps->desc) > pr_info("%s %s\n", info, caps->desc); > cpus_set_cap(caps->capability); > + > + if (scope_mask & SCOPE_BOOT_CPU) > + __set_bit(caps->capability, &boot_capabilities); Julien I think this check is problematic. The scope_mask passed on by the boot CPU is (SCOPE_BOOT_CPU | SCOPE_LOCAL_CPU) to cover both BOOT CPU capabilities *and* CPU local capabilites on the boot CPU. So, you might apply the alternatives for a "local" CPU erratum, which is not intended. You may change the above check to : if (caps->type & SCOPE_BOOT_CPU) to make sure you check the "capability" has the SCOPE_BOOT_CPU set. Suzuki