Skip to content

Commit 7c7f9dd

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.16-1-2025-06-20' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fix some file descriptor leaks that stand out with recent changes to 'perf list' - Fix prctl include to fix building 'perf bench futex' hash with musl libc - Restrict 'perf test' uniquifying entry to machines with 'uncore_imc' PMUs - Document new output fields (op, cache, mem, dtlb, snoop) used with 'perf mem' - Synchronize kernel header copies * tag 'perf-tools-fixes-for-v6.16-1-2025-06-20' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: tools headers x86 cpufeatures: Sync with the kernel sources perf bench futex: Fix prctl include in musl libc perf test: Directory file descriptor leak perf evsel: Missed close() when probing hybrid core PMUs tools headers: Synchronize linux/bits.h with the kernel sources tools arch amd ibs: Sync ibs.h with the kernel sources tools arch x86: Sync the msr-index.h copy with the kernel sources tools headers: Syncronize linux/build_bug.h with the kernel sources tools headers: Update the copy of x86's mem{cpy,set}_64.S used in 'perf bench' tools headers UAPI: Sync linux/kvm.h with the kernel sources tools headers UAPI: Sync the drm/drm.h with the kernel sources perf beauty: Update copy of linux/socket.h with the kernel sources tools headers UAPI: Sync kvm header with the kernel sources tools headers x86 svm: Sync svm headers with the kernel sources tools headers UAPI: Sync KVM's vmx.h header with the kernel sources tools kvm headers arm64: Update KVM header from the kernel sources tools headers UAPI: Sync linux/prctl.h with the kernel sources to pick FUTEX knob perf mem: Document new output fields (op, cache, mem, dtlb, snoop) tools headers: Update the fs headers with the kernel sources perf test: Restrict uniquifying test to machines with 'uncore_imc'
2 parents 3f75bff + d222b6e commit 7c7f9dd

File tree

30 files changed

+329
-53
lines changed

30 files changed

+329
-53
lines changed

include/uapi/linux/bits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#ifndef _UAPI_LINUX_BITS_H
55
#define _UAPI_LINUX_BITS_H
66

7-
#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
7+
#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))
88

9-
#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
9+
#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
1010

1111
#define __GENMASK_U128(h, l) \
1212
((_BIT128((h)) << 1) - (_BIT128(l)))

