Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e8c4f6e
perf: Remove redundant condition for AUX buffer size
KAGA-KOKO Aug 12, 2025
81e026c
perf: Split out mlock limit handling
KAGA-KOKO Aug 12, 2025
1ea3e3b
perf: Split out VM accounting
KAGA-KOKO Aug 12, 2025
86a0a7c
perf: Move perf_mmap_calc_limits() into both rb and aux branches
Aug 12, 2025
3821f25
perf: Merge consecutive conditionals in perf_mmap()
Aug 12, 2025
4118994
perf: Move common code into both rb and aux branches
Aug 12, 2025
41b80e1
perf: Remove redundant aux_unlock label
Aug 12, 2025
b33a515
perf: Use guard() for aux_mutex in perf_mmap()
Aug 12, 2025
8558dca
perf: Reflow to get rid of aux_success label
Aug 12, 2025
2aee376
perf: Split out the AUX buffer allocation
Aug 12, 2025
191759e
perf: Make RB allocation branch self sufficient
Aug 12, 2025
5d29989
perf: Split out the RB allocation
Aug 12, 2025
d23a6db
perf: Use scoped_guard() for mmap_mutex in perf_mmap()
Aug 12, 2025
5974145
perf: Identify the 0->1 transition for event::mmap_count
Aug 12, 2025
448f97f
perf: Convert mmap() refcounts to refcount_t
KAGA-KOKO Aug 12, 2025
7769cb1
uprobes: Remove breakpoint in unapply_uprobe under mmap_write_lock
olsajiri Jul 20, 2025
0f07b79
uprobes: Rename arch_uretprobe_trampoline function
olsajiri Jul 20, 2025
82afdd0
uprobes: Make copy_from_page global
olsajiri Jul 20, 2025
33d7b2b
uprobes: Add uprobe_write function
olsajiri Jul 20, 2025
f8b7c52
uprobes: Add nbytes argument to uprobe_write
olsajiri Jul 20, 2025
ec46350
uprobes: Add is_register argument to uprobe_write and uprobe_write_op…
olsajiri Jul 20, 2025
18a1112
uprobes: Add do_ref_ctr argument to uprobe_write function
olsajiri Jul 20, 2025
91440ff
uprobes/x86: Add mapping for optimized uprobe trampolines
olsajiri Jul 20, 2025
56101b6
uprobes/x86: Add uprobe syscall to speed up uprobe
olsajiri Jul 20, 2025
ba2bfc9
uprobes/x86: Add support to optimize uprobes
olsajiri Jul 20, 2025
985e820
uprobes/x86: Add struct uretprobe_syscall_args
Aug 20, 2025
fd54052
uprobes/x86: Optimize is_optimize()
Aug 20, 2025
7c2bfc1
uprobes/x86: Accept more NOP forms
Aug 20, 2025
f349ec8
uprobes/x86: Fix uprobe syscall vs shadow stack
Aug 20, 2025
60ed85b
uprobes/x86: Make asm style consistent
Aug 21, 2025
354492a
uprobes/x86: Add SLS mitigation to the trampolines
Aug 20, 2025
17c3b00
selftests/bpf: Import usdt.h from libbpf/usdt project
olsajiri Jul 20, 2025
4e70052
selftests/bpf: Reorg the uprobe_syscall test function
olsajiri Jul 20, 2025
7932c4c
selftests/bpf: Rename uprobe_syscall_executed prog to test_uretprobe_…
olsajiri Jul 20, 2025
d5c86c3
selftests/bpf: Add uprobe/usdt syscall tests
olsajiri Jul 20, 2025
c8be596
selftests/bpf: Add hit/attach/detach race optimized uprobe test
olsajiri Jul 20, 2025
c11661b
selftests/bpf: Add uprobe syscall sigill signal test
olsajiri Jul 20, 2025
875e170
selftests/bpf: Add optimized usdt variant for basic usdt test
olsajiri Jul 20, 2025
275eae6
selftests/bpf: Add uprobe_regs_equal test
olsajiri Jul 20, 2025
3abf429
selftests/bpf: Change test_uretprobe_regs_change for uprobe and uretp…
olsajiri Jul 20, 2025
5271843
selftests/bpf: Fix uprobe syscall shadow stack test
olsajiri Aug 21, 2025
89d1d84
seccomp: passthrough uprobe systemcall without filtering
olsajiri Jul 20, 2025
9ffc7a6
selftests/seccomp: validate uprobe syscall passes through seccomp
olsajiri Jul 20, 2025
e173287
uprobes: Remove redundant __GFP_NOWARN
qianfengrong Aug 5, 2025
d9cf9c6
perf/x86/intel: Use early_initcall() to hook bts_init()
Aug 20, 2025
43796f3
perf/x86/intel: Fix IA32_PMC_x_CFG_B MSRs access error
Aug 20, 2025
0c5caea
perf/x86: Add PERF_CAP_PEBS_TIMING_INFO flag
Aug 20, 2025
9b3e119
perf/x86/intel: Change macro GLOBAL_CTRL_EN_PERF_METRICS to BIT_ULL(48)
Aug 20, 2025
2676dbf
perf/x86/intel: Add ICL_FIXED_0_ADAPTIVE bit into INTEL_FIXED_BITS_MASK
Aug 20, 2025
f49e1be
perf/x86: Print PMU counters bitmap in x86_pmu_show_pmu_cap()
Aug 20, 2025
e649bcd
perf: Remove get_perf_callchain() init_nr argument
jpoimboe Aug 20, 2025
153f9e7
perf: Have get_perf_callchain() return NULL if crosstask and user are…
jpoimboe Aug 20, 2025
90942f9
perf: Use current->flags & PF_KTHREAD|PF_USER_WORKER instead of curre…
rostedt Aug 20, 2025
d77e331
perf: Simplify get_perf_callchain() user logic
jpoimboe Aug 20, 2025
16ed389
perf: Skip user unwind if the task is a kernel thread
jpoimboe Aug 20, 2025
26ab9fd
Merge remote-tracking branch 'tip/perf/core' into uprobe_regs_ci
olsajiri Sep 1, 2025
44325b9
uprobes: Add unique flag to uprobe consumer
olsajiri Aug 4, 2025
bce71cd
uprobes: Skip emulate/sstep on unique uprobe when ip is changed
olsajiri Aug 4, 2025
1ac7a14
perf: Add support to attach standard unique uprobe
olsajiri Sep 1, 2025
a7b5bb4
bpf: Add support to attach uprobe_multi unique uprobe
olsajiri Sep 2, 2025
778c32e
bpf: Allow uprobe program to change context registers
olsajiri Jul 31, 2025
aa64249
libbpf: Add support to attach unique uprobe_multi uprobe
olsajiri Sep 2, 2025
db168c9
libbpf: Add support to attach generic unique uprobe
olsajiri Sep 1, 2025
bf502d8
selftests/bpf: Add uprobe multi context registers changes test
olsajiri Aug 6, 2025
f26daa3
selftests/bpf: Add uprobe multi context ip register change test
olsajiri Aug 8, 2025
269a90e
selftests/bpf: Add uprobe multi unique attach test
olsajiri Aug 8, 2025
ef664af
selftests/bpf: Add uprobe unique attach test
olsajiri Sep 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/probes/uprobes/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int set_swbp(struct arch_uprobe *auprobe, struct vm_area_struct *vma,
unsigned long vaddr)
{
return uprobe_write_opcode(auprobe, vma, vaddr,
__opcode_to_mem_arm(auprobe->bpinsn));
__opcode_to_mem_arm(auprobe->bpinsn), true);
}

