Skip to content
  • Will Deacon's avatar
    arm64: barriers: fix smp_load_acquire to work with const arguments · c139aa60
    Will Deacon authored
    
    
    A newly introduced function in include/net/sock.h passes a const
    argument to smp_load_acquire:
    
      static inline int sk_state_load(const struct sock *sk)
      {
    	return smp_load_acquire(&sk->sk_state);
      }
    
    This cause an allmodconfig build failure, since our underlying
    load-acquire implementation does not handle const types correctly:
    
      include/net/sock.h: In function 'sk_state_load':
      ./arch/arm64/include/asm/barrier.h:71:3: error: read-only variable '___p1' used as 'asm' output
         asm volatile ("ldarb %w0, %1"    \
    
    This patch fixes the problem by reusing the trick in READ_ONCE that
    loads via a non-const member of an anonymous union. This has the
    advantage of allowing us to use smp_load_acquire on packed structures
    (e.g. arch_spinlock_t) as well as primitive types.
    
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: David Daney <david.daney@cavium.com>
    Cc: Eric Dumazet <eric.dumazet@gmail.com>
    Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
    Reported-by: default avatarDavid Daney <david.daney@cavium.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    c139aa60