All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] arm: virt: ensure visibility of __boot_cpu_mode
Date: Tue, 9 Jul 2013 17:32:18 +0100	[thread overview]
Message-ID: <20130709163217.GC2911@localhost.localdomain> (raw)
In-Reply-To: <1373379366-15689-3-git-send-email-mark.rutland@arm.com>

On Tue, Jul 09, 2013 at 03:16:05PM +0100, Mark Rutland wrote:
> Secondary CPUs write to __boot_cpu_mode with caches disabled, and thus a
> cached value of __boot_cpu_mode may be incoherent with that in memory.
> This could lead to a failure to detect mismatched boot modes.
> 
> This patch adds flushing to ensure that writes by secondaries to
> __boot_cpu_mode are made visible before we test against it.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Dave Martin <dave.martin@arm.com>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Christoffer Dall <cdall@cs.columbia.edu>

Acked-by: Dave Martin <Dave.Martin@arm.com>

> ---
>  arch/arm/include/asm/virt.h | 12 ++++++++++++
>  arch/arm/kernel/setup.c     |  2 ++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/arch/arm/include/asm/virt.h b/arch/arm/include/asm/virt.h
> index 50af92b..4371f45 100644
> --- a/arch/arm/include/asm/virt.h
> +++ b/arch/arm/include/asm/virt.h
> @@ -29,6 +29,7 @@
>  #define BOOT_CPU_MODE_MISMATCH	PSR_N_BIT
>  
>  #ifndef __ASSEMBLY__
> +#include <asm/cacheflush.h>
>  
>  #ifdef CONFIG_ARM_VIRT_EXT
>  /*
> @@ -41,10 +42,21 @@
>   */
>  extern int __boot_cpu_mode;
>  
> +static inline void sync_boot_mode(void)
> +{
> +	/*
> +	 * As secondaries write to __boot_cpu_mode with caches disabled, we
> +	 * must flush the corresponding cache entries to ensure the visibility
> +	 * of their writes.
> +	 */
> +	sync_cache_r(&__boot_cpu_mode);
> +}
> +
>  void __hyp_set_vectors(unsigned long phys_vector_base);
>  unsigned long __hyp_get_vectors(void);
>  #else
>  #define __boot_cpu_mode	(SVC_MODE)
> +#define sync_boot_mode()
>  #endif
>  
>  #ifndef ZIMAGE
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> index b4b1d39..4af9b38 100644
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -744,6 +744,8 @@ static int __init meminfo_cmp(const void *_a, const void *_b)
>  void __init hyp_mode_check(void)
>  {
>  #ifdef CONFIG_ARM_VIRT_EXT
> +	sync_boot_mode();
> +
>  	if (is_hyp_mode_available()) {
>  		pr_info("CPU: All CPU(s) started in HYP mode.\n");
>  		pr_info("CPU: Virtualization extensions available.\n");
> -- 
> 1.8.1.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2013-07-09 16:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 14:16 [PATCH 0/3] arm/arm64: a trio of boot mode detection fixes Mark Rutland
2013-07-09 14:16 ` [PATCH 1/3] arm: hyp: fix macro parameterisation Mark Rutland
2013-07-09 16:29   ` Dave Martin
2013-07-09 14:16 ` [PATCH 2/3] arm: virt: ensure visibility of __boot_cpu_mode Mark Rutland
2013-07-09 16:32   ` Dave Martin [this message]
2013-07-09 14:16 ` [PATCH 3/3] arm64: " Mark Rutland
2013-07-18 15:26 ` [PATCH 0/3] arm/arm64: a trio of boot mode detection fixes Marc Zyngier
2013-07-18 16:25   ` Mark Rutland
2013-07-23 10:01     ` Catalin Marinas

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=20130709163217.GC2911@localhost.localdomain \
    --to=dave.martin@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.