All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] powerpc/pseries: Macros and wrapper functions for H_HTM call
@ 2024-08-28  8:52 Madhavan Srinivasan
  2024-08-28  8:52 ` [PATCH v3 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs Madhavan Srinivasan
  2024-08-28  8:52 ` [PATCH v3 3/3] powerpc: Document details on H_HTM hcall Madhavan Srinivasan
  0 siblings, 2 replies; 4+ messages in thread
From: Madhavan Srinivasan @ 2024-08-28  8:52 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, naveen.n.rao, linuxppc-dev,
	Madhavan Srinivasan

Define macros and wrapper functions to handle
H_HTM (Hardware Trace Macro) hypervisor call.
H_HTM is new HCALL added to export data from
Hardware Trace Macro (HTM) function.

Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
---
Changelog v2:
- No changes
Changelog v1:
- No changes

 arch/powerpc/include/asm/hvcall.h         | 34 +++++++++++++++++++++++
 arch/powerpc/include/asm/plpar_wrappers.h | 21 ++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h
index 7a8495660c2f..7ad13685c127 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -348,6 +348,7 @@
 #define H_SCM_FLUSH		0x44C
 #define H_GET_ENERGY_SCALE_INFO	0x450
 #define H_PKS_SIGNED_UPDATE	0x454
+#define H_HTM			0x458
 #define H_WATCHDOG		0x45C
 #define H_GUEST_GET_CAPABILITIES 0x460
 #define H_GUEST_SET_CAPABILITIES 0x464
@@ -497,6 +498,39 @@
 #define H_GUEST_CAP_POWER10	(1UL<<(63-2))
 #define H_GUEST_CAP_BITMAP2	(1UL<<(63-63))
 
+/*
+ * Defines for H_HTM - Macros for hardware trace macro (HTM) function.
+ */
+#define H_HTM_FLAGS_HARDWARE_TARGET	(1ul << 63)
+#define H_HTM_FLAGS_LOGICAL_TARGET	(1ul << 62)
+#define H_HTM_FLAGS_PROCID_TARGET	(1ul << 61)
+#define H_HTM_FLAGS_NOWRAP		(1ul << 60)
+
+#define H_HTM_OP_SHIFT			(63-15)
+#define H_HTM_OP(x)			((unsigned long)(x)<<H_HTM_OP_SHIFT)
+#define H_HTM_OP_CAPABILITIES		0x01
+#define H_HTM_OP_STATUS			0x02
+#define H_HTM_OP_SETUP			0x03
+#define H_HTM_OP_CONFIGURE		0x04
+#define H_HTM_OP_START			0x05
+#define H_HTM_OP_STOP			0x06
+#define H_HTM_OP_DECONFIGURE		0x07
+#define H_HTM_OP_DUMP_DETAILS		0x08
+#define H_HTM_OP_DUMP_DATA		0x09
+#define H_HTM_OP_DUMP_SYSMEM_CONF	0x0a
+#define H_HTM_OP_DUMP_SYSPROC_CONF	0x0b
+
+#define H_HTM_TYPE_SHIFT		(63-31)
+#define H_HTM_TYPE(x)			((unsigned long)(x)<<H_HTM_TYPE_SHIFT)
+#define H_HTM_TYPE_NEST			0x01
+#define H_HTM_TYPE_CORE			0x02
+#define H_HTM_TYPE_LLAT			0x03
+#define H_HTM_TYPE_GLOBAL		0xff
+
+#define H_HTM_TARGET_NODE_INDEX(x)		((unsigned long)(x)<<(63-15))
+#define H_HTM_TARGET_NODAL_CHIP_INDEX(x)	((unsigned long)(x)<<(63-31))
+#define H_HTM_TARGET_CORE_INDEX_ON_CHIP(x)	((unsigned long)(x)<<(63-47))
+
 #ifndef __ASSEMBLY__
 #include <linux/types.h>
 
diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index 71648c126970..a63a4d29cfdf 100644
--- a/arch/powerpc/include/asm/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -65,6 +65,27 @@ static inline long register_dtl(unsigned long cpu, unsigned long vpa)
 	return vpa_call(H_VPA_REG_DTL, cpu, vpa);
 }
 
