Skip to content

Commit 178d52c

Browse files
committed
powerpc: Only include kup-radix.h for 64-bit Book3S
In kup.h we currently include kup-radix.h for all 64-bit builds, which includes Book3S and Book3E. The latter doesn't make sense, Book3E never uses the Radix MMU. This has worked up until now, but almost by accident, and the recent uaccess flush changes introduced a build breakage on Book3E because of the bad structure of the code. So disentangle things so that we only use kup-radix.h for Book3S. This requires some more stubs in kup.h and fixing an include in syscall_64.c. Signed-off-by: Michael Ellerman <[email protected]>
1 parent 9a32a7e commit 178d52c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

arch/powerpc/include/asm/book3s/64/kup-radix.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#endif
2828
.endm
2929

30+
#ifdef CONFIG_PPC_KUAP
3031
.macro kuap_check_amr gpr1, gpr2
3132
#ifdef CONFIG_PPC_KUAP_DEBUG
3233
BEGIN_MMU_FTR_SECTION_NESTED(67)
@@ -38,6 +39,7 @@
3839
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
3940
#endif
4041
.endm
42+
#endif
4143

4244
.macro kuap_save_amr_and_lock gpr1, gpr2, use_cr, msr_pr_cr
4345
#ifdef CONFIG_PPC_KUAP
@@ -148,8 +150,6 @@ static inline unsigned long kuap_get_and_check_amr(void)
148150
return 0UL;
149151
}
150152

151-
static inline void kuap_check_amr(void) { }
152-
153153
static inline unsigned long get_kuap(void)
154154
{
155155
return AMR_KUAP_BLOCKED;

arch/powerpc/include/asm/kup.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define KUAP_CURRENT_WRITE 8
1515
#define KUAP_CURRENT (KUAP_CURRENT_READ | KUAP_CURRENT_WRITE)
1616

17-
#ifdef CONFIG_PPC64
17+
#ifdef CONFIG_PPC_BOOK3S_64
1818
#include <asm/book3s/64/kup-radix.h>
1919
#endif
2020
#ifdef CONFIG_PPC_8xx
@@ -35,6 +35,9 @@
3535
.macro kuap_check current, gpr
3636
.endm
3737

38+
.macro kuap_check_amr gpr1, gpr2
39+
.endm
40+
3841
#endif
3942

4043
#else /* !__ASSEMBLY__ */
@@ -60,19 +63,21 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
6063
return false;
6164
}
6265

66+
static inline void kuap_check_amr(void) { }
67+
6368
/*
6469
* book3s/64/kup-radix.h defines these functions for the !KUAP case to flush
6570
* the L1D cache after user accesses. Only include the empty stubs for other
6671
* platforms.
6772
*/
68-
#ifndef CONFIG_PPC64
73+
#ifndef CONFIG_PPC_BOOK3S_64
6974
static inline void allow_user_access(void __user *to, const void __user *from,
7075
unsigned long size, unsigned long dir) { }
7176
static inline void prevent_user_access(void __user *to, const void __user *from,
7277
unsigned long size, unsigned long dir) { }
7378
static inline unsigned long prevent_user_access_return(void) { return 0UL; }
7479
static inline void restore_user_access(unsigned long flags) { }
75-
#endif /* CONFIG_PPC64 */
80+
#endif /* CONFIG_PPC_BOOK3S_64 */
7681
#endif /* CONFIG_PPC_KUAP */
7782

7883
static inline void allow_read_from_user(const void __user *from, unsigned long size)

arch/powerpc/kernel/syscall_64.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <linux/err.h>
44
#include <asm/asm-prototypes.h>
5-
#include <asm/book3s/64/kup-radix.h>
5+
#include <asm/kup.h>
66
#include <asm/cputime.h>
77
#include <asm/hw_irq.h>
88
#include <asm/kprobes.h>

0 commit comments

Comments
 (0)