a2cf7d
commit e627106266ad8785457fadbf5bf67ed604d2a353
a2cf7d
Author: Florian Weimer <fweimer@redhat.com>
a2cf7d
Date:   Mon May 11 11:20:02 2020 +0200
a2cf7d
a2cf7d
    POWER: Add context-synchronizing instructions to pkey_write [BZ #25954]
a2cf7d
    
a2cf7d
    Sandipan Das reported that,
a2cf7d
    
a2cf7d
    "The Power ISA mandates that all writes to the Authority
a2cf7d
    Mask Register (AMR) must always be preceded as well as
a2cf7d
    succeeded by a context-synchronizing instruction. This
a2cf7d
    applies to both the privileged and unprivileged variants
a2cf7d
    of the Move To AMR instruction.
a2cf7d
    
a2cf7d
    This [requirement] is from Table 6 of Chapter 11 in page 1134 of Power
a2cf7d
    ISA 3.0B. The document can be found here:
a2cf7d
    <https://ibm.ent.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv>
a2cf7d
    "
a2cf7d
    
a2cf7d
    See this kernel patch submission:
a2cf7d
    
a2cf7d
    <https://lore.kernel.org/linuxppc-dev/5f65cf37be993760de8112a88da194e3ccbb2bf8.1588959697.git.sandipan@linux.ibm.com/>
a2cf7d
a2cf7d
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/arch-pkey.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/arch-pkey.h
a2cf7d
index 623b073d5a585d51..25d080c9a6f30942 100644
a2cf7d
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/arch-pkey.h
a2cf7d
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/arch-pkey.h
a2cf7d
@@ -37,7 +37,7 @@ pkey_read (void)
a2cf7d
 static inline void
a2cf7d
 pkey_write (unsigned long int value)
a2cf7d
 {
a2cf7d
-  __asm__ volatile ("mtspr 13, %0" : : "r" (value));
a2cf7d
+  __asm__ volatile ("isync; mtspr 13, %0; isync" : : "r" (value));
a2cf7d
 }
a2cf7d
 
a2cf7d
 /* Number of the largest supported key.  This depends on the width of