[PATCH 20/25] x86/MCE/AMD: Define function to insert CS ID into address
From: Yazen Ghannam
Date: Fri May 07 2021 - 15:02:54 EST
From: Yazen Ghannam <yazen.ghannam@xxxxxxx>
Move the code that inserts the CS ID into the address into a separate
helper function. This will be expanded for future DF versions.
Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
arch/x86/kernel/cpu/mce/amd.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index ae49cef4792f..b017e4613d8f 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -937,10 +937,13 @@ static int calculate_cs_id(struct addr_ctx *ctx)
return 0;
}
-static int denormalize_addr(struct addr_ctx *ctx)
+static void insert_cs_id(struct addr_ctx *ctx)
{
- u8 num_intlv_bits;
+ ctx->ret_addr |= (ctx->cs_id << ctx->intlv_addr_bit);
+}
+static int denormalize_addr(struct addr_ctx *ctx)
+{
/* Return early if no interleaving. */
if (ctx->intlv_mode == NONE)
return 0;
@@ -957,20 +960,7 @@ static int denormalize_addr(struct addr_ctx *ctx)
if (calculate_cs_id(ctx))
return -EINVAL;
- if (num_intlv_bits > 0) {
- u64 temp_addr_i;
-
- /*
- * The pre-interleaved address consists of XXXXXXIIIYYYYY
- * where III is the ID for this CS, and XXXXXXYYYYY are the
- * address bits from the post-interleaved address.
- * "num_intlv_bits" has been calculated to tell us how many "I"
- * bits there are. "intlv_addr_bit" tells us how many "Y" bits
- * there are (where "I" starts).
- */
- temp_addr_i = (ctx->cs_id << ctx->intlv_addr_bit);
- ctx->ret_addr |= temp_addr_i;
- }
+ insert_cs_id(ctx);
return 0;
}
--
2.25.1