mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-22 20:23:57 +08:00
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: perf, x86: Fix incorrect branches event on AMD CPUs perf tools: Fix find tids routine by excluding "." and ".." x86: Send a SIGTRAP for user icebp traps
This commit is contained in:
commit
3f7d7b4bde
@ -102,8 +102,8 @@ static const u64 amd_perfmon_event_map[] =
|
|||||||
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
|
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
|
||||||
[PERF_COUNT_HW_CACHE_REFERENCES] = 0x0080,
|
[PERF_COUNT_HW_CACHE_REFERENCES] = 0x0080,
|
||||||
[PERF_COUNT_HW_CACHE_MISSES] = 0x0081,
|
[PERF_COUNT_HW_CACHE_MISSES] = 0x0081,
|
||||||
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4,
|
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2,
|
||||||
[PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5,
|
[PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3,
|
||||||
};
|
};
|
||||||
|
|
||||||
static u64 amd_pmu_event_map(int hw_event)
|
static u64 amd_pmu_event_map(int hw_event)
|
||||||
|
@ -526,6 +526,7 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
|
|||||||
dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
|
dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
|
||||||
{
|
{
|
||||||
struct task_struct *tsk = current;
|
struct task_struct *tsk = current;
|
||||||
|
int user_icebp = 0;
|
||||||
unsigned long dr6;
|
unsigned long dr6;
|
||||||
int si_code;
|
int si_code;
|
||||||
|
|
||||||
@ -534,6 +535,14 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
|
|||||||
/* Filter out all the reserved bits which are preset to 1 */
|
/* Filter out all the reserved bits which are preset to 1 */
|
||||||
dr6 &= ~DR6_RESERVED;
|
dr6 &= ~DR6_RESERVED;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If dr6 has no reason to give us about the origin of this trap,
|
||||||
|
* then it's very likely the result of an icebp/int01 trap.
|
||||||
|
* User wants a sigtrap for that.
|
||||||
|
*/
|
||||||
|
if (!dr6 && user_mode(regs))
|
||||||
|
user_icebp = 1;
|
||||||
|
|
||||||
/* Catch kmemcheck conditions first of all! */
|
/* Catch kmemcheck conditions first of all! */
|
||||||
if ((dr6 & DR_STEP) && kmemcheck_trap(regs))
|
if ((dr6 & DR_STEP) && kmemcheck_trap(regs))
|
||||||
return;
|
return;
|
||||||
@ -575,7 +584,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
|
|||||||
regs->flags &= ~X86_EFLAGS_TF;
|
regs->flags &= ~X86_EFLAGS_TF;
|
||||||
}
|
}
|
||||||
si_code = get_si_code(tsk->thread.debugreg6);
|
si_code = get_si_code(tsk->thread.debugreg6);
|
||||||
if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS))
|
if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS) || user_icebp)
|
||||||
send_sigtrap(tsk, regs, error_code, si_code);
|
send_sigtrap(tsk, regs, error_code, si_code);
|
||||||
preempt_conditional_cli(regs);
|
preempt_conditional_cli(regs);
|
||||||
|
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
/* Skip "." and ".." directories */
|
||||||
|
static int filter(const struct dirent *dir)
|
||||||
|
{
|
||||||
|
if (dir->d_name[0] == '.')
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int find_all_tid(int pid, pid_t ** all_tid)
|
int find_all_tid(int pid, pid_t ** all_tid)
|
||||||
{
|
{
|
||||||
char name[256];
|
char name[256];
|
||||||
@ -16,7 +25,7 @@ int find_all_tid(int pid, pid_t ** all_tid)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
sprintf(name, "/proc/%d/task", pid);
|
sprintf(name, "/proc/%d/task", pid);
|
||||||
items = scandir(name, &namelist, NULL, NULL);
|
items = scandir(name, &namelist, filter, NULL);
|
||||||
if (items <= 0)
|
if (items <= 0)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
*all_tid = malloc(sizeof(pid_t) * items);
|
*all_tid = malloc(sizeof(pid_t) * items);
|
||||||
|
Loading…
Reference in New Issue
Block a user