Skip to contentSkip to conversation

Sync tools headers with the kernel source

PATCH In review Namhyung Kim 7 participants 24 messages Apr 8, 2024 – Apr 9, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Sync tools headers with the kernel source

Hello,

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

This is the full explanation from Arnaldo:

There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model.

The way these headers are used in perf are not restricted to just including them to compile something.

There are sometimes used in scripts that convert defines into string tables, etc, so some change may break one of these scripts, or new MSRs may use some different #define pattern, etc.

E.g.:

  $ ls -1 tools/perf/trace/beauty/*.sh | head -5
  tools/perf/trace/beauty/arch_errno_names.sh
  tools/perf/trace/beauty/drm_ioctl.sh
  tools/perf/trace/beauty/fadvise.sh
  tools/perf/trace/beauty/fsconfig.sh
  tools/perf/trace/beauty/fsmount.sh
  $
  $ tools/perf/trace/beauty/fadvise.sh
  static const char *fadvise_advices[] = {
        [0] = "NORMAL",
        [1] = "RANDOM",
        [2] = "SEQUENTIAL",
        [3] = "WILLNEED",
        [4] = "DONTNEED",
        [5] = "NOREUSE",
  };
  $

The tools/perf/check-headers.sh script, part of the tools/ build process, points out changes in the original files.

So its important not to touch the copies in tools/ when doing changes in the original kernel headers, that will be done later, when check-headers.sh inform about the change to the perf tools hackers.

Thanks,
Namhyung

Namhyung Kim (9):
tools/include: Sync uapi/drm/i915_drm.h with the kernel sources tools/include: Sync uapi/linux/fs.h with the kernel sources tools/include: Sync uapi/linux/kvm.h and asm/kvm.h with the kernel
sources
tools/include: Sync uapi/sound/asound.h with the kernel sources tools/include: Sync x86 CPU feature headers with the kernel sources tools/include: Sync x86 asm/irq_vectors.h with the kernel sources tools/include: Sync x86 asm/msr-index.h with the kernel sources tools/include: Sync asm-generic/bitops/fls.h with the kernel sources tools/include: Sync arm64 asm/cputype.h with the kernel sources

 tools/arch/arm64/include/asm/cputype.h        |   4 +
 tools/arch/arm64/include/uapi/asm/kvm.h       |  15 +-
 tools/arch/powerpc/include/uapi/asm/kvm.h     |  45 +-
 tools/arch/s390/include/uapi/asm/kvm.h        | 315 +++++++-
 tools/arch/x86/include/asm/cpufeatures.h      |  17 +-
 .../arch/x86/include/asm/disabled-features.h  |  11 +-
 tools/arch/x86/include/asm/irq_vectors.h      |   2 -
 tools/arch/x86/include/asm/msr-index.h        |  74 +-
 .../arch/x86/include/asm/required-features.h  |   3 +-
 tools/arch/x86/include/uapi/asm/kvm.h         | 308 +++++++-
 tools/include/asm-generic/bitops/__fls.h      |   8 +-
 tools/include/asm-generic/bitops/fls.h        |   8 +-
 tools/include/uapi/drm/i915_drm.h             |  16 +
 tools/include/uapi/linux/fs.h                 |  30 +-
 tools/include/uapi/linux/kvm.h                | 689 +-----------------
 tools/include/uapi/sound/asound.h             |   4 +-
 16 files changed, 809 insertions(+), 740 deletions(-)

base-commit: 25e973a0e077da585e472b4cadb1d2f4c1113285

Signature · 1 line
2.44.0.478.gd926399ef9-goog
#1 lore raw

PATCH 1/9 tools/include: Sync uapi/drm/i915_drm.h with the kernel sources

To pick up changes from:

b112364867499 ("drm/i915: Add GuC submission interface version query") 5cf0fbf763741 ("drm/i915: Add some boring kerneldoc")

This should be used to beautify DRM syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:

    diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tools/include/uapi/drm/i915_drm.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tools/include/uapi/drm/i915_drm.h +16 -0
index fd4f9574d177..2ee338860b7e 100644
@@ -3013,6 +3013,7 @@ struct drm_i915_query_item {
 	 *  - %DRM_I915_QUERY_MEMORY_REGIONS (see struct drm_i915_query_memory_regions)
 	 *  - %DRM_I915_QUERY_HWCONFIG_BLOB (see `GuC HWCONFIG blob uAPI`)
 	 *  - %DRM_I915_QUERY_GEOMETRY_SUBSLICES (see struct drm_i915_query_topology_info)
+	 *  - %DRM_I915_QUERY_GUC_SUBMISSION_VERSION (see struct drm_i915_query_guc_submission_version)
 	 */
 	__u64 query_id;
 #define DRM_I915_QUERY_TOPOLOGY_INFO		1