+static inline long htm_call(unsigned long flags, unsigned long target,
+		unsigned long operation, unsigned long param1,
+		unsigned long param2, unsigned long param3)
+{
+	return plpar_hcall_norets(H_HTM, flags, target, operation,
+				  param1, param2, param3);
+}
+
+static inline long htm_get_dump_hardware(unsigned long nodeindex,
+		unsigned long nodalchipindex, unsigned long coreindexonchip,
+		unsigned long type, unsigned long addr, unsigned long size,
+		unsigned long offset)
+{
+	return htm_call(H_HTM_FLAGS_HARDWARE_TARGET,
+			H_HTM_TARGET_NODE_INDEX(nodeindex) |
+			H_HTM_TARGET_NODAL_CHIP_INDEX(nodalchipindex) |
+			H_HTM_TARGET_CORE_INDEX_ON_CHIP(coreindexonchip),
+			H_HTM_OP(H_HTM_OP_DUMP_DATA) | H_HTM_TYPE(type),
+			addr, size, offset);
+}
+
 extern void vpa_init(int cpu);
 
 static inline long plpar_pte_enter(unsigned long flags,
-- 
2.45.2



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

* [PATCH v3 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs
  2024-08-28  8:52 [PATCH v3 1/3] powerpc/pseries: Macros and wrapper functions for H_HTM call Madhavan Srinivasan
@ 2024-08-28  8:52 ` Madhavan Srinivasan
  2024-09-20 16:15   ` Ritesh Harjani
  2024-08-28  8:52 ` [PATCH v3 3/3] powerpc: Document details on H_HTM hcall Madhavan Srinivasan
  1 sibling, 1 reply; 4+ messages in thread
From: Madhavan Srinivasan @ 2024-08-28  8:52 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, naveen.n.rao, linuxppc-dev,
	Madhavan Srinivasan

This patch adds debugfs interface to export Hardware Trace Macro (HTM)
function data in a LPAR. New hypervisor call "H_HTM" has been
defined to setup, configure, control and dump the HTM data.
This patch supports only dumping of HTM data in a LPAR.
New debugfs folder called "htmdump" has been added under
/sys/kernel/debug/arch path which contains files need to
pass required parameters for the H_HTM dump function. New Kconfig
option called "CONFIG_HTMDUMP" has been in platform/pseries for the same.

With this module loaded, list of files in debugfs path

/sys/kernel/debug/powerpc/htmdump
coreindexonchip  htmtype  nodalchipindex  nodeindex  trace

Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
---
Changelog v2:
- Made driver as modules based on review comments
Changelog v1:
- Changed from tristate to bool with dependency flags
- Trimmed the include headers

 arch/powerpc/platforms/pseries/Kconfig   |   9 ++
 arch/powerpc/platforms/pseries/Makefile  |   1 +
 arch/powerpc/platforms/pseries/htmdump.c | 130 +++++++++++++++++++++++
 3 files changed, 140 insertions(+)
 create mode 100644 arch/powerpc/platforms/pseries/htmdump.c

diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index afc0f6a61337..a66be66d690e 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -128,6 +128,15 @@ config CMM
 	  will be reused for other LPARs. The interface allows firmware to
 	  balance memory across many LPARs.
 
+config HTMDUMP
+	tristate "PHYP HTM data dumper"
+	depends on PPC_PSERIES && DEBUG_FS
+	default m
+	help
+	  Select this option, if you want to enable the kernel debugfs
+	  interface to dump the Hardware Trace Macro (HTM) function data
+	  in the LPAR.
+
 config HV_PERF_CTRS
 	bool "Hypervisor supplied PMU events (24x7 & GPCI)"
 	default y
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 7bf506f6b8c8..3f3e3492e436 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_HVC_CONSOLE)	+= hvconsole.o
 obj-$(CONFIG_HVCS)		+= hvcserver.o
 obj-$(CONFIG_HCALL_STATS)	+= hvCall_inst.o
 obj-$(CONFIG_CMM)		+= cmm.o
+obj-$(CONFIG_HTMDUMP)		+= htmdump.o
 obj-$(CONFIG_IO_EVENT_IRQ)	+= io_event_irq.o
 obj-$(CONFIG_LPARCFG)		+= lparcfg.o
 obj-$(CONFIG_IBMVIO)		+= vio.o
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
new file mode 100644
index 000000000000..54c28525c4a7
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) IBM Corporation, 2024
+ */
+
+#define pr_fmt(fmt) "htmdump: " fmt
+
+#include <linux/debugfs.h>
+
+#include <asm/machdep.h>
+#include <asm/plpar_wrappers.h>
+
+/* This enables us to keep track of the memory removed from each node. */
+struct htmdump_entry {
+	void *buf;
+	struct dentry *dir;
+	char name[16];
+};
+
+static u32 nodeindex;
+static u32 nodalchipindex;
+static u32 coreindexonchip;
+static u32 htmtype;
+static struct dentry *htmdump_debugfs_dir;
+static struct htmdump_entry *ent;
+
+#define BUFFER_SIZE PAGE_SIZE
+
+static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
+			     size_t count, loff_t *ppos)
+{
+	struct htmdump_entry *ent = filp->private_data;
+	unsigned long page, read_size, available;
+	loff_t offset;
+	long rc;
+
+	page = ALIGN_DOWN(*ppos, BUFFER_SIZE);
+	offset = (*ppos) % BUFFER_SIZE;
+
+	rc = htm_get_dump_hardware(nodeindex, nodalchipindex, coreindexonchip,
+				   htmtype, virt_to_phys(ent->buf), BUFFER_SIZE, page);
+
+	switch (rc) {
+	case H_SUCCESS:
+	case H_PARTIAL:
+		break;
+	case H_NOT_AVAILABLE:
+		return 0;
+	case H_BUSY:
+	case H_LONG_BUSY_ORDER_1_MSEC:
+	case H_LONG_BUSY_ORDER_10_MSEC:
+	case H_LONG_BUSY_ORDER_100_MSEC:
+	case H_LONG_BUSY_ORDER_1_SEC:
+	case H_LONG_BUSY_ORDER_10_SEC:
+	case H_LONG_BUSY_ORDER_100_SEC:
+	case H_PARAMETER:
+	case H_P2:
+	case H_P3:
+	case H_P4:
+	case H_P5:
+	case H_P6:
+	case H_STATE:
+	case H_AUTHORITY:
+		return -EINVAL;
+	}
+
+	available = BUFFER_SIZE - offset;
+	read_size = min(count, available);
+	*ppos += read_size;
+	return simple_read_from_buffer(ubuf, count, &offset, ent->buf, available);
+}
+
+static const struct file_operations htmdump_fops = {
+	.llseek = default_llseek,
+	.read	= htmdump_read,
+	.open	= simple_open,
+};
+
+static int htmdump_init_debugfs(void)
+{
+	ent = kcalloc(1, sizeof(struct htmdump_entry), GFP_KERNEL);
+	if (!ent) {
+		pr_err("Failed to allocate ent\n");
+		return -EINVAL;
+	}
+
+	ent->buf = kmalloc(BUFFER_SIZE, GFP_KERNEL);
+	if (!ent->buf) {
+		pr_err("Failed to allocate htmdump buf\n");
+		return -ENOMEM;
+	}
+
+	pr_debug("%s: ent:%lx buf:%lx\n",
+			__func__, (long unsigned int)ent, (long unsigned int)ent->buf);
+
+	htmdump_debugfs_dir = debugfs_create_dir("htmdump",
+						  arch_debugfs_dir);
+
+	debugfs_create_u32("nodeindex", 0600,
+			htmdump_debugfs_dir, &nodeindex);
+	debugfs_create_u32("nodalchipindex", 0600,
+			htmdump_debugfs_dir, &nodalchipindex);
+	debugfs_create_u32("coreindexonchip", 0600,
+			htmdump_debugfs_dir, &coreindexonchip);
+	debugfs_create_u32("htmtype", 0600,
+			htmdump_debugfs_dir, &htmtype);
+	debugfs_create_file("trace", 0400, htmdump_debugfs_dir, ent, &htmdump_fops);
+
+	return 0;
+}
+
+static int __init htmdump_init(void)
+{
+	if (htmdump_init_debugfs())
+		return -EINVAL;
+
+	return 0;
+}
+
+static void __exit htmdump_exit(void)
+{
+	debugfs_remove_recursive(htmdump_debugfs_dir);
+	kfree(ent->buf);
+	kfree(ent);
+}
+
+module_init(htmdump_init);
+module_exit(htmdump_exit);
+MODULE_DESCRIPTION("PHYP Hardware Trace Macro (HTM) data dumper");
+MODULE_LICENSE("GPL");
-- 
2.45.2



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

* [PATCH v3 3/3] powerpc: Document details on H_HTM hcall
  2024-08-28  8:52 [PATCH v3 1/3] powerpc/pseries: Macros and wrapper functions for H_HTM call Madhavan Srinivasan
  2024-08-28  8:52 ` [PATCH v3 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs Madhavan Srinivasan
@ 2024-08-28  8:52 ` Madhavan Srinivasan
  1 sibling, 0 replies; 4+ messages in thread
From: Madhavan Srinivasan @ 2024-08-28  8:52 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, naveen.n.rao, linuxppc-dev,
	Madhavan Srinivasan

Add documentation to 'papr_hcalls.rst' describing the
input, output and return values of the H_HTM hcall as
per the internal specification.

Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
---
Changelog v2:
- No changes
Changelog v1:
- Updated commit message to include htmdump folder files 

 Documentation/arch/powerpc/papr_hcalls.rst | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/arch/powerpc/papr_hcalls.rst b/Documentation/arch/powerpc/papr_hcalls.rst
index 80d2c0aadab5..805e1cb9bab9 100644
--- a/Documentation/arch/powerpc/papr_hcalls.rst
+++ b/Documentation/arch/powerpc/papr_hcalls.rst
@@ -289,6 +289,17 @@ to be issued multiple times in order to be completely serviced. The
 subsequent hcalls to the hypervisor until the hcall is completely serviced
 at which point H_SUCCESS or other error is returned by the hypervisor.
 
+**H_HTM**
+
+| Input: flags, target, operation (op), op-param1, op-param2, op-param3
+| Out: *dumphtmbufferdata*
+| Return Value: *H_Success,H_Busy,H_LongBusyOrder,H_Partial,H_Parameter,
+		 H_P2,H_P3,H_P4,H_P5,H_P6,H_State,H_Not_Available,H_Authority*
+
+H_HTM supports setup, configuration, control and dumping of Hardware Trace
+Macro (HTM) function and its data. HTM buffer stores tracing data for functions
+like core instruction, core LLAT and nest.
+
 References
 ==========
 .. [1] "Power Architecture Platform Reference"
-- 
2.45.2



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

* Re: [PATCH v3 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs
  2024-08-28  8:52 ` [PATCH v3 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs Madhavan Srinivasan
@ 2024-09-20 16:15   ` Ritesh Harjani
  0 siblings, 0 replies; 4+ messages in thread
From: Ritesh Harjani @ 2024-09-20 16:15 UTC (permalink / raw)
  To: Madhavan Srinivasan, mpe
  Cc: npiggin, christophe.leroy, naveen.n.rao, linuxppc-dev,
	Madhavan Srinivasan

Madhavan Srinivasan <maddy@linux.ibm.com> writes:

> This patch adds debugfs interface to export Hardware Trace Macro (HTM)
> function data in a LPAR. New hypervisor call "H_HTM" has been
> defined to setup, configure, control and dump the HTM data.
> This patch supports only dumping of HTM data in a LPAR.
> New debugfs folder called "htmdump" has been added under
> /sys/kernel/debug/arch path which contains files need to
> pass required parameters for the H_HTM dump function. New Kconfig
> option called "CONFIG_HTMDUMP" has been in platform/pseries for the same.
>
> With this module loaded, list of files in debugfs path
>
> /sys/kernel/debug/powerpc/htmdump
> coreindexonchip  htmtype  nodalchipindex  nodeindex  trace
>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> ---
> Changelog v2:
> - Made driver as modules based on review comments
> Changelog v1:
> - Changed from tristate to bool with dependency flags
> - Trimmed the include headers
>
>  arch/powerpc/platforms/pseries/Kconfig   |   9 ++
>  arch/powerpc/platforms/pseries/Makefile  |   1 +
>  arch/powerpc/platforms/pseries/htmdump.c | 130 +++++++++++++++++++++++
>  3 files changed, 140 insertions(+)
>  create mode 100644 arch/powerpc/platforms/pseries/htmdump.c
>
> diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
> index afc0f6a61337..a66be66d690e 100644
> --- a/arch/powerpc/platforms/pseries/Kconfig
> +++ b/arch/powerpc/platforms/pseries/Kconfig
> @@ -128,6 +128,15 @@ config CMM
>  	  will be reused for other LPARs. The interface allows firmware to
>  	  balance memory across many LPARs.
>  
> +config HTMDUMP
> +	tristate "PHYP HTM data dumper"
> +	depends on PPC_PSERIES && DEBUG_FS
> +	default m
> +	help
> +	  Select this option, if you want to enable the kernel debugfs
> +	  interface to dump the Hardware Trace Macro (HTM) function data
> +	  in the LPAR.
> +
>  config HV_PERF_CTRS
>  	bool "Hypervisor supplied PMU events (24x7 & GPCI)"
>  	default y
> diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
> index 7bf506f6b8c8..3f3e3492e436 100644
> --- a/arch/powerpc/platforms/pseries/Makefile
> +++ b/arch/powerpc/platforms/pseries/Makefile
> @@ -19,6 +19,7 @@ obj-$(CONFIG_HVC_CONSOLE)	+= hvconsole.o
>  obj-$(CONFIG_HVCS)		+= hvcserver.o
>  obj-$(CONFIG_HCALL_STATS)	+= hvCall_inst.o
>  obj-$(CONFIG_CMM)		+= cmm.o
> +obj-$(CONFIG_HTMDUMP)		+= htmdump.o
>  obj-$(CONFIG_IO_EVENT_IRQ)	+= io_event_irq.o
>  obj-$(CONFIG_LPARCFG)		+= lparcfg.o
>  obj-$(CONFIG_IBMVIO)		+= vio.o
> diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
> new file mode 100644
> index 000000000000..54c28525c4a7
> --- /dev/null
> +++ b/arch/powerpc/platforms/pseries/htmdump.c
> @@ -0,0 +1,130 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) IBM Corporation, 2024
> + */
> +
> +#define pr_fmt(fmt) "htmdump: " fmt
> +
> +#include <linux/debugfs.h>
> +
> +#include <asm/machdep.h>
> +#include <asm/plpar_wrappers.h>
> +
> +/* This enables us to keep track of the memory removed from each node. */
> +struct htmdump_entry {
> +	void *buf;
> +	struct dentry *dir;
> +	char name[16];
> +};
>

How does dir and name gets used?
It isn't that obvious, so maybe a comment will be gr8.

> +static u32 nodeindex;
> +static u32 nodalchipindex;
> +static u32 coreindexonchip;
> +static u32 htmtype;
> +static struct dentry *htmdump_debugfs_dir;
> +static struct htmdump_entry *ent;
> +
> +#define BUFFER_SIZE PAGE_SIZE
> +
> +static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
> +			     size_t count, loff_t *ppos)
> +{
> +	struct htmdump_entry *ent = filp->private_data;
> +	unsigned long page, read_size, available;
> +	loff_t offset;
> +	long rc;
> +
> +	page = ALIGN_DOWN(*ppos, BUFFER_SIZE);
> +	offset = (*ppos) % BUFFER_SIZE;
> +
> +	rc = htm_get_dump_hardware(nodeindex, nodalchipindex, coreindexonchip,
> +				   htmtype, virt_to_phys(ent->buf), BUFFER_SIZE, page);
> +
> +	switch (rc) {
> +	case H_SUCCESS:
> +	case H_PARTIAL:
> +		break;
> +	case H_NOT_AVAILABLE:
> +		return 0;

Minor nits for error returns here...

Is returning 0 correct here? Maybe it is (since 0 means no data read),
but wanted to confirm if we should return -ENODATA, or -ENODEV 
(not sure what does H_NOT_AVAILABLE here means)

#define	ENODATA		61	/* No data available */

> +	case H_BUSY:
> +	case H_LONG_BUSY_ORDER_1_MSEC:
> +	case H_LONG_BUSY_ORDER_10_MSEC:
> +	case H_LONG_BUSY_ORDER_100_MSEC:
> +	case H_LONG_BUSY_ORDER_1_SEC:
> +	case H_LONG_BUSY_ORDER_10_SEC:
> +	case H_LONG_BUSY_ORDER_100_SEC:

Similarly for above maybe -EBUSY perhaps, instead of -EINVAL

#define	EBUSY		16	/* Device or resource busy */

> +	case H_PARAMETER:
> +	case H_P2:
> +	case H_P3:
> +	case H_P4:
> +	case H_P5:
> +	case H_P6:
> +	case H_STATE:
> +	case H_AUTHORITY:
> +		return -EINVAL;
> +	}
> +
> +	available = BUFFER_SIZE - offset;
> +	read_size = min(count, available);
> +	*ppos += read_size;
> +	return simple_read_from_buffer(ubuf, count, &offset, ent->buf, available);
> +}
> +
> +static const struct file_operations htmdump_fops = {
> +	.llseek = default_llseek,
> +	.read	= htmdump_read,
> +	.open	= simple_open,
> +};
> +
> +static int htmdump_init_debugfs(void)
> +{
> +	ent = kcalloc(1, sizeof(struct htmdump_entry), GFP_KERNEL);
> +	if (!ent) {
> +		pr_err("Failed to allocate ent\n");
> +		return -EINVAL;

return value can be -ENOMEM;

> +	}
> +
> +	ent->buf = kmalloc(BUFFER_SIZE, GFP_KERNEL);
> +	if (!ent->buf) {
> +		pr_err("Failed to allocate htmdump buf\n");
> +		return -ENOMEM;

kfree(ent)?


> +	}
> +
> +	pr_debug("%s: ent:%lx buf:%lx\n",
> +			__func__, (long unsigned int)ent, (long unsigned int)ent->buf);
> +

maybe %p perhaps? 


<Documentation/core-api/printk-formats.rst>
Plain Pointers
--------------

::

	%p	abcdef12 or 00000000abcdef12

Pointers printed without a specifier extension (i.e unadorned %p) are
hashed to prevent leaking information about the kernel memory layout. This
has the added benefit of providing a unique identifier.
<...>
...the aim of printing the address is to provide
more information for debugging, use %p and boot the kernel with the
``no_hash_pointers`` parameter during debugging, which will print all %p
addresses unmodified. If you *really* always want the unmodified address, see
%px below.


> +	htmdump_debugfs_dir = debugfs_create_dir("htmdump",
> +						  arch_debugfs_dir);
> +
> +	debugfs_create_u32("nodeindex", 0600,
> +			htmdump_debugfs_dir, &nodeindex);
> +	debugfs_create_u32("nodalchipindex", 0600,
> +			htmdump_debugfs_dir, &nodalchipindex);
> +	debugfs_create_u32("coreindexonchip", 0600,
> +			htmdump_debugfs_dir, &coreindexonchip);
> +	debugfs_create_u32("htmtype", 0600,
> +			htmdump_debugfs_dir, &htmtype);
> +	debugfs_create_file("trace", 0400, htmdump_debugfs_dir, ent, &htmdump_fops);
> +
> +	return 0;
> +}
> +
> +static int __init htmdump_init(void)
> +{
> +	if (htmdump_init_debugfs())
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static void __exit htmdump_exit(void)
> +{
> +	debugfs_remove_recursive(htmdump_debugfs_dir);
> +	kfree(ent->buf);
> +	kfree(ent);
> +}
> +
> +module_init(htmdump_init);
> +module_exit(htmdump_exit);
> +MODULE_DESCRIPTION("PHYP Hardware Trace Macro (HTM) data dumper");
> +MODULE_LICENSE("GPL");
> -- 
> 2.45.2


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

end of thread, other threads:[~2024-09-20 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28  8:52 [PATCH v3 1/3] powerpc/pseries: Macros and wrapper functions for H_HTM call Madhavan Srinivasan
2024-08-28  8:52 ` [PATCH v3 2/3] powerpc/pseries: Export hardware trace macro dump via debugfs Madhavan Srinivasan
2024-09-20 16:15   ` Ritesh Harjani
2024-08-28  8:52 ` [PATCH v3 3/3] powerpc: Document details on H_HTM hcall Madhavan Srinivasan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.