Received: by 10.223.185.116 with SMTP id b49csp2004588wrg; Sat, 24 Feb 2018 08:46:26 -0800 (PST) X-Google-Smtp-Source: AH8x2260xe9fJc44O1dPtafzTaGDw74JBU0fIfa8red31RnLvQzLR0jZaEpoWwYEob2QEMjlYtxI X-Received: by 2002:a17:902:b413:: with SMTP id x19-v6mr5315960plr.420.1519490786186; Sat, 24 Feb 2018 08:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519490786; cv=none; d=google.com; s=arc-20160816; b=Xez4hEuKScFSBh5jMgL3r9e6mS/Ee1tT8AsTjOrUEA08utjie3Xe7VPyiRFVhFkaZa tHR02lMFEKIwqVkHraghsyVkSF6JvP9oPhMOb20Ic1O0Ffnihx9qBKkNhDPJRmAAQCA8 2+MqPPPGbveEKr/XpScN1NBo6BvIUVNOpD+aLg/Xa3x10LVEpWthRTE43nagRhrfYfVk eCIWas9z1CtvEL0/0wVLcW80WW8hmF+meJJmykmyGUVXwR2SeBsRPw5+zH69YZj7X7BI olG3Eo3K32TGSWmVmfMzXvxbYc/Y2bNJhViq92YmWhhfd0MWdBtFKKTZBenwTe27mioq gT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Y9kcI/JiGyYMXmz7HyjhbRxmmMu5yKIAEFanjJqezCk=; b=Gc8MsVkmsroIdq0JHyGSittxl5ZbKOvgEzl2vyvnikz4LiZLlxqC4ll/KCoMCD7gR9 Eqlp3EeCP0/SkNEEtFZ9FWIk4IRvvHlRk9by/eiJXIQIRubMgGUwks2oRg9+R6o1shro VX/WbvyowtlhNN+PnLCUBdYvt9RVPtvU29FHZsJnxuDYtPYHaG0JJutDvZtLZesdwS1Q oi/2MglNCNuh0X6gTMjs7MwtQDDhfTBdZo00dmqSRSzk+nn9re/+SusEPXlgPK7eyLfI +EYON/NKfhL7YOap2qQtkSlYCHmrTcz34S+WcfTDlwBjsTV6RA2UDDuRCBIn9MkwbHcS QbNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VgSKb9mz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20si3813409pfi.13.2018.02.24.08.46.12; Sat, 24 Feb 2018 08:46:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VgSKb9mz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbeBXQpd (ORCPT + 99 others); Sat, 24 Feb 2018 11:45:33 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:39542 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbeBXQpb (ORCPT ); Sat, 24 Feb 2018 11:45:31 -0500 Received: by mail-io0-f193.google.com with SMTP id b34so12973189ioj.6 for ; Sat, 24 Feb 2018 08:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Y9kcI/JiGyYMXmz7HyjhbRxmmMu5yKIAEFanjJqezCk=; b=VgSKb9mzvorVQY2Oq/Dw52ES4sZFPfPDcWpYzdOFKsPP23wZKUVILIYkPxjzwX8PC4 brsVSI/iCRsTNcz027i53QRVf1SCksHxnmuuY5Cl0zPr/YxkKWki/iakJHTUpGaYV8SX jG7XuxxlCbkAMue53iN9QLRgaUnTnuroWyVrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Y9kcI/JiGyYMXmz7HyjhbRxmmMu5yKIAEFanjJqezCk=; b=NfvxSpXrkpINFDRSD/dooCIWxWR70fj2/5vUlu5wrWj5YxLEpBdzpk+O1HR9a3JnK6 ve7s44VzRFnN31C4CwYZUoZ0LDPXBfuDmz2c8HPLtZI7X5174qAdAY2gUHrmboNou5H5 TxmYGlWSCRrifbOMri6fXlXUUG+gg2PlyZaHu/FPdvJy5OcqrC5jyFfHwfTi0BlMYZaW Oz0TF62MH4E5yj3qy9H5iNIdKLvp90lj6c5GEVG6R4k4nrNOpyMpKY2s6cZ2ne+XOsok NPoHjEaAIgafYvcvWetpI//O/TAcC0aZk3igmOHxUZWeihSSwt2kMb1ZdodbD567WzYA hqaA== X-Gm-Message-State: APf1xPCHYKZyukfzFJPwUgQxxhlVAuZnDjizfEexvuLAa/gMKFiGWTiW KBsGbbzlJypE4No6LvD3KFZkxWApG0Tc/+R6+sRKyg== X-Received: by 10.107.52.73 with SMTP id b70mr6258481ioa.60.1519490730676; Sat, 24 Feb 2018 08:45:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.138.209 with HTTP; Sat, 24 Feb 2018 08:45:30 -0800 (PST) In-Reply-To: <20180223200333.6410-9-Yazen.Ghannam@amd.com> References: <20180223200333.6410-1-Yazen.Ghannam@amd.com> <20180223200333.6410-9-Yazen.Ghannam@amd.com> From: Ard Biesheuvel Date: Sat, 24 Feb 2018 16:45:30 +0000 Message-ID: Subject: Re: [PATCH 8/8] efi: Decode IA32/X64 Context Info structure To: Yazen Ghannam Cc: linux-efi@vger.kernel.org, Linux Kernel Mailing List , Borislav Petkov , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23 February 2018 at 20:03, Yazen Ghannam wrote: > From: Yazen Ghannam > > Print the fields of the IA32/X64 Context Information structure. > > Print the "Register Array" as raw values. Some context types are defined > in the UEFI spec, so more detailed decoded may be added in the future. > > Based on UEFI 2.7 section N.2.4.2.2 IA32/X64 Processor Context > Information Structure. > > Cc: # 4.16.x > Signed-off-by: Yazen Ghannam > --- > drivers/firmware/efi/cper-x86.c | 55 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > > diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c > index 02b1b424f537..bb6cef0b5e53 100644 > --- a/drivers/firmware/efi/cper-x86.c > +++ b/drivers/firmware/efi/cper-x86.c > @@ -13,6 +13,7 @@ > #define VALID_LAPIC_ID BIT_ULL(0) > #define VALID_CPUID_INFO BIT_ULL(1) > #define VALID_PROC_ERR_INFO_NUM(bits) ((bits & GENMASK_ULL(7, 2)) >> 2) > +#define VALID_PROC_CNXT_INFO_NUM(bits) ((bits & GENMASK_ULL(13, 8)) >> 8) Parens Also, CNXT isn't really idiomatic when abbreviating 'context' (and you use CTX below as well) > > #define INFO_ERR_STRUCT_TYPE_CACHE \ > GUID_INIT(0xA55701F5, 0xE3EF, 0x43DE, 0xAC, 0x72, 0x24, 0x9B, \ > @@ -74,6 +75,9 @@ > #define CHECK_MS_RESTARTABLE_IP BIT_ULL(22) > #define CHECK_MS_OVERFLOW BIT_ULL(23) > > +#define CTX_TYPE_MSR 1 > +#define CTX_TYPE_MMREG 7 > + > enum err_types { > ERR_TYPE_CACHE = 0, > ERR_TYPE_TLB, > @@ -137,6 +141,17 @@ static const char * const ia_check_ms_error_type_strs[] = { > "Internal Unclassified", > }; > > +static const char * const ia_reg_ctx_strs[] = { > + "Unclassified Data", > + "MSR Registers (Machine Check and other MSRs)", > + "32-bit Mode Execution Context", > + "64-bit Mode Execution Context", > + "FXSAVE Context", > + "32-bit Mode Debug Registers (DR0-DR7)", > + "64-bit Mode Debug Registers (DR0-DR7)", > + "Memory Mapped Registers", > +}; > + > static inline void print_bool(char *str, const char *pfx, u64 check, u64 bit) > { > printk("%s%s: %s\n", pfx, str, (check & bit) ? "true" : "false"); > @@ -247,8 +262,10 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) > { > int i; > struct cper_ia_err_info *err_info; > + struct cper_ia_proc_ctx *ctx_info; > char newpfx[64], infopfx[64]; > enum err_types err_type; > + unsigned int max_ctx_type = ARRAY_SIZE(ia_reg_ctx_strs) - 1; > > printk("%sValidation Bits: 0x%016llx\n", pfx, proc->validation_bits); > > @@ -313,4 +330,42 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) > > err_info++; > } > + > + ctx_info = (struct cper_ia_proc_ctx *)err_info; > + for (i = 0; i < VALID_PROC_CNXT_INFO_NUM(proc->validation_bits); i++) { > + int size = sizeof(*ctx_info) + ctx_info->reg_arr_size; > + int groupsize = 4; > + > + printk("%sContext Information Structure %d:\n", pfx, i); > + > + if (ctx_info->reg_ctx_type > max_ctx_type) { > + printk("%sInvalid Register Context Type: %d (max: %d)\n", > + newpfx, ctx_info->reg_ctx_type, max_ctx_type); > + goto next_ctx; > + } > + > + printk("%sRegister Context Type: %s\n", newpfx, > + ia_reg_ctx_strs[ctx_info->reg_ctx_type]); > + > + printk("%sRegister Array Size: 0x%04x\n", newpfx, > + ctx_info->reg_arr_size); > + > + if (ctx_info->reg_ctx_type == CTX_TYPE_MSR) { > + groupsize = 8; /* MSRs are 8 bytes wide. */ > + printk("%sMSR Address: 0x%08x\n", newpfx, > + ctx_info->msr_addr); > + } > + > + if (ctx_info->reg_ctx_type == CTX_TYPE_MMREG) { > + printk("%sMM Register Address: 0x%016llx\n", newpfx, > + ctx_info->mm_reg_addr); > + } > + > + printk("%sRegister Array:\n", newpfx); > + print_hex_dump(newpfx, "", DUMP_PREFIX_OFFSET, 16, groupsize, > + (ctx_info + 1), ctx_info->reg_arr_size, 0); > + > +next_ctx: > + ctx_info = (struct cper_ia_proc_ctx *)((long)ctx_info + size); > + } > } > -- > 2.14.1 >