bool arch_uprobe_ignore(struct arch_uprobe *auprobe, struct pt_regs *regs)
Expand Down
1 change: 1 addition & 0 deletions arch/x86/entry/syscalls/syscall_64.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
333 common io_pgetevents sys_io_pgetevents
334 common rseq sys_rseq
335 common uretprobe sys_uretprobe
336 common uprobe sys_uprobe
# don't use numbers 387 through 423, add new calls after the last
# 'common' entry
424 common pidfd_send_signal sys_pidfd_send_signal
Expand Down
16 changes: 9 additions & 7 deletions arch/x86/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2069,13 +2069,15 @@ static void _x86_pmu_read(struct perf_event *event)

void x86_pmu_show_pmu_cap(struct pmu *pmu)
{
pr_info("... version: %d\n", x86_pmu.version);
pr_info("... bit width: %d\n", x86_pmu.cntval_bits);
pr_info("... generic registers: %d\n", x86_pmu_num_counters(pmu));
pr_info("... value mask: %016Lx\n", x86_pmu.cntval_mask);
pr_info("... max period: %016Lx\n", x86_pmu.max_period);
pr_info("... fixed-purpose events: %d\n", x86_pmu_num_counters_fixed(pmu));
pr_info("... event mask: %016Lx\n", hybrid(pmu, intel_ctrl));
pr_info("... version: %d\n", x86_pmu.version);
pr_info("... bit width: %d\n", x86_pmu.cntval_bits);
pr_info("... generic counters: %d\n", x86_pmu_num_counters(pmu));
pr_info("... generic bitmap: %016llx\n", hybrid(pmu, cntr_mask64));
pr_info("... fixed-purpose counters: %d\n", x86_pmu_num_counters_fixed(pmu));
pr_info("... fixed-purpose bitmap: %016llx\n", hybrid(pmu, fixed_cntr_mask64));
pr_info("... value mask: %016llx\n", x86_pmu.cntval_mask);
pr_info("... max period: %016llx\n", x86_pmu.max_period);
pr_info("... global_ctrl mask: %016llx\n", hybrid(pmu, intel_ctrl));
}

