Skip to content

Commit

Permalink
[ARM] 5196/1: fix inline asm constraints for preload
Browse files Browse the repository at this point in the history
With gcc 4.3 and later, a pointer that has already been dereferenced is
assumed not to be null since it should have caused a segmentation fault
otherwise, hence any subsequent test against NULL is optimized away.

Current inline asm constraint used in the implementation of prefetch()
makes gcc believe that the pointer is dereferenced even though the PLD
instruction does not load any data and does not cause a segmentation
fault on null pointers, which causes all sorts of interesting results
when reaching the end of a linked lists for example.

Let's use a better constraint to properly represent the actual usage of
the pointer value.

Problem reported by Chris Steel.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Nicolas Pitre authored and Russell King committed Aug 16, 2008
1 parent da1562a commit 16f719d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/arm/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
static inline void prefetch(const void *ptr)
{
__asm__ __volatile__(
"pld\t%0"
"pld\t%a0"
:
: "o" (*(char *)ptr)
: "p" (ptr)
: "cc");
}

Expand Down

0 comments on commit 16f719d

Please sign in to comment.