Skip to content

Commit 98d006e

Browse files
committed
Merge tag 'perf_urgent_for_v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Borislav Petkov: - Prevent the amd/power module from being removed while in use - Mark AMD IBS as not supporting content exclusion - Add a workaround for AMD erratum torvalds#1197 where IBS registers might not be restored properly after exiting CC6 state - Fix a potential truncation of a 32-bit variable due to shifting - Read the correct bits describing the number of configurable address ranges on Intel PT * tag 'perf_urgent_for_v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/amd/power: Assign pmu.module perf/x86/amd/ibs: Extend PERF_PMU_CAP_NO_EXCLUDE to IBS Op perf/x86/amd/ibs: Work around erratum torvalds#1197 perf/x86/intel/uncore: Fix integer overflow on 23 bit left shift of a u32 perf/x86/intel/pt: Fix mask of num_address_ranges
2 parents 072a276 + ccf2648 commit 98d006e

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

arch/x86/events/amd/ibs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct perf_ibs {
9090
unsigned long offset_mask[1];
9191
int offset_max;
9292
unsigned int fetch_count_reset_broken : 1;
93+
unsigned int fetch_ignore_if_zero_rip : 1;
9394
struct cpu_perf_ibs __percpu *pcpu;
9495

9596
struct attribute **format_attrs;
@@ -570,6 +571,7 @@ static struct perf_ibs perf_ibs_op = {
570571
.start = perf_ibs_start,
571572
.stop = perf_ibs_stop,
572573
.read = perf_ibs_read,
574+
.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
573575
},
574576
.msr = MSR_AMD64_IBSOPCTL,
575577
.config_mask = IBS_OP_CONFIG_MASK,
@@ -672,6 +674,10 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
672674
if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {
673675
regs.flags &= ~PERF_EFLAGS_EXACT;
674676
} else {
677+
/* Workaround for erratum #1197 */
678+
if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
679+
goto out;
680+
675681
set_linear_ip(&regs, ibs_data.regs[1]);
676682
regs.flags |= PERF_EFLAGS_EXACT;
677683
}
@@ -769,6 +775,9 @@ static __init void perf_event_ibs_init(void)
769775
if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
770776
perf_ibs_fetch.fetch_count_reset_broken = 1;
771777

778+
if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10)
779+
perf_ibs_fetch.fetch_ignore_if_zero_rip = 1;
780+
772781
perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
773782

774783
if (ibs_caps & IBS_CAPS_OPCNT) {

arch/x86/events/amd/power.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static struct pmu pmu_class = {
213213
.stop = pmu_event_stop,
214214
.read = pmu_event_read,
215215
.capabilities = PERF_PMU_CAP_NO_EXCLUDE,
216+
.module = THIS_MODULE,
216217
};
217218

218219
static int power_cpu_exit(unsigned int cpu)

arch/x86/events/intel/pt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static struct pt_cap_desc {
6262
PT_CAP(single_range_output, 0, CPUID_ECX, BIT(2)),
6363
PT_CAP(output_subsys, 0, CPUID_ECX, BIT(3)),
6464
PT_CAP(payloads_lip, 0, CPUID_ECX, BIT(31)),
65-
PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x3),
65+
PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x7),
6666
PT_CAP(mtc_periods, 1, CPUID_EAX, 0xffff0000),
6767
PT_CAP(cycle_thresholds, 1, CPUID_EBX, 0xffff),
6868
PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),

arch/x86/events/intel/uncore_snbep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4811,7 +4811,7 @@ static void __snr_uncore_mmio_init_box(struct intel_uncore_box *box,
48114811
return;
48124812

48134813
pci_read_config_dword(pdev, SNR_IMC_MMIO_BASE_OFFSET, &pci_dword);
4814-
addr = (pci_dword & SNR_IMC_MMIO_BASE_MASK) << 23;
4814+
addr = ((resource_size_t)pci_dword & SNR_IMC_MMIO_BASE_MASK) << 23;
48154815

48164816
pci_read_config_dword(pdev, mem_offset, &pci_dword);
48174817
addr |= (pci_dword & SNR_IMC_MMIO_MEM0_MASK) << 12;

0 commit comments

Comments
 (0)