powerpc/32s: Fix another build failure with CONFIG_PPC_KUAP_DEBUG
[linux-2.6-microblaze.git] / arch / powerpc / include / asm / book3s / 32 / kup.h
index 3c0ba22..32fd445 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef _ASM_POWERPC_BOOK3S_32_KUP_H
 #define _ASM_POWERPC_BOOK3S_32_KUP_H
 
+#include <asm/bug.h>
 #include <asm/book3s/32/mmu-hash.h>
 
 #ifdef __ASSEMBLY__
@@ -75,7 +76,7 @@
 
 .macro kuap_check      current, gpr
 #ifdef CONFIG_PPC_KUAP_DEBUG
-       lwz     \gpr2, KUAP(thread)
+       lwz     \gpr, THREAD + KUAP(\current)
 999:   twnei   \gpr, 0
        EMIT_BUG_ENTRY 999b, __FILE__, __LINE__, (BUGFLAG_WARNING | BUGFLAG_ONCE)
 #endif
@@ -108,7 +109,7 @@ static __always_inline void allow_user_access(void __user *to, const void __user
        u32 addr, end;
 
        BUILD_BUG_ON(!__builtin_constant_p(dir));
-       BUILD_BUG_ON(dir == KUAP_CURRENT);
+       BUILD_BUG_ON(dir & ~KUAP_READ_WRITE);
 
        if (!(dir & KUAP_WRITE))
                return;
@@ -131,7 +132,7 @@ static __always_inline void prevent_user_access(void __user *to, const void __us
 
        BUILD_BUG_ON(!__builtin_constant_p(dir));
 
-       if (dir == KUAP_CURRENT) {
+       if (dir & KUAP_CURRENT_WRITE) {
                u32 kuap = current->thread.kuap;
 
                if (unlikely(!kuap))