All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v2 3/7] arm64: alternative: Apply alternatives early in boot process
Date: Wed, 16 Sep 2015 14:05:49 +0100	[thread overview]
Message-ID: <20150916130549.GJ28771@arm.com> (raw)
In-Reply-To: <1442237181-17064-4-git-send-email-daniel.thompson@linaro.org>

On Mon, Sep 14, 2015 at 02:26:17PM +0100, Daniel Thompson wrote:
> 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_alternatives_early() to allow some alternatives to be
> applied immediately after we detect the CPU features of the boot CPU.
> 
> Currently apply_alternatives_all() is not optimized and will re-patch
> code that has already been updated. This is harmless but could be
> removed by adding extra flags to the alternatives store.
> 
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
>  arch/arm64/include/asm/alternative.h |  1 +
>  arch/arm64/kernel/alternative.c      | 15 +++++++++++++++
>  arch/arm64/kernel/setup.c            |  7 +++++++
>  3 files changed, 23 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index d56ec0715157..f9dad1b7c651 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -17,6 +17,7 @@ struct alt_instr {
>  	u8  alt_len;		/* size of new instruction(s), <= orig_len */
>  };
>  
> +void __init apply_alternatives_early(void);
>  void __init apply_alternatives_all(void);
>  void apply_alternatives(void *start, size_t length);
>  void free_alternatives_memory(void);
> diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
> index ab9db0e9818c..59989a4bed7c 100644
> --- a/arch/arm64/kernel/alternative.c
> +++ b/arch/arm64/kernel/alternative.c
> @@ -117,6 +117,21 @@ static void __apply_alternatives(void *alt_region)
>  }
>  
>  /*
> + * This is called very early in the boot process (directly after we run
> + * a feature detect on the boot CPU). No need to worry about other CPUs
> + * here.
> + */
> +void apply_alternatives_early(void)
> +{
> +	struct alt_region region = {
> +		.begin	= __alt_instructions,
> +		.end	= __alt_instructions_end,
> +	};
> +
> +	__apply_alternatives(&region);
> +}

How do you choose which alternatives are applied early and which are
applied later? AFAICT, this just applies everything before we've
established the capabilities of the CPUs in the system, which could cause
problems for big/little SoCs.

Also, why do we need this for the NMI?

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Daniel Thompson <daniel.thompson@linaro.org>
Cc: "linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"patches@linaro.org" <patches@linaro.org>,
	"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
	John Stultz <john.stultz@linaro.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Marc Zyngier <Marc.Zyngier@arm.com>,
	Andrew Thoelke <Andrew.Thoelke@arm.com>,
	Dave P Martin <Dave.Martin@arm.com>
Subject: Re: [RFC PATCH v2 3/7] arm64: alternative: Apply alternatives early in boot process
Date: Wed, 16 Sep 2015 14:05:49 +0100	[thread overview]
Message-ID: <20150916130549.GJ28771@arm.com> (raw)
In-Reply-To: <1442237181-17064-4-git-send-email-daniel.thompson@linaro.org>

On Mon, Sep 14, 2015 at 02:26:17PM +0100, Daniel Thompson wrote:
> 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_alternatives_early() to allow some alternatives to be
> applied immediately after we detect the CPU features of the boot CPU.
> 
> Currently apply_alternatives_all() is not optimized and will re-patch
> code that has already been updated. This is harmless but could be
> removed by adding extra flags to the alternatives store.
> 
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
>  arch/arm64/include/asm/alternative.h |  1 +
>  arch/arm64/kernel/alternative.c      | 15 +++++++++++++++
>  arch/arm64/kernel/setup.c            |  7 +++++++
>  3 files changed, 23 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index d56ec0715157..f9dad1b7c651 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -17,6 +17,7 @@ struct alt_instr {
>  	u8  alt_len;		/* size of new instruction(s), <= orig_len */
>  };
>  
> +void __init apply_alternatives_early(void);
>  void __init apply_alternatives_all(void);
>  void apply_alternatives(void *start, size_t length);
>  void free_alternatives_memory(void);
> diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
> index ab9db0e9818c..59989a4bed7c 100644
> --- a/arch/arm64/kernel/alternative.c
> +++ b/arch/arm64/kernel/alternative.c
> @@ -117,6 +117,21 @@ static void __apply_alternatives(void *alt_region)
>  }
>  
>  /*
> + * This is called very early in the boot process (directly after we run
> + * a feature detect on the boot CPU). No need to worry about other CPUs
> + * here.
> + */
> +void apply_alternatives_early(void)
> +{
> +	struct alt_region region = {
> +		.begin	= __alt_instructions,
> +		.end	= __alt_instructions_end,
> +	};
> +
> +	__apply_alternatives(&region);
> +}

How do you choose which alternatives are applied early and which are
applied later? AFAICT, this just applies everything before we've
established the capabilities of the CPUs in the system, which could cause
problems for big/little SoCs.

Also, why do we need this for the NMI?

Will

  reply	other threads:[~2015-09-16 13:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 13:26 [RFC PATCH v2 0/7] Pseudo-NMI for arm64 using ICC_PMR_EL1 (GICv3) Daniel Thompson
2015-09-14 13:26 ` Daniel Thompson
2015-09-14 13:26 ` [RFC PATCH v2 1/7] irqchip: gic-v3: Reset BPR during initialization Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-14 13:26 ` [RFC PATCH v2 2/7] arm64: Add support for on-demand backtrace of other CPUs Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-14 13:26 ` [RFC PATCH v2 3/7] arm64: alternative: Apply alternatives early in boot process Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-16 13:05   ` Will Deacon [this message]
2015-09-16 13:05     ` Will Deacon
2015-09-16 15:51     ` Daniel Thompson
2015-09-16 15:51       ` Daniel Thompson
2015-09-16 16:24       ` Will Deacon
2015-09-16 16:24         ` Will Deacon
2015-09-17 13:25         ` Daniel Thompson
2015-09-17 13:25           ` Daniel Thompson
2015-09-17 14:01           ` Will Deacon
2015-09-17 14:01             ` Will Deacon
2015-09-17 15:28             ` Daniel Thompson
2015-09-17 15:28               ` Daniel Thompson
2015-09-17 15:43               ` Will Deacon
2015-09-17 15:43                 ` Will Deacon
2015-09-14 13:26 ` [RFC PATCH v2 4/7] arm64: irqflags: Reorder the fiq & async macros Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-14 13:26 ` [RFC PATCH v2 5/7] arm64: irqflags: Use ICC sysregs to implement IRQ masking Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-14 13:26 ` [RFC PATCH v2 6/7] arm64: Implement IPI_CPU_BACKTRACE using pseudo-NMIs Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-14 13:26 ` [RFC PATCH v2 7/7] arm64: irqflags: Automatically identify I bit mis-management Daniel Thompson
2015-09-14 13:26   ` Daniel Thompson
2015-09-18  5:11 ` [RFC PATCH v2 0/7] Pseudo-NMI for arm64 using ICC_PMR_EL1 (GICv3) Jon Masters
2015-09-18  5:11   ` Jon Masters
2015-09-18 11:23   ` Daniel Thompson
2015-09-18 11:23     ` Daniel Thompson
2015-09-22 18:08     ` 答复: " Dingtianhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150916130549.GJ28771@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.