|
67 | 67 | #endif
|
68 | 68 | .endm
|
69 | 69 |
|
70 |
| -#ifdef CONFIG_CPU_SW_DOMAIN_PAN |
| 70 | +#if defined(CONFIG_CPU_SW_DOMAIN_PAN) || defined(CONFIG_CPU_USE_DOMAINS) |
71 | 71 | #define DACR(x...) x
|
72 | 72 | #else
|
73 | 73 | #define DACR(x...)
|
74 | 74 | #endif
|
75 | 75 |
|
76 | 76 | /*
|
77 |
| - * Save the address limit on entry to a privileged exception and |
78 |
| - * if using PAN, save and disable usermode access. |
| 77 | + * Save the address limit on entry to a privileged exception. |
| 78 | + * |
| 79 | + * If we are using the DACR for kernel access by the user accessors |
| 80 | + * (CONFIG_CPU_USE_DOMAINS=y), always reset the DACR kernel domain |
| 81 | + * back to client mode, whether or not \disable is set. |
| 82 | + * |
| 83 | + * If we are using SW PAN, set the DACR user domain to no access |
| 84 | + * if \disable is set. |
79 | 85 | */
|
80 | 86 | .macro uaccess_entry, tsk, tmp0, tmp1, tmp2, disable
|
81 | 87 | ldr \tmp1, [\tsk, #TI_ADDR_LIMIT]
|
|
84 | 90 | DACR( mrc p15, 0, \tmp0, c3, c0, 0)
|
85 | 91 | DACR( str \tmp0, [sp, #SVC_DACR])
|
86 | 92 | str \tmp1, [sp, #SVC_ADDR_LIMIT]
|
87 |
| - .if \disable |
88 |
| - uaccess_disable \tmp0 |
| 93 | + .if \disable && IS_ENABLED(CONFIG_CPU_SW_DOMAIN_PAN) |
| 94 | + /* kernel=client, user=no access */ |
| 95 | + mov \tmp2, #DACR_UACCESS_DISABLE |
| 96 | + mcr p15, 0, \tmp2, c3, c0, 0 |
| 97 | + instr_sync |
| 98 | + .elseif IS_ENABLED(CONFIG_CPU_USE_DOMAINS) |
| 99 | + /* kernel=client */ |
| 100 | + bic \tmp2, \tmp0, #domain_mask(DOMAIN_KERNEL) |
| 101 | + orr \tmp2, \tmp2, #domain_val(DOMAIN_KERNEL, DOMAIN_CLIENT) |
| 102 | + mcr p15, 0, \tmp2, c3, c0, 0 |
| 103 | + instr_sync |
89 | 104 | .endif
|
90 | 105 | .endm
|
91 | 106 |
|
|
0 commit comments