static int __init init_hw_perf_events(void)
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/events/intel/bts.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,4 @@ static __init int bts_init(void)

return perf_pmu_register(&bts_pmu, "intel_bts", -1);
}
arch_initcall(bts_init);
early_initcall(bts_init);
21 changes: 9 additions & 12 deletions arch/x86/events/intel/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2845,8 +2845,8 @@ static void intel_pmu_enable_fixed(struct perf_event *event)
{
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
struct hw_perf_event *hwc = &event->hw;
u64 mask, bits = 0;
int idx = hwc->idx;
u64 bits = 0;

if (is_topdown_idx(idx)) {
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
Expand Down Expand Up @@ -2885,14 +2885,10 @@ static void intel_pmu_enable_fixed(struct perf_event *event)

idx -= INTEL_PMC_IDX_FIXED;
bits = intel_fixed_bits_by_idx(idx, bits);
mask = intel_fixed_bits_by_idx(idx, INTEL_FIXED_BITS_MASK);

if (x86_pmu.intel_cap.pebs_baseline && event->attr.precise_ip) {
if (x86_pmu.intel_cap.pebs_baseline && event->attr.precise_ip)
bits |= intel_fixed_bits_by_idx(idx, ICL_FIXED_0_ADAPTIVE);
mask |= intel_fixed_bits_by_idx(idx, ICL_FIXED_0_ADAPTIVE);
}

cpuc->fixed_ctrl_val &= ~mask;
cpuc->fixed_ctrl_val &= ~intel_fixed_bits_by_idx(idx, INTEL_FIXED_BITS_MASK);
cpuc->fixed_ctrl_val |= bits;
}

Expand Down Expand Up @@ -2997,7 +2993,8 @@ static void intel_pmu_acr_late_setup(struct cpu_hw_events *cpuc)
if (event->group_leader != leader->group_leader)
break;
for_each_set_bit(idx, (unsigned long *)&event->attr.config2, X86_PMC_IDX_MAX) {
if (WARN_ON_ONCE(i + idx > cpuc->n_events))
if (i + idx >= cpuc->n_events ||
!is_acr_event_group(cpuc->event_list[i + idx]))
return;
__set_bit(cpuc->assign[i + idx], (unsigned long *)&event->hw.config1);
}
Expand Down Expand Up @@ -5318,9 +5315,9 @@ static void intel_pmu_check_hybrid_pmus(struct x86_hybrid_pmu *pmu)
0, x86_pmu_num_counters(&pmu->pmu), 0, 0);

