[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210507190140.18854-9-Yazen.Ghannam@amd.com>
Date: Fri, 7 May 2021 15:01:23 -0400
From: Yazen Ghannam <Yazen.Ghannam@....com>
To: linux-edac@...r.kernel.org
Cc: Yazen Ghannam <Yazen.Ghannam@....com>,
linux-kernel@...r.kernel.org, tony.luck@...el.com, x86@...nel.org,
Smita.KoralahalliChannabasappa@....com
Subject: [PATCH 08/25] x86/MCE/AMD: Define function to dehash address
From: Yazen Ghannam <yazen.ghannam@....com>
Move the dehashing code into a separate helper function. Define a
DF2-specific function for the current code. Specific helper functions
will be added for future DF versions.
Signed-off-by: Yazen Ghannam <yazen.ghannam@....com>
---
arch/x86/kernel/cpu/mce/amd.c | 41 ++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index d1a6405bb990..e341737e03d4 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -961,12 +961,34 @@ static int add_base_and_hole(struct addr_ctx *ctx)
return 0;
}
+static int dehash_addr_df2(struct addr_ctx *ctx)
+{
+ u8 hashed_bit = (ctx->ret_addr >> 12) ^
+ (ctx->ret_addr >> 18) ^
+ (ctx->ret_addr >> 21) ^
+ (ctx->ret_addr >> 30) ^
+ ctx->cs_id;
+
+ hashed_bit &= BIT(0);
+
+ if (hashed_bit != ((ctx->ret_addr >> ctx->intlv_addr_bit) & BIT(0)))
+ ctx->ret_addr ^= BIT(ctx->intlv_addr_bit);
+
+ return 0;
+}
+
+static int dehash_addr(struct addr_ctx *ctx)
+{
+ if (!ctx->hash_enabled)
+ return 0;
+
+ return dehash_addr_df2(ctx);
+}
+
int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
{
u64 dram_limit_addr;
- u8 hashed_bit;
-
struct addr_ctx ctx;
memset(&ctx, 0, sizeof(ctx));
@@ -996,19 +1018,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
if (add_base_and_hole(&ctx))
goto out_err;
- if (ctx.hash_enabled) {
- /* Save some parentheses and grab ls-bit at the end. */
- hashed_bit = (ctx.ret_addr >> 12) ^
- (ctx.ret_addr >> 18) ^
- (ctx.ret_addr >> 21) ^
- (ctx.ret_addr >> 30) ^
- ctx.cs_id;
-
- hashed_bit &= BIT(0);
-
- if (hashed_bit != ((ctx.ret_addr >> ctx.intlv_addr_bit) & BIT(0)))
- ctx.ret_addr ^= BIT(ctx.intlv_addr_bit);
- }
+ if (dehash_addr(&ctx))
+ goto out_err;
/* Is calculated system address is above DRAM limit address? */
if (ctx.ret_addr > dram_limit_addr)
--
2.25.1
Powered by blists - more mailing lists