@@ -3021,6 +3022,7 @@ struct drm_i915_query_item {
 #define DRM_I915_QUERY_MEMORY_REGIONS		4
 #define DRM_I915_QUERY_HWCONFIG_BLOB		5
 #define DRM_I915_QUERY_GEOMETRY_SUBSLICES	6
+#define DRM_I915_QUERY_GUC_SUBMISSION_VERSION	7
 /* Must be kept compact -- no holes and well documented */
 
 	/**
@@ -3566,6 +3568,20 @@ struct drm_i915_query_memory_regions {
 	struct drm_i915_memory_region_info regions[];
 };
 
+/**
+ * struct drm_i915_query_guc_submission_version - query GuC submission interface version
+ */
+struct drm_i915_query_guc_submission_version {
+	/** @branch: Firmware branch version. */
+	__u32 branch;
+	/** @major: Firmware major version. */
+	__u32 major;
+	/** @minor: Firmware minor version. */
+	__u32 minor;
+	/** @patch: Firmware patch version. */
+	__u32 patch;
+};
+
 /**
  * DOC: GuC HWCONFIG blob uAPI
  *
Signature · 1 line
2.44.0.478.gd926399ef9-goog
#2 lore raw

Re: [PATCH 1/9] tools/include: Sync uapi/drm/i915_drm.h with the kernel sources

Quoted 10 lines · Namhyung Kim

To pick up changes from:

b112364867499 ("drm/i915: Add GuC submission interface version query") 5cf0fbf763741 ("drm/i915: Add some boring kerneldoc")

This should be used to beautify DRM syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:

    diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h

All these years and I never realized there are header copies there. But... why copies?

BR,
Jani.

Signature · 1 line
Jani Nikula, Intel
#3 lore raw

Re: [PATCH 1/9] tools/include: Sync uapi/drm/i915_drm.h with the kernel sources

Quoted 6 lines · Jani Nikula
Quoted 5 lines · Namhyung Kim

To pick up changes from:

b112364867499 ("drm/i915: Add GuC submission interface version query") 5cf0fbf763741 ("drm/i915: Add some boring kerneldoc")

Quoted 8 lines
Quoted 5 lines

This should be used to beautify DRM syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:

    diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h

All these years and I never realized there are header copies there. But... why copies?

It's better than all the alternatives we tried so far:

- Symbolic links and direct #includes: this was the original approach but was pushed back on from the kernel side, when tooling modified the headers and broke them accidentally for kernel builds.

- Duplicate self-defined ABI headers like glibc: double the maintenance burden, double the chance for mistakes, plus there's no tech-driven notification mechanism to look at new kernel side changes.

What we are doing now is a third option:

- A software-enforced copy-on-write mechanism of kernel headers to tooling, driven by non-fatal warnings on the tooling side build when kernel headers get modified:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
...

The tooling policy is to always pick up the kernel side headers as-is, and integate them into the tooling build. The warnings above serve as a notification to tooling maintainers that there's changes on the kernel side.

We've been using this for many years now, and it might seem hacky, but works surprisingly well.

Does this make sense to you?

Thanks,

Ingo

#4 lore raw

Re: [PATCH 1/9] tools/include: Sync uapi/drm/i915_drm.h with the kernel sources

Quoted 44 lines · Ingo Molnar
Quoted 6 lines · Jani Nikula
Quoted 5 lines · Namhyung Kim

To pick up changes from:

b112364867499 ("drm/i915: Add GuC submission interface version query") 5cf0fbf763741 ("drm/i915: Add some boring kerneldoc")

Quoted 8 lines
Quoted 5 lines

This should be used to beautify DRM syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:

    diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h

All these years and I never realized there are header copies there. But... why copies?

It's better than all the alternatives we tried so far:

- Symbolic links and direct #includes: this was the original approach but was pushed back on from the kernel side, when tooling modified the headers and broke them accidentally for kernel builds.

- Duplicate self-defined ABI headers like glibc: double the maintenance burden, double the chance for mistakes, plus there's no tech-driven notification mechanism to look at new kernel side changes.

What we are doing now is a third option:

- A software-enforced copy-on-write mechanism of kernel headers to tooling, driven by non-fatal warnings on the tooling side build when kernel headers get modified:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
...

The tooling policy is to always pick up the kernel side headers as-is, and integate them into the tooling build. The warnings above serve as a notification to tooling maintainers that there's changes on the kernel side.

Quoted 4 lines

We've been using this for many years now, and it might seem hacky, but works surprisingly well.

Does this make sense to you?

Yes, although there are probably pieces of the puzzle I'm missing. Thanks for the explanation! (That might work almost as-is copied to tools/include/uapi/README. ;)

It's also kind of funny to find this kind of back alleys of the kernel repo I've never wandered to before.

BR,
Jani.

Signature · 1 line
Jani Nikula, Intel
#5 lore raw

Re: [PATCH 1/9] tools/include: Sync uapi/drm/i915_drm.h with the kernel sources

Hello,

Quoted 49 lines · Jani Nikula
Quoted 47 lines · Ingo Molnar
Quoted 6 lines · Jani Nikula
Quoted 5 lines · Namhyung Kim

To pick up changes from:

b112364867499 ("drm/i915: Add GuC submission interface version query") 5cf0fbf763741 ("drm/i915: Add some boring kerneldoc")

Quoted 8 lines
Quoted 5 lines

This should be used to beautify DRM syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:

    diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h

All these years and I never realized there are header copies there. But... why copies?

It's better than all the alternatives we tried so far:

- Symbolic links and direct #includes: this was the original approach but was pushed back on from the kernel side, when tooling modified the headers and broke them accidentally for kernel builds.

- Duplicate self-defined ABI headers like glibc: double the maintenance burden, double the chance for mistakes, plus there's no tech-driven notification mechanism to look at new kernel side changes.

What we are doing now is a third option:

- A software-enforced copy-on-write mechanism of kernel headers to tooling, driven by non-fatal warnings on the tooling side build when kernel headers get modified:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
...

The tooling policy is to always pick up the kernel side headers as-is, and integate them into the tooling build. The warnings above serve as a notification to tooling maintainers that there's changes on the kernel side.

We've been using this for many years now, and it might seem hacky, but works surprisingly well.

Quoted 8 lines
Quoted 1 line

Does this make sense to you?

Yes, although there are probably pieces of the puzzle I'm missing. Thanks for the explanation! (That might work almost as-is copied to tools/include/uapi/README. ;)

It's also kind of funny to find this kind of back alleys of the kernel repo I've never wandered to before.

I have some explanation in the cover letter of the series but I forgot to mention that in each commit message. Probably I can update the explanation with Ingo's reply.

Thanks,
Namhyung

#6 lore raw

Re: [PATCH 1/9] tools/include: Sync uapi/drm/i915_drm.h with the kernel sources

Quoted 58 lines · Namhyung Kim

Hello,

Quoted 55 lines · Jani Nikula
Quoted 44 lines · Ingo Molnar
Quoted 6 lines · Jani Nikula
Quoted 5 lines · Namhyung Kim

To pick up changes from:

b112364867499 ("drm/i915: Add GuC submission interface version query") 5cf0fbf763741 ("drm/i915: Add some boring kerneldoc")

Quoted 8 lines
Quoted 5 lines

This should be used to beautify DRM syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:

    diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h

All these years and I never realized there are header copies there. But... why copies?

It's better than all the alternatives we tried so far:

- Symbolic links and direct #includes: this was the original approach but was pushed back on from the kernel side, when tooling modified the headers and broke them accidentally for kernel builds.

- Duplicate self-defined ABI headers like glibc: double the maintenance burden, double the chance for mistakes, plus there's no tech-driven notification mechanism to look at new kernel side changes.

What we are doing now is a third option:

- A software-enforced copy-on-write mechanism of kernel headers to tooling, driven by non-fatal warnings on the tooling side build when kernel headers get modified:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
...

The tooling policy is to always pick up the kernel side headers as-is, and integate them into the tooling build. The warnings above serve as a notification to tooling maintainers that there's changes on the kernel side.

Quoted 4 lines

We've been using this for many years now, and it might seem hacky, but works surprisingly well.

Does this make sense to you?

Yes, although there are probably pieces of the puzzle I'm missing. Thanks for the explanation! (That might work almost as-is copied to tools/include/uapi/README. ;)

Quoted 6 lines
Quoted 2 lines

It's also kind of funny to find this kind of back alleys of the kernel repo I've never wandered to before.

I have some explanation in the cover letter of the series but I forgot to mention that in each commit message. Probably I can update the explanation with Ingo's reply.

I think we can combine Ingo's with the reply I used and you adopted and continue to have it when sending the update messages, probably keep it in the cover letter (the combined text) and add a link to each individual update:

"Please see tools/include/README.kernel-copies."

The recommendation that developers shouldn't update the copy seems important to have there as well.

- Arnaldo

#7 lore raw

PATCH 2/9 tools/include: Sync uapi/linux/fs.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

41bcbe59c3b3f ("fs: FS_IOC_GETUUID") ae8c511757304 ("fs: add FS_IOC_GETFSSYSFSPATH") 73fa7547c70b3 ("vfs: add RWF_NOAPPEND flag for pwritev2")

This should be used to beautify fs syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h

Cc Alexander Viro <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Jan Kara <[email protected]>
---
 tools/include/uapi/linux/fs.h | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
tools/include/uapi/linux/fs.h +29 -1
index 48ad69f7722e..45e4e64fd664 100644
@@ -64,6 +64,24 @@ struct fstrim_range {
 	__u64 minlen;
 };
 
+/*
+ * We include a length field because some filesystems (vfat) have an identifier
+ * that we do want to expose as a UUID, but doesn't have the standard length.
+ *
+ * We use a fixed size buffer beacuse this interface will, by fiat, never
+ * support "UUIDs" longer than 16 bytes; we don't want to force all downstream
+ * users to have to deal with that.
+ */
+struct fsuuid2 {
+	__u8	len;
+	__u8	uuid[16];
+};
+
+struct fs_sysfs_path {
+	__u8			len;
+	__u8			name[128];
+};
+
 /* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */
 #define FILE_DEDUPE_RANGE_SAME		0
 #define FILE_DEDUPE_RANGE_DIFFERS	1
@@ -215,6 +233,13 @@ struct fsxattr {
 #define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)
 #define FS_IOC_GETFSLABEL		_IOR(0x94, 49, char[FSLABEL_MAX])
 #define FS_IOC_SETFSLABEL		_IOW(0x94, 50, char[FSLABEL_MAX])
+/* Returns the external filesystem UUID, the same one blkid returns */
+#define FS_IOC_GETFSUUID		_IOR(0x15, 0, struct fsuuid2)
+/*
+ * Returns the path component under /sys/fs/ that refers to this filesystem;
+ * also /sys/kernel/debug/ for filesystems with debugfs exports
+ */
+#define FS_IOC_GETFSSYSFSPATH		_IOR(0x15, 1, struct fs_sysfs_path)
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
@@ -301,9 +326,12 @@ typedef int __bitwise __kernel_rwf_t;
 /* per-IO O_APPEND */
 #define RWF_APPEND	((__force __kernel_rwf_t)0x00000010)
 
+/* per-IO negation of O_APPEND */
+#define RWF_NOAPPEND	((__force __kernel_rwf_t)0x00000020)
+
 /* mask of flags supported by the kernel */
 #define RWF_SUPPORTED	(RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
-			 RWF_APPEND)
+			 RWF_APPEND | RWF_NOAPPEND)
 
 /* Pagemap ioctl */
 #define PAGEMAP_SCAN	_IOWR('f', 16, struct pm_scan_arg)
