Skip to content

Commit 4a0c7a6

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.2-3-2023-01-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Prevent reading into undefined memory in the expression lexer, accounting for a trailer backslash followed by the null byte. - Fix file mode when copying files to the build id cache, the problem happens when the cache directory is in a different file system than the file being cached, otherwise the mode was preserved as only a hard link would be done to save space. - Fix a related build-id 'perf test' entry that checked that permission when caching PE (Portable Executable) files, used when profiling Windows executables under wine. - Sync the tools/ copies of kvm headers, build_bug.h, socket.h and arm64's cputype.h with the kernel sources. * tag 'perf-tools-fixes-for-v6.2-3-2023-01-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf test build-id: Fix test check for PE file perf buildid-cache: Fix the file mode with copyfile() while adding file to build-id cache perf expr: Prevent normalize() from reading into undefined memory in the expression lexer tools headers: Syncronize linux/build_bug.h with the kernel sources perf beauty: Update copy of linux/socket.h with the kernel sources tools headers arm64: Sync arm64's cputype.h with the kernel sources tools kvm headers arm64: Update KVM header from 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
2 parents d368967 + 3d9c07c commit 4a0c7a6

File tree

9 files changed

+54
-7
lines changed

9 files changed

+54
-7
lines changed

tools/arch/arm64/include/asm/cputype.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
(((midr) & MIDR_IMPLEMENTOR_MASK) >> MIDR_IMPLEMENTOR_SHIFT)
4242

