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