Skip to content

Commit 092055f

Browse files
brooniectmarinas
authored andcommitted
arm64/mm: Allocate PIE slots for EL0 guarded control stack
Pages used for guarded control stacks need to be described to the hardware using the Permission Indirection Extension, GCS is not supported without PIE. In order to support copy on write for guarded stacks we allocate two values, one for active GCSs and one for GCS pages marked as read only prior to copy. Since the actual effect is defined using PIE the specific bit pattern used does not matter to the hardware but we choose two values which differ only in PTE_WRITE in order to help share code with non-PIE cases. Reviewed-by: Thiago Jung Bauermann <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 6487c96 commit 092055f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/arm64/include/asm/pgtable-prot.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,32 @@ static inline bool __pure lpa2_is_enabled(void)
144144
/* 6: PTE_PXN | PTE_WRITE */
145145
/* 7: PAGE_SHARED_EXEC PTE_PXN | PTE_WRITE | PTE_USER */
146146
/* 8: PAGE_KERNEL_ROX PTE_UXN */
147-
/* 9: PTE_UXN | PTE_USER */
147+
/* 9: PAGE_GCS_RO PTE_UXN | PTE_USER */
148148
/* a: PAGE_KERNEL_EXEC PTE_UXN | PTE_WRITE */
149-
/* b: PTE_UXN | PTE_WRITE | PTE_USER */
149+
/* b: PAGE_GCS PTE_UXN | PTE_WRITE | PTE_USER */
150150
/* c: PAGE_KERNEL_RO PTE_UXN | PTE_PXN */
151151
/* d: PAGE_READONLY PTE_UXN | PTE_PXN | PTE_USER */
152152
/* e: PAGE_KERNEL PTE_UXN | PTE_PXN | PTE_WRITE */
153153
/* f: PAGE_SHARED PTE_UXN | PTE_PXN | PTE_WRITE | PTE_USER */
154154

155+
#define _PAGE_GCS (_PAGE_DEFAULT | PTE_NG | PTE_UXN | PTE_WRITE | PTE_USER)
156+
#define _PAGE_GCS_RO (_PAGE_DEFAULT | PTE_NG | PTE_UXN | PTE_USER)
157+
158+
#define PAGE_GCS __pgprot(_PAGE_GCS)
159+
#define PAGE_GCS_RO __pgprot(_PAGE_GCS_RO)
160+
155161
#define PIE_E0 ( \
162+
PIRx_ELx_PERM(pte_pi_index(_PAGE_GCS), PIE_GCS) | \
163+
PIRx_ELx_PERM(pte_pi_index(_PAGE_GCS_RO), PIE_R) | \
156164
PIRx_ELx_PERM(pte_pi_index(_PAGE_EXECONLY), PIE_X_O) | \
157165
PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY_EXEC), PIE_RX_O) | \
158166
PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED_EXEC), PIE_RWX_O) | \
159167
PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY), PIE_R_O) | \
160168
PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED), PIE_RW_O))
161169

162170
#define PIE_E1 ( \
171+
PIRx_ELx_PERM(pte_pi_index(_PAGE_GCS), PIE_NONE_O) | \
172+
PIRx_ELx_PERM(pte_pi_index(_PAGE_GCS_RO), PIE_NONE_O) | \
163173
PIRx_ELx_PERM(pte_pi_index(_PAGE_EXECONLY), PIE_NONE_O) | \
164174
PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY_EXEC), PIE_R) | \
165175
PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED_EXEC), PIE_RW) | \

0 commit comments

Comments
 (0)