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