if (pmu->intel_cap.perf_metrics)
pmu->intel_ctrl |= 1ULL << GLOBAL_CTRL_EN_PERF_METRICS;
pmu->intel_ctrl |= GLOBAL_CTRL_EN_PERF_METRICS;
else
pmu->intel_ctrl &= ~(1ULL << GLOBAL_CTRL_EN_PERF_METRICS);
pmu->intel_ctrl &= ~GLOBAL_CTRL_EN_PERF_METRICS;

intel_pmu_check_event_constraints(pmu->event_constraints,
pmu->cntr_mask64,
Expand Down Expand Up @@ -5455,7 +5452,7 @@ static void intel_pmu_cpu_starting(int cpu)
rdmsrq(MSR_IA32_PERF_CAPABILITIES, perf_cap.capabilities);
if (!perf_cap.perf_metrics) {
x86_pmu.intel_cap.perf_metrics = 0;
x86_pmu.intel_ctrl &= ~(1ULL << GLOBAL_CTRL_EN_PERF_METRICS);
x86_pmu.intel_ctrl &= ~GLOBAL_CTRL_EN_PERF_METRICS;
}
}

Expand Down Expand Up @@ -7789,7 +7786,7 @@ __init int intel_pmu_init(void)
}

if (!is_hybrid() && x86_pmu.intel_cap.perf_metrics)
x86_pmu.intel_ctrl |= 1ULL << GLOBAL_CTRL_EN_PERF_METRICS;
x86_pmu.intel_ctrl |= GLOBAL_CTRL_EN_PERF_METRICS;

if (x86_pmu.intel_cap.pebs_timing_info)
x86_pmu.flags |= PMU_FL_RETIRE_LATENCY;
Expand Down
14 changes: 8 additions & 6 deletions arch/x86/include/asm/msr-index.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,14 @@
#define PERF_CAP_PT_IDX 16

#define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6
#define PERF_CAP_PEBS_TRAP BIT_ULL(6)
#define PERF_CAP_ARCH_REG BIT_ULL(7)
#define PERF_CAP_PEBS_FORMAT 0xf00
#define PERF_CAP_PEBS_BASELINE BIT_ULL(14)
#define PERF_CAP_PEBS_MASK (PERF_CAP_PEBS_TRAP | PERF_CAP_ARCH_REG | \
PERF_CAP_PEBS_FORMAT | PERF_CAP_PEBS_BASELINE)
#define PERF_CAP_PEBS_TRAP BIT_ULL(6)
#define PERF_CAP_ARCH_REG BIT_ULL(7)
#define PERF_CAP_PEBS_FORMAT 0xf00
#define PERF_CAP_PEBS_BASELINE BIT_ULL(14)
#define PERF_CAP_PEBS_TIMING_INFO BIT_ULL(17)
#define PERF_CAP_PEBS_MASK (PERF_CAP_PEBS_TRAP | PERF_CAP_ARCH_REG | \
PERF_CAP_PEBS_FORMAT | PERF_CAP_PEBS_BASELINE | \
PERF_CAP_PEBS_TIMING_INFO)

#define MSR_IA32_RTIT_CTL 0x00000570
#define RTIT_CTL_TRACEEN BIT(0)
Expand Down
8 changes: 6 additions & 2 deletions arch/x86/include/asm/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#define ARCH_PERFMON_EVENTSEL_EQ (1ULL << 36)
#define ARCH_PERFMON_EVENTSEL_UMASK2 (0xFFULL << 40)

#define INTEL_FIXED_BITS_MASK 0xFULL
#define INTEL_FIXED_BITS_STRIDE 4
#define INTEL_FIXED_0_KERNEL (1ULL << 0)
#define INTEL_FIXED_0_USER (1ULL << 1)
Expand All @@ -48,6 +47,11 @@
#define ICL_EVENTSEL_ADAPTIVE (1ULL << 34)
#define ICL_FIXED_0_ADAPTIVE (1ULL << 32)

