Skip to content

Commit 26a0198

Browse files
committed
Merge tag 'perf-tools-fixes-for-v7.0-2-2026-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fix parsing 'overwrite' in command line event definitions in big-endian machines by writing correct union member - Fix finding default metric in 'perf stat' - Fix relative paths for including headers in 'perf kvm stat' - Sync header copies with the kernel sources: msr-index.h, kvm, build_bug.h * tag 'perf-tools-fixes-for-v7.0-2-2026-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: tools headers: Synchronize linux/build_bug.h with the kernel sources tools headers UAPI: Sync x86's asm/kvm.h with the kernel sources tools headers UAPI: Sync linux/kvm.h with the kernel sources tools arch x86: Sync the msr-index.h copy with the kernel sources perf kvm stat: Fix relative paths for including headers perf parse-events: Fix big-endian 'overwrite' by writing correct union member perf metricgroup: Fix metricgroup__has_metric_or_groups() tools headers: Skip arm64 cputype.h check
2 parents 97a48d1 + 493ad07 commit 26a0198

8 files changed

Lines changed: 87 additions & 26 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,10 @@
740740
#define MSR_AMD64_SNP_SMT_PROT BIT_ULL(MSR_AMD64_SNP_SMT_PROT_BIT)
741741
#define MSR_AMD64_SNP_SECURE_AVIC_BIT 18
742742
#define MSR_AMD64_SNP_SECURE_AVIC BIT_ULL(MSR_AMD64_SNP_SECURE_AVIC_BIT)
743-
#define MSR_AMD64_SNP_RESV_BIT 19
743+
#define MSR_AMD64_SNP_RESERVED_BITS19_22 GENMASK_ULL(22, 19)
744+
#define MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT 23
745+
#define MSR_AMD64_SNP_IBPB_ON_ENTRY BIT_ULL(MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT)
746+
#define MSR_AMD64_SNP_RESV_BIT 24
744747
#define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, MSR_AMD64_SNP_RESV_BIT)
745748
#define MSR_AMD64_SAVIC_CONTROL 0xc0010138
746749
#define MSR_AMD64_SAVIC_EN_BIT 0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ struct kvm_sync_regs {
476476
#define KVM_X86_QUIRK_SLOT_ZAP_ALL (1 << 7)
477477
#define KVM_X86_QUIRK_STUFF_FEATURE_MSRS (1 << 8)
478478
#define KVM_X86_QUIRK_IGNORE_GUEST_PAT (1 << 9)
479+
#define KVM_X86_QUIRK_VMCS12_ALLOW_FREEZE_IN_SMM (1 << 10)
479480

480481
#define KVM_STATE_NESTED_FORMAT_VMX 0
481482
#define KVM_STATE_NESTED_FORMAT_SVM 1

tools/include/linux/build_bug.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
/**
3333
* BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied
3434
* error message.
35-
* @condition: the condition which the compiler should know is false.
35+
* @cond: the condition which the compiler should know is false.
36+
* @msg: build-time error message
3637
*
3738
* See BUILD_BUG_ON for description.
3839
*/
@@ -60,6 +61,7 @@
6061

6162
/**
6263
* static_assert - check integer constant expression at build time
64+
* @expr: expression to be checked
6365
*
6466
* static_assert() is a wrapper for the C11 _Static_assert, with a
6567
* little macro magic to make the message optional (defaulting to the

tools/include/uapi/linux/kvm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include <linux/ioctl.h>
1515
#include <asm/kvm.h>
1616

17+
#ifdef __KERNEL__
18+
#include <linux/kvm_types.h>
19+
#endif
20+
1721
#define KVM_API_VERSION 12
1822

1923
/*
@@ -1601,7 +1605,11 @@ struct kvm_stats_desc {
16011605
__u16 size;
16021606
__u32 offset;
16031607
__u32 bucket_size;
1608+
#ifdef __KERNEL__
1609+
char name[KVM_STATS_NAME_SIZE];
1610+
#else
16041611
char name[];
1612+
#endif
16051613
};
16061614

16071615
#define KVM_GET_STATS_FD _IO(KVMIO, 0xce)

tools/perf/check-headers.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ done
187187
check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))" -I"^#include <linux/cfi_types.h>"'
188188
check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"'
189189
check arch/x86/include/asm/amd/ibs.h '-I "^#include .*/msr-index.h"'
190-
check arch/arm64/include/asm/cputype.h '-I "^#include [<\"]\(asm/\)*sysreg.h"'
191190
check include/linux/unaligned.h '-I "^#include <linux/unaligned/packed_struct.h>" -I "^#include <asm/byteorder.h>" -I "^#pragma GCC diagnostic"'
192191
check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
193192
check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'

tools/perf/util/kvm-stat-arch/kvm-stat-x86.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include "../kvm-stat.h"
55
#include "../evsel.h"
66
#include "../env.h"
7-
#include "../../arch/x86/include/uapi/asm/svm.h"
8-
#include "../../arch/x86/include/uapi/asm/vmx.h"
9-
#include "../../arch/x86/include/uapi/asm/kvm.h"
7+
#include "../../../arch/x86/include/uapi/asm/svm.h"
8+
#include "../../../arch/x86/include/uapi/asm/vmx.h"
9+
#include "../../../arch/x86/include/uapi/asm/kvm.h"
1010
#include <subcmd/parse-options.h>
1111

1212
define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);

tools/perf/util/metricgroup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,9 +1605,9 @@ bool metricgroup__has_metric_or_groups(const char *pmu, const char *metric_or_gr
16051605
.metric_or_groups = metric_or_groups,
16061606
};
16071607

