Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

riscv: ptrace: expand "LP" references to "branch landing pads" in uapi headers

Per Linus' comments about the unreadability of abbreviations such as
"LP", rename the RISC-V ptrace landing pad CFI macro names to be more
explicit. This primarily involves expanding "LP" in the names to some
variant of "branch landing pad."

Link: https://lore.kernel.org/linux-riscv/CAHk-=whhSLGZAx3N5jJpb4GLFDqH_QvS07D+6BnkPWmCEzTAgw@mail.gmail.com/
Cc: Deepak Gupta <debug@rivosinc.com>
Signed-off-by: Paul Walmsley <pjw@kernel.org>

+19 -16
+11 -9
arch/riscv/include/uapi/asm/ptrace.h
··· 132 132 unsigned long ss_ptr; /* shadow stack pointer */ 133 133 }; 134 134 135 - #define PTRACE_CFI_LP_EN_BIT 0 136 - #define PTRACE_CFI_LP_LOCK_BIT 1 137 - #define PTRACE_CFI_ELP_BIT 2 135 + #define PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT 0 136 + #define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT 1 137 + #define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT 2 138 138 #define PTRACE_CFI_SS_EN_BIT 3 139 139 #define PTRACE_CFI_SS_LOCK_BIT 4 140 140 #define PTRACE_CFI_SS_PTR_BIT 5 141 141 142 - #define PTRACE_CFI_LP_EN_STATE _BITUL(PTRACE_CFI_LP_EN_BIT) 143 - #define PTRACE_CFI_LP_LOCK_STATE _BITUL(PTRACE_CFI_LP_LOCK_BIT) 144 - #define PTRACE_CFI_ELP_STATE _BITUL(PTRACE_CFI_ELP_BIT) 142 + #define PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE _BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT) 143 + #define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE \ 144 + _BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT) 145 + #define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE \ 146 + _BITUL(PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT) 145 147 #define PTRACE_CFI_SS_EN_STATE _BITUL(PTRACE_CFI_SS_EN_BIT) 146 148 #define PTRACE_CFI_SS_LOCK_STATE _BITUL(PTRACE_CFI_SS_LOCK_BIT) 147 149 #define PTRACE_CFI_SS_PTR_STATE _BITUL(PTRACE_CFI_SS_PTR_BIT) 148 150 149 - #define PTRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_LP_EN_STATE | \ 150 - PTRACE_CFI_LP_LOCK_STATE | \ 151 - PTRACE_CFI_ELP_STATE | \ 151 + #define PTRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \ 152 + PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE | \ 153 + PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE | \ 152 154 PTRACE_CFI_SS_EN_STATE | \ 153 155 PTRACE_CFI_SS_LOCK_STATE | \ 154 156 PTRACE_CFI_SS_PTR_STATE)
+5 -5
arch/riscv/kernel/ptrace.c
··· 303 303 regs = task_pt_regs(target); 304 304 305 305 if (is_indir_lp_enabled(target)) { 306 - user_cfi.cfi_status.cfi_state |= PTRACE_CFI_LP_EN_STATE; 306 + user_cfi.cfi_status.cfi_state |= PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE; 307 307 user_cfi.cfi_status.cfi_state |= is_indir_lp_locked(target) ? 308 - PTRACE_CFI_LP_LOCK_STATE : 0; 308 + PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE : 0; 309 309 user_cfi.cfi_status.cfi_state |= (regs->status & SR_ELP) ? 310 - PTRACE_CFI_ELP_STATE : 0; 310 + PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE : 0; 311 311 } 312 312 313 313 if (is_shstk_enabled(target)) { ··· 349 349 * rsvd field should be set to zero so that if those fields are needed in future 350 350 */ 351 351 if ((user_cfi.cfi_status.cfi_state & 352 - (PTRACE_CFI_LP_EN_STATE | PTRACE_CFI_LP_LOCK_STATE | 352 + (PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE | 353 353 PTRACE_CFI_SS_EN_STATE | PTRACE_CFI_SS_LOCK_STATE)) || 354 354 (user_cfi.cfi_status.cfi_state & PTRACE_CFI_STATE_INVALID_MASK)) 355 355 return -EINVAL; ··· 357 357 /* If lpad is enabled on target and ptrace requests to set / clear elp, do that */ 358 358 if (is_indir_lp_enabled(target)) { 359 359 if (user_cfi.cfi_status.cfi_state & 360 - PTRACE_CFI_ELP_STATE) /* set elp state */ 360 + PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE) /* set elp state */ 361 361 regs->status |= SR_ELP; 362 362 else 363 363 regs->status &= ~SR_ELP; /* clear elp state */
+3 -2
tools/testing/selftests/riscv/cfi/cfitests.c
··· 94 94 } 95 95 96 96 switch (ptrace_test_num) { 97 - #define CFI_ENABLE_MASK (PTRACE_CFI_LP_EN_STATE | \ 97 + #define CFI_ENABLE_MASK (PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \ 98 98 PTRACE_CFI_SS_EN_STATE | \ 99 99 PTRACE_CFI_SS_PTR_STATE) 100 100 case 0: ··· 106 106 __func__); 107 107 break; 108 108 case 1: 109 - if (!(cfi_reg.cfi_status.cfi_state & PTRACE_CFI_ELP_STATE)) 109 + if (!(cfi_reg.cfi_status.cfi_state & 110 + PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE)) 110 111 ksft_exit_fail_msg("%s: elp must have been set\n", __func__); 111 112 /* clear elp state. not interested in anything else */ 112 113 cfi_reg.cfi_status.cfi_state = 0;