Signature · 1 line
2.44.0.478.gd926399ef9-goog
reviewer Reviewed-by on v1 2/9
#8 lore raw

Re: [PATCH 2/9] tools/include: Sync uapi/linux/fs.h with the kernel sources

Quoted 9 lines · Namhyung Kim

To pick up the changes from:

41bcbe59c3b3f ("fs: FS_IOC_GETUUID") ae8c511757304 ("fs: add FS_IOC_GETFSSYSFSPATH") 73fa7547c70b3 ("vfs: add RWF_NOAPPEND flag for pwritev2")

This should be used to beautify fs syscall arguments and it addresses these tools/perf build warnings:

Quoted 8 lines

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h

Cc Alexander Viro <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Jan Kara <[email protected]>

Makes sense. Feel free to add:

Honza

Quoted 64 lines
---
 tools/include/uapi/linux/fs.h | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
tools/include/uapi/linux/fs.h +29 -1
index 48ad69f7722e..45e4e64fd664 100644
@@ -64,6 +64,24 @@ struct fstrim_range {
 	__u64 minlen;
 };
 
+/*
+ * We include a length field because some filesystems (vfat) have an identifier
+ * that we do want to expose as a UUID, but doesn't have the standard length.
+ *
+ * We use a fixed size buffer beacuse this interface will, by fiat, never
+ * support "UUIDs" longer than 16 bytes; we don't want to force all downstream
+ * users to have to deal with that.
+ */
+struct fsuuid2 {
+	__u8	len;
+	__u8	uuid[16];
+};
+
+struct fs_sysfs_path {
+	__u8			len;
+	__u8			name[128];
+};
+
 /* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */
 #define FILE_DEDUPE_RANGE_SAME		0
 #define FILE_DEDUPE_RANGE_DIFFERS	1
@@ -215,6 +233,13 @@ struct fsxattr {
 #define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)
 #define FS_IOC_GETFSLABEL		_IOR(0x94, 49, char[FSLABEL_MAX])
 #define FS_IOC_SETFSLABEL		_IOW(0x94, 50, char[FSLABEL_MAX])
+/* Returns the external filesystem UUID, the same one blkid returns */
+#define FS_IOC_GETFSUUID		_IOR(0x15, 0, struct fsuuid2)
+/*
+ * Returns the path component under /sys/fs/ that refers to this filesystem;
+ * also /sys/kernel/debug/ for filesystems with debugfs exports
+ */
+#define FS_IOC_GETFSSYSFSPATH		_IOR(0x15, 1, struct fs_sysfs_path)
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
@@ -301,9 +326,12 @@ typedef int __bitwise __kernel_rwf_t;
 /* per-IO O_APPEND */
 #define RWF_APPEND	((__force __kernel_rwf_t)0x00000010)
 
+/* per-IO negation of O_APPEND */
+#define RWF_NOAPPEND	((__force __kernel_rwf_t)0x00000020)
+
 /* mask of flags supported by the kernel */
 #define RWF_SUPPORTED	(RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
-			 RWF_APPEND)
+			 RWF_APPEND | RWF_NOAPPEND)
 
 /* Pagemap ioctl */
 #define PAGEMAP_SCAN	_IOWR('f', 16, struct pm_scan_arg)
Signature · 1 line
2.44.0.478.gd926399ef9-goog
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Reviewed-by
#9 lore raw

Re: [PATCH 2/9] tools/include: Sync uapi/linux/fs.h with the kernel sources

Quoted 19 lines · Jan Kara
Quoted 9 lines · Namhyung Kim

To pick up the changes from:

41bcbe59c3b3f ("fs: FS_IOC_GETUUID") ae8c511757304 ("fs: add FS_IOC_GETFSSYSFSPATH") 73fa7547c70b3 ("vfs: add RWF_NOAPPEND flag for pwritev2")

This should be used to beautify fs syscall arguments and it addresses these tools/perf build warnings:

Quoted 8 lines

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/linux/fs.h include/uapi/linux/fs.h

Cc Alexander Viro <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Jan Kara <[email protected]>
Quoted 3 lines

Makes sense. Feel free to add:

#10 lore raw

PATCH 3/9 tools/include: Sync uapi/linux/kvm.h and asm/kvm.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

6bda055d6258 ("KVM: define __KVM_HAVE_GUEST_DEBUG unconditionally") 5d9cb71642db ("KVM: arm64: move ARM-specific defines to uapi/asm/kvm.h") 71cd774ad2f9 ("KVM: s390: move s390-specific structs to uapi/asm/kvm.h") d750951c9ed7 ("KVM: powerpc: move powerpc-specific structs to uapi/asm/kvm.h") bcac0477277e ("KVM: x86: move x86-specific structs to uapi/asm/kvm.h") c0a411904e15 ("KVM: remove more traces of device assignment UAPI") f3c80061c0d3 ("KVM: SEV: fix compat ABI for KVM_MEMORY_ENCRYPT_OP")

That should be used to beautify the KVM arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h diff -u tools/arch/powerpc/include/uapi/asm/kvm.h arch/powerpc/include/uapi/asm/kvm.h diff -u tools/arch/s390/include/uapi/asm/kvm.h arch/s390/include/uapi/asm/kvm.h diff -u tools/arch/arm64/include/uapi/asm/kvm.h arch/arm64/include/uapi/asm/kvm.h

---
 tools/arch/arm64/include/uapi/asm/kvm.h   |  15 +-
 tools/arch/powerpc/include/uapi/asm/kvm.h |  45 +-
 tools/arch/s390/include/uapi/asm/kvm.h    | 315 +++++++++-
 tools/arch/x86/include/uapi/asm/kvm.h     | 308 +++++++++-
 tools/include/uapi/linux/kvm.h            | 689 +---------------------
 5 files changed, 672 insertions(+), 700 deletions(-)
tools/arch/arm64/include/uapi/asm/kvm.h +9 -6
index 89d2fc872d9f..964df31da975 100644
@@ -37,9 +37,7 @@
 #include <asm/ptrace.h>
 #include <asm/sve_context.h>
 
