All of lore.kernel.org
 help / color / mirror / Atom feed
From: santosh.shilimkar@ti.com (Santosh Shilimkar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] ARM: mm: fix __phys_to_virt to work with 64 bit phys_addr_t in BE case
Date: Tue, 5 Nov 2013 09:46:41 -0500	[thread overview]
Message-ID: <527904D1.6000007@ti.com> (raw)
In-Reply-To: <1383617765-28052-3-git-send-email-victor.kamensky@linaro.org>

On Monday 04 November 2013 09:16 PM, Victor Kamensky wrote:
> Make sure that inline assembler that expects 'r' operand
> receives 32 bit value.
> 
> Before this fix in case of CONFIG_ARCH_PHYS_ADDR_T_64BIT and
> CONFIG_ARM_PATCH_PHYS_VIRT __phys_to_virt function passed 64 bit
> value to __pv_stub inline assembler where 'r' operand is
> expected. Compiler behavior in such case is not well specified.
> It worked in little endian case, but in big endian case
> incorrect code was generated, where compiler confused which
> part of 64 bit value it needed to modify. For example BE
> snippet looked like this:
> 
> N:0x80904E08 : MOV      r2,#0
> N:0x80904E0C : SUB      r2,r2,#0x81000000
> 
> when LE similar code looked like this
> 
> N:0x808FCE2C : MOV      r2,r0
> N:0x808FCE30 : SUB      r2,r2,#0xc0, 8 ; #0xc0000000
> 
> Note 'r0' register is va that have to be translated into phys
> 
> To avoid this situation use explicit cast to 'unsigned long',
> which explicitly discard upper part of phys address and convert
> value to 32 bit. Also add comment so such cast will not be
> removed in the future.
> 
> Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
> ---
>  arch/arm/include/asm/memory.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 4dd2145..7a8599c 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -226,7 +226,13 @@ static inline phys_addr_t __virt_to_phys(unsigned long x)
>  static inline unsigned long __phys_to_virt(phys_addr_t x)
>  {
>  	unsigned long t;
> -	__pv_stub(x, t, "sub", __PV_BITS_31_24);
Minor nit. An extra line would be good here for a comment to follow.
> +        /*
> +         * 'unsigned long' cast discard upper word when
> +         * phys_addr_t is 64 bit, and makes sure that inline
> +         * assembler expression receives 32 bit argument
> +         * in place where 'r' 32 bit operand is expected.
> +         */
> +	__pv_stub((unsigned long) x, t, "sub", __PV_BITS_31_24);
>  	return t;
>  }
>  
> 
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

  reply	other threads:[~2013-11-05 14:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05  2:16 [PATCH 0/3] follow up fixes for V7 big endian changes Victor Kamensky
2013-11-05  2:16 ` [PATCH 1/3] ARM: __fixup_smp read of SCU config should do byteswap in BE case Victor Kamensky
2013-11-05 14:45   ` Santosh Shilimkar
2013-11-05  2:16 ` [PATCH 2/3] ARM: mm: fix __phys_to_virt to work with 64 bit phys_addr_t " Victor Kamensky
2013-11-05 14:46   ` Santosh Shilimkar [this message]
2013-11-05 15:17   ` Russell King - ARM Linux
2013-11-05  2:16 ` [PATCH 3/3] ARM: fix mov to mvn conversion in case of 64 bit phys_addr_t and BE Victor Kamensky
2013-11-05 10:53   ` Sricharan R
2013-11-05 14:47   ` Santosh Shilimkar
2013-11-05 15:20 ` [PATCH 0/3] follow up fixes for V7 big endian changes Russell King - ARM Linux
2013-11-06  7:37   ` Victor Kamensky

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=527904D1.6000007@ti.com \
    --to=santosh.shilimkar@ti.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.