lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231219165737.GUZYHLgTRNlOohXFFj@fat_crate.local>
Date: Tue, 19 Dec 2023 17:57:37 +0100
From: Borislav Petkov <bp@...en8.de>
To: Yazen Ghannam <yazen.ghannam@....com>
Cc: linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org,
	avadhut.naik@....com, tony.luck@...el.com, john.allen@....com,
	william.roche@...cle.com, muralidhara.mk@....com
Subject: Re: [PATCH v4 1/3] RAS: Introduce AMD Address Translation Library

On Mon, Dec 18, 2023 at 01:04:04PM -0600, Yazen Ghannam wrote:
> +#define atl_debug(fmt, arg...) \
> +	pr_debug("socket_id=%u die_id=%u coh_st_inst_id=%u norm_addr=0x%016llx: " fmt,\
> +		 ctx->inputs.socket_id, ctx->inputs.die_id,\
> +		 ctx->inputs.coh_st_inst_id, ctx->inputs.norm_addr, ##arg)

Yeah, you need to pass in "ctx" as a macro argument - otherwise it is
kinda sneaky and non-obvious to reference a pointer which is hidden
inside the macro definition.

Diff ontop:

---

diff --git a/drivers/ras/amd/atl/core.c b/drivers/ras/amd/atl/core.c
index 013aaee4e99c..6dc4e06305f7 100644
--- a/drivers/ras/amd/atl/core.c
+++ b/drivers/ras/amd/atl/core.c
@@ -31,7 +31,7 @@ static int addr_over_limit(struct addr_ctx *ctx)
 
 	/* Is calculated system address above DRAM limit address? */
 	if (ctx->ret_addr > dram_limit_addr) {
-		atl_debug("Calculated address (0x%016llx) > DRAM limit (0x%016llx)",
+		atl_debug(ctx, "Calculated address (0x%016llx) > DRAM limit (0x%016llx)",
 			  ctx->ret_addr, dram_limit_addr);
 		return -EINVAL;
 	}
diff --git a/drivers/ras/amd/atl/denormalize.c b/drivers/ras/amd/atl/denormalize.c
index fb182dd7cca6..01f1d0fb6799 100644
--- a/drivers/ras/amd/atl/denormalize.c
+++ b/drivers/ras/amd/atl/denormalize.c
@@ -339,7 +339,8 @@ static u16 get_logical_coh_st_fabric_id(struct addr_ctx *ctx)
 	}
 
 	if (log_fabric_id == MAX_COH_ST_CHANNELS)
-		atl_debug("COH_ST remap entry not found for 0x%x", log_fabric_id);
+		atl_debug(ctx, "COH_ST remap entry not found for 0x%x",
+			  log_fabric_id);
 
 	/* Get the Node ID bits from the physical and apply to the logical. */
 	return (phys_fabric_id & df_cfg.node_id_mask) | log_fabric_id;
diff --git a/drivers/ras/amd/atl/internal.h b/drivers/ras/amd/atl/internal.h
index a1996811aa34..f17c5f5c9950 100644
--- a/drivers/ras/amd/atl/internal.h
+++ b/drivers/ras/amd/atl/internal.h
@@ -279,10 +279,10 @@ static inline u64 remove_bits(u8 low_bit, u8 high_bit, u64 data)
 	return temp1 | temp2;
 }
 
-#define atl_debug(fmt, arg...) \
+#define atl_debug(ctx, fmt, arg...) \
 	pr_debug("socket_id=%u die_id=%u coh_st_inst_id=%u norm_addr=0x%016llx: " fmt,\
-		 ctx->inputs.socket_id, ctx->inputs.die_id,\
-		 ctx->inputs.coh_st_inst_id, ctx->inputs.norm_addr, ##arg)
+		 (ctx)->inputs.socket_id, (ctx)->inputs.die_id,\
+		 (ctx)->inputs.coh_st_inst_id, (ctx)->inputs.norm_addr, ##arg)
 
 static inline void atl_debug_on_bad_df_rev(void)
 {
@@ -291,7 +291,7 @@ static inline void atl_debug_on_bad_df_rev(void)
 
 static inline void atl_debug_on_bad_intlv_mode(struct addr_ctx *ctx)
 {
-	atl_debug("Unrecognized interleave mode: %u", ctx->map.intlv_mode);
+	atl_debug(ctx, "Unrecognized interleave mode: %u", ctx->map.intlv_mode);
 }
 
 #endif /* __AMD_ATL_INTERNAL_H__ */
diff --git a/drivers/ras/amd/atl/map.c b/drivers/ras/amd/atl/map.c
index d160662f534f..2ed477d94b4f 100644
--- a/drivers/ras/amd/atl/map.c
+++ b/drivers/ras/amd/atl/map.c
@@ -140,7 +140,7 @@ static int get_dram_offset(struct addr_ctx *ctx, u64 *norm_offset)
 
 	/* Should not be called for map 0. */
 	if (!ctx->map.num) {
-		atl_debug("Trying to find DRAM offset for map 0");
+		atl_debug(ctx, "Trying to find DRAM offset for map 0");
 		return -EINVAL;
 	}
 
@@ -398,13 +398,13 @@ static int find_normalized_offset(struct addr_ctx *ctx, u64 *norm_offset)
 
 		/* Enabled offsets should never be 0. */
 		if (*norm_offset == 0) {
-			atl_debug("Enabled map %u offset is 0", ctx->map.num);
+			atl_debug(ctx, "Enabled map %u offset is 0", ctx->map.num);
 			return -EINVAL;
 		}
 
 		/* Offsets should always increase from one map to the next. */
 		if (*norm_offset <= last_offset) {
-			atl_debug("Map %u offset (0x%016llx) <= previous (0x%016llx)",
+			atl_debug(ctx, "Map %u offset (0x%016llx) <= previous (0x%016llx)",
 				  ctx->map.num, *norm_offset, last_offset);
 			return -EINVAL;
 		}
diff --git a/drivers/ras/amd/atl/system.c b/drivers/ras/amd/atl/system.c
index 3b6b5a5ddaab..af61f2f1d6de 100644
--- a/drivers/ras/amd/atl/system.c
+++ b/drivers/ras/amd/atl/system.c
@@ -17,7 +17,7 @@ int determine_node_id(struct addr_ctx *ctx, u8 socket_id, u8 die_id)
 	u16 socket_id_bits, die_id_bits;
 
 	if (socket_id > 0 && df_cfg.socket_id_mask == 0) {
-		atl_debug("Invalid socket inputs: socket_id=%u socket_id_mask=0x%x",
+		atl_debug(ctx, "Invalid socket inputs: socket_id=%u socket_id_mask=0x%x",
 			  socket_id, df_cfg.socket_id_mask);
 		return -EINVAL;
 	}
@@ -28,7 +28,7 @@ int determine_node_id(struct addr_ctx *ctx, u8 socket_id, u8 die_id)
 	socket_id_bits &=	df_cfg.socket_id_mask;
 
 	if (die_id > 0 && df_cfg.die_id_mask == 0) {
-		atl_debug("Invalid die inputs: die_id=%u die_id_mask=0x%x",
+		atl_debug(ctx, "Invalid die inputs: die_id=%u die_id_mask=0x%x",
 			  die_id, df_cfg.die_id_mask);
 		return -EINVAL;
 	}

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