-#define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_IRQ_LINE
-#define __KVM_HAVE_READONLY_MEM
 #define __KVM_HAVE_VCPU_EVENTS
 
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
@@ -76,11 +74,11 @@ struct kvm_regs {
 
 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
 #define KVM_ARM_DEVICE_TYPE_SHIFT	0
-#define KVM_ARM_DEVICE_TYPE_MASK	GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
-						KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK	__GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
+						  KVM_ARM_DEVICE_TYPE_SHIFT)
 #define KVM_ARM_DEVICE_ID_SHIFT		16
-#define KVM_ARM_DEVICE_ID_MASK		GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
-						KVM_ARM_DEVICE_ID_SHIFT)
+#define KVM_ARM_DEVICE_ID_MASK		__GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
+						  KVM_ARM_DEVICE_ID_SHIFT)
 
 /* Supported device IDs */
 #define KVM_ARM_DEVICE_VGIC_V2		0
@@ -162,6 +160,11 @@ struct kvm_sync_regs {
 	__u64 device_irq_level;
 };
 
+/* Bits for run->s.regs.device_irq_level */
+#define KVM_ARM_DEV_EL1_VTIMER		(1 << 0)
+#define KVM_ARM_DEV_EL1_PTIMER		(1 << 1)
+#define KVM_ARM_DEV_PMU			(1 << 2)
+
 /*
  * PMU filter structure. Describe a range of events with a particular
  * action. To be used with KVM_ARM_VCPU_PMU_V3_FILTER.
tools/arch/powerpc/include/uapi/asm/kvm.h +44 -1

55 lines not on this page · raw message

tools/arch/s390/include/uapi/asm/kvm.h +314 -1

321 lines not on this page · raw message

tools/arch/x86/include/uapi/asm/kvm.h +300 -8

346 lines not on this page · raw message

tools/include/uapi/linux/kvm.h +5 -684

774 lines not on this page · raw message

Signature · 1 line
2.44.0.478.gd926399ef9-goog
#11 lore raw

PATCH 4/9 tools/include: Sync uapi/sound/asound.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

85df6b5a6658 ("ALSA: pcm: clarify and fix default msbits value for all formats")

This should be used to beautify sound syscall arguments and it addresses these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h

---
 tools/include/uapi/sound/asound.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/include/uapi/sound/asound.h +2 -2
index d5b9cfbd9cea..628d46a0da92 100644
@@ -142,7 +142,7 @@ struct snd_hwdep_dsp_image {
  *                                                                           *
  *****************************************************************************/
 
-#define SNDRV_PCM_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 16)
+#define SNDRV_PCM_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 17)
 
 typedef unsigned long snd_pcm_uframes_t;
 typedef signed long snd_pcm_sframes_t;
@@ -416,7 +416,7 @@ struct snd_pcm_hw_params {
 	unsigned int rmask;		/* W: requested masks */
 	unsigned int cmask;		/* R: changed masks */
 	unsigned int info;		/* R: Info flags for returned setup */
-	unsigned int msbits;		/* R: used most significant bits */
+	unsigned int msbits;		/* R: used most significant bits (in sample bit-width) */
 	unsigned int rate_num;		/* R: rate numerator */
 	unsigned int rate_den;		/* R: rate denominator */
 	snd_pcm_uframes_t fifo_size;	/* R: chip FIFO size in frames */
Signature · 1 line
2.44.0.478.gd926399ef9-goog
#12 lore raw

PATCH 5/9 tools/include: Sync x86 CPU feature headers with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

598c2fafc06f ("perf/x86/amd/lbr: Use freeze based on availability") 7f274e609f3d ("x86/cpufeatures: Add new word for scattered features")

This should address these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h diff -u tools/arch/x86/include/asm/required-features.h arch/x86/include/asm/required-features.h diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 tools/arch/x86/include/asm/cpufeatures.h       | 17 ++++++++++++-----
 tools/arch/x86/include/asm/disabled-features.h | 11 +++++++++--
 tools/arch/x86/include/asm/required-features.h |  3 ++-
 3 files changed, 23 insertions(+), 8 deletions(-)
tools/arch/x86/include/asm/cpufeatures.h +12 -5
index 25160d26764b..a38f8f9ba657 100644
@@ -13,7 +13,7 @@
 /*
  * Defines x86 CPU feature bits
  */
-#define NCAPINTS			21	   /* N 32-bit words worth of info */
+#define NCAPINTS			22	   /* N 32-bit words worth of info */
 #define NBUGINTS			2	   /* N 32-bit bug flags */
 
 /*
@@ -81,10 +81,8 @@
 #define X86_FEATURE_K6_MTRR		( 3*32+ 1) /* AMD K6 nonstandard MTRRs */
 #define X86_FEATURE_CYRIX_ARR		( 3*32+ 2) /* Cyrix ARRs (= MTRRs) */
 #define X86_FEATURE_CENTAUR_MCR		( 3*32+ 3) /* Centaur MCRs (= MTRRs) */
-
-/* CPU types for specific tunings: */
 #define X86_FEATURE_K8			( 3*32+ 4) /* "" Opteron, Athlon64 */
-/* FREE, was #define X86_FEATURE_K7			( 3*32+ 5) "" Athlon */
+#define X86_FEATURE_ZEN5		( 3*32+ 5) /* "" CPU based on Zen5 microarchitecture */
 #define X86_FEATURE_P3			( 3*32+ 6) /* "" P3 */
 #define X86_FEATURE_P4			( 3*32+ 7) /* "" P4 */
 #define X86_FEATURE_CONSTANT_TSC	( 3*32+ 8) /* TSC ticks at a constant rate */
@@ -97,7 +95,7 @@
 #define X86_FEATURE_SYSENTER32		( 3*32+15) /* "" sysenter in IA32 userspace */
 #define X86_FEATURE_REP_GOOD		( 3*32+16) /* REP microcode works well */
 #define X86_FEATURE_AMD_LBR_V2		( 3*32+17) /* AMD Last Branch Record Extension Version 2 */
-/* FREE, was #define X86_FEATURE_LFENCE_RDTSC		( 3*32+18) "" LFENCE synchronizes RDTSC */
+#define X86_FEATURE_CLEAR_CPU_BUF	( 3*32+18) /* "" Clear CPU buffers using VERW */
 #define X86_FEATURE_ACC_POWER		( 3*32+19) /* AMD Accumulated Power Mechanism */
 #define X86_FEATURE_NOPL		( 3*32+20) /* The NOPL (0F 1F) instructions */
 #define X86_FEATURE_ALWAYS		( 3*32+21) /* "" Always-present feature */
@@ -461,6 +459,14 @@
 #define X86_FEATURE_IBPB_BRTYPE		(20*32+28) /* "" MSR_PRED_CMD[IBPB] flushes all branch type predictions */
 #define X86_FEATURE_SRSO_NO		(20*32+29) /* "" CPU is not affected by SRSO */
 
+/*
+ * Extended auxiliary flags: Linux defined - for features scattered in various
+ * CPUID levels like 0x80000022, etc.
+ *
+ * Reuse free bits when adding new feature flags!
+ */
+#define X86_FEATURE_AMD_LBR_PMC_FREEZE	(21*32+ 0) /* AMD LBR and PMC Freeze */
+
 /*
  * BUG word(s)
  */
@@ -508,4 +514,5 @@
 /* BUG word 2 */
 #define X86_BUG_SRSO			X86_BUG(1*32 + 0) /* AMD SRSO bug */
 #define X86_BUG_DIV0			X86_BUG(1*32 + 1) /* AMD DIV0 speculation bug */
+#define X86_BUG_RFDS			X86_BUG(1*32 + 2) /* CPU is vulnerable to Register File Data Sampling */
 #endif /* _ASM_X86_CPUFEATURES_H */
tools/arch/x86/include/asm/disabled-features.h +9 -2
index 1f23960d2b06..c492bdc97b05 100644
@@ -123,6 +123,12 @@
 # define DISABLE_FRED	(1 << (X86_FEATURE_FRED & 31))
 #endif
 
+#ifdef CONFIG_KVM_AMD_SEV
+#define DISABLE_SEV_SNP		0
+#else
+#define DISABLE_SEV_SNP		(1 << (X86_FEATURE_SEV_SNP & 31))
+#endif
+
 /*
  * Make sure to add features to the correct mask
  */
@@ -147,8 +153,9 @@
 			 DISABLE_ENQCMD)
 #define DISABLED_MASK17	0
 #define DISABLED_MASK18	(DISABLE_IBT)
-#define DISABLED_MASK19	0
+#define DISABLED_MASK19	(DISABLE_SEV_SNP)
 #define DISABLED_MASK20	0
-#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
+#define DISABLED_MASK21	0
+#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 22)
 
 #endif /* _ASM_X86_DISABLED_FEATURES_H */
tools/arch/x86/include/asm/required-features.h +2 -1
index 7ba1726b71c7..e9187ddd3d1f 100644
@@ -99,6 +99,7 @@
 #define REQUIRED_MASK18	0
 #define REQUIRED_MASK19	0
 #define REQUIRED_MASK20	0
-#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
+#define REQUIRED_MASK21	0
+#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 22)
 
 #endif /* _ASM_X86_REQUIRED_FEATURES_H */
Signature · 1 line
2.44.0.478.gd926399ef9-goog
#13 lore raw

PATCH 6/9 tools/include: Sync x86 asm/irq_vectors.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

0cbca1bf44a0 ("x86: irq: unconditionally define KVM interrupt vectors")

This should address these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/arch/x86/include/asm/irq_vectors.h arch/x86/include/asm/irq_vectors.h

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 tools/arch/x86/include/asm/irq_vectors.h | 2 --
 1 file changed, 2 deletions(-)
tools/arch/x86/include/asm/irq_vectors.h +0 -2
index 3f73ac3ed3a0..d18bfb238f66 100644
@@ -84,11 +84,9 @@
 #define HYPERVISOR_CALLBACK_VECTOR	0xf3
 
 /* Vector for KVM to deliver posted interrupt IPI */
-#if IS_ENABLED(CONFIG_KVM)
 #define POSTED_INTR_VECTOR		0xf2
 #define POSTED_INTR_WAKEUP_VECTOR	0xf1
 #define POSTED_INTR_NESTED_VECTOR	0xf0
-#endif
 
 #define MANAGED_IRQ_SHUTDOWN_VECTOR	0xef
 
Signature · 1 line
2.44.0.478.gd926399ef9-goog
#14 lore raw

PATCH 7/9 tools/include: Sync x86 asm/msr-index.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

8076fcde016c ("x86/rfds: Mitigate Register File Data Sampling (RFDS)") d7b69b590bc9 ("x86/sev: Dump SEV_STATUS")
cd6df3f378f6 ("x86/cpu: Add MSR numbers for FRED configuration") 216d106c7ff7 ("x86/sev: Add SEV-SNP host initialization support")

This should address these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 tools/arch/x86/include/asm/msr-index.h | 74 ++++++++++++++++++--------
 1 file changed, 51 insertions(+), 23 deletions(-)
tools/arch/x86/include/asm/msr-index.h +51 -23
index 1f9dc9bd13eb..05956bd8bacf 100644
@@ -176,6 +176,14 @@
 						 * CPU is not vulnerable to Gather
 						 * Data Sampling (GDS).
 						 */
+#define ARCH_CAP_RFDS_NO		BIT(27)	/*
+						 * Not susceptible to Register
+						 * File Data Sampling.
+						 */
+#define ARCH_CAP_RFDS_CLEAR		BIT(28)	/*
+						 * VERW clears CPU Register
+						 * File.
+						 */
 
 #define ARCH_CAP_XAPIC_DISABLE		BIT(21)	/*
 						 * IA32_XAPIC_DISABLE_STATUS MSR
@@ -605,34 +613,47 @@
 #define MSR_AMD64_SEV_ES_GHCB		0xc0010130
 #define MSR_AMD64_SEV			0xc0010131
 #define MSR_AMD64_SEV_ENABLED_BIT	0
-#define MSR_AMD64_SEV_ES_ENABLED_BIT	1
-#define MSR_AMD64_SEV_SNP_ENABLED_BIT	2
 #define MSR_AMD64_SEV_ENABLED		BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT)
+#define MSR_AMD64_SEV_ES_ENABLED_BIT	1
 #define MSR_AMD64_SEV_ES_ENABLED	BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT)
+#define MSR_AMD64_SEV_SNP_ENABLED_BIT	2
 #define MSR_AMD64_SEV_SNP_ENABLED	BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT)
-
-/* SNP feature bits enabled by the hypervisor */
-#define MSR_AMD64_SNP_VTOM			BIT_ULL(3)
-#define MSR_AMD64_SNP_REFLECT_VC		BIT_ULL(4)
-#define MSR_AMD64_SNP_RESTRICTED_INJ		BIT_ULL(5)
-#define MSR_AMD64_SNP_ALT_INJ			BIT_ULL(6)
-#define MSR_AMD64_SNP_DEBUG_SWAP		BIT_ULL(7)
-#define MSR_AMD64_SNP_PREVENT_HOST_IBS		BIT_ULL(8)
-#define MSR_AMD64_SNP_BTB_ISOLATION		BIT_ULL(9)
-#define MSR_AMD64_SNP_VMPL_SSS			BIT_ULL(10)
-#define MSR_AMD64_SNP_SECURE_TSC		BIT_ULL(11)
-#define MSR_AMD64_SNP_VMGEXIT_PARAM		BIT_ULL(12)
-#define MSR_AMD64_SNP_IBS_VIRT			BIT_ULL(14)
-#define MSR_AMD64_SNP_VMSA_REG_PROTECTION	BIT_ULL(16)
-#define MSR_AMD64_SNP_SMT_PROTECTION		BIT_ULL(17)
-
-/* SNP feature bits reserved for future use. */
-#define MSR_AMD64_SNP_RESERVED_BIT13		BIT_ULL(13)
-#define MSR_AMD64_SNP_RESERVED_BIT15		BIT_ULL(15)
-#define MSR_AMD64_SNP_RESERVED_MASK		GENMASK_ULL(63, 18)
+#define MSR_AMD64_SNP_VTOM_BIT		3
+#define MSR_AMD64_SNP_VTOM		BIT_ULL(MSR_AMD64_SNP_VTOM_BIT)
+#define MSR_AMD64_SNP_REFLECT_VC_BIT	4
+#define MSR_AMD64_SNP_REFLECT_VC	BIT_ULL(MSR_AMD64_SNP_REFLECT_VC_BIT)
+#define MSR_AMD64_SNP_RESTRICTED_INJ_BIT 5
+#define MSR_AMD64_SNP_RESTRICTED_INJ	BIT_ULL(MSR_AMD64_SNP_RESTRICTED_INJ_BIT)
+#define MSR_AMD64_SNP_ALT_INJ_BIT	6
+#define MSR_AMD64_SNP_ALT_INJ		BIT_ULL(MSR_AMD64_SNP_ALT_INJ_BIT)
+#define MSR_AMD64_SNP_DEBUG_SWAP_BIT	7
+#define MSR_AMD64_SNP_DEBUG_SWAP	BIT_ULL(MSR_AMD64_SNP_DEBUG_SWAP_BIT)
+#define MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT 8
+#define MSR_AMD64_SNP_PREVENT_HOST_IBS	BIT_ULL(MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT)
+#define MSR_AMD64_SNP_BTB_ISOLATION_BIT	9
+#define MSR_AMD64_SNP_BTB_ISOLATION	BIT_ULL(MSR_AMD64_SNP_BTB_ISOLATION_BIT)
+#define MSR_AMD64_SNP_VMPL_SSS_BIT	10
+#define MSR_AMD64_SNP_VMPL_SSS		BIT_ULL(MSR_AMD64_SNP_VMPL_SSS_BIT)
+#define MSR_AMD64_SNP_SECURE_TSC_BIT	11
+#define MSR_AMD64_SNP_SECURE_TSC	BIT_ULL(MSR_AMD64_SNP_SECURE_TSC_BIT)
+#define MSR_AMD64_SNP_VMGEXIT_PARAM_BIT	12
+#define MSR_AMD64_SNP_VMGEXIT_PARAM	BIT_ULL(MSR_AMD64_SNP_VMGEXIT_PARAM_BIT)
+#define MSR_AMD64_SNP_RESERVED_BIT13	BIT_ULL(13)
+#define MSR_AMD64_SNP_IBS_VIRT_BIT	14
+#define MSR_AMD64_SNP_IBS_VIRT		BIT_ULL(MSR_AMD64_SNP_IBS_VIRT_BIT)
+#define MSR_AMD64_SNP_RESERVED_BIT15	BIT_ULL(15)
+#define MSR_AMD64_SNP_VMSA_REG_PROT_BIT	16
+#define MSR_AMD64_SNP_VMSA_REG_PROT	BIT_ULL(MSR_AMD64_SNP_VMSA_REG_PROT_BIT)
+#define MSR_AMD64_SNP_SMT_PROT_BIT	17
+#define MSR_AMD64_SNP_SMT_PROT		BIT_ULL(MSR_AMD64_SNP_SMT_PROT_BIT)
+#define MSR_AMD64_SNP_RESV_BIT		18
+#define MSR_AMD64_SNP_RESERVED_MASK	GENMASK_ULL(63, MSR_AMD64_SNP_RESV_BIT)
 
 #define MSR_AMD64_VIRT_SPEC_CTRL	0xc001011f
 
+#define MSR_AMD64_RMP_BASE		0xc0010132
+#define MSR_AMD64_RMP_END		0xc0010133
+
 /* AMD Collaborative Processor Performance Control MSRs */
 #define MSR_AMD_CPPC_CAP1		0xc00102b0
 #define MSR_AMD_CPPC_ENABLE		0xc00102b1
@@ -719,8 +740,15 @@
 #define MSR_K8_TOP_MEM1			0xc001001a
 #define MSR_K8_TOP_MEM2			0xc001001d
 #define MSR_AMD64_SYSCFG		0xc0010010
-#define MSR_AMD64_SYSCFG_MEM_ENCRYPT_BIT	23
+#define MSR_AMD64_SYSCFG_MEM_ENCRYPT_BIT 23
 #define MSR_AMD64_SYSCFG_MEM_ENCRYPT	BIT_ULL(MSR_AMD64_SYSCFG_MEM_ENCRYPT_BIT)
+#define MSR_AMD64_SYSCFG_SNP_EN_BIT	24
+#define MSR_AMD64_SYSCFG_SNP_EN		BIT_ULL(MSR_AMD64_SYSCFG_SNP_EN_BIT)
+#define MSR_AMD64_SYSCFG_SNP_VMPL_EN_BIT 25
+#define MSR_AMD64_SYSCFG_SNP_VMPL_EN	BIT_ULL(MSR_AMD64_SYSCFG_SNP_VMPL_EN_BIT)
+#define MSR_AMD64_SYSCFG_MFDM_BIT	19
+#define MSR_AMD64_SYSCFG_MFDM		BIT_ULL(MSR_AMD64_SYSCFG_MFDM_BIT)
+
 #define MSR_K8_INT_PENDING_MSG		0xc0010055
 /* C1E active bits in int pending message */
 #define K8_INTP_C1E_ACTIVE_MASK		0x18000000
Signature · 1 line
2.44.0.478.gd926399ef9-goog
#15 lore raw

PATCH 8/9 tools/include: Sync asm-generic/bitops/fls.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

cb4ede926134 ("riscv: Avoid code duplication with generic bitops implementation")

This should address these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/include/asm-generic/bitops/__fls.h include/asm-generic/bitops/__fls.h diff -u tools/include/asm-generic/bitops/fls.h include/asm-generic/bitops/fls.h

Cc Arnd Bergmann <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Palmer Dabbelt <[email protected]>
---
 tools/include/asm-generic/bitops/__fls.h | 8 ++++++--
 tools/include/asm-generic/bitops/fls.h   | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
tools/include/asm-generic/bitops/__fls.h +6 -2
index 03f721a8a2b1..54ccccf96e21 100644
@@ -5,12 +5,12 @@
 #include <asm/types.h>
 
 /**
- * __fls - find last (most-significant) set bit in a long word
+ * generic___fls - find last (most-significant) set bit in a long word
  * @word: the word to search
  *
  * Undefined if no set bit exists, so code should check against 0 first.
  */
-static __always_inline unsigned long __fls(unsigned long word)
+static __always_inline unsigned long generic___fls(unsigned long word)
 {
 	int num = BITS_PER_LONG - 1;
 
@@ -41,4 +41,8 @@ static __always_inline unsigned long __fls(unsigned long word)
 	return num;
 }
 
+#ifndef __HAVE_ARCH___FLS
+#define __fls(word) generic___fls(word)
+#endif
+
 #endif /* _ASM_GENERIC_BITOPS___FLS_H_ */
tools/include/asm-generic/bitops/fls.h +6 -2
index b168bb10e1be..26f3ce1dd6e4 100644
@@ -3,14 +3,14 @@
 #define _ASM_GENERIC_BITOPS_FLS_H_
 
 /**
- * fls - find last (most-significant) bit set
+ * generic_fls - find last (most-significant) bit set
  * @x: the word to search
  *
  * This is defined the same way as ffs.
  * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
  */
 
-static __always_inline int fls(unsigned int x)
+static __always_inline int generic_fls(unsigned int x)
 {
 	int r = 32;
 
@@ -39,4 +39,8 @@ static __always_inline int fls(unsigned int x)
 	return r;
 }
 
+#ifndef __HAVE_ARCH_FLS
+#define fls(x) generic_fls(x)
+#endif
+
 #endif /* _ASM_GENERIC_BITOPS_FLS_H_ */
Signature · 1 line
2.44.0.478.gd926399ef9-goog
#16 lore raw

PATCH 9/9 tools/include: Sync arm64 asm/cputype.h with the kernel sources

In reply to Namhyung Kim

To pick up the changes from:

fb091ff39479 ("arm64: Subscribe Microsoft Azure Cobalt 100 to ARM Neoverse N2 errata")

This should address these tools/perf build warnings:

Warning: Kernel ABI header differences:
diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h

---
 tools/arch/arm64/include/asm/cputype.h | 4 ++++
 1 file changed, 4 insertions(+)
tools/arch/arm64/include/asm/cputype.h +4 -0
index 7c7493cb571f..52f076afeb96 100644
@@ -61,6 +61,7 @@
 #define ARM_CPU_IMP_HISI		0x48
 #define ARM_CPU_IMP_APPLE		0x61
 #define ARM_CPU_IMP_AMPERE		0xC0
+#define ARM_CPU_IMP_MICROSOFT		0x6D
 
 #define ARM_CPU_PART_AEM_V8		0xD0F
 #define ARM_CPU_PART_FOUNDATION		0xD00
@@ -135,6 +136,8 @@
 
 #define AMPERE_CPU_PART_AMPERE1		0xAC3
 
+#define MICROSOFT_CPU_PART_AZURE_COBALT_100	0xD49 /* Based on r0p0 of ARM Neoverse N2 */
+
 #define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)
 #define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57)
 #define MIDR_CORTEX_A72 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72)
@@ -193,6 +196,7 @@
 #define MIDR_APPLE_M2_BLIZZARD_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX)
 #define MIDR_APPLE_M2_AVALANCHE_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX)
 #define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1)
+#define MIDR_MICROSOFT_AZURE_COBALT_100 MIDR_CPU_MODEL(ARM_CPU_IMP_MICROSOFT, MICROSOFT_CPU_PART_AZURE_COBALT_100)
 
 /* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */
 #define MIDR_FUJITSU_ERRATUM_010001		MIDR_FUJITSU_A64FX
Signature · 1 line
2.44.0.478.gd926399ef9-goog
Reviewed-by Ian Rogers on the v1 series
#17 lore raw
In reply to Namhyung Kim
Quoted 4 lines · Namhyung Kim

Hello,

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

Humm, maybe its not a good idea to do that this cycle? I mean some of these were moved from tools/{include,arch} to tools/perf/trace/beauty/{include,arch}, like tools/perf/trace/beauty/arch/x86/include/asm/irq_vectors.h.

But having said that, probably isn't a problem, when you get this pulled upstream I'll do a merge with perf-tools-next and this should be trivially resolved, I think.

Using the above example:

⬢[acme@toolbox perf-tools-next]$ git log tools/perf/trace/beauty/arch/x86/include/asm/irq_vectors.h commit c8bfe3fad4f86a029da7157bae9699c816f0c309

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Mon Mar 11 17:07:33 2024 -0300

perf beauty: Move arch/x86/include/asm/irq_vectors.h copy out of the directory used to build perf

It is used only to generate string tables, not to build perf, so move it to the tools/perf/trace/beauty/include/ hierarchy, that is used just for scraping.

This is a something that should've have happened, as happened with the linux/socket.h scrapper, do it now as Ian suggested while doing an audit/refactor session in the headers used by perf.

No other tools/ living code uses it.

- Arnaldo

Quoted 80 lines

This is the full explanation from Arnaldo:

There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model.

The way these headers are used in perf are not restricted to just including them to compile something.

There are sometimes used in scripts that convert defines into string tables, etc, so some change may break one of these scripts, or new MSRs may use some different #define pattern, etc.

E.g.:

  $ ls -1 tools/perf/trace/beauty/*.sh | head -5
  tools/perf/trace/beauty/arch_errno_names.sh
  tools/perf/trace/beauty/drm_ioctl.sh
  tools/perf/trace/beauty/fadvise.sh
  tools/perf/trace/beauty/fsconfig.sh
  tools/perf/trace/beauty/fsmount.sh
  $
  $ tools/perf/trace/beauty/fadvise.sh
  static const char *fadvise_advices[] = {
        [0] = "NORMAL",
        [1] = "RANDOM",
        [2] = "SEQUENTIAL",
        [3] = "WILLNEED",
        [4] = "DONTNEED",
        [5] = "NOREUSE",
  };
  $

The tools/perf/check-headers.sh script, part of the tools/ build process, points out changes in the original files.

So its important not to touch the copies in tools/ when doing changes in the original kernel headers, that will be done later, when check-headers.sh inform about the change to the perf tools hackers.

Thanks,
Namhyung

Namhyung Kim (9):
tools/include: Sync uapi/drm/i915_drm.h with the kernel sources tools/include: Sync uapi/linux/fs.h with the kernel sources tools/include: Sync uapi/linux/kvm.h and asm/kvm.h with the kernel
sources
tools/include: Sync uapi/sound/asound.h with the kernel sources tools/include: Sync x86 CPU feature headers with the kernel sources tools/include: Sync x86 asm/irq_vectors.h with the kernel sources tools/include: Sync x86 asm/msr-index.h with the kernel sources tools/include: Sync asm-generic/bitops/fls.h with the kernel sources tools/include: Sync arm64 asm/cputype.h with the kernel sources

 tools/arch/arm64/include/asm/cputype.h        |   4 +
 tools/arch/arm64/include/uapi/asm/kvm.h       |  15 +-
 tools/arch/powerpc/include/uapi/asm/kvm.h     |  45 +-
 tools/arch/s390/include/uapi/asm/kvm.h        | 315 +++++++-
 tools/arch/x86/include/asm/cpufeatures.h      |  17 +-
 .../arch/x86/include/asm/disabled-features.h  |  11 +-
 tools/arch/x86/include/asm/irq_vectors.h      |   2 -
 tools/arch/x86/include/asm/msr-index.h        |  74 +-
 .../arch/x86/include/asm/required-features.h  |   3 +-
 tools/arch/x86/include/uapi/asm/kvm.h         | 308 +++++++-
 tools/include/asm-generic/bitops/__fls.h      |   8 +-
 tools/include/asm-generic/bitops/fls.h        |   8 +-
 tools/include/uapi/drm/i915_drm.h             |  16 +
 tools/include/uapi/linux/fs.h                 |  30 +-
 tools/include/uapi/linux/kvm.h                | 689 +-----------------
 tools/include/uapi/sound/asound.h             |   4 +-
 16 files changed, 809 insertions(+), 740 deletions(-)

base-commit: 25e973a0e077da585e472b4cadb1d2f4c1113285

Signature · 1 line
2.44.0.478.gd926399ef9-goog
#18 lore raw
Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 4 lines · Namhyung Kim

Hello,

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

Humm, maybe its not a good idea to do that this cycle?

Maybe it's just me, but I've been looking sadly at all the header warnings for months. :-) Would be better to keep them in sync with a bit higher frequency, IMO - which would reduce the pain and churn rate:

Quoted 1 line
Quoted 1 line
 16 files changed, 809 insertions(+), 740 deletions(-)

That's like about a year of changes missed? An update once per cycle and this wouldn't be nearly as painful, right?

Thanks,

Ingo

Reviewed-by Ian Rogers
#19 lore raw
Quoted 6 lines · Ingo Molnar
Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines · Namhyung Kim

Hello,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

Humm, maybe its not a good idea to do that this cycle?

Maybe it's just me, but I've been looking sadly at all the header warnings for months. :-) Would be better to keep them in sync with a bit higher

I backtracked from asking for a delay, the reason for me first thinking about not doing it this time is because in perf-tools-next we have, to be merged for 6.10:

⬢[acme@toolbox perf-tools-next]$ git log --oneline torvalds/master.. | tail
f324b73c2c05832b perf beauty: Stop using the copy of uapi/linux/prctl.h
c8bfe3fad4f86a02 perf beauty: Move arch/x86/include/asm/irq_vectors.h copy out of the directory used to build perf 7050e33e86ad03d2 perf beauty: Move uapi/sound/asound.h copy out of the directory used to build perf 44512bd6136ec7bb perf beauty: Move uapi/linux/usbdevice_fs.h copy out of the directory used to build perf ab3316119f9d0b3a perf beauty: Move uapi/linux/mount.h copy out of the directory used to build perf 22916d2cbad9a20d perf beauty: Don't include uapi/linux/mount.h, use sys/mount.h instead faf7217a397f041f perf beauty: Move uapi/linux/fs.h copy out of the directory used to build perf 5d8c646038f2f173 perf beauty: Fix dependency of tables using uapi/linux/mount.h 4b3761eebb1c5c1b perf c2c: Fix a punctuation
a9f4c6c999008c92 perf trace: Collect sys_nanosleep first argument
⬢[acme@toolbox perf-tools-next]$

The reasoning for these changes is in the csets, for instance:

⬢[acme@toolbox perf-tools-next]$ git show 7050e33e86ad03d2 | head -21 commit 7050e33e86ad03d26d7b969bba1d48ee159be496

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Mon Mar 11 17:07:33 2024 -0300

perf beauty: Move uapi/sound/asound.h copy out of the directory used to build perf

It is used only to generate string tables, not to build perf, so move it to the tools/perf/trace/beauty/include/ hierarchy, that is used just for scraping.

This is a something that should've have happened, as happened with the linux/socket.h scraper, do it now as Ian suggested while doing an audit/refactor session in the headers used by perf.

⬢[acme@toolbox perf-tools-next]$

I.e. I had moved some of the stuff that is being updated, but nah, better to have v6.9 tools/perf building without warnings, I'll fixup the merge when I merge perf-tools-next with torvalds/master after the updates are merged upstream.

This is sometimes difficult to achieve tho or would require more pull requests to be sent to Linus to get some last minute changes, its not something common, but I think happened a few times.

Quoted 6 lines

frequency, IMO - which would reduce the pain and churn rate:

Quoted 1 line
Quoted 1 line
 16 files changed, 809 insertions(+), 740 deletions(-)

That's like about a year of changes missed? An update once per cycle and this wouldn't be nearly as painful, right?

Humm, I haven't checked if it stays that long without merging, what I've agreed with Namhyung is to wait a bit for things to reach upstream, say -rc3, and then do the update, trying not to do these things nor early not late in the -rc sequence, to pick a sweet spot where most likely no changes will be made, we make the update and the perf build has no warnings in the final release.

- Arnaldo

#20 lore raw

Hi Arnaldo and Ingo,

Quoted 57 lines · Arnaldo Carvalho de Melo
Quoted 6 lines · Ingo Molnar
Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines · Namhyung Kim

Hello,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

Humm, maybe its not a good idea to do that this cycle?

Maybe it's just me, but I've been looking sadly at all the header warnings for months. :-) Would be better to keep them in sync with a bit higher

I backtracked from asking for a delay, the reason for me first thinking about not doing it this time is because in perf-tools-next we have, to be merged for 6.10:

⬢[acme@toolbox perf-tools-next]$ git log --oneline torvalds/master.. | tail
f324b73c2c05832b perf beauty: Stop using the copy of uapi/linux/prctl.h
c8bfe3fad4f86a02 perf beauty: Move arch/x86/include/asm/irq_vectors.h copy out of the directory used to build perf 7050e33e86ad03d2 perf beauty: Move uapi/sound/asound.h copy out of the directory used to build perf 44512bd6136ec7bb perf beauty: Move uapi/linux/usbdevice_fs.h copy out of the directory used to build perf ab3316119f9d0b3a perf beauty: Move uapi/linux/mount.h copy out of the directory used to build perf 22916d2cbad9a20d perf beauty: Don't include uapi/linux/mount.h, use sys/mount.h instead faf7217a397f041f perf beauty: Move uapi/linux/fs.h copy out of the directory used to build perf 5d8c646038f2f173 perf beauty: Fix dependency of tables using uapi/linux/mount.h 4b3761eebb1c5c1b perf c2c: Fix a punctuation
a9f4c6c999008c92 perf trace: Collect sys_nanosleep first argument
⬢[acme@toolbox perf-tools-next]$

The reasoning for these changes is in the csets, for instance:

⬢[acme@toolbox perf-tools-next]$ git show 7050e33e86ad03d2 | head -21 commit 7050e33e86ad03d26d7b969bba1d48ee159be496

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Mon Mar 11 17:07:33 2024 -0300

perf beauty: Move uapi/sound/asound.h copy out of the directory used to build perf

It is used only to generate string tables, not to build perf, so move it to the tools/perf/trace/beauty/include/ hierarchy, that is used just for scraping.

This is a something that should've have happened, as happened with the linux/socket.h scraper, do it now as Ian suggested while doing an audit/refactor session in the headers used by perf.

Quoted 6 lines

⬢[acme@toolbox perf-tools-next]$

I.e. I had moved some of the stuff that is being updated, but nah, better to have v6.9 tools/perf building without warnings, I'll fixup the merge when I merge perf-tools-next with torvalds/master after the updates are merged upstream.

Yeah I noticed that, but I thought it's better to keep v6.9 headers in sync. Please take care of them in perf-tools-next for v6.10.

Quoted 12 lines

This is sometimes difficult to achieve tho or would require more pull requests to be sent to Linus to get some last minute changes, its not something common, but I think happened a few times.

Quoted 6 lines

frequency, IMO - which would reduce the pain and churn rate:

Quoted 1 line
Quoted 1 line
 16 files changed, 809 insertions(+), 740 deletions(-)

That's like about a year of changes missed? An update once per cycle and this wouldn't be nearly as painful, right?

Quoted 6 lines

Humm, I haven't checked if it stays that long without merging, what I've agreed with Namhyung is to wait a bit for things to reach upstream, say -rc3, and then do the update, trying not to do these things nor early not late in the -rc sequence, to pick a sweet spot where most likely no changes will be made, we make the update and the perf build has no warnings in the final release.

I think we're doing it once per release cycle already. This is just for v6.9. The kvm changes moved some code to arch directories.

This is what I did for v6.7.

https://lore.kernel.org/r/[email protected]/

Thanks,
Namhyung

#21 lore raw
In reply to Namhyung Kim

Hi Namhyung, Arnaldo,

Quoted 9 lines · Namhyung Kim

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

This is the full explanation from Arnaldo:

There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model.

Do you have a reference to that?
I was gonna reply to [PATCH 8/9] (where I was CCed) with "why can't you use the original include file directly?", then read the cover letter.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#22 lore raw
Quoted 6 lines · Geert Uytterhoeven

Hi Namhyung, Arnaldo,

Quoted 3 lines · Namhyung Kim

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

Quoted 8 lines
Quoted 6 lines

This is the full explanation from Arnaldo:

There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model.

Do you have a reference to that?

I would have to do a search on the mailing list to find the exact exchange, this is from memory and from people asking this repeatedly.

Ingo replied with reasons similar to the ones I use in this canned explanation when sending the notice of updating the files.

- Arnaldo

Quoted 16 lines

I was gonna reply to [PATCH 8/9] (where I was CCed) with "why can't you use the original include file directly?", then read the cover letter.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#23 lore raw

Hello,

Quoted 15 lines · Arnaldo Carvalho de Melo
Quoted 13 lines · Geert Uytterhoeven

Hi Namhyung, Arnaldo,

Quoted 9 lines · Namhyung Kim

I'm gonna carry these changes on the perf tools tree. I'll update the vhost.h once it lands on the mainline.

This is the full explanation from Arnaldo:

There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model.

Quoted 7 lines
Quoted 1 line

Do you have a reference to that?

I would have to do a search on the mailing list to find the exact exchange, this is from memory and from people asking this repeatedly.

Ingo replied with reasons similar to the ones I use in this canned explanation when sending the notice of updating the files.

This is the Ingo's reply:

https://lore.kernel.org/r/[email protected]/

Thanks,
Namhyung