1608-
return pmu_metrics_table__for_each_metric(table,
1609-
metricgroup__has_metric_or_groups_callback,
1610-
&data)
1608+
return metricgroup__for_each_metric(table,
1609+
metricgroup__has_metric_or_groups_callback,
1610+
&data)
16111611
? true : false;
16121612
}
16131613

tools/perf/util/parse-events.c

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ static int config_attr(struct perf_event_attr *attr,
11171117

11181118
static struct evsel_config_term *add_config_term(enum evsel_term_type type,
11191119
struct list_head *head_terms,
1120-
bool weak)
1120+
bool weak, char *str, u64 val)
11211121
{
11221122
struct evsel_config_term *t;
11231123

@@ -1128,8 +1128,62 @@ static struct evsel_config_term *add_config_term(enum evsel_term_type type,
11281128
INIT_LIST_HEAD(&t->list);
11291129
t->type = type;
11301130
t->weak = weak;
1131-
list_add_tail(&t->list, head_terms);
11321131

1132+
switch (type) {
1133+
case EVSEL__CONFIG_TERM_PERIOD:
1134+
case EVSEL__CONFIG_TERM_FREQ:
1135+
case EVSEL__CONFIG_TERM_STACK_USER:
1136+
case EVSEL__CONFIG_TERM_USR_CHG_CONFIG:
1137+
case EVSEL__CONFIG_TERM_USR_CHG_CONFIG1:
1138+
case EVSEL__CONFIG_TERM_USR_CHG_CONFIG2:
1139+
case EVSEL__CONFIG_TERM_USR_CHG_CONFIG3:
1140+
case EVSEL__CONFIG_TERM_USR_CHG_CONFIG4:
1141+
t->val.val = val;
1142+
break;
1143+
case EVSEL__CONFIG_TERM_TIME:
1144+
t->val.time = val;
1145+
break;
1146+
case EVSEL__CONFIG_TERM_INHERIT:
1147+
t->val.inherit = val;
1148+
break;
1149+
case EVSEL__CONFIG_TERM_OVERWRITE:
1150+
t->val.overwrite = val;
1151+
break;
1152+
case EVSEL__CONFIG_TERM_MAX_STACK:
1153+
t->val.max_stack = val;
1154+
break;
1155+
case EVSEL__CONFIG_TERM_MAX_EVENTS:
1156+
t->val.max_events = val;
1157+
break;
1158+
case EVSEL__CONFIG_TERM_PERCORE:
1159+
t->val.percore = val;
1160+
break;
1161+
case EVSEL__CONFIG_TERM_AUX_OUTPUT:
1162+
t->val.aux_output = val;
1163+
break;
1164+
case EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE:
1165+
t->val.aux_sample_size = val;
1166+
break;
1167+
case EVSEL__CONFIG_TERM_CALLGRAPH:
1168+
case EVSEL__CONFIG_TERM_BRANCH:
1169+
case EVSEL__CONFIG_TERM_DRV_CFG:
1170+
case EVSEL__CONFIG_TERM_RATIO_TO_PREV:
1171+
case EVSEL__CONFIG_TERM_AUX_ACTION:
1172+
if (str) {
1173+
t->val.str = strdup(str);
1174+
if (!t->val.str) {
1175+
zfree(&t);
1176+
return NULL;
1177+
}
1178+
t->free_str = true;
1179+
}
1180+
break;
1181+
default:
1182+
t->val.val = val;
1183+
break;
1184+
}
1185+
1186+
list_add_tail(&t->list, head_terms);
11331187
return t;
11341188
}
11351189

@@ -1142,7 +1196,7 @@ static int get_config_terms(const struct parse_events_terms *head_config,
11421196
struct evsel_config_term *new_term;
11431197
enum evsel_term_type new_type;
11441198
bool str_type = false;
1145-
u64 val;
1199+
u64 val = 0;
11461200

11471201
switch (term->type_term) {
11481202
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
@@ -1234,20 +1288,15 @@ static int get_config_terms(const struct parse_events_terms *head_config,
12341288
continue;
12351289
}
12361290

1237-
new_term = add_config_term(new_type, head_terms, term->weak);
1291+
/*
1292+
* Note: Members evsel_config_term::val and
1293+
* parse_events_term::val are unions and endianness needs
1294+
* to be taken into account when changing such union members.
1295+
*/
1296+
new_term = add_config_term(new_type, head_terms, term->weak,
1297+
str_type ? term->val.str : NULL, val);
12381298
if (!new_term)
12391299
return -ENOMEM;
1240-
1241-
if (str_type) {
1242-
new_term->val.str = strdup(term->val.str);
1243-
if (!new_term->val.str) {
1244-
zfree(&new_term);
1245-
return -ENOMEM;
1246-
}
1247-
new_term->free_str = true;
1248-
} else {
1249-
new_term->val.val = val;
1250-
}
12511300
}
12521301
return 0;
12531302
}
@@ -1277,10 +1326,9 @@ static int add_cfg_chg(const struct perf_pmu *pmu,
12771326
if (bits) {
12781327
struct evsel_config_term *new_term;
12791328

1280-
new_term = add_config_term(new_term_type, head_terms, false);
1329+
new_term = add_config_term(new_term_type, head_terms, false, NULL, bits);
12811330
if (!new_term)
12821331
return -ENOMEM;
1283-
new_term->val.cfg_chg = bits;
12841332
}
12851333

12861334
return 0;

0 commit comments

Comments
 (0)