#define INTEL_FIXED_BITS_MASK \
(INTEL_FIXED_0_KERNEL | INTEL_FIXED_0_USER | \
INTEL_FIXED_0_ANYTHREAD | INTEL_FIXED_0_ENABLE_PMI | \
ICL_FIXED_0_ADAPTIVE)

#define intel_fixed_bits_by_idx(_idx, _bits) \
((_bits) << ((_idx) * INTEL_FIXED_BITS_STRIDE))

Expand Down Expand Up @@ -430,7 +434,7 @@ static inline bool is_topdown_idx(int idx)
#define GLOBAL_STATUS_TRACE_TOPAPMI BIT_ULL(GLOBAL_STATUS_TRACE_TOPAPMI_BIT)
#define GLOBAL_STATUS_PERF_METRICS_OVF_BIT 48

#define GLOBAL_CTRL_EN_PERF_METRICS 48
#define GLOBAL_CTRL_EN_PERF_METRICS BIT_ULL(48)
/*
* We model guest LBR event tracing as another fixed-mode PMC like BTS.
*
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/include/asm/shstk.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ int setup_signal_shadow_stack(struct ksignal *ksig);
int restore_signal_shadow_stack(void);
int shstk_update_last_frame(unsigned long val);
bool shstk_is_enabled(void);
int shstk_pop(u64 *val);
int shstk_push(u64 val);
#else
static inline long shstk_prctl(struct task_struct *task, int option,
unsigned long arg2) { return -EINVAL; }
Expand All @@ -35,6 +37,8 @@ static inline int setup_signal_shadow_stack(struct ksignal *ksig) { return 0; }
static inline int restore_signal_shadow_stack(void) { return 0; }
static inline int shstk_update_last_frame(unsigned long val) { return 0; }
static inline bool shstk_is_enabled(void) { return false; }
static inline int shstk_pop(u64 *val) { return -ENOTSUPP; }
static inline int shstk_push(u64 val) { return -ENOTSUPP; }
#endif /* CONFIG_X86_USER_SHADOW_STACK */

#endif /* __ASSEMBLER__ */
Expand Down
7 changes: 7 additions & 0 deletions arch/x86/include/asm/uprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ typedef u8 uprobe_opcode_t;
#define UPROBE_SWBP_INSN 0xcc
#define UPROBE_SWBP_INSN_SIZE 1

enum {
ARCH_UPROBE_FLAG_CAN_OPTIMIZE = 0,
ARCH_UPROBE_FLAG_OPTIMIZE_FAIL = 1,
};

struct uprobe_xol_ops;

struct arch_uprobe {
Expand All @@ -45,6 +50,8 @@ struct arch_uprobe {
u8 ilen;
} push;
};

unsigned long flags;
};

struct arch_uprobe_task {
Expand Down
40 changes: 40 additions & 0 deletions arch/x86/kernel/shstk.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,46 @@ static unsigned long get_user_shstk_addr(void)
return ssp;
}

int shstk_pop(u64 *val)
{
int ret = 0;
u64 ssp;

if (!features_enabled(ARCH_SHSTK_SHSTK))
return -ENOTSUPP;

fpregs_lock_and_load();

rdmsrq(MSR_IA32_PL3_SSP, ssp);
if (val && get_user(*val, (__user u64 *)ssp))
ret = -EFAULT;
else
wrmsrq(MSR_IA32_PL3_SSP, ssp + SS_FRAME_SIZE);
fpregs_unlock();

return ret;
}

int shstk_push(u64 val)
{
u64 ssp;
int ret;

if (!features_enabled(ARCH_SHSTK_SHSTK))
return -ENOTSUPP;

fpregs_lock_and_load();

rdmsrq(MSR_IA32_PL3_SSP, ssp);
ssp -= SS_FRAME_SIZE;
ret = write_user_shstk_64((__user void *)ssp, val);
if (!ret)
wrmsrq(MSR_IA32_PL3_SSP, ssp);
fpregs_unlock();

return ret;
}

#define SHSTK_DATA_BIT BIT(63)

static int put_shstk_data(u64 __user *addr, u64 data)
Expand Down
Loading
Loading