public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@snapgear.com>
To: David Howells <dhowells@redhat.com>
Cc: <paul.gortmaker@windriver.com>, <hpa@zytor.com>,
	<torvalds@linux-foundation.org>, <linux-kernel@vger.kernel.org>,
	<linux-arch@vger.kernel.org>, <arnd@arndb.de>,
	<linux-m68k@vger.kernel.org>
Subject: Re: [PATCH 13/35] Disintegrate asm/system.h for M68K [ver #2]
Date: Mon, 19 Mar 2012 12:24:01 +1000	[thread overview]
Message-ID: <4F6698C1.3070105@snapgear.com> (raw)
In-Reply-To: <17434.1331905343@redhat.com>

Hi David,

On 16/03/12 23:42, David Howells wrote:
> How about if I insert the attached patch prior?

Yep, that fixes it. Builds on its own, and with the asm/system.h
disintegration patch applied (and rejects fixed) as well.

Regards
Greg



> ---
> From: David Howells<dhowells@redhat.com>
>
> m68k: Fix xchg/cmpxchg to fail to link if given an inappropriate pointer
>
> Fix the m68k versions of xchg() and cmpxchg() to fail to link if given an
> inappropriately sized pointer rather than BUG()'ing at runtime.
>
> Signed-off-by: David Howells<dhowells@redhat.com>
> ---
>
>   arch/m68k/include/asm/system.h |   20 ++++++++++++++++----
>   1 files changed, 16 insertions(+), 4 deletions(-)
>
>
> diff --git a/arch/m68k/include/asm/system.h b/arch/m68k/include/asm/system.h
> index 47b01f4..a10c4d1 100644
> --- a/arch/m68k/include/asm/system.h
> +++ b/arch/m68k/include/asm/system.h
> @@ -68,6 +68,8 @@ asmlinkage void resume(void);
>   struct __xchg_dummy { unsigned long a[100]; };
>   #define __xg(x) ((volatile struct __xchg_dummy *)(x))
>
> +extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);
> +
>   #ifndef CONFIG_RMW_INSNS
>   static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
>   {
> @@ -92,7 +94,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
>   		x = tmp;
>   		break;
>   	default:
> -		BUG();
> +		tmp = __invalid_xchg_size(x, ptr, size);
> +		break;
>   	}
>
>   	local_irq_restore(flags);
> @@ -102,7 +105,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
>   static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
>   {
>   	switch (size) {
> -	    case 1:
> +	case 1:
>   		__asm__ __volatile__
>   			("moveb %2,%0\n\t"
>   			 "1:\n\t"
> @@ -110,7 +113,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
>   			 "jne 1b"
>   			 : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
>   		break;
> -	    case 2:
> +	case 2:
>   		__asm__ __volatile__
>   			("movew %2,%0\n\t"
>   			 "1:\n\t"
> @@ -118,7 +121,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
>   			 "jne 1b"
>   			 : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
>   		break;
> -	    case 4:
> +	case 4:
>   		__asm__ __volatile__
>   			("movel %2,%0\n\t"
>   			 "1:\n\t"
> @@ -126,6 +129,9 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
>   			 "jne 1b"
>   			 : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
>   		break;
> +	default:
> +		x = __invalid_xchg_size(x, ptr, size);
> +		break;
>   	}
>   	return x;
>   }
> @@ -135,6 +141,9 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
>
>   #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
>
> +extern unsigned long __invalid_cmpxchg_size(volatile void *,
> +					    unsigned long, unsigned long, int);
> +
>   /*
>    * Atomic compare and exchange.  Compare OLD with MEM, if identical,
>    * store NEW in MEM.  Return the initial value in MEM.  Success is
> @@ -162,6 +171,9 @@ static inline unsigned long __cmpxchg(volatile void *p, unsigned long old,
>   				      : "=d" (old), "=m" (*(int *)p)
>   				      : "d" (new), "0" (old), "m" (*(int *)p));
>   		break;
> +	default:
> +		old = __invalid_cmpxchg_size(p, old, new, size);
> +		break;
>   	}
>   	return old;
>   }
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

  reply	other threads:[~2012-03-19  2:26 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12 23:36 [RFC][PATCH 00/35] Disintegrate and kill asm/system.h [ver #2] David Howells
2012-03-12 23:36 ` [PATCH 01/35] Disintegrate asm/system.h for X86 " David Howells
2012-03-12 23:36 ` [PATCH 02/35] Disintegrate asm/system.h for Alpha " David Howells
2012-03-12 23:36 ` [PATCH 03/35] Disintegrate asm/system.h for ARM " David Howells
2012-03-12 23:36 ` [PATCH 04/35] Disintegrate asm/system.h for AVR32 " David Howells
2012-03-12 23:36 ` [PATCH 05/35] Disintegrate asm/system.h for Blackfin " David Howells
2012-03-13  4:44   ` Bob Liu
2012-03-12 23:37 ` [PATCH 06/35] Disintegrate asm/system.h for C6X " David Howells
2012-03-14 12:29   ` Mark Salter
2012-03-14 13:29     ` [Linux-c6x-dev] " Jacquiot, Aurelien
2012-03-14 13:39       ` Mark Salter
2012-03-15 17:41       ` David Howells
2012-03-15 17:41     ` David Howells
2012-03-12 23:37 ` [PATCH 07/35] Disintegrate asm/system.h for CRIS " David Howells
2012-03-13  9:16   ` Jesper Nilsson
2012-03-12 23:37 ` [PATCH 08/35] Disintegrate asm/system.h for FRV " David Howells
2012-03-12 23:37 ` [PATCH 09/35] Disintegrate asm/system.h for H8300 " David Howells
2012-03-12 23:37 ` [PATCH 10/35] Disintegrate asm/system.h for Hexagon " David Howells
2012-03-13  9:16   ` Arnd Bergmann
2012-03-13 10:01     ` David Howells
2012-03-13 11:33       ` Arnd Bergmann
2012-03-13 16:31       ` Richard Kuo
2012-03-13 18:34   ` Richard Kuo
2012-03-12 23:37 ` [PATCH 11/35] Disintegrate asm/system.h for IA64 " David Howells
2012-03-12 23:38 ` [PATCH 12/35] Disintegrate asm/system.h for M32R " David Howells
2012-03-12 23:38 ` [PATCH 13/35] Disintegrate asm/system.h for M68K " David Howells
2012-03-14 12:07   ` Greg Ungerer
2012-03-15 20:18     ` David Howells
2012-03-16  1:05       ` Greg Ungerer
2012-03-16 13:42     ` David Howells
2012-03-19  2:24       ` Greg Ungerer [this message]
2012-03-19 10:49         ` David Howells
2012-03-19 11:48           ` Greg Ungerer
2012-03-12 23:38 ` [PATCH 14/35] Disintegrate asm/system.h for Microblaze " David Howells
2012-03-12 23:38 ` [PATCH 15/35] Disintegrate asm/system.h for MIPS " David Howells
2012-03-12 23:38 ` [PATCH 16/35] Disintegrate asm/system.h for MN10300 " David Howells
2012-03-12 23:38 ` [PATCH 17/35] Make asm-generic/cmpxchg.h #include asm-generic/cmpxchg-local.h " David Howells
2012-03-13  9:00   ` Arnd Bergmann
2012-03-13 17:26     ` [ORLinux] " Jonas Bonn
2012-03-14 11:10       ` David Howells
2012-03-14 14:43         ` Jonas Bonn
2012-03-14 15:17           ` David Howells
2012-03-14 15:23             ` Jonas Bonn
2012-03-14 17:07               ` David Howells
2012-03-14 17:36                 ` Jonas Bonn
2012-03-19 10:51                   ` David Howells
2012-03-19 11:33                     ` Jonas Bonn
2012-03-19 12:05                       ` David Howells
2012-03-12 23:39 ` [PATCH 18/35] Create asm-generic/barrier.h " David Howells
2012-03-13  9:10   ` Arnd Bergmann
2012-03-12 23:39 ` [PATCH 19/35] Move the asm-generic/system.h xchg() implementation to asm-generic/cmpxchg.h " David Howells
2012-03-13  9:11   ` Arnd Bergmann
2012-03-12 23:39 ` [PATCH 20/35] Split the switch_to() wrapper out of asm-generic/system.h " David Howells
2012-03-13  9:11   ` Arnd Bergmann
2012-03-12 23:39 ` [PATCH 21/35] Split arch_align_stack() out from " David Howells
2012-03-13  9:11   ` Arnd Bergmann
2012-03-12 23:39 ` [PATCH 22/35] Disintegrate asm/system.h for OpenRISC " David Howells
2012-03-13  9:12   ` Arnd Bergmann
2012-03-12 23:39 ` [PATCH 23/35] Disintegrate asm/system.h for PA-RISC " David Howells
2012-03-12 23:40 ` [PATCH 24/35] Disintegrate asm/system.h for PowerPC " David Howells
2012-03-12 23:40 ` [PATCH 25/35] Disintegrate asm/system.h for S390 " David Howells
2012-03-12 23:40 ` [PATCH 26/35] Disintegrate asm/system.h for Score " David Howells
2012-03-12 23:40 ` [PATCH 27/35] Disintegrate asm/system.h for SH " David Howells
2012-03-12 23:40 ` [PATCH 28/35] Disintegrate asm/system.h for Sparc " David Howells
2012-03-12 23:40 ` [PATCH 29/35] Disintegrate asm/system.h for Tile " David Howells
2012-03-13 17:59   ` Chris Metcalf
2012-03-12 23:41 ` [PATCH 30/35] Disintegrate asm/system.h for Unicore32 " David Howells
2012-03-12 23:41 ` [PATCH 31/35] Disintegrate asm/system.h for Xtensa " David Howells
2012-03-12 23:41 ` [PATCH 32/35] Move all declarations of free_initmem() to linux/mm.h " David Howells
2012-03-12 23:41 ` [PATCH 33/35] Disintegrate asm/system.h on all arches " David Howells
2012-03-12 23:41 ` [PATCH 34/35] Remove all #inclusions of asm/system.h " David Howells
2012-03-14 12:35   ` Mark Salter
2012-03-12 23:42 ` [PATCH 35/35] Delete all instances " David Howells
2012-03-13 14:11 ` [RFC][PATCH 00/35] Disintegrate and kill " David Howells

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=4F6698C1.3070105@snapgear.com \
    --to=gerg@snapgear.com \
    --cc=arnd@arndb.de \
    --cc=dhowells@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox