linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/17] tools perf: fix build warnings
@ 2023-05-10 10:21 Yanteng Si
  2023-05-10 10:21 ` [PATCH v2 01/17] tools headers UAPI: Sync the linux/in.h with the kernel sources Yanteng Si
                   ` (17 more replies)
  0 siblings, 18 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:21 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

v2:

* Drop <tools arch s390: Sync the ptrace headers with the kernel sources>
   Because ptrace.h has been fixed in other tree, detail see:
    selftests/bpf: Remove not used headers
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1f265d2aea0d
    tools headers: Remove s390 ptrace.h in check-headers.sh
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed4da0d3de1e

* BTW, I made these patches in the next tree, so most of the warnings haven't appeared in the perf tree yet. :)


v1:
* When I try to build perf, a lot of warnings are output, let's fix them.

Yanteng Si (17):
  tools headers UAPI: Sync the linux/in.h with the kernel sources
  tools headers UAPI: Sync the linux/prctl.h with the kernel sources
  tools headers UAPI: Sync the drm/drm.h with the kernel sources
  tools headers UAPI: Sync the i915_drm.h with the kernel sources
  tools headers UAPI: Sync the coresight-pmu headers copy with the
    kernel sources
  tools headers UAPI: Sync the linux/const.h with the kernel headers
  tools headers UAPI: Sync the linux/perf_event.h with the kernel
    headers
  tools include UAPI: Sync the sound/asound.h copy with the kernel
    sources
  tools headers UAPI: Sync the linux/mman.h with the kernel sources
  tools headers UAPI: Sync the unistd with the kernel sources
  tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel
    sources
  tools arch x86: Sync the disabled-features with the kernel sources
  tools arch x86: Sync the memcpy_64 with the kernel sources
  tools arch x86: Sync the cpufeatures with the kernel sources
  tools arch x86: Sync the msr-index.h copy with the kernel sources
  tools arch x86: Sync the prctl headers with the kernel sources
  tools arch arm64: Sync the perf_regs headers with the kernel sources

 tools/arch/arm64/include/uapi/asm/kvm.h       | 36 ++++++++++++
 tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++--
 tools/arch/x86/include/asm/cpufeatures.h      | 28 +++++++--
 .../arch/x86/include/asm/disabled-features.h  | 24 +++++++-
 tools/arch/x86/include/asm/msr-index.h        |  2 +
 tools/arch/x86/include/uapi/asm/kvm.h         |  3 +
 tools/arch/x86/include/uapi/asm/prctl.h       | 20 +++++++
 tools/arch/x86/lib/memcpy_64.S                | 35 ++++--------
 tools/arch/x86/lib/memset_64.S                | 47 ++++-----------
 tools/include/linux/coresight-pmu.h           | 13 -----
 tools/include/uapi/asm-generic/unistd.h       |  5 +-
 tools/include/uapi/drm/drm.h                  | 57 ++++++++++++++++++-
 tools/include/uapi/drm/i915_drm.h             | 25 +++++++-
 tools/include/uapi/linux/const.h              |  2 +-
 tools/include/uapi/linux/in.h                 |  1 +
 tools/include/uapi/linux/kvm.h                | 12 +++-
 tools/include/uapi/linux/mman.h               | 14 +++++
 tools/include/uapi/linux/perf_event.h         |  3 +-
 tools/include/uapi/linux/prctl.h              |  2 +
 tools/include/uapi/sound/asound.h             | 14 +++--
 .../perf/arch/s390/entry/syscalls/syscall.tbl |  2 +-
 .../arch/x86/entry/syscalls/syscall_64.tbl    |  2 +
 22 files changed, 258 insertions(+), 99 deletions(-)

-- 
2.31.4


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 01/17] tools headers UAPI: Sync the linux/in.h with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
@ 2023-05-10 10:21 ` Yanteng Si
  2023-05-10 10:21 ` [PATCH v2 02/17] tools headers UAPI: Sync the linux/prctl.h " Yanteng Si
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:21 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 91d0b78c5177f3e4 ("inet: Add IP_LOCAL_PORT_RANGE socket option")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs
   from latest version at 'include/uapi/linux/in.h'
  diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/linux/in.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h
index 07a4cb149305..4b7f2df66b99 100644
--- a/tools/include/uapi/linux/in.h
+++ b/tools/include/uapi/linux/in.h
@@ -162,6 +162,7 @@ struct in_addr {
 #define MCAST_MSFILTER			48
 #define IP_MULTICAST_ALL		49
 #define IP_UNICAST_IF			50
+#define IP_LOCAL_PORT_RANGE		51
 
 #define MCAST_EXCLUDE	0
 #define MCAST_INCLUDE	1
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 02/17] tools headers UAPI: Sync the linux/prctl.h with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
  2023-05-10 10:21 ` [PATCH v2 01/17] tools headers UAPI: Sync the linux/in.h with the kernel sources Yanteng Si
@ 2023-05-10 10:21 ` Yanteng Si
  2023-05-10 10:21 ` [PATCH v2 03/17] tools headers UAPI: Sync the drm/drm.h " Yanteng Si
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:21 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit f9c6df5fb149437f ("prctl: add PR_GET_AUXV to copy auxv to
   userspace")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/uapi/linux/prctl.h'
   differs from latest version at 'include/uapi/linux/prctl.h'
  diff -u tools/include/uapi/linux/prctl.h include/uapi/linux/prctl.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/linux/prctl.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index 759b3f53e53f..f23d9a16507f 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -290,6 +290,8 @@ struct prctl_mm_map {
 #define PR_SET_VMA		0x53564d41
 # define PR_SET_VMA_ANON_NAME		0
 
+#define PR_GET_AUXV			0x41555856
+
 #define PR_SET_MEMORY_MERGE		67
 #define PR_GET_MEMORY_MERGE		68
 #endif /* _LINUX_PRCTL_H */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 03/17] tools headers UAPI: Sync the drm/drm.h with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
  2023-05-10 10:21 ` [PATCH v2 01/17] tools headers UAPI: Sync the linux/in.h with the kernel sources Yanteng Si
  2023-05-10 10:21 ` [PATCH v2 02/17] tools headers UAPI: Sync the linux/prctl.h " Yanteng Si
@ 2023-05-10 10:21 ` Yanteng Si
  2023-05-10 10:22 ` [PATCH v2 04/17] tools headers UAPI: Sync the i915_drm.h " Yanteng Si
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:21 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 6068771673a38efc ("drm: document DRM_IOCTL_PRIME_HANDLE_TO_FD and
   PRIME_FD_TO_HANDLE")
  commit 61a55f8b1ebcde68 ("drm: document expectations for GETFB2
   handles")
  commit 158350aae16a4e66 ("drm: document DRM_IOCTL_GEM_CLOSE")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/uapi/drm/drm.h' differs
   from latest version at 'include/uapi/drm/drm.h'
  diff -u tools/include/uapi/drm/drm.h include/uapi/drm/drm.h

No changes in tooling as these are just C comment documentation changes.

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/drm/drm.h | 57 ++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/tools/include/uapi/drm/drm.h b/tools/include/uapi/drm/drm.h
index 642808520d92..a87bbbbca2d4 100644
--- a/tools/include/uapi/drm/drm.h
+++ b/tools/include/uapi/drm/drm.h
@@ -972,6 +972,19 @@ extern "C" {
 #define DRM_IOCTL_GET_STATS             DRM_IOR( 0x06, struct drm_stats)
 #define DRM_IOCTL_SET_VERSION		DRM_IOWR(0x07, struct drm_set_version)
 #define DRM_IOCTL_MODESET_CTL           DRM_IOW(0x08, struct drm_modeset_ctl)
+/**
+ * DRM_IOCTL_GEM_CLOSE - Close a GEM handle.
+ *
+ * GEM handles are not reference-counted by the kernel. User-space is
+ * responsible for managing their lifetime. For example, if user-space imports
+ * the same memory object twice on the same DRM file description, the same GEM
+ * handle is returned by both imports, and user-space needs to ensure
+ * &DRM_IOCTL_GEM_CLOSE is performed once only. The same situation can happen
+ * when a memory object is allocated, then exported and imported again on the
+ * same DRM file description. The &DRM_IOCTL_MODE_GETFB2 IOCTL is an exception
+ * and always returns fresh new GEM handles even if an existing GEM handle
+ * already refers to the same memory object before the IOCTL is performed.
+ */
 #define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
 #define DRM_IOCTL_GEM_FLINK		DRM_IOWR(0x0a, struct drm_gem_flink)
 #define DRM_IOCTL_GEM_OPEN		DRM_IOWR(0x0b, struct drm_gem_open)
@@ -1012,7 +1025,37 @@ extern "C" {
 #define DRM_IOCTL_UNLOCK		DRM_IOW( 0x2b, struct drm_lock)
 #define DRM_IOCTL_FINISH		DRM_IOW( 0x2c, struct drm_lock)
 
+/**
+ * DRM_IOCTL_PRIME_HANDLE_TO_FD - Convert a GEM handle to a DMA-BUF FD.
+ *
+ * User-space sets &drm_prime_handle.handle with the GEM handle to export and
+ * &drm_prime_handle.flags, and gets back a DMA-BUF file descriptor in
+ * &drm_prime_handle.fd.
+ *
+ * The export can fail for any driver-specific reason, e.g. because export is
+ * not supported for this specific GEM handle (but might be for others).
+ *
+ * Support for exporting DMA-BUFs is advertised via &DRM_PRIME_CAP_EXPORT.
+ */
 #define DRM_IOCTL_PRIME_HANDLE_TO_FD    DRM_IOWR(0x2d, struct drm_prime_handle)
+/**
+ * DRM_IOCTL_PRIME_FD_TO_HANDLE - Convert a DMA-BUF FD to a GEM handle.
+ *
+ * User-space sets &drm_prime_handle.fd with a DMA-BUF file descriptor to
+ * import, and gets back a GEM handle in &drm_prime_handle.handle.
+ * &drm_prime_handle.flags is unused.
+ *
+ * If an existing GEM handle refers to the memory object backing the DMA-BUF,
+ * that GEM handle is returned. Therefore user-space which needs to handle
+ * arbitrary DMA-BUFs must have a user-space lookup data structure to manually
+ * reference-count duplicated GEM handles. For more information see
+ * &DRM_IOCTL_GEM_CLOSE.
+ *
+ * The import can fail for any driver-specific reason, e.g. because import is
+ * only supported for DMA-BUFs allocated on this DRM device.
+ *
+ * Support for importing DMA-BUFs is advertised via &DRM_PRIME_CAP_IMPORT.
+ */
 #define DRM_IOCTL_PRIME_FD_TO_HANDLE    DRM_IOWR(0x2e, struct drm_prime_handle)
 
 #define DRM_IOCTL_AGP_ACQUIRE		DRM_IO(  0x30)
@@ -1104,8 +1147,13 @@ extern "C" {
  * struct as the output.
  *
  * If the client is DRM master or has &CAP_SYS_ADMIN, &drm_mode_fb_cmd2.handles
- * will be filled with GEM buffer handles. Planes are valid until one has a
- * zero handle -- this can be used to compute the number of planes.
+ * will be filled with GEM buffer handles. Fresh new GEM handles are always
+ * returned, even if another GEM handle referring to the same memory object
+ * already exists on the DRM file description. The caller is responsible for
+ * removing the new handles, e.g. via the &DRM_IOCTL_GEM_CLOSE IOCTL. The same
+ * new handle will be returned for multiple planes in case they use the same
+ * memory object. Planes are valid until one has a zero handle -- this can be
+ * used to compute the number of planes.
  *
  * Otherwise, &drm_mode_fb_cmd2.handles will be zeroed and planes are valid
  * until one has a zero &drm_mode_fb_cmd2.pitches.
@@ -1113,6 +1161,11 @@ extern "C" {
  * If the framebuffer has a format modifier, &DRM_MODE_FB_MODIFIERS will be set
  * in &drm_mode_fb_cmd2.flags and &drm_mode_fb_cmd2.modifier will contain the
  * modifier. Otherwise, user-space must ignore &drm_mode_fb_cmd2.modifier.
+ *
+ * To obtain DMA-BUF FDs for each plane without leaking GEM handles, user-space
+ * can export each handle via &DRM_IOCTL_PRIME_HANDLE_TO_FD, then immediately
+ * close each unique handle via &DRM_IOCTL_GEM_CLOSE, making sure to not
+ * double-close handles which are specified multiple times in the array.
  */
 #define DRM_IOCTL_MODE_GETFB2		DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
 
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 04/17] tools headers UAPI: Sync the i915_drm.h with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (2 preceding siblings ...)
  2023-05-10 10:21 ` [PATCH v2 03/17] tools headers UAPI: Sync the drm/drm.h " Yanteng Si
@ 2023-05-10 10:22 ` Yanteng Si
  2023-05-10 10:22 ` [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy " Yanteng Si
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:22 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 1cc064dce4ed0ff1 ("drm/i915/perf: Add support for OA media
   units")
  commit c61d04c9eb435498 ("drm/i915/perf: Add engine class instance
   parameters to perf")
  commit 02abecdeebfcd384 ("drm/i915/uapi: Replace fake flex-array with
   flexible-array member")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h'
   differs from latest version at 'include/uapi/drm/i915_drm.h'
  diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/drm/i915_drm.h | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h
index 8df261c5ab9b..dba7c5a5b25e 100644
--- a/tools/include/uapi/drm/i915_drm.h
+++ b/tools/include/uapi/drm/i915_drm.h
@@ -2491,7 +2491,7 @@ struct i915_context_param_engines {
 #define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */
 #define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */
 #define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */
-	struct i915_engine_class_instance engines[0];
+	struct i915_engine_class_instance engines[];
 } __attribute__((packed));
 
 #define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \
@@ -2676,6 +2676,10 @@ enum drm_i915_oa_format {
 	I915_OAR_FORMAT_A32u40_A4u32_B8_C8,
 	I915_OA_FORMAT_A24u40_A14u32_B8_C8,
 
+	/* MTL OAM */
+	I915_OAM_FORMAT_MPEC8u64_B8_C8,
+	I915_OAM_FORMAT_MPEC8u32_B8_C8,
+
 	I915_OA_FORMAT_MAX	    /* non-ABI */
 };
 
@@ -2758,6 +2762,25 @@ enum drm_i915_perf_property_id {
 	 */
 	DRM_I915_PERF_PROP_POLL_OA_PERIOD,
 
+	/**
+	 * Multiple engines may be mapped to the same OA unit. The OA unit is
+	 * identified by class:instance of any engine mapped to it.
+	 *
+	 * This parameter specifies the engine class and must be passed along
+	 * with DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE.
+	 *
+	 * This property is available in perf revision 6.
+	 */
+	DRM_I915_PERF_PROP_OA_ENGINE_CLASS,
+
+	/**
+	 * This parameter specifies the engine instance and must be passed along
+	 * with DRM_I915_PERF_PROP_OA_ENGINE_CLASS.
+	 *
+	 * This property is available in perf revision 6.
+	 */
+	DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE,
+
 	DRM_I915_PERF_PROP_MAX /* non-ABI */
 };
 
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (3 preceding siblings ...)
  2023-05-10 10:22 ` [PATCH v2 04/17] tools headers UAPI: Sync the i915_drm.h " Yanteng Si
@ 2023-05-10 10:22 ` Yanteng Si
  2023-05-10 15:41   ` Arnaldo Carvalho de Melo
  2023-05-10 10:22 ` [PATCH v2 06/17] tools headers UAPI: Sync the linux/const.h with the kernel headers Yanteng Si
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:22 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Removing CORESIGHT_TRACE_ID_UNUSED_FLAG and CORESIGHT_TRACE_ID_UNUSED_VAL.

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h'
   differs from latest version at 'include/linux/coresight-pmu.h'
  diff -u tools/include/linux/coresight-pmu.h include/linux
   /coresight-pmu.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/linux/coresight-pmu.h | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h
index cef3b1c25335..51ac441a37c3 100644
--- a/tools/include/linux/coresight-pmu.h
+++ b/tools/include/linux/coresight-pmu.h
@@ -21,19 +21,6 @@
  */
 #define CORESIGHT_LEGACY_CPU_TRACE_ID(cpu)  (0x10 + (cpu * 2))
 
-/* CoreSight trace ID is currently the bottom 7 bits of the value */
-#define CORESIGHT_TRACE_ID_VAL_MASK	GENMASK(6, 0)
-
-/*
- * perf record will set the legacy meta data values as unused initially.
- * This allows perf report to manage the decoders created when dynamic
- * allocation in operation.
- */
-#define CORESIGHT_TRACE_ID_UNUSED_FLAG	BIT(31)
-
-/* Value to set for unused trace ID values */
-#define CORESIGHT_TRACE_ID_UNUSED_VAL	0x7F
-
 /*
  * Below are the definition of bit offsets for perf option, and works as
  * arbitrary values for all ETM versions.
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 06/17] tools headers UAPI: Sync the linux/const.h with the kernel headers
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (4 preceding siblings ...)
  2023-05-10 10:22 ` [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy " Yanteng Si
@ 2023-05-10 10:22 ` Yanteng Si
  2023-05-10 10:22 ` [PATCH v2 07/17] tools headers UAPI: Sync the linux/perf_event.h " Yanteng Si
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:22 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 31088f6f7906253e ("uapi/linux/const.h: prefer ISO-friendly
   __typeof__")

Silencing these perf build warnings::

  Warning: Kernel ABI header at 'tools/include/uapi/linux/const.h' differs
   from latest version at 'include/uapi/linux/const.h'
  diff -u tools/include/uapi/linux/const.h include/uapi/linux/const.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/linux/const.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/include/uapi/linux/const.h b/tools/include/uapi/linux/const.h
index af2a44c08683..a429381e7ca5 100644
--- a/tools/include/uapi/linux/const.h
+++ b/tools/include/uapi/linux/const.h
@@ -28,7 +28,7 @@
 #define _BITUL(x)	(_UL(1) << (x))
 #define _BITULL(x)	(_ULL(1) << (x))
 
-#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
 #define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
 
 #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 07/17] tools headers UAPI: Sync the linux/perf_event.h with the kernel headers
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (5 preceding siblings ...)
  2023-05-10 10:22 ` [PATCH v2 06/17] tools headers UAPI: Sync the linux/const.h with the kernel headers Yanteng Si
@ 2023-05-10 10:22 ` Yanteng Si
  2023-05-10 15:44   ` Arnaldo Carvalho de Melo
  2023-05-10 10:24 ` [PATCH v2 08/17] tools include UAPI: Sync the sound/asound.h copy with the kernel sources Yanteng Si
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:22 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 09519ec3b19e4144 ("perf: Add perf_event_attr::config3")
  commit cb6c18b5a41622c7 ("perf/mem: Rename PERF_MEM_LVLNUM_EXTN_MEM to
   PERF_MEM_LVLNUM_CXL")

Silencing these perf build warnings::

  Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h'
   differs from latest version at 'include/uapi/linux/perf_event.h'
  diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux
   /perf_event.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/linux/perf_event.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 39c6a250dd1b..37675437b768 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -1339,8 +1339,7 @@ union perf_mem_data_src {
 #define PERF_MEM_LVLNUM_L2	0x02 /* L2 */
 #define PERF_MEM_LVLNUM_L3	0x03 /* L3 */
 #define PERF_MEM_LVLNUM_L4	0x04 /* L4 */
-/* 5-0x7 available */
-#define PERF_MEM_LVLNUM_UNC	0x08 /* Uncached */
+/* 5-0x8 available */
 #define PERF_MEM_LVLNUM_CXL	0x09 /* CXL */
 #define PERF_MEM_LVLNUM_IO	0x0a /* I/O */
 #define PERF_MEM_LVLNUM_ANY_CACHE 0x0b /* Any cache */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 08/17] tools include UAPI: Sync the sound/asound.h copy with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (6 preceding siblings ...)
  2023-05-10 10:22 ` [PATCH v2 07/17] tools headers UAPI: Sync the linux/perf_event.h " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:24 ` [PATCH v2 09/17] tools headers UAPI: Sync the linux/mman.h " Yanteng Si
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 102882b5c62f6bfe ("ALSA: document that struct
   __snd_pcm_mmap_control64 is messed up")
  commit 9f656705c5faa18a ("ALSA: pcm: rewrite
   snd_pcm_playback_silence()")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/uapi/sound/asound.h'
   differs from latest version at 'include/uapi/sound/asound.h'
  diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/sound/asound.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/include/uapi/sound/asound.h b/tools/include/uapi/sound/asound.h
index de6810e94abe..0aa955aa8246 100644
--- a/tools/include/uapi/sound/asound.h
+++ b/tools/include/uapi/sound/asound.h
@@ -429,9 +429,14 @@ struct snd_pcm_sw_params {
 	snd_pcm_uframes_t avail_min;		/* min avail frames for wakeup */
 	snd_pcm_uframes_t xfer_align;		/* obsolete: xfer size need to be a multiple */
 	snd_pcm_uframes_t start_threshold;	/* min hw_avail frames for automatic start */
-	snd_pcm_uframes_t stop_threshold;	/* min avail frames for automatic stop */
-	snd_pcm_uframes_t silence_threshold;	/* min distance from noise for silence filling */
-	snd_pcm_uframes_t silence_size;		/* silence block size */
+	/*
+	 * The following two thresholds alleviate playback buffer underruns; when
+	 * hw_avail drops below the threshold, the respective action is triggered:
+	 */
+	snd_pcm_uframes_t stop_threshold;	/* - stop playback */
+	snd_pcm_uframes_t silence_threshold;	/* - pre-fill buffer with silence */
+	snd_pcm_uframes_t silence_size;		/* max size of silence pre-fill; when >= boundary,
+						 * fill played area with silence immediately */
 	snd_pcm_uframes_t boundary;		/* pointers wrap point */
 	unsigned int proto;			/* protocol version */
 	unsigned int tstamp_type;		/* timestamp type (req. proto >= 2.0.12) */
@@ -570,7 +575,8 @@ struct __snd_pcm_mmap_status64 {
 struct __snd_pcm_mmap_control64 {
 	__pad_before_uframe __pad1;
 	snd_pcm_uframes_t appl_ptr;	 /* RW: appl ptr (0...boundary-1) */
-	__pad_before_uframe __pad2;
+	__pad_before_uframe __pad2;	 // This should be __pad_after_uframe, but binary
+					 // backwards compatibility constraints prevent a fix.
 
 	__pad_before_uframe __pad3;
 	snd_pcm_uframes_t  avail_min;	 /* RW: min available frames for wakeup */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 09/17] tools headers UAPI: Sync the linux/mman.h with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (7 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 08/17] tools include UAPI: Sync the sound/asound.h copy with the kernel sources Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:24 ` [PATCH v2 10/17] tools headers UAPI: Sync the unistd " Yanteng Si
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 5c289a59b1d08fd8 ("cachestat: implement cachestat syscall")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/include/uapi/linux/mman.h'
   differs from latest version at 'include/uapi/linux/mman.h'
  diff -u tools/include/uapi/linux/mman.h include/uapi/linux/mman.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/linux/mman.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/include/uapi/linux/mman.h b/tools/include/uapi/linux/mman.h
index f55bc680b5b0..a246e11988d5 100644
--- a/tools/include/uapi/linux/mman.h
+++ b/tools/include/uapi/linux/mman.h
@@ -4,6 +4,7 @@
 
 #include <asm/mman.h>
 #include <asm-generic/hugetlb_encode.h>
+#include <linux/types.h>
 
 #define MREMAP_MAYMOVE		1
 #define MREMAP_FIXED		2
@@ -41,4 +42,17 @@
 #define MAP_HUGE_2GB	HUGETLB_FLAG_ENCODE_2GB
 #define MAP_HUGE_16GB	HUGETLB_FLAG_ENCODE_16GB
 
+struct cachestat_range {
+	__u64 off;
+	__u64 len;
+};
+
+struct cachestat {
+	__u64 nr_cache;
+	__u64 nr_dirty;
+	__u64 nr_writeback;
+	__u64 nr_evicted;
+	__u64 nr_recently_evicted;
+};
+
 #endif /* _UAPI_LINUX_MMAN_H */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 10/17] tools headers UAPI: Sync the unistd with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (8 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 09/17] tools headers UAPI: Sync the linux/mman.h " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:24 ` [PATCH v2 11/17] tools headers kvm: Sync uapi/{asm/linux} kvm.h headers " Yanteng Si
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 7608f70adcb1ea69 ("s390: wire up memfd_secret system call")
  commit 5c289a59b1d08fd8 ("cachestat: implement cachestat syscall")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/perf/arch/s390/entry/syscalls
   /syscall.tbl' differs from latest version at 'arch/s390/kernel
    /syscalls/syscall.tbl'
  diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390
   /kernel/syscalls/syscall.tbl
  Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls
   /syscall_64.tbl' differs from latest version at 'arch/x86/entry
   /syscalls/syscall_64.tbl'
  diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86
  /entry/syscalls/syscall_64.tbl
  Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h'
   differs from latest version at 'include/uapi/asm-generic/unistd.h'
  diff -u tools/include/uapi/asm-generic/unistd.h include/uapi
   /asm-generic/unistd.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/include/uapi/asm-generic/unistd.h           | 5 ++++-
 tools/perf/arch/s390/entry/syscalls/syscall.tbl   | 2 +-
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index 45fa180cc56a..cd639fae9086 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -886,8 +886,11 @@ __SYSCALL(__NR_futex_waitv, sys_futex_waitv)
 #define __NR_set_mempolicy_home_node 450
 __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
 
+#define __NR_cachestat 451
+__SYSCALL(__NR_cachestat, sys_cachestat)
+
 #undef __NR_syscalls
-#define __NR_syscalls 451
+#define __NR_syscalls 452
 
 /*
  * 32 bit systems traditionally used different
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
index 799147658dee..b68f47541169 100644
--- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
@@ -449,7 +449,7 @@
 444  common	landlock_create_ruleset	sys_landlock_create_ruleset	sys_landlock_create_ruleset
 445  common	landlock_add_rule	sys_landlock_add_rule		sys_landlock_add_rule
 446  common	landlock_restrict_self	sys_landlock_restrict_self	sys_landlock_restrict_self
-# 447 reserved for memfd_secret
+447  common	memfd_secret		sys_memfd_secret		sys_memfd_secret
 448  common	process_mrelease	sys_process_mrelease		sys_process_mrelease
 449  common	futex_waitv		sys_futex_waitv			sys_futex_waitv
 450  common	set_mempolicy_home_node	sys_set_mempolicy_home_node	sys_set_mempolicy_home_node
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index c84d12608cd2..38db4b1c291a 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -372,6 +372,8 @@
 448	common	process_mrelease	sys_process_mrelease
 449	common	futex_waitv		sys_futex_waitv
 450	common	set_mempolicy_home_node	sys_set_mempolicy_home_node
+451	common	cachestat		sys_cachestat
+452	64	map_shadow_stack	sys_map_shadow_stack
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 11/17] tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (9 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 10/17] tools headers UAPI: Sync the unistd " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:24 ` [PATCH v2 12/17] tools arch x86: Sync the disabled-features " Yanteng Si
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit e65733b5c59a1ea2 ("KVM: x86: Redefine 'longmode' as a flag for
   KVM_EXIT_HYPERCALL")
  commit 30ec7997d175cd68 ("KVM: arm64: timers: Allow userspace to set
   the global counter offset")
  commit 821d935c87bc9525 ("KVM: arm64: Introduce support for userspace
   SMCCC filtering")
  commit 81dc9504a7006b48 ("KVM: arm64: nv: timers: Support hyp timer
   emulation")
  commit a8308b3fc9494953 ("KVM: arm64: Refactor hvc filtering to support
   different actions")
  commit 0e5c9a9d6548e9b1 ("KVM: arm64: Expose SMC/HVC width to
   userspace")

Silencing these perf build warnings:

 Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs
  from latest version at 'include/uapi/linux/kvm.h'
 diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
 Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/kvm.h'
  differs from latest version at 'arch/x86/include/uapi/asm/kvm.h'
 diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi
  /asm/kvm.h
 Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/kvm.h'
  differs from latest version at 'arch/arm64/include/uapi/asm/kvm.h'
 diff -u tools/arch/arm64/include/uapi/asm/kvm.h arch/arm64/include/uapi
  /asm/kvm.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/arch/arm64/include/uapi/asm/kvm.h | 36 +++++++++++++++++++++++++
 tools/arch/x86/include/uapi/asm/kvm.h   |  3 +++
 tools/include/uapi/linux/kvm.h          | 12 +++++++--
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/tools/arch/arm64/include/uapi/asm/kvm.h b/tools/arch/arm64/include/uapi/asm/kvm.h
index f8129c624b07..f7ddd73a8c0f 100644
--- a/tools/arch/arm64/include/uapi/asm/kvm.h
+++ b/tools/arch/arm64/include/uapi/asm/kvm.h
@@ -198,6 +198,15 @@ struct kvm_arm_copy_mte_tags {
 	__u64 reserved[2];
 };
 
+/*
+ * Counter/Timer offset structure. Describe the virtual/physical offset.
+ * To be used with KVM_ARM_SET_COUNTER_OFFSET.
+ */
+struct kvm_arm_counter_offset {
+	__u64 counter_offset;
+	__u64 reserved;
+};
+
 #define KVM_ARM_TAGS_TO_GUEST		0
 #define KVM_ARM_TAGS_FROM_GUEST		1
 
@@ -372,6 +381,10 @@ enum {
 #endif
 };
 
+/* Device Control API on vm fd */
+#define KVM_ARM_VM_SMCCC_CTRL		0
+#define   KVM_ARM_VM_SMCCC_FILTER	0
+
 /* Device Control API: ARM VGIC */
 #define KVM_DEV_ARM_VGIC_GRP_ADDR	0
 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS	1
@@ -411,6 +424,8 @@ enum {
 #define KVM_ARM_VCPU_TIMER_CTRL		1
 #define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER		0
 #define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER		1
+#define   KVM_ARM_VCPU_TIMER_IRQ_HVTIMER	2
+#define   KVM_ARM_VCPU_TIMER_IRQ_HPTIMER	3
 #define KVM_ARM_VCPU_PVTIME_CTRL	2
 #define   KVM_ARM_VCPU_PVTIME_IPA	0
 
@@ -469,6 +484,27 @@ enum {
 /* run->fail_entry.hardware_entry_failure_reason codes. */
 #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED	(1ULL << 0)
 
+enum kvm_smccc_filter_action {
+	KVM_SMCCC_FILTER_HANDLE = 0,
+	KVM_SMCCC_FILTER_DENY,
+	KVM_SMCCC_FILTER_FWD_TO_USER,
+
+#ifdef __KERNEL__
+	NR_SMCCC_FILTER_ACTIONS
+#endif
+};
+
+struct kvm_smccc_filter {
+	__u32 base;
+	__u32 nr_functions;
+	__u8 action;
+	__u8 pad[15];
+};
+
+/* arm64-specific KVM_EXIT_HYPERCALL flags */
+#define KVM_HYPERCALL_EXIT_SMC		(1U << 0)
+#define KVM_HYPERCALL_EXIT_16BIT	(1U << 1)
+
 #endif
 
 #endif /* __ARM_KVM_H__ */
diff --git a/tools/arch/x86/include/uapi/asm/kvm.h b/tools/arch/x86/include/uapi/asm/kvm.h
index 7f467fe05d42..1a6a1f987949 100644
--- a/tools/arch/x86/include/uapi/asm/kvm.h
+++ b/tools/arch/x86/include/uapi/asm/kvm.h
@@ -559,4 +559,7 @@ struct kvm_pmu_event_filter {
 #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
 #define   KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
 
+/* x86-specific KVM_EXIT_HYPERCALL flags. */
+#define KVM_EXIT_HYPERCALL_LONG_MODE	BIT(0)
+
 #endif /* _ASM_X86_KVM_H */
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 4003a166328c..737318b1c1d9 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -341,8 +341,13 @@ struct kvm_run {
 			__u64 nr;
 			__u64 args[6];
 			__u64 ret;
-			__u32 longmode;
-			__u32 pad;
+
+			union {
+#ifndef __KERNEL__
+				__u32 longmode;
+#endif
+				__u64 flags;
+			};
 		} hypercall;
 		/* KVM_EXIT_TPR_ACCESS */
 		struct {
@@ -1184,6 +1189,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
 #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
 #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
+#define KVM_CAP_COUNTER_OFFSET 227
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -1543,6 +1549,8 @@ struct kvm_s390_ucas_mapping {
 #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)
 #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3)
 #define KVM_ARM_MTE_COPY_TAGS	  _IOR(KVMIO,  0xb4, struct kvm_arm_copy_mte_tags)
+/* Available with KVM_CAP_COUNTER_OFFSET */
+#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset)
 
 /* ioctl for vm fd */
 #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device)
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 12/17] tools arch x86: Sync the disabled-features with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (10 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 11/17] tools headers kvm: Sync uapi/{asm/linux} kvm.h headers " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:24 ` [PATCH v2 13/17] tools arch x86: Sync the memcpy_64 " Yanteng Si
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit ac591488436ec62d ("x86/shstk: Add user control-protection fault
   handler")
  commit d1b5e84f943c7b5b ("x86/cpufeatures: Add CPU feature flags for
   shadow stacks")
  commit e0bddc19ba9578bc ("x86/mm: Reduce untagged_addr() overhead for
   systems without LAM")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/arch/x86/include/asm
   /disabled-features.h' differs from latest version at 'arch/x86/include
   /asm/disabled-features.h'
  diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include
   /asm/disabled-features.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 .../arch/x86/include/asm/disabled-features.h  | 24 ++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tools/arch/x86/include/asm/disabled-features.h b/tools/arch/x86/include/asm/disabled-features.h
index 5dfa4fb76f4b..702d93fdd10e 100644
--- a/tools/arch/x86/include/asm/disabled-features.h
+++ b/tools/arch/x86/include/asm/disabled-features.h
@@ -75,6 +75,12 @@
 # define DISABLE_CALL_DEPTH_TRACKING	(1 << (X86_FEATURE_CALL_DEPTH & 31))
 #endif
 
+#ifdef CONFIG_ADDRESS_MASKING
+# define DISABLE_LAM		0
+#else
+# define DISABLE_LAM		(1 << (X86_FEATURE_LAM & 31))
+#endif
+
 #ifdef CONFIG_INTEL_IOMMU_SVM
 # define DISABLE_ENQCMD		0
 #else
@@ -99,6 +105,18 @@
 # define DISABLE_TDX_GUEST	(1 << (X86_FEATURE_TDX_GUEST & 31))
 #endif
 
+#ifdef CONFIG_X86_USER_SHADOW_STACK
+#define DISABLE_USER_SHSTK	0
+#else
+#define DISABLE_USER_SHSTK	(1 << (X86_FEATURE_USER_SHSTK & 31))
+#endif
+
+#ifdef CONFIG_X86_KERNEL_IBT
+#define DISABLE_IBT	0
+#else
+#define DISABLE_IBT	(1 << (X86_FEATURE_IBT & 31))
+#endif
+
 /*
  * Make sure to add features to the correct mask
  */
@@ -114,15 +132,15 @@
 #define DISABLED_MASK9	(DISABLE_SGX)
 #define DISABLED_MASK10	0
 #define DISABLED_MASK11	(DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET| \
-			 DISABLE_CALL_DEPTH_TRACKING)
-#define DISABLED_MASK12	0
+			 DISABLE_CALL_DEPTH_TRACKING|DISABLE_USER_SHSTK)
+#define DISABLED_MASK12	(DISABLE_LAM)
 #define DISABLED_MASK13	0
 #define DISABLED_MASK14	0
 #define DISABLED_MASK15	0
 #define DISABLED_MASK16	(DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \
 			 DISABLE_ENQCMD)
 #define DISABLED_MASK17	0
-#define DISABLED_MASK18	0
+#define DISABLED_MASK18	(DISABLE_IBT)
 #define DISABLED_MASK19	0
 #define DISABLED_MASK20	0
 #define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 13/17] tools arch x86: Sync the memcpy_64 with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (11 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 12/17] tools arch x86: Sync the disabled-features " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 15:48   ` Arnaldo Carvalho de Melo
  2023-05-10 10:24 ` [PATCH v2 14/17] tools arch x86: Sync the cpufeatures " Yanteng Si
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 68674f94ffc9dddc ("x86: don't use REP_GOOD or ERMS for small
   memory copies")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs
   from latest version at 'arch/x86/lib/memcpy_64.S'
  diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
  Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs
   from latest version at 'arch/x86/lib/memset_64.S'
  diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/arch/x86/lib/memcpy_64.S | 35 ++++++++-----------------
 tools/arch/x86/lib/memset_64.S | 47 ++++++++--------------------------
 2 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S
index a91ac666f758..8f95fb267caa 100644
--- a/tools/arch/x86/lib/memcpy_64.S
+++ b/tools/arch/x86/lib/memcpy_64.S
@@ -2,6 +2,7 @@
 /* Copyright 2002 Andi Kleen */
 
 #include <linux/linkage.h>
+#include <linux/cfi_types.h>
 #include <asm/errno.h>
 #include <asm/cpufeatures.h>
 #include <asm/alternative.h>
@@ -9,13 +10,6 @@
 
 .section .noinstr.text, "ax"
 
-/*
- * We build a jump to memcpy_orig by default which gets NOPped out on
- * the majority of x86 CPUs which set REP_GOOD. In addition, CPUs which
- * have the enhanced REP MOVSB/STOSB feature (ERMS), change those NOPs
- * to a jmp to memcpy_erms which does the REP; MOVSB mem copy.
- */
-
 /*
  * memcpy - Copy a memory block.
  *
@@ -26,17 +20,21 @@
  *
  * Output:
  * rax original destination
+ *
+ * The FSRM alternative should be done inline (avoiding the call and
+ * the disgusting return handling), but that would require some help
+ * from the compiler for better calling conventions.
+ *
+ * The 'rep movsb' itself is small enough to replace the call, but the
+ * two register moves blow up the code. And one of them is "needed"
+ * only for the return value that is the same as the source input,
+ * which the compiler could/should do much better anyway.
  */
 SYM_TYPED_FUNC_START(__memcpy)
-	ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
-		      "jmp memcpy_erms", X86_FEATURE_ERMS
+	ALTERNATIVE "jmp memcpy_orig", "", X86_FEATURE_FSRM
 
 	movq %rdi, %rax
 	movq %rdx, %rcx
-	shrq $3, %rcx
-	andl $7, %edx
-	rep movsq
-	movl %edx, %ecx
 	rep movsb
 	RET
 SYM_FUNC_END(__memcpy)
@@ -45,17 +43,6 @@ EXPORT_SYMBOL(__memcpy)
 SYM_FUNC_ALIAS(memcpy, __memcpy)
 EXPORT_SYMBOL(memcpy)
 
-/*
- * memcpy_erms() - enhanced fast string memcpy. This is faster and
- * simpler than memcpy. Use memcpy_erms when possible.
- */
-SYM_FUNC_START_LOCAL(memcpy_erms)
-	movq %rdi, %rax
-	movq %rdx, %rcx
-	rep movsb
-	RET
-SYM_FUNC_END(memcpy_erms)
-
 SYM_FUNC_START_LOCAL(memcpy_orig)
 	movq %rdi, %rax
 
diff --git a/tools/arch/x86/lib/memset_64.S b/tools/arch/x86/lib/memset_64.S
index 6143b1a6fa2c..7c59a704c458 100644
--- a/tools/arch/x86/lib/memset_64.S
+++ b/tools/arch/x86/lib/memset_64.S
@@ -18,27 +18,22 @@
  * rdx   count (bytes)
  *
  * rax   original destination
+ *
+ * The FSRS alternative should be done inline (avoiding the call and
+ * the disgusting return handling), but that would require some help
+ * from the compiler for better calling conventions.
+ *
+ * The 'rep stosb' itself is small enough to replace the call, but all
+ * the register moves blow up the code. And two of them are "needed"
+ * only for the return value that is the same as the source input,
+ * which the compiler could/should do much better anyway.
  */
 SYM_FUNC_START(__memset)
-	/*
-	 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
-	 * to use it when possible. If not available, use fast string instructions.
-	 *
-	 * Otherwise, use original memset function.
-	 */
-	ALTERNATIVE_2 "jmp memset_orig", "", X86_FEATURE_REP_GOOD, \
-		      "jmp memset_erms", X86_FEATURE_ERMS
+	ALTERNATIVE "jmp memset_orig", "", X86_FEATURE_FSRS
 
 	movq %rdi,%r9
+	movb %sil,%al
 	movq %rdx,%rcx
-	andl $7,%edx
-	shrq $3,%rcx
-	/* expand byte value  */
-	movzbl %sil,%esi
-	movabs $0x0101010101010101,%rax
-	imulq %rsi,%rax
-	rep stosq
-	movl %edx,%ecx
 	rep stosb
 	movq %r9,%rax
 	RET
@@ -48,26 +43,6 @@ EXPORT_SYMBOL(__memset)
 SYM_FUNC_ALIAS(memset, __memset)
 EXPORT_SYMBOL(memset)
 
-/*
- * ISO C memset - set a memory block to a byte value. This function uses
- * enhanced rep stosb to override the fast string function.
- * The code is simpler and shorter than the fast string function as well.
- *
- * rdi   destination
- * rsi   value (char)
- * rdx   count (bytes)
- *
- * rax   original destination
- */
-SYM_FUNC_START_LOCAL(memset_erms)
-	movq %rdi,%r9
-	movb %sil,%al
-	movq %rdx,%rcx
-	rep stosb
-	movq %r9,%rax
-	RET
-SYM_FUNC_END(memset_erms)
-
 SYM_FUNC_START_LOCAL(memset_orig)
 	movq %rdi,%r10
 
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 14/17] tools arch x86: Sync the cpufeatures with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (12 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 13/17] tools arch x86: Sync the memcpy_64 " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:24 ` [PATCH v2 15/17] tools arch x86: Sync the msr-index.h copy " Yanteng Si
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit 3d8f61bf8bcd69bc ("x86: KVM: Add common feature flag for AMD's
   PSFD")
  commit 3763bf58029f3459 ("x86/cpufeatures: Redefine synthetic virtual
   NMI bit as AMD's "real" vNMI")
  commit d1b5e84f943c7b5b ("x86/cpufeatures: Add CPU feature flags for
   shadow stacks")
  commit 6449dcb0cac73821 ("x86: CPUID and CR3/CR4 flags for Linear
   Address Masking")
  commit be8de49bea505e77 ("x86/speculation: Identify processors
   vulnerable to SMT RSB predictions")
  commit e7862eda309ecfcc ("x86/cpu: Support AMD Automatic IBRS")
  commit faabfcb194a8d068 ("x86/cpu, kvm: Add the SMM_CTL MSR not present
   feature")
  commit 5b909d4ae59aedc7 ("x86/cpu, kvm: Add the Null Selector Clears
   Base feature")
  commit 84168ae786f8a15a ("x86/cpu, kvm: Move X86_FEATURE_LFENCE_RDTSC
   to its native leaf")
  commit a9dc9ec5a1fafc3d ("x86/cpu, kvm: Add the NO_NESTED_DATA_BP
   feature")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h'
   differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
  diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm
   /cpufeatures.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/arch/x86/include/asm/cpufeatures.h | 28 +++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index b89005819cd5..d7215c8b7923 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -97,7 +97,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 */
-#define X86_FEATURE_LFENCE_RDTSC	( 3*32+18) /* "" LFENCE synchronizes RDTSC */
+/* FREE, was #define X86_FEATURE_LFENCE_RDTSC		( 3*32+18) "" LFENCE synchronizes RDTSC */
 #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 */
@@ -226,10 +226,9 @@
 
 /* Virtualization flags: Linux defined, word 8 */
 #define X86_FEATURE_TPR_SHADOW		( 8*32+ 0) /* Intel TPR Shadow */
-#define X86_FEATURE_VNMI		( 8*32+ 1) /* Intel Virtual NMI */
-#define X86_FEATURE_FLEXPRIORITY	( 8*32+ 2) /* Intel FlexPriority */
-#define X86_FEATURE_EPT			( 8*32+ 3) /* Intel Extended Page Table */
-#define X86_FEATURE_VPID		( 8*32+ 4) /* Intel Virtual Processor ID */
+#define X86_FEATURE_FLEXPRIORITY	( 8*32+ 1) /* Intel FlexPriority */
+#define X86_FEATURE_EPT			( 8*32+ 2) /* Intel Extended Page Table */
+#define X86_FEATURE_VPID		( 8*32+ 3) /* Intel Virtual Processor ID */
 
 #define X86_FEATURE_VMMCALL		( 8*32+15) /* Prefer VMMCALL to VMCALL */
 #define X86_FEATURE_XENPV		( 8*32+16) /* "" Xen paravirtual guest */
@@ -307,14 +306,22 @@
 #define X86_FEATURE_SGX_EDECCSSA	(11*32+18) /* "" SGX EDECCSSA user leaf function */
 #define X86_FEATURE_CALL_DEPTH		(11*32+19) /* "" Call depth tracking for RSB stuffing */
 #define X86_FEATURE_MSR_TSX_CTRL	(11*32+20) /* "" MSR IA32_TSX_CTRL (Intel) implemented */
+#define X86_FEATURE_SMBA		(11*32+21) /* "" Slow Memory Bandwidth Allocation */
+#define X86_FEATURE_BMEC		(11*32+22) /* "" Bandwidth Monitoring Event Configuration */
+#define X86_FEATURE_USER_SHSTK		(11*32+23) /* Shadow stack support for user mode applications */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
 #define X86_FEATURE_AVX_VNNI		(12*32+ 4) /* AVX VNNI instructions */
 #define X86_FEATURE_AVX512_BF16		(12*32+ 5) /* AVX512 BFLOAT16 instructions */
 #define X86_FEATURE_CMPCCXADD           (12*32+ 7) /* "" CMPccXADD instructions */
+#define X86_FEATURE_ARCH_PERFMON_EXT	(12*32+ 8) /* "" Intel Architectural PerfMon Extension */
+#define X86_FEATURE_FZRM		(12*32+10) /* "" Fast zero-length REP MOVSB */
+#define X86_FEATURE_FSRS		(12*32+11) /* "" Fast short REP STOSB */
+#define X86_FEATURE_FSRC		(12*32+12) /* "" Fast short REP {CMPSB,SCASB} */
 #define X86_FEATURE_LKGS		(12*32+18) /* "" Load "kernel" (userspace) GS */
 #define X86_FEATURE_AMX_FP16		(12*32+21) /* "" AMX fp16 Support */
 #define X86_FEATURE_AVX_IFMA            (12*32+23) /* "" Support for VPMADD52[H,L]UQ */
+#define X86_FEATURE_LAM			(12*32+26) /* Linear Address Masking */
 
 /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
 #define X86_FEATURE_CLZERO		(13*32+ 0) /* CLZERO instruction */
@@ -331,6 +338,7 @@
 #define X86_FEATURE_VIRT_SSBD		(13*32+25) /* Virtualized Speculative Store Bypass Disable */
 #define X86_FEATURE_AMD_SSB_NO		(13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */
 #define X86_FEATURE_CPPC		(13*32+27) /* Collaborative Processor Performance Control */
+#define X86_FEATURE_AMD_PSFD            (13*32+28) /* "" Predictive Store Forwarding Disable */
 #define X86_FEATURE_BTC_NO		(13*32+29) /* "" Not vulnerable to Branch Type Confusion */
 #define X86_FEATURE_BRS			(13*32+31) /* Branch Sampling available */
 
@@ -363,6 +371,7 @@
 #define X86_FEATURE_VGIF		(15*32+16) /* Virtual GIF */
 #define X86_FEATURE_X2AVIC		(15*32+18) /* Virtual x2apic */
 #define X86_FEATURE_V_SPEC_CTRL		(15*32+20) /* Virtual SPEC_CTRL */
+#define X86_FEATURE_VNMI		(15*32+25) /* Virtual NMI */
 #define X86_FEATURE_SVME_ADDR_CHK	(15*32+28) /* "" SVME addr check */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */
@@ -372,6 +381,7 @@
 #define X86_FEATURE_OSPKE		(16*32+ 4) /* OS Protection Keys Enable */
 #define X86_FEATURE_WAITPKG		(16*32+ 5) /* UMONITOR/UMWAIT/TPAUSE Instructions */
 #define X86_FEATURE_AVX512_VBMI2	(16*32+ 6) /* Additional AVX512 Vector Bit Manipulation Instructions */
+#define X86_FEATURE_SHSTK		(16*32+ 7) /* "" Shadow stack */
 #define X86_FEATURE_GFNI		(16*32+ 8) /* Galois Field New Instructions */
 #define X86_FEATURE_VAES		(16*32+ 9) /* Vector AES */
 #define X86_FEATURE_VPCLMULQDQ		(16*32+10) /* Carry-Less Multiplication Double Quadword */
@@ -427,6 +437,13 @@
 #define X86_FEATURE_V_TSC_AUX		(19*32+ 9) /* "" Virtual TSC_AUX */
 #define X86_FEATURE_SME_COHERENT	(19*32+10) /* "" AMD hardware-enforced cache coherency */
 
+/* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */
+#define X86_FEATURE_NO_NESTED_DATA_BP	(20*32+ 0) /* "" No Nested Data Breakpoints */
+#define X86_FEATURE_LFENCE_RDTSC	(20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */
+#define X86_FEATURE_NULL_SEL_CLR_BASE	(20*32+ 6) /* "" Null Selector Clears Base */
+#define X86_FEATURE_AUTOIBRS		(20*32+ 8) /* "" Automatic IBRS */
+#define X86_FEATURE_NO_SMM_CTL_MSR	(20*32+ 9) /* "" SMM_CTL MSR is not present */
+
 /*
  * BUG word(s)
  */
@@ -467,5 +484,6 @@
 #define X86_BUG_MMIO_UNKNOWN		X86_BUG(26) /* CPU is too old and its MMIO Stale Data status is unknown */
 #define X86_BUG_RETBLEED		X86_BUG(27) /* CPU is affected by RETBleed */
 #define X86_BUG_EIBRS_PBRSB		X86_BUG(28) /* EIBRS is vulnerable to Post Barrier RSB Predictions */
+#define X86_BUG_SMT_RSB			X86_BUG(29) /* CPU is vulnerable to Cross-Thread Return Address Predictions */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 15/17] tools arch x86: Sync the msr-index.h copy with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (13 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 14/17] tools arch x86: Sync the cpufeatures " Yanteng Si
@ 2023-05-10 10:24 ` Yanteng Si
  2023-05-10 10:25 ` [PATCH v2 16/17] tools arch x86: Sync the prctl headers " Yanteng Si
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:24 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit c68e3d473988b9af ("x86/include/asm/msr-index.h: Add IFS Array
   test bits")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h'
   differs from latest version at 'arch/x86/include/asm/msr-index.h'
  diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm
   /msr-index.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/arch/x86/include/asm/msr-index.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/arch/x86/include/asm/msr-index.h b/tools/arch/x86/include/asm/msr-index.h
index ad35355ee43e..3aedae61af4f 100644
--- a/tools/arch/x86/include/asm/msr-index.h
+++ b/tools/arch/x86/include/asm/msr-index.h
@@ -206,6 +206,8 @@
 
 /* Abbreviated from Intel SDM name IA32_INTEGRITY_CAPABILITIES */
 #define MSR_INTEGRITY_CAPS			0x000002d9
+#define MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT      2
+#define MSR_INTEGRITY_CAPS_ARRAY_BIST          BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT	4
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST	BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
 
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 16/17] tools arch x86: Sync the prctl headers with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (14 preceding siblings ...)
  2023-05-10 10:24 ` [PATCH v2 15/17] tools arch x86: Sync the msr-index.h copy " Yanteng Si
@ 2023-05-10 10:25 ` Yanteng Si
  2023-05-10 10:25 ` [PATCH v2 17/17] tools arch arm64: Sync the perf_regs " Yanteng Si
  2023-05-10 17:06 ` [PATCH v2 00/17] tools perf: fix build warnings Arnaldo Carvalho de Melo
  17 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:25 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit a03c376ebaf38394 ("x86/arch_prctl: Add AMX feature numbers as ABI
   constants")
  commit b642e9e5f0dc797f ("x86/shstk: Add ARCH_SHSTK_STATUS")
  commit d30299329def886f ("x86/shstk: Add ARCH_SHSTK_UNLOCK")
  commit 44600eec3f2b708c ("x86/shstk: Support WRSS for userspace")
  commit 2e30e007142374b6 ("x86/shstk: Add user-mode shadow stack
   support")
  commit c40a7569ad82fb47 ("x86: Introduce userspace API for shadow
   stack")
  commit 23e5d9ec2bab53c4 ("x86/mm/iommu/sva: Make LAM and SVA mutually
   exclusive")
  commit 2f8794bd087e7958 ("x86/mm: Provide arch_prctl() interface for
   LAM")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/prctl.h'
   differs from latest version at 'arch/x86/include/uapi/asm/prctl.h'
  diff -u tools/arch/x86/include/uapi/asm/prctl.h arch/x86/include/uapi
   /asm/prctl.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/arch/x86/include/uapi/asm/prctl.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/arch/x86/include/uapi/asm/prctl.h b/tools/arch/x86/include/uapi/asm/prctl.h
index 500b96e71f18..384e2cc6ac19 100644
--- a/tools/arch/x86/include/uapi/asm/prctl.h
+++ b/tools/arch/x86/include/uapi/asm/prctl.h
@@ -16,8 +16,28 @@
 #define ARCH_GET_XCOMP_GUEST_PERM	0x1024
 #define ARCH_REQ_XCOMP_GUEST_PERM	0x1025
 
+#define ARCH_XCOMP_TILECFG		17
+#define ARCH_XCOMP_TILEDATA		18
+
 #define ARCH_MAP_VDSO_X32		0x2001
 #define ARCH_MAP_VDSO_32		0x2002
 #define ARCH_MAP_VDSO_64		0x2003
 
+/* Don't use 0x3001-0x3004 because of old glibcs */
+
+#define ARCH_GET_UNTAG_MASK		0x4001
+#define ARCH_ENABLE_TAGGED_ADDR		0x4002
+#define ARCH_GET_MAX_TAG_BITS		0x4003
+#define ARCH_FORCE_TAGGED_SVA		0x4004
+
+#define ARCH_SHSTK_ENABLE		0x5001
+#define ARCH_SHSTK_DISABLE		0x5002
+#define ARCH_SHSTK_LOCK			0x5003
+#define ARCH_SHSTK_UNLOCK		0x5004
+#define ARCH_SHSTK_STATUS		0x5005
+
+/* ARCH_SHSTK_ features bits */
+#define ARCH_SHSTK_SHSTK		(1ULL <<  0)
+#define ARCH_SHSTK_WRSS			(1ULL <<  1)
+
 #endif /* _ASM_X86_PRCTL_H */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 17/17] tools arch arm64: Sync the perf_regs headers with the kernel sources
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (15 preceding siblings ...)
  2023-05-10 10:25 ` [PATCH v2 16/17] tools arch x86: Sync the prctl headers " Yanteng Si
@ 2023-05-10 10:25 ` Yanteng Si
  2023-05-10 15:26   ` Arnaldo Carvalho de Melo
  2023-05-10 17:06 ` [PATCH v2 00/17] tools perf: fix build warnings Arnaldo Carvalho de Melo
  17 siblings, 1 reply; 27+ messages in thread
From: Yanteng Si @ 2023-05-10 10:25 UTC (permalink / raw)
  To: acme
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel

Picking the changes from:

  commit aa3e49b606e0796a ("arm64: asm/perf_regs.h: Avoid C++-style
   comment in UAPI header")
  commit 2ee0d7fd36a3f87b ("ARM64: perf: add support for perf
   registers API")
  commit cbb0c02caf4bd98b ("perf: arm64: Add SVE vector granule
   register to user regs")

Silencing these perf build warnings:

  Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi
   /asm/perf_regs.h' differs from latest version at 'arch/arm64
    /include/uapi/asm/perf_regs.h'
  diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64
   /include/uapi/asm/perf_regs.h

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/arch/arm64/include/uapi/asm/perf_regs.h b/tools/arch/arm64/include/uapi/asm/perf_regs.h
index fd157f46727e..86e556429e0e 100644
--- a/tools/arch/arm64/include/uapi/asm/perf_regs.h
+++ b/tools/arch/arm64/include/uapi/asm/perf_regs.h
@@ -36,11 +36,13 @@ enum perf_event_arm_regs {
 	PERF_REG_ARM64_LR,
 	PERF_REG_ARM64_SP,
 	PERF_REG_ARM64_PC,
+	PERF_REG_ARM64_MAX,
 
 	/* Extended/pseudo registers */
-	PERF_REG_ARM64_VG = 46, // SVE Vector Granule
-
-	PERF_REG_ARM64_MAX = PERF_REG_ARM64_PC + 1,
-	PERF_REG_ARM64_EXTENDED_MAX = PERF_REG_ARM64_VG + 1
+	PERF_REG_ARM64_VG = 46,				/* SVE Vector Granule */
+	PERF_REG_ARM64_EXTENDED_MAX
 };
+
+#define PERF_REG_EXTENDED_MASK	(1ULL << PERF_REG_ARM64_VG)
+
 #endif /* _ASM_ARM64_PERF_REGS_H */
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 17/17] tools arch arm64: Sync the perf_regs headers with the kernel sources
  2023-05-10 10:25 ` [PATCH v2 17/17] tools arch arm64: Sync the perf_regs " Yanteng Si
@ 2023-05-10 15:26   ` Arnaldo Carvalho de Melo
  2023-05-15  4:08     ` Leo Yan
  0 siblings, 1 reply; 27+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-10 15:26 UTC (permalink / raw)
  To: Yanteng Si
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel,
	Leo Yan, James Clark, German Gomez, Mathieu Poirier, Mike Leach,
	Will Deacon

Em Wed, May 10, 2023 at 06:25:24PM +0800, Yanteng Si escreveu:
> Picking the changes from:
> 
>   commit aa3e49b606e0796a ("arm64: asm/perf_regs.h: Avoid C++-style
>    comment in UAPI header")
>   commit 2ee0d7fd36a3f87b ("ARM64: perf: add support for perf
>    registers API")
>   commit cbb0c02caf4bd98b ("perf: arm64: Add SVE vector granule
>    register to user regs")
> 
> Silencing these perf build warnings:
> 
>   Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi
>    /asm/perf_regs.h' differs from latest version at 'arch/arm64
>     /include/uapi/asm/perf_regs.h'
>   diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64
>    /include/uapi/asm/perf_regs.h
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
>  tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/arch/arm64/include/uapi/asm/perf_regs.h b/tools/arch/arm64/include/uapi/asm/perf_regs.h
> index fd157f46727e..86e556429e0e 100644
> --- a/tools/arch/arm64/include/uapi/asm/perf_regs.h
> +++ b/tools/arch/arm64/include/uapi/asm/perf_regs.h
> @@ -36,11 +36,13 @@ enum perf_event_arm_regs {
>  	PERF_REG_ARM64_LR,
>  	PERF_REG_ARM64_SP,
>  	PERF_REG_ARM64_PC,
> +	PERF_REG_ARM64_MAX,
>  
>  	/* Extended/pseudo registers */
> -	PERF_REG_ARM64_VG = 46, // SVE Vector Granule
> -
> -	PERF_REG_ARM64_MAX = PERF_REG_ARM64_PC + 1,
> -	PERF_REG_ARM64_EXTENDED_MAX = PERF_REG_ARM64_VG + 1
> +	PERF_REG_ARM64_VG = 46,				/* SVE Vector Granule */
> +	PERF_REG_ARM64_EXTENDED_MAX
>  };
> +
> +#define PERF_REG_EXTENDED_MASK	(1ULL << PERF_REG_ARM64_VG)
> +
>  #endif /* _ASM_ARM64_PERF_REGS_H */

This needs some more work, note that -DCORESIGHT=1 in the make command line.

I added some ARM folks that may help you,

- Arnaldo

  CC      /tmp/build/perf-tools/util/arm64-frame-pointer-unwind-support.o
  CC      /tmp/build/perf-tools/util/perf_regs.o
  CC      /tmp/build/perf-tools/util/header.o
In file included from util/arm64-frame-pointer-unwind-support.c:9:
util/../../arch/arm64/include/uapi/asm/perf_regs.h:46: error: "PERF_REG_EXTENDED_MASK" redefined [-Werror]
   46 | #define PERF_REG_EXTENDED_MASK  (1ULL << PERF_REG_ARM64_VG)
      | 
In file included from /var/home/acme/git/perf-tools/tools/perf/arch/x86/include/perf_regs.h:7,
                 from util/perf_regs.h:33,
                 from util/arm64-frame-pointer-unwind-support.c:5:
/var/home/acme/git/perf-tools/tools/arch/x86/include/uapi/asm/perf_regs.h:56: note: this is the location of the previous definition
   56 | #define PERF_REG_EXTENDED_MASK  (~((1ULL << PERF_REG_X86_XMM0) - 1))
      | 
cc1: all warnings being treated as errors
make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:97: /tmp/build/perf-tools/util/arm64-frame-pointer-unwind-support.o] Error 1
make[4]: *** Waiting for unfinished jobs....
In file included from util/perf_regs.c:26:
util/../../arch/arm64/include/uapi/asm/perf_regs.h:46: error: "PERF_REG_EXTENDED_MASK" redefined [-Werror]
   46 | #define PERF_REG_EXTENDED_MASK  (1ULL << PERF_REG_ARM64_VG)
      | 
In file included from /var/home/acme/git/perf-tools/tools/perf/arch/x86/include/perf_regs.h:7,
                 from util/perf_regs.h:33,
                 from util/perf_regs.c:4:
/var/home/acme/git/perf-tools/tools/arch/x86/include/uapi/asm/perf_regs.h:56: note: this is the location of the previous definition
   56 | #define PERF_REG_EXTENDED_MASK  (~((1ULL << PERF_REG_X86_XMM0) - 1))
      | 
cc1: all warnings being treated as errors
make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:97: /tmp/build/perf-tools/util/perf_regs.o] Error 1
make[3]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:140: util] Error 2
make[2]: *** [Makefile.perf:676: /tmp/build/perf-tools/perf-in.o] Error 2
make[1]: *** [Makefile.perf:236: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/var/home/acme/git/perf-tools/tools/perf'

 Performance counter stats for 'make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools -C tools/perf install-bin':

       12326009385      cycles:u                                                              
       20646679547      instructions:u                   #    1.68  insn per cycle            

       4.225375000 seconds time elapsed

       2.853093000 seconds user
       1.630218000 seconds sys


⬢[acme@toolbox perf-tools]$

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy with the kernel sources
  2023-05-10 10:22 ` [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy " Yanteng Si
@ 2023-05-10 15:41   ` Arnaldo Carvalho de Melo
  2023-05-22  9:56     ` James Clark
  0 siblings, 1 reply; 27+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-10 15:41 UTC (permalink / raw)
  To: Yanteng Si
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel

Em Wed, May 10, 2023 at 06:22:50PM +0800, Yanteng Si escreveu:
> Removing CORESIGHT_TRACE_ID_UNUSED_FLAG and CORESIGHT_TRACE_ID_UNUSED_VAL.
> 
> Silencing these perf build warnings:
> 
>   Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h'
>    differs from latest version at 'include/linux/coresight-pmu.h'
>   diff -u tools/include/linux/coresight-pmu.h include/linux
>    /coresight-pmu.h
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>

I think this one, when built with 'make -DCORESIGHT=1' breaks the build,
so I'm not applying it:

  CC      /tmp/build/perf-tools/util/parse-branch-options.o
util/cs-etm-decoder/cs-etm-decoder.c: In function ‘cs_etm_decoder__create_etm_decoder’:
util/cs-etm-decoder/cs-etm-decoder.c:671:51: error: ‘CORESIGHT_TRACE_ID_VAL_MASK’ undeclared (first use in this function)
  671 |                 csid = (t_params->etmv3.reg_idr & CORESIGHT_TRACE_ID_VAL_MASK);
      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
util/cs-etm-decoder/cs-etm-decoder.c:671:51: note: each undeclared identifier is reported only once for each function it appears in
util/cs-etm-decoder/cs-etm-decoder.c:695:21: error: ‘CORESIGHT_TRACE_ID_UNUSED_VAL’ undeclared (first use in this function)
  695 |         if (csid == CORESIGHT_TRACE_ID_UNUSED_VAL)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[5]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:98: /tmp/build/perf-tools/util/cs-etm-decoder/cs-etm-decoder.o] Error 1
make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:140: cs-etm-decoder] Error 2
make[4]: *** Waiting for unfinished jobs....
  LD      /tmp/build/perf-tools/util/hisi-ptt-decoder/perf-in.o
  LD      /tmp/build/perf-tools/util/arm-spe-decoder/perf-in.o
util/cs-etm.c: In function ‘cs_etm__metadata_get_trace_id’:
util/cs-etm.c:246:39: error: ‘CORESIGHT_TRACE_ID_VAL_MASK’ undeclared (first use in this function)
  246 |                                       CORESIGHT_TRACE_ID_VAL_MASK);
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
util/cs-etm.c:246:39: note: each undeclared identifier is reported only once for each function it appears in
util/cs-etm.c: In function ‘cs_etm__map_trace_ids_metadata’:
util/cs-etm.c:3112:60: error: ‘CORESIGHT_TRACE_ID_VAL_MASK’ undeclared (first use in this function)
 3112 |                         metadata[i][CS_ETM_ETMTRACEIDR] &= CORESIGHT_TRACE_ID_VAL_MASK;
      |                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
util/cs-etm.c: In function ‘cs_etm__clear_unused_trace_ids_metadata’:
util/cs-etm.c:3144:63: error: ‘CORESIGHT_TRACE_ID_UNUSED_FLAG’ undeclared (first use in this function)
 3144 |                         if (metadata[i][CS_ETM_ETMTRACEIDR] & CORESIGHT_TRACE_ID_UNUSED_FLAG)
      |                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/cs-etm.c:3145:67: error: ‘CORESIGHT_TRACE_ID_UNUSED_VAL’ undeclared (first use in this function)
 3145 |                                 metadata[i][CS_ETM_ETMTRACEIDR] = CORESIGHT_TRACE_ID_UNUSED_VAL;
      |                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:97: /tmp/build/perf-tools/util/cs-etm.o] Error 1
  LD      /tmp/build/perf-tools/util/scripting-engines/perf-in.o
  LD      /tmp/build/perf-tools/util/intel-pt-decoder/perf-in.o
make[3]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:140: util] Error 2
make[2]: *** [Makefile.perf:676: /tmp/build/perf-tools/perf-in.o] Error 2
make[1]: *** [Makefile.perf:236: sub-make] Error 2
make: *** [Makefile:113: install-bin] Error 2
make: Leaving directory '/var/home/acme/git/perf-tools/tools/perf'

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 07/17] tools headers UAPI: Sync the linux/perf_event.h with the kernel headers
  2023-05-10 10:22 ` [PATCH v2 07/17] tools headers UAPI: Sync the linux/perf_event.h " Yanteng Si
@ 2023-05-10 15:44   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 27+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-10 15:44 UTC (permalink / raw)
  To: Yanteng Si
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel

Em Wed, May 10, 2023 at 06:22:52PM +0800, Yanteng Si escreveu:
> Picking the changes from:
> 
>   commit 09519ec3b19e4144 ("perf: Add perf_event_attr::config3")
>   commit cb6c18b5a41622c7 ("perf/mem: Rename PERF_MEM_LVLNUM_EXTN_MEM to
>    PERF_MEM_LVLNUM_CXL")
> 
> Silencing these perf build warnings::
> 
>   Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h'
>    differs from latest version at 'include/uapi/linux/perf_event.h'
>   diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux
>    /perf_event.h

Dropping this one as well:

  CC      /tmp/build/perf-tools/util/unwind-libunwind-local.o
  CC      /tmp/build/perf-tools/util/unwind-libunwind.o
  CC      /tmp/build/perf-tools/util/data-convert-bt.o
util/mem-events.c:298:10: error: ‘PERF_MEM_LVLNUM_UNC’ undeclared here (not in a function); did you mean ‘PERF_MEM_LVLNUM_NA’?
  298 |         [PERF_MEM_LVLNUM_UNC] = "Uncached",
      |          ^~~~~~~~~~~~~~~~~~~
      |          PERF_MEM_LVLNUM_NA
util/mem-events.c:298:10: error: array index in initializer not of integer type
util/mem-events.c:298:10: note: (near initialization for ‘mem_lvlnum’)
make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:98: /tmp/build/perf-tools/util/mem-events.o] Error 1
make[4]: *** Waiting for unfinished jobs....
  LD      /tmp/build/perf-tools/util/cs-etm-decoder/perf-in.o

 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
>  tools/include/uapi/linux/perf_event.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index 39c6a250dd1b..37675437b768 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h
> @@ -1339,8 +1339,7 @@ union perf_mem_data_src {
>  #define PERF_MEM_LVLNUM_L2	0x02 /* L2 */
>  #define PERF_MEM_LVLNUM_L3	0x03 /* L3 */
>  #define PERF_MEM_LVLNUM_L4	0x04 /* L4 */
> -/* 5-0x7 available */
> -#define PERF_MEM_LVLNUM_UNC	0x08 /* Uncached */
> +/* 5-0x8 available */
>  #define PERF_MEM_LVLNUM_CXL	0x09 /* CXL */
>  #define PERF_MEM_LVLNUM_IO	0x0a /* I/O */
>  #define PERF_MEM_LVLNUM_ANY_CACHE 0x0b /* Any cache */
> -- 
> 2.31.4
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 13/17] tools arch x86: Sync the memcpy_64 with the kernel sources
  2023-05-10 10:24 ` [PATCH v2 13/17] tools arch x86: Sync the memcpy_64 " Yanteng Si
@ 2023-05-10 15:48   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 27+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-10 15:48 UTC (permalink / raw)
  To: Yanteng Si
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel

Em Wed, May 10, 2023 at 06:24:50PM +0800, Yanteng Si escreveu:
> Picking the changes from:
> 
>   commit 68674f94ffc9dddc ("x86: don't use REP_GOOD or ERMS for small
>    memory copies")
> 
> Silencing these perf build warnings:
> 
>   Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs
>    from latest version at 'arch/x86/lib/memcpy_64.S'
>   diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
>   Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs
>    from latest version at 'arch/x86/lib/memset_64.S'
>   diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S

Dropping this one:

In file included from bench/mem-memcpy-x86-64-asm.S:14:
bench/../../arch/x86/lib/memcpy_64.S:5:10: fatal error: linux/cfi_types.h: No such file or directory
    5 | #include <linux/cfi_types.h>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
>  tools/arch/x86/lib/memcpy_64.S | 35 ++++++++-----------------
>  tools/arch/x86/lib/memset_64.S | 47 ++++++++--------------------------
>  2 files changed, 22 insertions(+), 60 deletions(-)
> 
> diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S
> index a91ac666f758..8f95fb267caa 100644
> --- a/tools/arch/x86/lib/memcpy_64.S
> +++ b/tools/arch/x86/lib/memcpy_64.S
> @@ -2,6 +2,7 @@
>  /* Copyright 2002 Andi Kleen */
>  
>  #include <linux/linkage.h>
> +#include <linux/cfi_types.h>
>  #include <asm/errno.h>
>  #include <asm/cpufeatures.h>
>  #include <asm/alternative.h>
> @@ -9,13 +10,6 @@
>  
>  .section .noinstr.text, "ax"
>  
> -/*
> - * We build a jump to memcpy_orig by default which gets NOPped out on
> - * the majority of x86 CPUs which set REP_GOOD. In addition, CPUs which
> - * have the enhanced REP MOVSB/STOSB feature (ERMS), change those NOPs
> - * to a jmp to memcpy_erms which does the REP; MOVSB mem copy.
> - */
> -
>  /*
>   * memcpy - Copy a memory block.
>   *
> @@ -26,17 +20,21 @@
>   *
>   * Output:
>   * rax original destination
> + *
> + * The FSRM alternative should be done inline (avoiding the call and
> + * the disgusting return handling), but that would require some help
> + * from the compiler for better calling conventions.
> + *
> + * The 'rep movsb' itself is small enough to replace the call, but the
> + * two register moves blow up the code. And one of them is "needed"
> + * only for the return value that is the same as the source input,
> + * which the compiler could/should do much better anyway.
>   */
>  SYM_TYPED_FUNC_START(__memcpy)
> -	ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
> -		      "jmp memcpy_erms", X86_FEATURE_ERMS
> +	ALTERNATIVE "jmp memcpy_orig", "", X86_FEATURE_FSRM
>  
>  	movq %rdi, %rax
>  	movq %rdx, %rcx
> -	shrq $3, %rcx
> -	andl $7, %edx
> -	rep movsq
> -	movl %edx, %ecx
>  	rep movsb
>  	RET
>  SYM_FUNC_END(__memcpy)
> @@ -45,17 +43,6 @@ EXPORT_SYMBOL(__memcpy)
>  SYM_FUNC_ALIAS(memcpy, __memcpy)
>  EXPORT_SYMBOL(memcpy)
>  
> -/*
> - * memcpy_erms() - enhanced fast string memcpy. This is faster and
> - * simpler than memcpy. Use memcpy_erms when possible.
> - */
> -SYM_FUNC_START_LOCAL(memcpy_erms)
> -	movq %rdi, %rax
> -	movq %rdx, %rcx
> -	rep movsb
> -	RET
> -SYM_FUNC_END(memcpy_erms)
> -
>  SYM_FUNC_START_LOCAL(memcpy_orig)
>  	movq %rdi, %rax
>  
> diff --git a/tools/arch/x86/lib/memset_64.S b/tools/arch/x86/lib/memset_64.S
> index 6143b1a6fa2c..7c59a704c458 100644
> --- a/tools/arch/x86/lib/memset_64.S
> +++ b/tools/arch/x86/lib/memset_64.S
> @@ -18,27 +18,22 @@
>   * rdx   count (bytes)
>   *
>   * rax   original destination
> + *
> + * The FSRS alternative should be done inline (avoiding the call and
> + * the disgusting return handling), but that would require some help
> + * from the compiler for better calling conventions.
> + *
> + * The 'rep stosb' itself is small enough to replace the call, but all
> + * the register moves blow up the code. And two of them are "needed"
> + * only for the return value that is the same as the source input,
> + * which the compiler could/should do much better anyway.
>   */
>  SYM_FUNC_START(__memset)
> -	/*
> -	 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
> -	 * to use it when possible. If not available, use fast string instructions.
> -	 *
> -	 * Otherwise, use original memset function.
> -	 */
> -	ALTERNATIVE_2 "jmp memset_orig", "", X86_FEATURE_REP_GOOD, \
> -		      "jmp memset_erms", X86_FEATURE_ERMS
> +	ALTERNATIVE "jmp memset_orig", "", X86_FEATURE_FSRS
>  
>  	movq %rdi,%r9
> +	movb %sil,%al
>  	movq %rdx,%rcx
> -	andl $7,%edx
> -	shrq $3,%rcx
> -	/* expand byte value  */
> -	movzbl %sil,%esi
> -	movabs $0x0101010101010101,%rax
> -	imulq %rsi,%rax
> -	rep stosq
> -	movl %edx,%ecx
>  	rep stosb
>  	movq %r9,%rax
>  	RET
> @@ -48,26 +43,6 @@ EXPORT_SYMBOL(__memset)
>  SYM_FUNC_ALIAS(memset, __memset)
>  EXPORT_SYMBOL(memset)
>  
> -/*
> - * ISO C memset - set a memory block to a byte value. This function uses
> - * enhanced rep stosb to override the fast string function.
> - * The code is simpler and shorter than the fast string function as well.
> - *
> - * rdi   destination
> - * rsi   value (char)
> - * rdx   count (bytes)
> - *
> - * rax   original destination
> - */
> -SYM_FUNC_START_LOCAL(memset_erms)
> -	movq %rdi,%r9
> -	movb %sil,%al
> -	movq %rdx,%rcx
> -	rep stosb
> -	movq %r9,%rax
> -	RET
> -SYM_FUNC_END(memset_erms)
> -
>  SYM_FUNC_START_LOCAL(memset_orig)
>  	movq %rdi,%r10
>  
> -- 
> 2.31.4
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 00/17] tools perf: fix build warnings
  2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
                   ` (16 preceding siblings ...)
  2023-05-10 10:25 ` [PATCH v2 17/17] tools arch arm64: Sync the perf_regs " Yanteng Si
@ 2023-05-10 17:06 ` Arnaldo Carvalho de Melo
  2023-05-15 11:08   ` Yanteng Si
  17 siblings, 1 reply; 27+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-10 17:06 UTC (permalink / raw)
  To: Yanteng Si
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel

Em Wed, May 10, 2023 at 06:21:43PM +0800, Yanteng Si escreveu:
> v2:

So had to drop the ones I explicitely replied due to build failures and
then some more because this is usually done when the window closes, i.e.
for v6.4, so that when it is finally released we don't have warnings
building perf.

The ones I applied:

⬢[acme@toolbox perf-tools]$ git log --oneline 558423699d9b37de..
79ae55cb5aa77ac2 (HEAD -> perf-tools) tools arch x86: Sync the msr-index.h copy with the kernel sources
d48eb7d03dcd623a tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel sources
14665fa481b7c947 tools include UAPI: Sync the sound/asound.h copy with the kernel sources
42252bb99c0eab81 tools headers UAPI: Sync the linux/const.h with the kernel headers
fcee73a84ed92b77 tools headers UAPI: Sync the i915_drm.h with the kernel sources
82fed3e30b2319e5 tools headers UAPI: Sync the drm/drm.h with the kernel sources
a7919a256f89bea6 tools headers UAPI: Sync the linux/in.h with the kernel sources
⬢[acme@toolbox perf-tools]$

- Arnaldo
 
> * Drop <tools arch s390: Sync the ptrace headers with the kernel sources>
>    Because ptrace.h has been fixed in other tree, detail see:
>     selftests/bpf: Remove not used headers
>     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1f265d2aea0d
>     tools headers: Remove s390 ptrace.h in check-headers.sh
>     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed4da0d3de1e
> 
> * BTW, I made these patches in the next tree, so most of the warnings haven't appeared in the perf tree yet. :)
> 
> 
> v1:
> * When I try to build perf, a lot of warnings are output, let's fix them.
> 
> Yanteng Si (17):
>   tools headers UAPI: Sync the linux/in.h with the kernel sources
>   tools headers UAPI: Sync the linux/prctl.h with the kernel sources
>   tools headers UAPI: Sync the drm/drm.h with the kernel sources
>   tools headers UAPI: Sync the i915_drm.h with the kernel sources
>   tools headers UAPI: Sync the coresight-pmu headers copy with the
>     kernel sources
>   tools headers UAPI: Sync the linux/const.h with the kernel headers
>   tools headers UAPI: Sync the linux/perf_event.h with the kernel
>     headers
>   tools include UAPI: Sync the sound/asound.h copy with the kernel
>     sources
>   tools headers UAPI: Sync the linux/mman.h with the kernel sources
>   tools headers UAPI: Sync the unistd with the kernel sources
>   tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel
>     sources
>   tools arch x86: Sync the disabled-features with the kernel sources
>   tools arch x86: Sync the memcpy_64 with the kernel sources
>   tools arch x86: Sync the cpufeatures with the kernel sources
>   tools arch x86: Sync the msr-index.h copy with the kernel sources
>   tools arch x86: Sync the prctl headers with the kernel sources
>   tools arch arm64: Sync the perf_regs headers with the kernel sources
> 
>  tools/arch/arm64/include/uapi/asm/kvm.h       | 36 ++++++++++++
>  tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++--
>  tools/arch/x86/include/asm/cpufeatures.h      | 28 +++++++--
>  .../arch/x86/include/asm/disabled-features.h  | 24 +++++++-
>  tools/arch/x86/include/asm/msr-index.h        |  2 +
>  tools/arch/x86/include/uapi/asm/kvm.h         |  3 +
>  tools/arch/x86/include/uapi/asm/prctl.h       | 20 +++++++
>  tools/arch/x86/lib/memcpy_64.S                | 35 ++++--------
>  tools/arch/x86/lib/memset_64.S                | 47 ++++-----------
>  tools/include/linux/coresight-pmu.h           | 13 -----
>  tools/include/uapi/asm-generic/unistd.h       |  5 +-
>  tools/include/uapi/drm/drm.h                  | 57 ++++++++++++++++++-
>  tools/include/uapi/drm/i915_drm.h             | 25 +++++++-
>  tools/include/uapi/linux/const.h              |  2 +-
>  tools/include/uapi/linux/in.h                 |  1 +
>  tools/include/uapi/linux/kvm.h                | 12 +++-
>  tools/include/uapi/linux/mman.h               | 14 +++++
>  tools/include/uapi/linux/perf_event.h         |  3 +-
>  tools/include/uapi/linux/prctl.h              |  2 +
>  tools/include/uapi/sound/asound.h             | 14 +++--
>  .../perf/arch/s390/entry/syscalls/syscall.tbl |  2 +-
>  .../arch/x86/entry/syscalls/syscall_64.tbl    |  2 +
>  22 files changed, 258 insertions(+), 99 deletions(-)
> 
> -- 
> 2.31.4
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 17/17] tools arch arm64: Sync the perf_regs headers with the kernel sources
  2023-05-10 15:26   ` Arnaldo Carvalho de Melo
@ 2023-05-15  4:08     ` Leo Yan
  2023-05-20  3:11       ` Leo Yan
  0 siblings, 1 reply; 27+ messages in thread
From: Leo Yan @ 2023-05-15  4:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel, James Clark, German Gomez, Mathieu Poirier,
	Mike Leach, Will Deacon

On Wed, May 10, 2023 at 12:26:41PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, May 10, 2023 at 06:25:24PM +0800, Yanteng Si escreveu:
> > Picking the changes from:
> > 
> >   commit aa3e49b606e0796a ("arm64: asm/perf_regs.h: Avoid C++-style
> >    comment in UAPI header")
> >   commit 2ee0d7fd36a3f87b ("ARM64: perf: add support for perf
> >    registers API")
> >   commit cbb0c02caf4bd98b ("perf: arm64: Add SVE vector granule
> >    register to user regs")
> > 
> > Silencing these perf build warnings:
> > 
> >   Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi
> >    /asm/perf_regs.h' differs from latest version at 'arch/arm64
> >     /include/uapi/asm/perf_regs.h'
> >   diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64
> >    /include/uapi/asm/perf_regs.h
> > 
> > Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> > ---
> >  tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/tools/arch/arm64/include/uapi/asm/perf_regs.h b/tools/arch/arm64/include/uapi/asm/perf_regs.h
> > index fd157f46727e..86e556429e0e 100644
> > --- a/tools/arch/arm64/include/uapi/asm/perf_regs.h
> > +++ b/tools/arch/arm64/include/uapi/asm/perf_regs.h
> > @@ -36,11 +36,13 @@ enum perf_event_arm_regs {
> >  	PERF_REG_ARM64_LR,
> >  	PERF_REG_ARM64_SP,
> >  	PERF_REG_ARM64_PC,
> > +	PERF_REG_ARM64_MAX,
> >  
> >  	/* Extended/pseudo registers */
> > -	PERF_REG_ARM64_VG = 46, // SVE Vector Granule
> > -
> > -	PERF_REG_ARM64_MAX = PERF_REG_ARM64_PC + 1,
> > -	PERF_REG_ARM64_EXTENDED_MAX = PERF_REG_ARM64_VG + 1
> > +	PERF_REG_ARM64_VG = 46,				/* SVE Vector Granule */
> > +	PERF_REG_ARM64_EXTENDED_MAX
> >  };
> > +
> > +#define PERF_REG_EXTENDED_MASK	(1ULL << PERF_REG_ARM64_VG)
> > +
> >  #endif /* _ASM_ARM64_PERF_REGS_H */
> 
> This needs some more work, note that -DCORESIGHT=1 in the make command line.

On the mainline kernel, the patch cbb0c02caf4bd ("perf: arm64: Add SVE
vector granule register to user regs") and f450f11b2d3f ("perf tools
arm64: Copy perf_regs.h from the kernel") are to update headers for
kernel header and tool's header respectively, but there are not
aligned with each other.  So Yanteng's patch is valid and we should
pick up it.

However, as Arnaldo tested, Yanteng's patch introduces building
regression due to arm64 and x86 both defines the macro
PERF_REG_EXTENDED_MASK, but this macro actually is architecture
specific.

The issue is now we use a single file util/perf_regs.c to maintain
perf register related stuffs for all architectures, this is fragile
since we cannot have any duplicated naming (e.g. for macros, structure
name, etc).  We need to refactor the source file util/perf_regs.c to
move architecture specific code into arch folders and only keep common
code.

@James, you is the best person to know this part for arm64.  If you
have already worked on this, please let me know.  Otherwise, I can
prepare a patch set for this, I tried a bit but found I cannot just
use a single patch to refactor util/perf_regs.c.

Thanks,
Leo

> I added some ARM folks that may help you,
> 
> - Arnaldo
> 
>   CC      /tmp/build/perf-tools/util/arm64-frame-pointer-unwind-support.o
>   CC      /tmp/build/perf-tools/util/perf_regs.o
>   CC      /tmp/build/perf-tools/util/header.o
> In file included from util/arm64-frame-pointer-unwind-support.c:9:
> util/../../arch/arm64/include/uapi/asm/perf_regs.h:46: error: "PERF_REG_EXTENDED_MASK" redefined [-Werror]
>    46 | #define PERF_REG_EXTENDED_MASK  (1ULL << PERF_REG_ARM64_VG)
>       | 
> In file included from /var/home/acme/git/perf-tools/tools/perf/arch/x86/include/perf_regs.h:7,
>                  from util/perf_regs.h:33,
>                  from util/arm64-frame-pointer-unwind-support.c:5:
> /var/home/acme/git/perf-tools/tools/arch/x86/include/uapi/asm/perf_regs.h:56: note: this is the location of the previous definition
>    56 | #define PERF_REG_EXTENDED_MASK  (~((1ULL << PERF_REG_X86_XMM0) - 1))
>       | 
> cc1: all warnings being treated as errors
> make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:97: /tmp/build/perf-tools/util/arm64-frame-pointer-unwind-support.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> In file included from util/perf_regs.c:26:
> util/../../arch/arm64/include/uapi/asm/perf_regs.h:46: error: "PERF_REG_EXTENDED_MASK" redefined [-Werror]
>    46 | #define PERF_REG_EXTENDED_MASK  (1ULL << PERF_REG_ARM64_VG)
>       | 
> In file included from /var/home/acme/git/perf-tools/tools/perf/arch/x86/include/perf_regs.h:7,
>                  from util/perf_regs.h:33,
>                  from util/perf_regs.c:4:
> /var/home/acme/git/perf-tools/tools/arch/x86/include/uapi/asm/perf_regs.h:56: note: this is the location of the previous definition
>    56 | #define PERF_REG_EXTENDED_MASK  (~((1ULL << PERF_REG_X86_XMM0) - 1))
>       | 
> cc1: all warnings being treated as errors
> make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:97: /tmp/build/perf-tools/util/perf_regs.o] Error 1
> make[3]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:140: util] Error 2
> make[2]: *** [Makefile.perf:676: /tmp/build/perf-tools/perf-in.o] Error 2
> make[1]: *** [Makefile.perf:236: sub-make] Error 2
> make: *** [Makefile:113: install-bin] Error 2
> make: Leaving directory '/var/home/acme/git/perf-tools/tools/perf'
> 
>  Performance counter stats for 'make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools -C tools/perf install-bin':
> 
>        12326009385      cycles:u                                                              
>        20646679547      instructions:u                   #    1.68  insn per cycle            
> 
>        4.225375000 seconds time elapsed
> 
>        2.853093000 seconds user
>        1.630218000 seconds sys
> 
> 
> ⬢[acme@toolbox perf-tools]$

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 00/17] tools perf: fix build warnings
  2023-05-10 17:06 ` [PATCH v2 00/17] tools perf: fix build warnings Arnaldo Carvalho de Melo
@ 2023-05-15 11:08   ` Yanteng Si
  0 siblings, 0 replies; 27+ messages in thread
From: Yanteng Si @ 2023-05-15 11:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel


On 2023/5/11 01:06, Arnaldo Carvalho de Melo wrote:
> Em Wed, May 10, 2023 at 06:21:43PM +0800, Yanteng Si escreveu:
>> v2:
> So had to drop the ones I explicitely replied due to build failures and
> then some more because this is usually done when the window closes, i.e.
> for v6.4, so that when it is finally released we don't have warnings
> building perf.
Oh yes, I see what you mean.
>
> The ones I applied:
>
> ⬢[acme@toolbox perf-tools]$ git log --oneline 558423699d9b37de..
> 79ae55cb5aa77ac2 (HEAD -> perf-tools) tools arch x86: Sync the msr-index.h copy with the kernel sources
> d48eb7d03dcd623a tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel sources
> 14665fa481b7c947 tools include UAPI: Sync the sound/asound.h copy with the kernel sources
> 42252bb99c0eab81 tools headers UAPI: Sync the linux/const.h with the kernel headers
> fcee73a84ed92b77 tools headers UAPI: Sync the i915_drm.h with the kernel sources
> 82fed3e30b2319e5 tools headers UAPI: Sync the drm/drm.h with the kernel sources
> a7919a256f89bea6 tools headers UAPI: Sync the linux/in.h with the kernel sources

Thank you very much!


Thanks,

Yanteng


> ⬢[acme@toolbox perf-tools]$
>
> - Arnaldo
>   
>> * Drop <tools arch s390: Sync the ptrace headers with the kernel sources>
>>     Because ptrace.h has been fixed in other tree, detail see:
>>      selftests/bpf: Remove not used headers
>>      https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1f265d2aea0d
>>      tools headers: Remove s390 ptrace.h in check-headers.sh
>>      https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed4da0d3de1e
>>
>> * BTW, I made these patches in the next tree, so most of the warnings haven't appeared in the perf tree yet. :)
>>
>>
>> v1:
>> * When I try to build perf, a lot of warnings are output, let's fix them.
>>
>> Yanteng Si (17):
>>    tools headers UAPI: Sync the linux/in.h with the kernel sources
>>    tools headers UAPI: Sync the linux/prctl.h with the kernel sources
>>    tools headers UAPI: Sync the drm/drm.h with the kernel sources
>>    tools headers UAPI: Sync the i915_drm.h with the kernel sources
>>    tools headers UAPI: Sync the coresight-pmu headers copy with the
>>      kernel sources
>>    tools headers UAPI: Sync the linux/const.h with the kernel headers
>>    tools headers UAPI: Sync the linux/perf_event.h with the kernel
>>      headers
>>    tools include UAPI: Sync the sound/asound.h copy with the kernel
>>      sources
>>    tools headers UAPI: Sync the linux/mman.h with the kernel sources
>>    tools headers UAPI: Sync the unistd with the kernel sources
>>    tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel
>>      sources
>>    tools arch x86: Sync the disabled-features with the kernel sources
>>    tools arch x86: Sync the memcpy_64 with the kernel sources
>>    tools arch x86: Sync the cpufeatures with the kernel sources
>>    tools arch x86: Sync the msr-index.h copy with the kernel sources
>>    tools arch x86: Sync the prctl headers with the kernel sources
>>    tools arch arm64: Sync the perf_regs headers with the kernel sources
>>
>>   tools/arch/arm64/include/uapi/asm/kvm.h       | 36 ++++++++++++
>>   tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++--
>>   tools/arch/x86/include/asm/cpufeatures.h      | 28 +++++++--
>>   .../arch/x86/include/asm/disabled-features.h  | 24 +++++++-
>>   tools/arch/x86/include/asm/msr-index.h        |  2 +
>>   tools/arch/x86/include/uapi/asm/kvm.h         |  3 +
>>   tools/arch/x86/include/uapi/asm/prctl.h       | 20 +++++++
>>   tools/arch/x86/lib/memcpy_64.S                | 35 ++++--------
>>   tools/arch/x86/lib/memset_64.S                | 47 ++++-----------
>>   tools/include/linux/coresight-pmu.h           | 13 -----
>>   tools/include/uapi/asm-generic/unistd.h       |  5 +-
>>   tools/include/uapi/drm/drm.h                  | 57 ++++++++++++++++++-
>>   tools/include/uapi/drm/i915_drm.h             | 25 +++++++-
>>   tools/include/uapi/linux/const.h              |  2 +-
>>   tools/include/uapi/linux/in.h                 |  1 +
>>   tools/include/uapi/linux/kvm.h                | 12 +++-
>>   tools/include/uapi/linux/mman.h               | 14 +++++
>>   tools/include/uapi/linux/perf_event.h         |  3 +-
>>   tools/include/uapi/linux/prctl.h              |  2 +
>>   tools/include/uapi/sound/asound.h             | 14 +++--
>>   .../perf/arch/s390/entry/syscalls/syscall.tbl |  2 +-
>>   .../arch/x86/entry/syscalls/syscall_64.tbl    |  2 +
>>   22 files changed, 258 insertions(+), 99 deletions(-)
>>
>> -- 
>> 2.31.4
>>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 17/17] tools arch arm64: Sync the perf_regs headers with the kernel sources
  2023-05-15  4:08     ` Leo Yan
@ 2023-05-20  3:11       ` Leo Yan
  0 siblings, 0 replies; 27+ messages in thread
From: Leo Yan @ 2023-05-20  3:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Yanteng Si, peterz, mingo, mark.rutland, alexander.shishkin,
	jolsa, namhyung, irogers, adrian.hunter, linux-perf-users,
	loongson-kernel, James Clark, German Gomez, Mathieu Poirier,
	Mike Leach, Will Deacon

On Mon, May 15, 2023 at 12:08:32PM +0800, Leo Yan wrote:
> On Wed, May 10, 2023 at 12:26:41PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, May 10, 2023 at 06:25:24PM +0800, Yanteng Si escreveu:
> > > Picking the changes from:
> > > 
> > >   commit aa3e49b606e0796a ("arm64: asm/perf_regs.h: Avoid C++-style
> > >    comment in UAPI header")
> > >   commit 2ee0d7fd36a3f87b ("ARM64: perf: add support for perf
> > >    registers API")
> > >   commit cbb0c02caf4bd98b ("perf: arm64: Add SVE vector granule
> > >    register to user regs")
> > > 
> > > Silencing these perf build warnings:
> > > 
> > >   Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi
> > >    /asm/perf_regs.h' differs from latest version at 'arch/arm64
> > >     /include/uapi/asm/perf_regs.h'
> > >   diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64
> > >    /include/uapi/asm/perf_regs.h
> > > 
> > > Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> > > ---
> > >  tools/arch/arm64/include/uapi/asm/perf_regs.h | 10 ++++++----
> > >  1 file changed, 6 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/tools/arch/arm64/include/uapi/asm/perf_regs.h b/tools/arch/arm64/include/uapi/asm/perf_regs.h
> > > index fd157f46727e..86e556429e0e 100644
> > > --- a/tools/arch/arm64/include/uapi/asm/perf_regs.h
> > > +++ b/tools/arch/arm64/include/uapi/asm/perf_regs.h
> > > @@ -36,11 +36,13 @@ enum perf_event_arm_regs {
> > >  	PERF_REG_ARM64_LR,
> > >  	PERF_REG_ARM64_SP,
> > >  	PERF_REG_ARM64_PC,
> > > +	PERF_REG_ARM64_MAX,
> > >  
> > >  	/* Extended/pseudo registers */
> > > -	PERF_REG_ARM64_VG = 46, // SVE Vector Granule
> > > -
> > > -	PERF_REG_ARM64_MAX = PERF_REG_ARM64_PC + 1,
> > > -	PERF_REG_ARM64_EXTENDED_MAX = PERF_REG_ARM64_VG + 1
> > > +	PERF_REG_ARM64_VG = 46,				/* SVE Vector Granule */
> > > +	PERF_REG_ARM64_EXTENDED_MAX
> > >  };
> > > +
> > > +#define PERF_REG_EXTENDED_MASK	(1ULL << PERF_REG_ARM64_VG)
> > > +
> > >  #endif /* _ASM_ARM64_PERF_REGS_H */
> > 
> > This needs some more work, note that -DCORESIGHT=1 in the make command line.
> 
> On the mainline kernel, the patch cbb0c02caf4bd ("perf: arm64: Add SVE
> vector granule register to user regs") and f450f11b2d3f ("perf tools
> arm64: Copy perf_regs.h from the kernel") are to update headers for
> kernel header and tool's header respectively, but there are not
> aligned with each other.  So Yanteng's patch is valid and we should
> pick up it.
> 
> However, as Arnaldo tested, Yanteng's patch introduces building
> regression due to arm64 and x86 both defines the macro
> PERF_REG_EXTENDED_MASK, but this macro actually is architecture
> specific.
> 
> The issue is now we use a single file util/perf_regs.c to maintain
> perf register related stuffs for all architectures, this is fragile
> since we cannot have any duplicated naming (e.g. for macros, structure
> name, etc).  We need to refactor the source file util/perf_regs.c to
> move architecture specific code into arch folders and only keep common
> code.
> 
> @James, you is the best person to know this part for arm64.  If you
> have already worked on this, please let me know.  Otherwise, I can
> prepare a patch set for this, I tried a bit but found I cannot just
> use a single patch to refactor util/perf_regs.c.

Hi,

I sent a patch series [1] for perf register refactoring, which will
resolve the building failure issue caused by this arm64 header syncing
change.

Thanks,
Leo

[1] https://lore.kernel.org/lkml/20230520025537.1811986-1-leo.yan@linaro.org/T/#mf286726bcfbc0fc5313798d1693db65ef902d9ed

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy with the kernel sources
  2023-05-10 15:41   ` Arnaldo Carvalho de Melo
@ 2023-05-22  9:56     ` James Clark
  0 siblings, 0 replies; 27+ messages in thread
From: James Clark @ 2023-05-22  9:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Yanteng Si
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, adrian.hunter, linux-perf-users, loongson-kernel



On 10/05/2023 16:41, Arnaldo Carvalho de Melo wrote:
> Em Wed, May 10, 2023 at 06:22:50PM +0800, Yanteng Si escreveu:
>> Removing CORESIGHT_TRACE_ID_UNUSED_FLAG and CORESIGHT_TRACE_ID_UNUSED_VAL.
>>
>> Silencing these perf build warnings:
>>
>>   Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h'
>>    differs from latest version at 'include/linux/coresight-pmu.h'
>>   diff -u tools/include/linux/coresight-pmu.h include/linux
>>    /coresight-pmu.h
>>
>> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> 
> I think this one, when built with 'make -DCORESIGHT=1' breaks the build,
> so I'm not applying it:
> 
>   CC      /tmp/build/perf-tools/util/parse-branch-options.o
> util/cs-etm-decoder/cs-etm-decoder.c: In function ‘cs_etm_decoder__create_etm_decoder’:
> util/cs-etm-decoder/cs-etm-decoder.c:671:51: error: ‘CORESIGHT_TRACE_ID_VAL_MASK’ undeclared (first use in this function)
>   671 |                 csid = (t_params->etmv3.reg_idr & CORESIGHT_TRACE_ID_VAL_MASK);
>       |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> util/cs-etm-decoder/cs-etm-decoder.c:671:51: note: each undeclared identifier is reported only once for each function it appears in
> util/cs-etm-decoder/cs-etm-decoder.c:695:21: error: ‘CORESIGHT_TRACE_ID_UNUSED_VAL’ undeclared (first use in this function)
>   695 |         if (csid == CORESIGHT_TRACE_ID_UNUSED_VAL)
>       |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> make[5]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:98: /tmp/build/perf-tools/util/cs-etm-decoder/cs-etm-decoder.o] Error 1
> make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:140: cs-etm-decoder] Error 2
> make[4]: *** Waiting for unfinished jobs....
>   LD      /tmp/build/perf-tools/util/hisi-ptt-decoder/perf-in.o
>   LD      /tmp/build/perf-tools/util/arm-spe-decoder/perf-in.o
> util/cs-etm.c: In function ‘cs_etm__metadata_get_trace_id’:
> util/cs-etm.c:246:39: error: ‘CORESIGHT_TRACE_ID_VAL_MASK’ undeclared (first use in this function)
>   246 |                                       CORESIGHT_TRACE_ID_VAL_MASK);
>       |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> util/cs-etm.c:246:39: note: each undeclared identifier is reported only once for each function it appears in
> util/cs-etm.c: In function ‘cs_etm__map_trace_ids_metadata’:
> util/cs-etm.c:3112:60: error: ‘CORESIGHT_TRACE_ID_VAL_MASK’ undeclared (first use in this function)
>  3112 |                         metadata[i][CS_ETM_ETMTRACEIDR] &= CORESIGHT_TRACE_ID_VAL_MASK;
>       |                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> util/cs-etm.c: In function ‘cs_etm__clear_unused_trace_ids_metadata’:
> util/cs-etm.c:3144:63: error: ‘CORESIGHT_TRACE_ID_UNUSED_FLAG’ undeclared (first use in this function)
>  3144 |                         if (metadata[i][CS_ETM_ETMTRACEIDR] & CORESIGHT_TRACE_ID_UNUSED_FLAG)
>       |                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> util/cs-etm.c:3145:67: error: ‘CORESIGHT_TRACE_ID_UNUSED_VAL’ undeclared (first use in this function)
>  3145 |                                 metadata[i][CS_ETM_ETMTRACEIDR] = CORESIGHT_TRACE_ID_UNUSED_VAL;
>       |                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> make[4]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:97: /tmp/build/perf-tools/util/cs-etm.o] Error 1
>   LD      /tmp/build/perf-tools/util/scripting-engines/perf-in.o
>   LD      /tmp/build/perf-tools/util/intel-pt-decoder/perf-in.o
> make[3]: *** [/var/home/acme/git/perf-tools/tools/build/Makefile.build:140: util] Error 2
> make[2]: *** [Makefile.perf:676: /tmp/build/perf-tools/perf-in.o] Error 2
> make[1]: *** [Makefile.perf:236: sub-make] Error 2
> make: *** [Makefile:113: install-bin] Error 2
> make: Leaving directory '/var/home/acme/git/perf-tools/tools/perf'

Looks like these were only ever added to the tools side header which was
probably a mistake.

I can send a fix to move them and then re-copy the kernel header.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-05-22  9:56 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 10:21 [PATCH v2 00/17] tools perf: fix build warnings Yanteng Si
2023-05-10 10:21 ` [PATCH v2 01/17] tools headers UAPI: Sync the linux/in.h with the kernel sources Yanteng Si
2023-05-10 10:21 ` [PATCH v2 02/17] tools headers UAPI: Sync the linux/prctl.h " Yanteng Si
2023-05-10 10:21 ` [PATCH v2 03/17] tools headers UAPI: Sync the drm/drm.h " Yanteng Si
2023-05-10 10:22 ` [PATCH v2 04/17] tools headers UAPI: Sync the i915_drm.h " Yanteng Si
2023-05-10 10:22 ` [PATCH v2 05/17] tools headers UAPI: Sync the coresight-pmu headers copy " Yanteng Si
2023-05-10 15:41   ` Arnaldo Carvalho de Melo
2023-05-22  9:56     ` James Clark
2023-05-10 10:22 ` [PATCH v2 06/17] tools headers UAPI: Sync the linux/const.h with the kernel headers Yanteng Si
2023-05-10 10:22 ` [PATCH v2 07/17] tools headers UAPI: Sync the linux/perf_event.h " Yanteng Si
2023-05-10 15:44   ` Arnaldo Carvalho de Melo
2023-05-10 10:24 ` [PATCH v2 08/17] tools include UAPI: Sync the sound/asound.h copy with the kernel sources Yanteng Si
2023-05-10 10:24 ` [PATCH v2 09/17] tools headers UAPI: Sync the linux/mman.h " Yanteng Si
2023-05-10 10:24 ` [PATCH v2 10/17] tools headers UAPI: Sync the unistd " Yanteng Si
2023-05-10 10:24 ` [PATCH v2 11/17] tools headers kvm: Sync uapi/{asm/linux} kvm.h headers " Yanteng Si
2023-05-10 10:24 ` [PATCH v2 12/17] tools arch x86: Sync the disabled-features " Yanteng Si
2023-05-10 10:24 ` [PATCH v2 13/17] tools arch x86: Sync the memcpy_64 " Yanteng Si
2023-05-10 15:48   ` Arnaldo Carvalho de Melo
2023-05-10 10:24 ` [PATCH v2 14/17] tools arch x86: Sync the cpufeatures " Yanteng Si
2023-05-10 10:24 ` [PATCH v2 15/17] tools arch x86: Sync the msr-index.h copy " Yanteng Si
2023-05-10 10:25 ` [PATCH v2 16/17] tools arch x86: Sync the prctl headers " Yanteng Si
2023-05-10 10:25 ` [PATCH v2 17/17] tools arch arm64: Sync the perf_regs " Yanteng Si
2023-05-10 15:26   ` Arnaldo Carvalho de Melo
2023-05-15  4:08     ` Leo Yan
2023-05-20  3:11       ` Leo Yan
2023-05-10 17:06 ` [PATCH v2 00/17] tools perf: fix build warnings Arnaldo Carvalho de Melo
2023-05-15 11:08   ` Yanteng Si

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).