tools/arch/arm64/include/uapi/asm/kvm.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,11 @@ enum {
431431

432432
/* Device Control API on vcpu fd */
433433
#define KVM_ARM_VCPU_PMU_V3_CTRL 0
434-
#define KVM_ARM_VCPU_PMU_V3_IRQ 0
435-
#define KVM_ARM_VCPU_PMU_V3_INIT 1
436-
#define KVM_ARM_VCPU_PMU_V3_FILTER 2
437-
#define KVM_ARM_VCPU_PMU_V3_SET_PMU 3
434+
#define KVM_ARM_VCPU_PMU_V3_IRQ 0
435+
#define KVM_ARM_VCPU_PMU_V3_INIT 1
436+
#define KVM_ARM_VCPU_PMU_V3_FILTER 2
437+
#define KVM_ARM_VCPU_PMU_V3_SET_PMU 3
438+
#define KVM_ARM_VCPU_PMU_V3_SET_NR_COUNTERS 4
438439
#define KVM_ARM_VCPU_TIMER_CTRL 1
439440
#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0
440441
#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1

tools/arch/x86/include/asm/amd/ibs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_X86_AMD_IBS_H
3+
#define _ASM_X86_AMD_IBS_H
4+
25
/*
36
* From PPR Vol 1 for AMD Family 19h Model 01h B1
47
* 55898 Rev 0.35 - Feb 5, 2021
@@ -151,3 +154,5 @@ struct perf_ibs_data {
151154
};
152155
u64 regs[MSR_AMD64_IBS_REG_COUNT_MAX];
153156
};
157+
158+
#endif /* _ASM_X86_AMD_IBS_H */

tools/arch/x86/include/asm/cpufeatures.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
#define X86_FEATURE_AMD_IBRS (13*32+14) /* Indirect Branch Restricted Speculation */
337337
#define X86_FEATURE_AMD_STIBP (13*32+15) /* Single Thread Indirect Branch Predictors */
338338
#define X86_FEATURE_AMD_STIBP_ALWAYS_ON (13*32+17) /* Single Thread Indirect Branch Predictors always-on preferred */
339-
#define X86_FEATURE_AMD_IBRS_SAME_MODE (13*32+19) /* Indirect Branch Restricted Speculation same mode protection*/
339+
#define X86_FEATURE_AMD_IBRS_SAME_MODE (13*32+19) /* Indirect Branch Restricted Speculation same mode protection*/
340340
#define X86_FEATURE_AMD_PPIN (13*32+23) /* "amd_ppin" Protected Processor Inventory Number */
341341
#define X86_FEATURE_AMD_SSBD (13*32+24) /* Speculative Store Bypass Disable */
342342
#define X86_FEATURE_VIRT_SSBD (13*32+25) /* "virt_ssbd" Virtualized Speculative Store Bypass Disable */
@@ -379,6 +379,7 @@
379379
#define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* "v_spec_ctrl" Virtual SPEC_CTRL */
380380
#define X86_FEATURE_VNMI (15*32+25) /* "vnmi" Virtual NMI */
381381
#define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* SVME addr check */
382+
#define X86_FEATURE_BUS_LOCK_THRESHOLD (15*32+29) /* Bus lock threshold */
382383
#define X86_FEATURE_IDLE_HLT (15*32+30) /* IDLE HLT intercept */
383384

384385
/* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */
@@ -447,6 +448,7 @@
447448
#define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */
448449
#define X86_FEATURE_RMPREAD (19*32+21) /* RMPREAD instruction */
449450
#define X86_FEATURE_SEGMENTED_RMP (19*32+23) /* Segmented RMP support */
451+
#define X86_FEATURE_ALLOWED_SEV_FEATURES (19*32+27) /* Allowed SEV Features */
450452
#define X86_FEATURE_SVSM (19*32+28) /* "svsm" SVSM present */
451453
#define X86_FEATURE_HV_INUSE_WR_ALLOWED (19*32+30) /* Allow Write to in-use hypervisor-owned pages */
452454

@@ -458,6 +460,7 @@
458460
#define X86_FEATURE_AUTOIBRS (20*32+ 8) /* Automatic IBRS */
459461
#define X86_FEATURE_NO_SMM_CTL_MSR (20*32+ 9) /* SMM_CTL MSR is not present */
460462

463+
#define X86_FEATURE_PREFETCHI (20*32+20) /* Prefetch Data/Instruction to Cache Level */
461464
#define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */
462465
#define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */
463466
#define X86_FEATURE_SRSO_NO (20*32+29) /* CPU is not affected by SRSO */
@@ -482,7 +485,8 @@
482485
#define X86_FEATURE_AMD_HTR_CORES (21*32+ 6) /* Heterogeneous Core Topology */
483486
#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32+ 7) /* Workload Classification */
484487
#define X86_FEATURE_PREFER_YMM (21*32+ 8) /* Avoid ZMM registers due to downclocking */
485-
#define X86_FEATURE_INDIRECT_THUNK_ITS (21*32+ 9) /* Use thunk for indirect branches in lower half of cacheline */
488+
#define X86_FEATURE_APX (21*32+ 9) /* Advanced Performance Extensions */
489+
#define X86_FEATURE_INDIRECT_THUNK_ITS (21*32+10) /* Use thunk for indirect branches in lower half of cacheline */
486490

487491
/*
488492
* BUG word(s)
@@ -535,6 +539,8 @@
535539
#define X86_BUG_BHI X86_BUG( 1*32+ 3) /* "bhi" CPU is affected by Branch History Injection */
536540
#define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */
537541
#define X86_BUG_SPECTRE_V2_USER X86_BUG( 1*32+ 5) /* "spectre_v2_user" CPU is affected by Spectre variant 2 attack between user processes */
538-
#define X86_BUG_ITS X86_BUG( 1*32+ 6) /* "its" CPU is affected by Indirect Target Selection */
539-
#define X86_BUG_ITS_NATIVE_ONLY X86_BUG( 1*32+ 7) /* "its_native_only" CPU is affected by ITS, VMX is not affected */
542+
#define X86_BUG_OLD_MICROCODE X86_BUG( 1*32+ 6) /* "old_microcode" CPU has old microcode, it is surely vulnerable to something */
543+
#define X86_BUG_ITS X86_BUG( 1*32+ 7) /* "its" CPU is affected by Indirect Target Selection */
544+
#define X86_BUG_ITS_NATIVE_ONLY X86_BUG( 1*32+ 8) /* "its_native_only" CPU is affected by ITS, VMX is not affected */
545+
540546
#endif /* _ASM_X86_CPUFEATURES_H */

tools/arch/x86/include/asm/msr-index.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@
533533
#define MSR_HWP_CAPABILITIES 0x00000771
534534
#define MSR_HWP_REQUEST_PKG 0x00000772
535535
#define MSR_HWP_INTERRUPT 0x00000773
536-
#define MSR_HWP_REQUEST 0x00000774
536+
#define MSR_HWP_REQUEST 0x00000774
537537
#define MSR_HWP_STATUS 0x00000777
538538

539539
/* CPUID.6.EAX */
@@ -550,16 +550,16 @@
550550
#define HWP_LOWEST_PERF(x) (((x) >> 24) & 0xff)
551551

552552
/* IA32_HWP_REQUEST */
553-
#define HWP_MIN_PERF(x) (x & 0xff)
554-
#define HWP_MAX_PERF(x) ((x & 0xff) << 8)
553+
#define HWP_MIN_PERF(x) (x & 0xff)
554+
#define HWP_MAX_PERF(x) ((x & 0xff) << 8)
555555
#define HWP_DESIRED_PERF(x) ((x & 0xff) << 16)
556-
#define HWP_ENERGY_PERF_PREFERENCE(x) (((unsigned long long) x & 0xff) << 24)
556+
#define HWP_ENERGY_PERF_PREFERENCE(x) (((u64)x & 0xff) << 24)
557557
#define HWP_EPP_PERFORMANCE 0x00
558558
#define HWP_EPP_BALANCE_PERFORMANCE 0x80
559559
#define HWP_EPP_BALANCE_POWERSAVE 0xC0
560560
#define HWP_EPP_POWERSAVE 0xFF
561-
#define HWP_ACTIVITY_WINDOW(x) ((unsigned long long)(x & 0xff3) << 32)
562-
#define HWP_PACKAGE_CONTROL(x) ((unsigned long long)(x & 0x1) << 42)
561+
#define HWP_ACTIVITY_WINDOW(x) ((u64)(x & 0xff3) << 32)
562+
#define HWP_PACKAGE_CONTROL(x) ((u64)(x & 0x1) << 42)
563563

564564
/* IA32_HWP_STATUS */
565565
#define HWP_GUARANTEED_CHANGE(x) (x & 0x1)
@@ -602,7 +602,11 @@
602602
/* V6 PMON MSR range */
603603
#define MSR_IA32_PMC_V6_GP0_CTR 0x1900
604604
#define MSR_IA32_PMC_V6_GP0_CFG_A 0x1901
605+
#define MSR_IA32_PMC_V6_GP0_CFG_B 0x1902
606+
#define MSR_IA32_PMC_V6_GP0_CFG_C 0x1903
605607
#define MSR_IA32_PMC_V6_FX0_CTR 0x1980
608+
#define MSR_IA32_PMC_V6_FX0_CFG_B 0x1982
609+
#define MSR_IA32_PMC_V6_FX0_CFG_C 0x1983
606610
#define MSR_IA32_PMC_V6_STEP 4
607611

608612
/* KeyID partitioning between MKTME and TDX */

tools/arch/x86/include/uapi/asm/kvm.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ struct kvm_sync_regs {
441441
#define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6)
442442
#define KVM_X86_QUIRK_SLOT_ZAP_ALL (1 << 7)
443443
#define KVM_X86_QUIRK_STUFF_FEATURE_MSRS (1 << 8)
444+
#define KVM_X86_QUIRK_IGNORE_GUEST_PAT (1 << 9)
444445

445446
#define KVM_STATE_NESTED_FORMAT_VMX 0
446447
#define KVM_STATE_NESTED_FORMAT_SVM 1
@@ -931,4 +932,74 @@ struct kvm_hyperv_eventfd {
931932
#define KVM_X86_SNP_VM 4
932933
#define KVM_X86_TDX_VM 5
933934

935+
/* Trust Domain eXtension sub-ioctl() commands. */
936+
enum kvm_tdx_cmd_id {
937+
KVM_TDX_CAPABILITIES = 0,
938+
KVM_TDX_INIT_VM,
939+
KVM_TDX_INIT_VCPU,
940+
KVM_TDX_INIT_MEM_REGION,
941+
KVM_TDX_FINALIZE_VM,
942+
KVM_TDX_GET_CPUID,
943+
944+
KVM_TDX_CMD_NR_MAX,
945+
};
946+
947+
struct kvm_tdx_cmd {
948+
/* enum kvm_tdx_cmd_id */
949+
__u32 id;
950+
/* flags for sub-commend. If sub-command doesn't use this, set zero. */
951+
__u32 flags;
952+
/*
953+
* data for each sub-command. An immediate or a pointer to the actual
954+
* data in process virtual address. If sub-command doesn't use it,
955+
* set zero.
956+
*/
957+
__u64 data;
958+
/*
959+
* Auxiliary error code. The sub-command may return TDX SEAMCALL
960+
* status code in addition to -Exxx.
961+
*/
962+
__u64 hw_error;
963+
};
964+
965+
struct kvm_tdx_capabilities {
966+
__u64 supported_attrs;
967+
__u64 supported_xfam;
968+
__u64 reserved[254];
969+
970+
/* Configurable CPUID bits for userspace */
971+
struct kvm_cpuid2 cpuid;
972+
};
973+
974+
struct kvm_tdx_init_vm {
975+
__u64 attributes;
976+
__u64 xfam;
977+
__u64 mrconfigid[6]; /* sha384 digest */
978+
__u64 mrowner[6]; /* sha384 digest */
979+
__u64 mrownerconfig[6]; /* sha384 digest */
980+
981+
/* The total space for TD_PARAMS before the CPUIDs is 256 bytes */
982+
__u64 reserved[12];
983+
984+
/*
985+
* Call KVM_TDX_INIT_VM before vcpu creation, thus before
986+
* KVM_SET_CPUID2.
987+
* This configuration supersedes KVM_SET_CPUID2s for VCPUs because the
988+
* TDX module directly virtualizes those CPUIDs without VMM. The user
989+
* space VMM, e.g. qemu, should make KVM_SET_CPUID2 consistent with
990+
* those values. If it doesn't, KVM may have wrong idea of vCPUIDs of
991+
* the guest, and KVM may wrongly emulate CPUIDs or MSRs that the TDX
992+
* module doesn't virtualize.
993+
*/
994+
struct kvm_cpuid2 cpuid;
995+
};
996+
997+
#define KVM_TDX_MEASURE_MEMORY_REGION _BITULL(0)
998+
999+
struct kvm_tdx_init_mem_region {
1000+
__u64 source_addr;
1001+
__u64 gpa;
1002+
__u64 nr_pages;
1003+
};
1004+
9341005
#endif /* _ASM_X86_KVM_H */

tools/arch/x86/include/uapi/asm/svm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#define SVM_EXIT_CR14_WRITE_TRAP 0x09e
9696
#define SVM_EXIT_CR15_WRITE_TRAP 0x09f
9797
#define SVM_EXIT_INVPCID 0x0a2
98+
#define SVM_EXIT_BUS_LOCK 0x0a5
9899
#define SVM_EXIT_IDLE_HLT 0x0a6
99100
#define SVM_EXIT_NPF 0x400
100101
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
@@ -225,6 +226,7 @@
225226
{ SVM_EXIT_CR4_WRITE_TRAP, "write_cr4_trap" }, \
226227
{ SVM_EXIT_CR8_WRITE_TRAP, "write_cr8_trap" }, \
227228
{ SVM_EXIT_INVPCID, "invpcid" }, \
229+
{ SVM_EXIT_BUS_LOCK, "buslock" }, \
228230
{ SVM_EXIT_IDLE_HLT, "idle-halt" }, \
229231
{ SVM_EXIT_NPF, "npf" }, \
230232
{ SVM_EXIT_AVIC_INCOMPLETE_IPI, "avic_incomplete_ipi" }, \

tools/arch/x86/include/uapi/asm/vmx.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define EXIT_REASON_TRIPLE_FAULT 2
3535
#define EXIT_REASON_INIT_SIGNAL 3
3636
#define EXIT_REASON_SIPI_SIGNAL 4
37+
#define EXIT_REASON_OTHER_SMI 6
3738

3839
#define EXIT_REASON_INTERRUPT_WINDOW 7
3940
#define EXIT_REASON_NMI_WINDOW 8
@@ -92,6 +93,7 @@
9293
#define EXIT_REASON_TPAUSE 68
9394
#define EXIT_REASON_BUS_LOCK 74
9495
#define EXIT_REASON_NOTIFY 75
96+
#define EXIT_REASON_TDCALL 77
9597

9698
#define VMX_EXIT_REASONS \
9799
{ EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
@@ -155,7 +157,8 @@
155157
{ EXIT_REASON_UMWAIT, "UMWAIT" }, \
156158
{ EXIT_REASON_TPAUSE, "TPAUSE" }, \
157159
{ EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \
158-
{ EXIT_REASON_NOTIFY, "NOTIFY" }
160+
{ EXIT_REASON_NOTIFY, "NOTIFY" }, \
161+
{ EXIT_REASON_TDCALL, "TDCALL" }
159162

160163
#define VMX_EXIT_REASON_FLAGS \
161164
{ VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }

tools/arch/x86/lib/memcpy_64.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SYM_FUNC_END(__memcpy)
4040
EXPORT_SYMBOL(__memcpy)
4141

4242
SYM_FUNC_ALIAS_MEMFUNC(memcpy, __memcpy)
43+
SYM_PIC_ALIAS(memcpy)
4344
EXPORT_SYMBOL(memcpy)
4445

4546
SYM_FUNC_START_LOCAL(memcpy_orig)

tools/arch/x86/lib/memset_64.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SYM_FUNC_END(__memset)
4242
EXPORT_SYMBOL(__memset)
4343

4444
SYM_FUNC_ALIAS_MEMFUNC(memset, __memset)
45+
SYM_PIC_ALIAS(memset)
4546
EXPORT_SYMBOL(memset)
4647

4748
SYM_FUNC_START_LOCAL(memset_orig)

0 commit comments

Comments
 (0)