4343
#define MIDR_CPU_MODEL(imp, partnum) \
44-
(((imp) << MIDR_IMPLEMENTOR_SHIFT) | \
44+
((_AT(u32, imp) << MIDR_IMPLEMENTOR_SHIFT) | \
4545
(0xf << MIDR_ARCHITECTURE_SHIFT) | \
4646
((partnum) << MIDR_PARTNUM_SHIFT))
4747

@@ -80,6 +80,7 @@
8080
#define ARM_CPU_PART_CORTEX_X1 0xD44
8181
#define ARM_CPU_PART_CORTEX_A510 0xD46
8282
#define ARM_CPU_PART_CORTEX_A710 0xD47
83+
#define ARM_CPU_PART_CORTEX_A715 0xD4D
8384
#define ARM_CPU_PART_CORTEX_X2 0xD48
8485
#define ARM_CPU_PART_NEOVERSE_N2 0xD49
8586
#define ARM_CPU_PART_CORTEX_A78C 0xD4B
@@ -123,6 +124,8 @@
123124
#define APPLE_CPU_PART_M1_FIRESTORM_PRO 0x025
124125
#define APPLE_CPU_PART_M1_ICESTORM_MAX 0x028
125126
#define APPLE_CPU_PART_M1_FIRESTORM_MAX 0x029
127+
#define APPLE_CPU_PART_M2_BLIZZARD 0x032
128+
#define APPLE_CPU_PART_M2_AVALANCHE 0x033
126129

127130
#define AMPERE_CPU_PART_AMPERE1 0xAC3
128131

@@ -142,6 +145,7 @@
142145
#define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1)
143146
#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510)
144147
#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)
148+
#define MIDR_CORTEX_A715 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A715)
145149
#define MIDR_CORTEX_X2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X2)
146150
#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2)
147151
#define MIDR_CORTEX_A78C MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78C)
@@ -175,6 +179,8 @@
175179
#define MIDR_APPLE_M1_FIRESTORM_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_PRO)
176180
#define MIDR_APPLE_M1_ICESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_MAX)
177181
#define MIDR_APPLE_M1_FIRESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX)
182+
#define MIDR_APPLE_M2_BLIZZARD MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD)
183+
#define MIDR_APPLE_M2_AVALANCHE MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE)
178184
#define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1)
179185

180186
/* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#define __KVM_HAVE_VCPU_EVENTS
4444

4545
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
46+
#define KVM_DIRTY_LOG_PAGE_OFFSET 64
4647

4748
#define KVM_REG_SIZE(id) \
4849
(1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ struct kvm_msr_list {
206206
struct kvm_msr_filter_range {
207207
#define KVM_MSR_FILTER_READ (1 << 0)
208208
#define KVM_MSR_FILTER_WRITE (1 << 1)
209+
#define KVM_MSR_FILTER_RANGE_VALID_MASK (KVM_MSR_FILTER_READ | \
210+
KVM_MSR_FILTER_WRITE)
209211
__u32 flags;
210212
__u32 nmsrs; /* number of msrs in bitmap */
211213
__u32 base; /* MSR index the bitmap starts at */
@@ -214,8 +216,11 @@ struct kvm_msr_filter_range {
214216

215217
#define KVM_MSR_FILTER_MAX_RANGES 16
216218
struct kvm_msr_filter {
219+
#ifndef __KERNEL__
217220
#define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
221+
#endif
218222
#define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0)
223+
#define KVM_MSR_FILTER_VALID_MASK (KVM_MSR_FILTER_DEFAULT_DENY)
219224
__u32 flags;
220225
struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
221226
};

tools/include/linux/build_bug.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,13 @@
7979
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
8080
#endif // static_assert
8181

82+
83+
/*
84+
* Compile time check that field has an expected offset
85+
*/
86+
#define ASSERT_STRUCT_OFFSET(type, field, expected_offset) \
87+
BUILD_BUG_ON_MSG(offsetof(type, field) != (expected_offset), \
88+
"Offset of " #field " in " #type " has changed.")
89+
90+
8291
#endif /* _LINUX_BUILD_BUG_H */

tools/include/uapi/linux/kvm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ struct kvm_xen_hvm_attr {
17671767
__u8 runstate_update_flag;
17681768
struct {
17691769
__u64 gfn;
1770+
#define KVM_XEN_INVALID_GFN ((__u64)-1)
17701771
} shared_info;
17711772
struct {
17721773
__u32 send_port;
@@ -1798,6 +1799,7 @@ struct kvm_xen_hvm_attr {
17981799
} u;
17991800
};
18001801

1802+
18011803
/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
18021804
#define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0
18031805
#define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1
@@ -1823,6 +1825,7 @@ struct kvm_xen_vcpu_attr {
18231825
__u16 pad[3];
18241826
union {
18251827
__u64 gpa;
1828+
#define KVM_XEN_INVALID_GPA ((__u64)-1)
18261829
__u64 pad[8];
18271830
struct {
18281831
__u64 state;

tools/perf/tests/shell/buildid.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,20 @@ check()
7777
file=${build_id_dir}/.build-id/${id:0:2}/`readlink ${link}`/elf
7878
echo "file: ${file}"
7979

80-
if [ ! -x $file ]; then
80+
# Check for file permission of original file
81+
# in case of pe-file.exe file
82+
echo $1 | grep ".exe"
83+
if [ $? -eq 0 ]; then
84+
if [ -x $1 -a ! -x $file ]; then
85+
echo "failed: file ${file} executable does not exist"
86+
exit 1
87+
fi
88+
89+
if [ ! -x $file -a ! -e $file ]; then
90+
echo "failed: file ${file} does not exist"
91+
exit 1
92+
fi
93+
elif [ ! -x $file ]; then
8194
echo "failed: file ${file} does not exist"
8295
exit 1
8396
fi

tools/perf/trace/beauty/include/linux/socket.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ typedef __kernel_sa_family_t sa_family_t;
3333

3434
struct sockaddr {
3535
sa_family_t sa_family; /* address family, AF_xxx */
36-
char sa_data[14]; /* 14 bytes of protocol address */
36+
union {
37+
char sa_data_min[14]; /* Minimum 14 bytes of protocol address */
38+
DECLARE_FLEX_ARRAY(char, sa_data);
39+
};
3740
};
3841

3942
struct linger {

tools/perf/util/build-id.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,13 @@ build_id_cache__add(const char *sbuild_id, const char *name, const char *realnam
715715
} else if (nsi && nsinfo__need_setns(nsi)) {
716716
if (copyfile_ns(name, filename, nsi))
717717
goto out_free;
718-
} else if (link(realname, filename) && errno != EEXIST &&
719-
copyfile(name, filename))
720-
goto out_free;
718+
} else if (link(realname, filename) && errno != EEXIST) {
719+
struct stat f_stat;
720+
721+
if (!(stat(name, &f_stat) < 0) &&
722+
copyfile_mode(name, filename, f_stat.st_mode))
723+
goto out_free;
724+
}
721725
}
722726

723727
/* Some binaries are stripped, but have .debug files with their symbol

tools/perf/util/expr.l

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ static char *normalize(char *str, int runtime)
4242
char *dst = str;
4343

4444
while (*str) {
45-
if (*str == '\\')
45+
if (*str == '\\') {
4646
*dst++ = *++str;
47+
if (!*str)
48+
break;
49+
}
4750
else if (*str == '?') {
4851
char *paramval;
4952
int i = 0;

0 commit comments

Comments
 (0)