mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
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>
This commit is contained in:
parent
a6ede084c4
commit
ac4e61c730
|
|
@ -132,23 +132,25 @@ struct __sc_riscv_cfi_state {
|
|||
unsigned long ss_ptr; /* shadow stack pointer */
|
||||
};
|
||||
|
||||
#define PTRACE_CFI_LP_EN_BIT 0
|
||||
#define PTRACE_CFI_LP_LOCK_BIT 1
|
||||
#define PTRACE_CFI_ELP_BIT 2
|
||||
#define PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT 0
|
||||
#define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT 1
|
||||
#define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT 2
|
||||
#define PTRACE_CFI_SS_EN_BIT 3
|
||||
#define PTRACE_CFI_SS_LOCK_BIT 4
|
||||
#define PTRACE_CFI_SS_PTR_BIT 5
|
||||
|
||||
#define PTRACE_CFI_LP_EN_STATE _BITUL(PTRACE_CFI_LP_EN_BIT)
|
||||
#define PTRACE_CFI_LP_LOCK_STATE _BITUL(PTRACE_CFI_LP_LOCK_BIT)
|
||||
#define PTRACE_CFI_ELP_STATE _BITUL(PTRACE_CFI_ELP_BIT)
|
||||
#define PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE _BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT)
|
||||
#define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE \
|
||||
_BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT)
|
||||
#define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE \
|
||||
_BITUL(PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT)
|
||||
#define PTRACE_CFI_SS_EN_STATE _BITUL(PTRACE_CFI_SS_EN_BIT)
|
||||
#define PTRACE_CFI_SS_LOCK_STATE _BITUL(PTRACE_CFI_SS_LOCK_BIT)
|
||||
#define PTRACE_CFI_SS_PTR_STATE _BITUL(PTRACE_CFI_SS_PTR_BIT)
|
||||
|
||||
#define PTRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_LP_EN_STATE | \
|
||||
PTRACE_CFI_LP_LOCK_STATE | \
|
||||
PTRACE_CFI_ELP_STATE | \
|
||||
#define PTRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \
|
||||
PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE | \
|
||||
PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE | \
|
||||
PTRACE_CFI_SS_EN_STATE | \
|
||||
PTRACE_CFI_SS_LOCK_STATE | \
|
||||
PTRACE_CFI_SS_PTR_STATE)
|
||||
|
|
|
|||
|
|
@ -303,11 +303,11 @@ static int riscv_cfi_get(struct task_struct *target,
|
|||
regs = task_pt_regs(target);
|
||||
|
||||
if (is_indir_lp_enabled(target)) {
|
||||
user_cfi.cfi_status.cfi_state |= PTRACE_CFI_LP_EN_STATE;
|
||||
user_cfi.cfi_status.cfi_state |= PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE;
|
||||
user_cfi.cfi_status.cfi_state |= is_indir_lp_locked(target) ?
|
||||
PTRACE_CFI_LP_LOCK_STATE : 0;
|
||||
PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE : 0;
|
||||
user_cfi.cfi_status.cfi_state |= (regs->status & SR_ELP) ?
|
||||
PTRACE_CFI_ELP_STATE : 0;
|
||||
PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE : 0;
|
||||
}
|
||||
|
||||
if (is_shstk_enabled(target)) {
|
||||
|
|
@ -349,7 +349,7 @@ static int riscv_cfi_set(struct task_struct *target,
|
|||
* rsvd field should be set to zero so that if those fields are needed in future
|
||||
*/
|
||||
if ((user_cfi.cfi_status.cfi_state &
|
||||
(PTRACE_CFI_LP_EN_STATE | PTRACE_CFI_LP_LOCK_STATE |
|
||||
(PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE |
|
||||
PTRACE_CFI_SS_EN_STATE | PTRACE_CFI_SS_LOCK_STATE)) ||
|
||||
(user_cfi.cfi_status.cfi_state & PTRACE_CFI_STATE_INVALID_MASK))
|
||||
return -EINVAL;
|
||||
|
|
@ -357,7 +357,7 @@ static int riscv_cfi_set(struct task_struct *target,
|
|||
/* If lpad is enabled on target and ptrace requests to set / clear elp, do that */
|
||||
if (is_indir_lp_enabled(target)) {
|
||||
if (user_cfi.cfi_status.cfi_state &
|
||||
PTRACE_CFI_ELP_STATE) /* set elp state */
|
||||
PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE) /* set elp state */
|
||||
regs->status |= SR_ELP;
|
||||
else
|
||||
regs->status &= ~SR_ELP; /* clear elp state */
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ bool cfi_ptrace_test(void)
|
|||
}
|
||||
|
||||
switch (ptrace_test_num) {
|
||||
#define CFI_ENABLE_MASK (PTRACE_CFI_LP_EN_STATE | \
|
||||
#define CFI_ENABLE_MASK (PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \
|
||||
PTRACE_CFI_SS_EN_STATE | \
|
||||
PTRACE_CFI_SS_PTR_STATE)
|
||||
case 0:
|
||||
|
|
@ -106,7 +106,8 @@ bool cfi_ptrace_test(void)
|
|||
__func__);
|
||||
break;
|
||||
case 1:
|
||||
if (!(cfi_reg.cfi_status.cfi_state & PTRACE_CFI_ELP_STATE))
|
||||
if (!(cfi_reg.cfi_status.cfi_state &
|
||||
PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE))
|
||||
ksft_exit_fail_msg("%s: elp must have been set\n", __func__);
|
||||
/* clear elp state. not interested in anything else */
|
||||
cfi_reg.cfi_status.cfi_state = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user