From patchwork Fri May 4 05:59:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134942 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp436845lji; Thu, 3 May 2018 23:01:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpgSG4Z59bJzObzrJY7qe8qLyzEKrXu489y1uQfqQKWQQeHc7/egQeKYxH7xDVufKRkSEYd X-Received: by 2002:a17:902:6b4c:: with SMTP id g12-v6mr26559886plt.148.1525413677002; Thu, 03 May 2018 23:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413676; cv=none; d=google.com; s=arc-20160816; b=iOk0T6OUN0kaJh+pvs5eZdRNeZPT3DVuWV5PNfLgqvzsdOansrQbL+K8shEJYvZSos EfLTb0ut4GQgqPr+dZ/3Gwqy+pktW5zEUI5azPjdkEGlJCI43D4xQRzq6V40NgAwWM67 1HSApRRmE2AGAa/PNYgT/eNYURjyIV9/iWB6ufTdPS7j52Ap/p/tGATN0kjhdZQuVJIc T+krruUYWLPkH60oWjN16gQ8hMyRTme5psEJhuuacD1kZgNJGZSYMMkt2RvRNIFZZq1j I8pWsttpwoHZpdzQMeI8IFH+4O6OQudGKXyYYzGaSOMabmLFY9wOrAl5lWE8XhWP1ufL 9Tcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=G4kxhD66Wvn9rFQJ4dGKYc6Iu1Lcl5TyW8V/Uf+YAIU=; b=Kgi468wnBPpghA90HU1+8LWSYN4zyp9mHeo+sogWNc9pTSPo9oduma3ksgoa74JWuC 8y308y5VMkAc7GMLgjyz3LXiU6IMqQNZzghRXUHPoAvJ2Y+gbYH30ZWAmnE1S9NFaJg5 9oJJgWQ0FF/UrLcu5EcTQupOxIoU/MpKrkmPpES+41rjNgD65NFG2WB24/PNt9jnearQ tsG5hMV2J6EeH2pyvPX22AqfLJbAFRxNCDnxcyE1r4nxSASrf/nHhcVJfXgYueqxdxdV BtG2wozUbasFj2UFfaByjF1Uu3LkydgiLUzFEC6Ji38IYYkTHXh22ZptXsl189efk78n wgsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EEpTXUoS; 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 y25si6655787pfn.248.2018.05.03.23.01.16; Thu, 03 May 2018 23:01:16 -0700 (PDT) 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=EEpTXUoS; 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 S1751512AbeEDGBM (ORCPT + 29 others); Fri, 4 May 2018 02:01:12 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37439 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbeEDGBG (ORCPT ); Fri, 4 May 2018 02:01:06 -0400 Received: by mail-wr0-f196.google.com with SMTP id c14-v6so19763221wrd.4 for ; Thu, 03 May 2018 23:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G4kxhD66Wvn9rFQJ4dGKYc6Iu1Lcl5TyW8V/Uf+YAIU=; b=EEpTXUoSQPyMXDIrwJrPcSqdcoEB1Q4G6DyMY+YGLw/R1y7AL0rqsKOJIo7+jlVEZt tHj96buQSLuO+DAoh3zpQ9gfOugog0K39Kcju/8OvaA+9r2K6rOiCrMxiyy43lAOALIE AoszcAucLOPXevQB08Y8XIaqdN1MezpvtMFXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G4kxhD66Wvn9rFQJ4dGKYc6Iu1Lcl5TyW8V/Uf+YAIU=; b=suML2Yr0lh5ViqDkoXkwSfsy4GiWns4xNsMzs6SGmCGd4gh0oUCVygaz0mBYPWpA/d qkpu78UP/Wr6Hti68dZZojRtGP38DGZeF/2wMBcwTwxPAJPF+EV22ecxcqtsKLkJCSeY H5OcisM73ymAo2Dy0RkilNy7oRtyqEIg2tjLgYM4bB563zmAdBsocBUqqFND7YAKFnyS IclB1LAbv20P7ps4CRRFE4sa2KQT2wB5zLar+fBB7xb4FZDByf4v3KE0m5jnDqXBP0tK bWBHUJlQKKz98tH+6h8rG7mLtB4rfbQX69iAqxXH2EbEsPT430Ia/aaCCZK89wRQGdks +kFw== X-Gm-Message-State: ALQs6tAPBPbCzTozpzxhHNc+9BjzpowCh3oPsJWWUFUfYM1nMEbygafG U/EXZs+zjmibOnug2zAS5/Fq2w== X-Received: by 2002:adf:c613:: with SMTP id n19-v6mr16498066wrg.177.1525413664974; Thu, 03 May 2018 23:01:04 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:04 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Borislav Petkov , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 02/17] efi/cper: Remove the INDENT_SP silliness Date: Fri, 4 May 2018 07:59:48 +0200 Message-Id: <20180504060003.19618-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov A separate define just to print a space character is silly and completely unneeded. Remove it. Signed-off-by: Borislav Petkov Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-arm.c | 6 ++---- drivers/firmware/efi/cper.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) -- 2.17.0 diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-arm.c index 698e5c8e0c8d..502811344e81 100644 --- a/drivers/firmware/efi/cper-arm.c +++ b/drivers/firmware/efi/cper-arm.c @@ -30,8 +30,6 @@ #include #include -#define INDENT_SP " " - static const char * const arm_reg_ctx_strs[] = { "AArch32 general purpose registers", "AArch32 EL1 context registers", @@ -283,7 +281,7 @@ void cper_print_proc_arm(const char *pfx, pfx, proc->psci_state); } - snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); + snprintf(newpfx, sizeof(newpfx), "%s ", pfx); err_info = (struct cper_arm_err_info *)(proc + 1); for (i = 0; i < proc->err_info_num; i++) { @@ -310,7 +308,7 @@ void cper_print_proc_arm(const char *pfx, if (err_info->validation_bits & CPER_ARM_INFO_VALID_ERR_INFO) { printk("%serror_info: 0x%016llx\n", newpfx, err_info->error_info); - snprintf(infopfx, sizeof(infopfx), "%s%s", newpfx, INDENT_SP); + snprintf(infopfx, sizeof(infopfx), "%s ", newpfx); cper_print_arm_err_info(infopfx, err_info->type, err_info->error_info); } diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index c165933ebf38..ab21f1614007 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -37,8 +37,6 @@ #include #include -#define INDENT_SP " " - static char rcd_decode_str[CPER_REC_LEN]; /* @@ -433,7 +431,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT) printk("%s""fru_text: %.20s\n", pfx, gdata->fru_text); - snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); + snprintf(newpfx, sizeof(newpfx), "%s ", pfx); if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) { struct cper_sec_proc_generic *proc_err = acpi_hest_get_payload(gdata); @@ -500,7 +498,7 @@ void cper_estatus_print(const char *pfx, "It has been corrected by h/w " "and requires no further action"); printk("%s""event severity: %s\n", pfx, cper_severity_str(severity)); - snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); + snprintf(newpfx, sizeof(newpfx), "%s ", pfx); apei_estatus_for_each_section(estatus, gdata) { cper_estatus_print_section(newpfx, gdata, sec_no); From patchwork Fri May 4 05:59:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134940 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp436774lji; Thu, 3 May 2018 23:01:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqDDOpeHtib6g+hhJzzkkBJTaIbnI5VlbhjbIldJEL4PFLyfopuN1LcUddGI0qwdScuZbNr X-Received: by 2002:a17:902:7082:: with SMTP id z2-v6mr14687938plk.373.1525413673616; Thu, 03 May 2018 23:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413673; cv=none; d=google.com; s=arc-20160816; b=kcYUGj5of3Xz0LWw65u548X26V6KpVrfodoPizzF4zLI+0bkyr5yVvUSs9yUyyCxGr unabWUQSq1vfdiE/weGrLb5Q5uFzDM8ZBbAYOXcOZATnsnlU+swh2pe5tBO8zUTViweq z8DibQHzUB9n4Xqwc6Ta6J+bKDJx4GmH9ZBMmyLDpuHCp5i47hyzXQv0eGwjVhXPimOx 0ECVB+9VqpI5dmRIyCIvjOQVP+B49miq6SCorCixBLL//UAhsXTjJlNEzgKSMJYz/4Mt PoEGI34bvg5AWDR8oAt1TlIyovVRolhVkST+1HWKxs6KDohHXaz4kat1x11rEt8eLTuV lFrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=94ziauSZ5Wo2Z4hgpQ84fCORn1eX0WWpUq9EAHa5SiM=; b=VWR8r8q+Kmh0VT7/COJG96s99RtD7Za++1uVFTQR9Xsc5vUXq5WBqkjk7iYr37hx9c lKs7ZgT3NF3a1scjq4YvXxZB7dVI+Yb5VYTWDtY6uzGLeRkX0ns/fiOwENdLxf9q1oBe 3+mYSMtMjKCLT913FjPw+Go+KyNV2y3sqjd3nrEYP9XYP0RcG0MyUE+DLO8HaeV08BuU 3Gk1SZSHDknvmKWYb/slUlT7zzruL1nNIaRFBGjY972ia7XIG1jTO5WckSWu1ucfj0vv GVE4JgI7Fck4C2TorNoc7N9ihSTvjj6VqLPdHgiVm1h0SEWyQTZx35WBBMt5RnYNC41M VLRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KSeFv8RT; 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 h64-v6si12817679pge.206.2018.05.03.23.01.13; Thu, 03 May 2018 23:01:13 -0700 (PDT) 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=KSeFv8RT; 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 S1751411AbeEDGBK (ORCPT + 29 others); Fri, 4 May 2018 02:01:10 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45885 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751354AbeEDGBI (ORCPT ); Fri, 4 May 2018 02:01:08 -0400 Received: by mail-wr0-f196.google.com with SMTP id p5-v6so19744600wre.12 for ; Thu, 03 May 2018 23:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=94ziauSZ5Wo2Z4hgpQ84fCORn1eX0WWpUq9EAHa5SiM=; b=KSeFv8RTYY+zt24VNR0Re2B9q8Y7134HawQzEaFUhNtT9yIA0/hk2Ei/Tg1N4XAW/d SO/NAW5grr52YMr5rfCnW2ayAdtSDQl6n6W0vKS9vP9hWkoBeU3jg1qquYc4sBMQWhwu HhpX92HflxbbdjbPvJYVyxsaahE1sWmoSFrPU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=94ziauSZ5Wo2Z4hgpQ84fCORn1eX0WWpUq9EAHa5SiM=; b=r/ysPyg2TWtauc8tcCcMj1EeMC4fuE0BUV70+9B9/ayFaZNSnDZA+PYNMUpsKlMGos FnnzMEwMKXczeTnynT6wTx4GBNmbh+ARWnhWj0sK8r2+h4ZtNs1pqtPTqSgXxWQFlrC0 zG4ynfzaMjVc8c89GYOL0RUCUKagB7ac59arI7XdTKRNHjoGTf/EX1AQgLMQDbAAX+Rm 8S+886Rxhe5nZ0ekaYcWaIkn+7PorP08RcQ/8nzOV6eRyO5t5MX50fSTr2tpceniyAEq +tKhrANZ9ccOr9aFngrQ7apqGN0U5JkHq19ulLdzW+EPgeLnzb1tqcOHNqypiBey7DGG zN+Q== X-Gm-Message-State: ALQs6tCWoFA+VQOqs2vxRKvYHWp4y/4rOGTXVHximzYA6IR5Hip3B+mE Bz9a2w1OsvfSRmdgAh+V1+8Jnw== X-Received: by 2002:adf:dfcc:: with SMTP id q12-v6mr20469724wrn.68.1525413667051; Thu, 03 May 2018 23:01:07 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:06 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 03/17] efi: Fix IA32/X64 Processor Error Record definition Date: Fri, 4 May 2018 07:59:49 +0200 Message-Id: <20180504060003.19618-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yazen Ghannam Based on UEFI 2.7 Table 255. Processor Error Record, the "Local APIC_ID" field is 8 bytes but Linux defines this field as 1 byte. Fix this in the struct cper_sec_proc_ia definition. Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- include/linux/cper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.0 diff --git a/include/linux/cper.h b/include/linux/cper.h index d14ef4e77c8a..4b5f8459b403 100644 --- a/include/linux/cper.h +++ b/include/linux/cper.h @@ -381,7 +381,7 @@ struct cper_sec_proc_generic { /* IA32/X64 Processor Error Section */ struct cper_sec_proc_ia { __u64 validation_bits; - __u8 lapic_id; + __u64 lapic_id; __u8 cpuid[48]; }; From patchwork Fri May 4 05:59:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134943 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp436930lji; Thu, 3 May 2018 23:01:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq/1BWPAb6hmjIwaWx9eR3+q0nNfe8w5HiiipvlU6AOIKmHpQrx44ly/93IBaR2a/xN4THN X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr26358739plq.207.1525413681374; Thu, 03 May 2018 23:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413681; cv=none; d=google.com; s=arc-20160816; b=xvjqN7N5ui7hZ5UK0KqGb3tLvPDFBwVoqFb3vjYLFu0ODlkk5CsfKQeK3IB7chUNgF ajEaPTo35Ywe2/SexqXnC/+dNGNfRC4Ma+Z9f5iCe1n1G/sBTNL4Bq4ytwu7bH/d0kt7 vsbAKXvEDGF+HhVmYL4pazfh8ul2iYXVkjzNvwSPXANz/5gXA/zTwIFwaDlXLunapydZ QftPKYG2nXKOa5NN3LoaRBGwVZ/IeuMaIjYGD9oCAJ7LNyGxRzIqzlC+7QtD2rlAoMy+ Dc8aVDf8wJPlArrAjiugRYXvFVAErYqqGySjtDMVJOTNIeCv16yQSSt3ZhK10xBIkMoJ RzcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=JDm3m7UDbVG4KfgQDEMlrfbGxlvkzv6SW44wCJUrqT0=; b=qnjEbHSedH9Njj83xHKxVyzOXcS5BsjvywMFNGykIOXtbwKRrdOkd42Zs7MXAeErrv rdwOIKQZ/ptOZW4tmMfFsExp2Jjb1b0KWbo+r7HL5Oxk77nr1XKuuf97ohSDEEoK8+M1 5tGOyz2zrYgxaHvrOLXpifDHPzivUJSUF+3SDJHC4V1FQlde/jOzJQuBu0Q9VxYl6qbH xW5ymtjsi1vJJAZ44tcPfGKnyGb1/6SY69v9UHnzV04McXPNZ+LGI/ehraUduld1UCz7 Xi2Ozh/EaRBMgYWREvvbRjlt8NFddTom1SW3y84zGmRMAJfemUYJdbKuXcI68np4ypqk l7cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQlJ5Nti; 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 b7-v6si16062119pla.345.2018.05.03.23.01.21; Thu, 03 May 2018 23:01:21 -0700 (PDT) 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=kQlJ5Nti; 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 S1751587AbeEDGBR (ORCPT + 29 others); Fri, 4 May 2018 02:01:17 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:40741 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbeEDGBO (ORCPT ); Fri, 4 May 2018 02:01:14 -0400 Received: by mail-wr0-f196.google.com with SMTP id v60-v6so19766678wrc.7 for ; Thu, 03 May 2018 23:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JDm3m7UDbVG4KfgQDEMlrfbGxlvkzv6SW44wCJUrqT0=; b=kQlJ5NtiI0axBLnvn193kYvFVvye4KEL8Qc19zMeZzLE9GmUnRGwTa+O4CDXkAL6Iz dhQ0ppe7diW09xrb6Fp/Hen7CIS1+0Nk797nB/HNpNUOxy5naiUGvfFv8VL6qH9MdEKV LC5oNVf5Edh6gYyS++0LDZ8/Wa0T9A6qmEQ90= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JDm3m7UDbVG4KfgQDEMlrfbGxlvkzv6SW44wCJUrqT0=; b=kVfMAVoOjOtHFwAqQUtlymjU/LBNIobl8B43F7OuCyUZC2J1qnqy6YMX3JK6l79Juv z1eRy0VwvuAY89S+fFl+gAl56v07MIpELyhziBw+eTGHDbNiBGJEMz1w+8IhjXnI/nL9 W2iMmqe5tW9fvUDPOtJdTt5h0NwaZJhbiEyP6KFz+sBst4YW1dl8pet7/Eis+gyZ4NuH 4D5bLjQsQJg1O4/gVU0CWGM2pBe0K7peblydxiLobPdQCoWdrOZCqpHVg+NTOkw+s2N6 woljNxHcXL416a++y+Cjr7YmIDEDjO0E4eGvQsAQTRQY4t4nqvSwg3WdEPCGsRYj8hzJ tiEQ== X-Gm-Message-State: ALQs6tBlgfmKwmUKyfbLyUj1nSOL5WauIfme5HxN4q37UmdPskugnrsv Jc39mjqou4sm2GR9LSG+DJ0yRA== X-Received: by 2002:adf:b18d:: with SMTP id q13-v6mr19265272wra.276.1525413672982; Thu, 03 May 2018 23:01:12 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:12 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 06/17] efi: Decode UEFI-defined IA32/X64 Error Structure GUIDs Date: Fri, 4 May 2018 07:59:52 +0200 Message-Id: <20180504060003.19618-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yazen Ghannam For easier handling, match the known IA32/X64 error structure GUIDs to enums. Also, print out the name of the matching Error Structure Type. Only print the GUID for unknown types. GUIDs taken from UEFI 2.7 section N.2.4.2.1 IA32/X64 Processor Error Information Structure. Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-x86.c | 47 +++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) -- 2.17.0 diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c index e0633a103fcf..5438097b93ac 100644 --- a/drivers/firmware/efi/cper-x86.c +++ b/drivers/firmware/efi/cper-x86.c @@ -11,17 +11,53 @@ #define VALID_CPUID_INFO BIT_ULL(1) #define VALID_PROC_ERR_INFO_NUM(bits) (((bits) & GENMASK_ULL(7, 2)) >> 2) +#define INFO_ERR_STRUCT_TYPE_CACHE \ + GUID_INIT(0xA55701F5, 0xE3EF, 0x43DE, 0xAC, 0x72, 0x24, 0x9B, \ + 0x57, 0x3F, 0xAD, 0x2C) +#define INFO_ERR_STRUCT_TYPE_TLB \ + GUID_INIT(0xFC06B535, 0x5E1F, 0x4562, 0x9F, 0x25, 0x0A, 0x3B, \ + 0x9A, 0xDB, 0x63, 0xC3) +#define INFO_ERR_STRUCT_TYPE_BUS \ + GUID_INIT(0x1CF3F8B3, 0xC5B1, 0x49a2, 0xAA, 0x59, 0x5E, 0xEF, \ + 0x92, 0xFF, 0xA6, 0x3C) +#define INFO_ERR_STRUCT_TYPE_MS \ + GUID_INIT(0x48AB7F57, 0xDC34, 0x4f6c, 0xA7, 0xD3, 0xB0, 0xB5, \ + 0xB0, 0xA7, 0x43, 0x14) + #define INFO_VALID_CHECK_INFO BIT_ULL(0) #define INFO_VALID_TARGET_ID BIT_ULL(1) #define INFO_VALID_REQUESTOR_ID BIT_ULL(2) #define INFO_VALID_RESPONDER_ID BIT_ULL(3) #define INFO_VALID_IP BIT_ULL(4) +enum err_types { + ERR_TYPE_CACHE = 0, + ERR_TYPE_TLB, + ERR_TYPE_BUS, + ERR_TYPE_MS, + N_ERR_TYPES +}; + +static enum err_types cper_get_err_type(const guid_t *err_type) +{ + if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_CACHE)) + return ERR_TYPE_CACHE; + else if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_TLB)) + return ERR_TYPE_TLB; + else if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_BUS)) + return ERR_TYPE_BUS; + else if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_MS)) + return ERR_TYPE_MS; + else + return N_ERR_TYPES; +} + void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) { int i; struct cper_ia_err_info *err_info; char newpfx[64]; + u8 err_type; if (proc->validation_bits & VALID_LAPIC_ID) printk("%sLocal APIC_ID: 0x%llx\n", pfx, proc->lapic_id); @@ -38,8 +74,15 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) for (i = 0; i < VALID_PROC_ERR_INFO_NUM(proc->validation_bits); i++) { printk("%sError Information Structure %d:\n", pfx, i); - printk("%sError Structure Type: %pUl\n", newpfx, - &err_info->err_type); + err_type = cper_get_err_type(&err_info->err_type); + printk("%sError Structure Type: %s\n", newpfx, + err_type < ARRAY_SIZE(cper_proc_error_type_strs) ? + cper_proc_error_type_strs[err_type] : "unknown"); + + if (err_type >= N_ERR_TYPES) { + printk("%sError Structure Type: %pUl\n", newpfx, + &err_info->err_type); + } if (err_info->validation_bits & INFO_VALID_CHECK_INFO) { printk("%sCheck Information: 0x%016llx\n", newpfx, From patchwork Fri May 4 05:59:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134954 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp438992lji; Thu, 3 May 2018 23:03:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZocwzzP2AIwB/ZlpBhvRFHzIaF5TrF5u+CU7pG4Dy///ON6Jpo16yxhyI35dMi4SbJ0hsFa X-Received: by 2002:a17:902:7896:: with SMTP id q22-v6mr27055964pll.243.1525413816705; Thu, 03 May 2018 23:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413816; cv=none; d=google.com; s=arc-20160816; b=eeXayH0k5lepQS+5xidx16dVIYARtU1O0B+Zcf50Ju3wMi56RZJZxGyXxyYpDx1MyB yvRvJOCae7dfC0fOOMFTzoxVWvfsYBRBfbRWUqKBdquWW+fdNwqod8WwaqCpGkjb0vxD nS63QIuryNGhcImUkCqsqKiPKBM3eEIucLqWRqAZZOijZrHMso+IzEj/q/wdeMJ72cC3 CYnduKslxdFihLNEHDJbfIi+45zlqLEhfloLoZPOg9JAiQTcc4iwhQl6Qs7b/0IqfzLq AiKn0nLHcY14LiOl7KXPra4iuo0jIxGs6Ph4DIB/V8z8HvrnqiDFOi9GdLvU38W2gZ5x w9Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=eGeFWs/GhoS9om+2olzj/nHLTfhI4eGSHX+frG7YW3Q=; b=tR4Zc+L4uk8NTHg4zjb++AIPQn1wKfPfIi8p9vC1SvgMWfjpKZrER95aVNjy2c6K1Y B7BwWmeUbw3uZZ1WrG1fM7PX/A4coQA2j3l/irgw+Wjb8/M4fs4IJ0dcmBQ59E2lbqJA 7UqdKYDTX3BRcR9mIPGdG0dl99EZzGSDd6tcKUXsstyMK1Pssk4ZKInPpZxIh50PJcpw 1/c34ItHcBPFLjfuXO2LP2oGEk0epNiErvzzSmFm0B5O+KPH7T/YF79/KtIjIAZdP1yR XmA5pp3iSeSCXwGsRsZ9ua2Pt7EW89Xpa++XIiAlPwn4xzOQNe9WM7tDUexu0s4z7Cag 22+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IxH5uTuf; 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 u6-v6si15517576plz.461.2018.05.03.23.03.36; Thu, 03 May 2018 23:03:36 -0700 (PDT) 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=IxH5uTuf; 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 S1751950AbeEDGDe (ORCPT + 29 others); Fri, 4 May 2018 02:03:34 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:43974 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561AbeEDGBQ (ORCPT ); Fri, 4 May 2018 02:01:16 -0400 Received: by mail-wr0-f196.google.com with SMTP id v15-v6so19755811wrm.10 for ; Thu, 03 May 2018 23:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eGeFWs/GhoS9om+2olzj/nHLTfhI4eGSHX+frG7YW3Q=; b=IxH5uTufGmFEb0gRJsEKsueFczs+UtJeuDSvL171H/dAfdTxTvtqGaY6Yh7160TAvZ bpXdAKGpo5nOn75i4Qg7KFvLxUcZyOGlRQwnEsjyQdOW833kWN3aOAUG+ZibRb9tB5q2 w0axDBh1LjBT7Ga/tHhIDAS/8/mpnlHiTM0QM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eGeFWs/GhoS9om+2olzj/nHLTfhI4eGSHX+frG7YW3Q=; b=nh5YokWK7f2LZygBLUTz0LRHIGvsCuPbQF3OhlWtZZmP96S+Xfb8VihnDPpAlPDNyF AGjy+151LrDxWYIUeoL1dpQXet5TwjcW0xCQinI1I6kTDQt7Wu6cJ0GyKAjRIp94wPA4 PW9BGoX6/oMyjLHwiBO/d6Uzg4qAxVRCxIGFkA+iZLOOmrxxY4YR5PemthkITThkPPEm BBFBaU3OJ2Wej+rzbTy4SJ1YpbVV7xU9loKUI6AyfxSJMTkQc4Q7+NPZgOncOCG6YoTM MXBKoNx5LFFG8/CkG7w0+D8/3osA3AbjHQMSnMm0t3k9JXq4/MTn8A5d0iE/fu6hQewK sujQ== X-Gm-Message-State: ALQs6tB1Hj3+wXlOimuno0iT+0eFYT6KezX8C08a7zpEm8poiRZ1WGbm tUpdUH/kkj7UOvpIi+CV3eOAXQ== X-Received: by 2002:adf:b90a:: with SMTP id k10-v6mr22654809wrf.283.1525413674969; Thu, 03 May 2018 23:01:14 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:14 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 07/17] efi: Decode IA32/X64 Cache, TLB, and Bus Check structures Date: Fri, 4 May 2018 07:59:53 +0200 Message-Id: <20180504060003.19618-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yazen Ghannam Print the common fields of the Cache, TLB, and Bus check structures.The fields of these three check types are the same except for a few more fields in the Bus check structure. The remaining Bus check structure fields will be decoded in a following patch. Based on UEFI 2.7, Table 254. IA32/X64 Cache Check Structure Table 255. IA32/X64 TLB Check Structure Table 256. IA32/X64 Bus Check Structure Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-x86.c | 99 ++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c index 5438097b93ac..f70c46f7a4db 100644 --- a/drivers/firmware/efi/cper-x86.c +++ b/drivers/firmware/efi/cper-x86.c @@ -30,6 +30,25 @@ #define INFO_VALID_RESPONDER_ID BIT_ULL(3) #define INFO_VALID_IP BIT_ULL(4) +#define CHECK_VALID_TRANS_TYPE BIT_ULL(0) +#define CHECK_VALID_OPERATION BIT_ULL(1) +#define CHECK_VALID_LEVEL BIT_ULL(2) +#define CHECK_VALID_PCC BIT_ULL(3) +#define CHECK_VALID_UNCORRECTED BIT_ULL(4) +#define CHECK_VALID_PRECISE_IP BIT_ULL(5) +#define CHECK_VALID_RESTARTABLE_IP BIT_ULL(6) +#define CHECK_VALID_OVERFLOW BIT_ULL(7) + +#define CHECK_VALID_BITS(check) (((check) & GENMASK_ULL(15, 0))) +#define CHECK_TRANS_TYPE(check) (((check) & GENMASK_ULL(17, 16)) >> 16) +#define CHECK_OPERATION(check) (((check) & GENMASK_ULL(21, 18)) >> 18) +#define CHECK_LEVEL(check) (((check) & GENMASK_ULL(24, 22)) >> 22) +#define CHECK_PCC BIT_ULL(25) +#define CHECK_UNCORRECTED BIT_ULL(26) +#define CHECK_PRECISE_IP BIT_ULL(27) +#define CHECK_RESTARTABLE_IP BIT_ULL(28) +#define CHECK_OVERFLOW BIT_ULL(29) + enum err_types { ERR_TYPE_CACHE = 0, ERR_TYPE_TLB, @@ -52,11 +71,81 @@ static enum err_types cper_get_err_type(const guid_t *err_type) return N_ERR_TYPES; } +static const char * const ia_check_trans_type_strs[] = { + "Instruction", + "Data Access", + "Generic", +}; + +static const char * const ia_check_op_strs[] = { + "generic error", + "generic read", + "generic write", + "data read", + "data write", + "instruction fetch", + "prefetch", + "eviction", + "snoop", +}; + +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"); +} + +static void print_err_info(const char *pfx, u8 err_type, u64 check) +{ + u16 validation_bits = CHECK_VALID_BITS(check); + + if (err_type == ERR_TYPE_MS) + return; + + if (validation_bits & CHECK_VALID_TRANS_TYPE) { + u8 trans_type = CHECK_TRANS_TYPE(check); + + printk("%sTransaction Type: %u, %s\n", pfx, trans_type, + trans_type < ARRAY_SIZE(ia_check_trans_type_strs) ? + ia_check_trans_type_strs[trans_type] : "unknown"); + } + + if (validation_bits & CHECK_VALID_OPERATION) { + u8 op = CHECK_OPERATION(check); + + /* + * CACHE has more operation types than TLB or BUS, though the + * name and the order are the same. + */ + u8 max_ops = (err_type == ERR_TYPE_CACHE) ? 9 : 7; + + printk("%sOperation: %u, %s\n", pfx, op, + op < max_ops ? ia_check_op_strs[op] : "unknown"); + } + + if (validation_bits & CHECK_VALID_LEVEL) + printk("%sLevel: %llu\n", pfx, CHECK_LEVEL(check)); + + if (validation_bits & CHECK_VALID_PCC) + print_bool("Processor Context Corrupt", pfx, check, CHECK_PCC); + + if (validation_bits & CHECK_VALID_UNCORRECTED) + print_bool("Uncorrected", pfx, check, CHECK_UNCORRECTED); + + if (validation_bits & CHECK_VALID_PRECISE_IP) + print_bool("Precise IP", pfx, check, CHECK_PRECISE_IP); + + if (validation_bits & CHECK_VALID_RESTARTABLE_IP) + print_bool("Restartable IP", pfx, check, CHECK_RESTARTABLE_IP); + + if (validation_bits & CHECK_VALID_OVERFLOW) + print_bool("Overflow", pfx, check, CHECK_OVERFLOW); +} + void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) { int i; struct cper_ia_err_info *err_info; - char newpfx[64]; + char newpfx[64], infopfx[64]; u8 err_type; if (proc->validation_bits & VALID_LAPIC_ID) @@ -87,6 +176,14 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) if (err_info->validation_bits & INFO_VALID_CHECK_INFO) { printk("%sCheck Information: 0x%016llx\n", newpfx, err_info->check_info); + + if (err_type < N_ERR_TYPES) { + snprintf(infopfx, sizeof(infopfx), "%s ", + newpfx); + + print_err_info(infopfx, err_type, + err_info->check_info); + } } if (err_info->validation_bits & INFO_VALID_TARGET_ID) { From patchwork Fri May 4 05:59:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134953 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp438693lji; Thu, 3 May 2018 23:03:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrbE7LCJTMcG5Ns/A4/cuH7Ham/wdujz+iaXg1o0BODzK36PmU4gNX9NTRJn6v+ayVWh4Z7 X-Received: by 2002:a65:4944:: with SMTP id q4-v6mr21797886pgs.424.1525413798771; Thu, 03 May 2018 23:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413798; cv=none; d=google.com; s=arc-20160816; b=lhzvwepJA6iKYrat0z2jtVufOTH5V0LHCzaIVVVWg+vun0tCnn6SERbs4TZL8eMoO2 D2qMKxGXO5k2st9Eos0CXVbSlmyi0ktxcJY00Zo1SVEi4yDTJ4jO1FqfZjvcpMhZqg6e 9Ay/+9Dq3j/48ET1Uw2mDZgF1Qmd215Bn873HFgacr+Ctqam30G/h50D2LpUFoO1eMBr zIXgvBsB+ZcGPWswMCWHcDzgW9pLAEOfmkPC/DR8rsfsvLMCWCHanyL9rnLXJu6+9bE7 pMNPOsBe8Umz2bLRqjuHldugXmsdSN4ZSAtPFdRM63IiiVhUTfIRUJgNfv41Almo7/J1 ME5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8RPmP673iKgidaREzK9EYXMfvDILehSjkoL4rWwjiHM=; b=k1yxbUMuuoR/aPe6Rd//Adzzw6Uh88b5xZChPHkpBhLrLYD5DsrYoooRN2Sbk2H/6r lP9BapUpgnnrbptPuF+Sq1OKW7uSlpbpylgea9OqlquYrtkL0pvH7PWeDQTQ0WgcXOHa 9RxpUEIh97AzxFkCmMMxAUr+tVlRMqHlRbKMvnj9sHmfnHuriSGIBI9HEmzw3UURae2G kVpR3UEFwbbv9tcpEH7PFO4X2M51QYX+w5NmaGqC+oi5656QAtwrLo6lpZtJNi81R9Bi hhLqzXy11PxmH1DpE04MVKyoL+YKcJEDEsD0Bu/4mvXOfVUGXpviWGqu18YE3GElouO0 6IKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=boHwZHH1; 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 p10si15502400pfn.65.2018.05.03.23.03.18; Thu, 03 May 2018 23:03:18 -0700 (PDT) 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=boHwZHH1; 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 S1751629AbeEDGBV (ORCPT + 29 others); Fri, 4 May 2018 02:01:21 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34616 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbeEDGBS (ORCPT ); Fri, 4 May 2018 02:01:18 -0400 Received: by mail-wm0-f65.google.com with SMTP id a137-v6so5575853wme.1 for ; Thu, 03 May 2018 23:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8RPmP673iKgidaREzK9EYXMfvDILehSjkoL4rWwjiHM=; b=boHwZHH1lHYYF+mNV8ZWIh+vqgJrmIWO37XwPFmIxfJI5BclBE83bppEEHDXd0/AhU sax9zbYFR2VWxYS6fvRqNfLQO4rJPNVFZvc6ZDoUSWGUI3+MvlsPtEes6KKixYAGqMKB vGDVgPteapmie7YYcbPqyoa12QC+LT8z++0oQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8RPmP673iKgidaREzK9EYXMfvDILehSjkoL4rWwjiHM=; b=hJ3zF9CFuvw64zZ/cm8BOIcUYtq5LKCc/lWHGLy72dqORiQGJcWcfMM7vXsbVbuBfA B1/iw0Om4mf31t8wceCcuM3LgxZ1l08eaW4Wf9EP+uwYopGgI6/kXOpFFaYTSdnIDu96 T0u8KvP5mOqwIftXrWG6j5gfsQaHefc5Gb/K2OUdTEj8/bJ2gOeCv4xatohnbrEGP84S YObXJNz50fbEKBkOse5jL7eAMPkBkea87iMNULiFkAms0ItXen7luJ8FVexpgc2hJGdb /lamz8sltCpORIi6K1gT1MIQNoRt/MpPBTUbDdZfIyrtMMbuuRIBqUACTuI1QX+f94mC 95dQ== X-Gm-Message-State: ALQs6tCk36QAjwyJ2LiC1POeGMexlkDhZ9EdEqmduTTT6wnAPTLrVZM5 6c+jDdsydivi/M5tU7mlKUzOJQ== X-Received: by 10.28.111.82 with SMTP id k79mr14665505wmc.38.1525413676913; Thu, 03 May 2018 23:01:16 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:16 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 08/17] efi: Decode additional IA32/X64 Bus Check fields Date: Fri, 4 May 2018 07:59:54 +0200 Message-Id: <20180504060003.19618-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yazen Ghannam The "Participation Type", "Time Out", and "Address Space" fields are unique to the IA32/X64 Bus Check structure. Print these fields. Based on UEFI 2.7 Table 256. IA32/X64 Bus Check Structure Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-x86.c | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.17.0 diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c index f70c46f7a4db..5e6716564dba 100644 --- a/drivers/firmware/efi/cper-x86.c +++ b/drivers/firmware/efi/cper-x86.c @@ -39,6 +39,10 @@ #define CHECK_VALID_RESTARTABLE_IP BIT_ULL(6) #define CHECK_VALID_OVERFLOW BIT_ULL(7) +#define CHECK_VALID_BUS_PART_TYPE BIT_ULL(8) +#define CHECK_VALID_BUS_TIME_OUT BIT_ULL(9) +#define CHECK_VALID_BUS_ADDR_SPACE BIT_ULL(10) + #define CHECK_VALID_BITS(check) (((check) & GENMASK_ULL(15, 0))) #define CHECK_TRANS_TYPE(check) (((check) & GENMASK_ULL(17, 16)) >> 16) #define CHECK_OPERATION(check) (((check) & GENMASK_ULL(21, 18)) >> 18) @@ -49,6 +53,10 @@ #define CHECK_RESTARTABLE_IP BIT_ULL(28) #define CHECK_OVERFLOW BIT_ULL(29) +#define CHECK_BUS_PART_TYPE(check) (((check) & GENMASK_ULL(31, 30)) >> 30) +#define CHECK_BUS_TIME_OUT BIT_ULL(32) +#define CHECK_BUS_ADDR_SPACE(check) (((check) & GENMASK_ULL(34, 33)) >> 33) + enum err_types { ERR_TYPE_CACHE = 0, ERR_TYPE_TLB, @@ -89,6 +97,20 @@ static const char * const ia_check_op_strs[] = { "snoop", }; +static const char * const ia_check_bus_part_type_strs[] = { + "Local Processor originated request", + "Local Processor responded to request", + "Local Processor observed", + "Generic", +}; + +static const char * const ia_check_bus_addr_space_strs[] = { + "Memory Access", + "Reserved", + "I/O", + "Other Transaction", +}; + 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"); @@ -139,6 +161,28 @@ static void print_err_info(const char *pfx, u8 err_type, u64 check) if (validation_bits & CHECK_VALID_OVERFLOW) print_bool("Overflow", pfx, check, CHECK_OVERFLOW); + + if (err_type != ERR_TYPE_BUS) + return; + + if (validation_bits & CHECK_VALID_BUS_PART_TYPE) { + u8 part_type = CHECK_BUS_PART_TYPE(check); + + printk("%sParticipation Type: %u, %s\n", pfx, part_type, + part_type < ARRAY_SIZE(ia_check_bus_part_type_strs) ? + ia_check_bus_part_type_strs[part_type] : "unknown"); + } + + if (validation_bits & CHECK_VALID_BUS_TIME_OUT) + print_bool("Time Out", pfx, check, CHECK_BUS_TIME_OUT); + + if (validation_bits & CHECK_VALID_BUS_ADDR_SPACE) { + u8 addr_space = CHECK_BUS_ADDR_SPACE(check); + + printk("%sAddress Space: %u, %s\n", pfx, addr_space, + addr_space < ARRAY_SIZE(ia_check_bus_addr_space_strs) ? + ia_check_bus_addr_space_strs[addr_space] : "unknown"); + } } void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) From patchwork Fri May 4 05:59:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134944 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437008lji; Thu, 3 May 2018 23:01:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpfMlYGs5i7H+0MHRh5joW3kbWKbMBD3piqcfPL6Y9Mar/3jGvNSprlGM+pGT9n4uMdu8r6 X-Received: by 10.98.7.75 with SMTP id b72mr18371060pfd.133.1525413686982; Thu, 03 May 2018 23:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413686; cv=none; d=google.com; s=arc-20160816; b=lhiLf1azkkQwtQaIsxh4UT1KNtqlbHKwTg8bFjgDd/wJSmRMk6BBUfb3IIoXW/jfdd fKqycp1W1A6cqe0j6DbTXOAlVhyo/cTVpPuYk8q/HYyHl+VQCvFGQyVtuJqNgtL3Lqhl kzv4O74n6nW3tlWD4yQDUx4kanbgtRuA4sfK8Rnx1FPAUtXkLbw8djdt24P7LtVVeiZs Jgg//NrRH7DQctDBMvEYIR2mV0EKKVFGEqaSt43cjqwISvr9dJDKVx9pBtoz6XjJwYRm jiwQXpFwaEf4nL2khc9XwmPpA+2RpyBXun4qaAMpN433WcHdJT9GSRNSLsngopMXjpGJ +bZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7B4c8Pjbxef6aiF7r7UqY+Hx8mO10Hq4pDea0nlrUGE=; b=FqW4pBEMEzvOM3lq8umhwUmBTq4OCbEuutHq3+qXvogXA7ZKelinx179KMlXqBRIb/ 74Z3WzWEizTjOI+eU5t/WfQNfJLeqdj2r6DHqzGqVBj7XmCB0IBDBbdU1/qTM+nfZjZ5 Sm1qem0BdAxe5acLg/jmY1XMwVucXSlpxh1fPA5gtlTfzBM5BNmUb1zkJhEBtekhR8sJ mTxjZ5CvQHctEatp6GrEuTEihtIcm111xRqgdh1I9KTaRBw2w16L72q+RqZBeedRjgdc EJpielD7VThQqMVdFC6jbI9C5OOBQZ3uOtUHhtyvFkgWsOyuNt/oE2NDZJq6T6/xGtWm IWGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O5uXqN1s; 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 b7-v6si16062119pla.345.2018.05.03.23.01.26; Thu, 03 May 2018 23:01:26 -0700 (PDT) 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=O5uXqN1s; 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 S1751674AbeEDGBX (ORCPT + 29 others); Fri, 4 May 2018 02:01:23 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:32854 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbeEDGBU (ORCPT ); Fri, 4 May 2018 02:01:20 -0400 Received: by mail-wm0-f67.google.com with SMTP id x12-v6so5590543wmc.0 for ; Thu, 03 May 2018 23:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7B4c8Pjbxef6aiF7r7UqY+Hx8mO10Hq4pDea0nlrUGE=; b=O5uXqN1sLVzaKVr+4W1zsp9aSQSlrW3SKqe8J3g1SdCRx+O6rxSboZaY8y7xoOyjom zfZcWwjIb4eSuXhWfCXH1WdDaz+g0wger4fmxs6IDzUYtVvuhf0Runz1Nm0Mal6ybHOX RkkcIYCSrda7fkZXjRDzxb6Sqpp9IpKBSOmw8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7B4c8Pjbxef6aiF7r7UqY+Hx8mO10Hq4pDea0nlrUGE=; b=PibhjuMZD0rMfSLHOq6Aax/jLLfI1AmL3RyM0e/xtR4PrIQw//HhSlzUU5Lu6VCvbm YDoxLgfnUwGMKhkxlvLyzWG7VCEknpWtiQf8v9ShGQQBAKIXjcGiOlmTu24NFqDw4PSy eMR6WYf2bqo1n5+unbw7peVdIaTUB96M56dgZfB/6cIbjEqozThq12Mt5LmS8WQjQNiS rHsfdy92MLhcDEBcreGL8CoEPWqxOKAG1Y6/SyI0pdfepta1qulc8OuawosmLztdnfb/ Dydp+HzXT4aY2F3dTbfFrF7q2ufNIh5xCPDJf6aPR1tIt+9MXBkoAKdMFaEW3smpTuL2 l5tw== X-Gm-Message-State: ALQs6tCUT5jLZ5+z7kMTLDOWGK1lKnr18zQgrnpMeKR1gJacmEtVE0nq qrJnf4mpHt1S/qsE1QcKu3ilxA== X-Received: by 10.28.197.136 with SMTP id v130mr2437477wmf.135.1525413678961; Thu, 03 May 2018 23:01:18 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:18 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 09/17] efi: Decode IA32/X64 MS Check structure Date: Fri, 4 May 2018 07:59:55 +0200 Message-Id: <20180504060003.19618-10-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yazen Ghannam The IA32/X64 MS Check structure varies from the other Check structures in the the bit positions of its fields, and it includes an additional "Error Type" field. Decode the MS Check structure in a separate function. Based on UEFI 2.7 Table 257. IA32/X64 MS Check Field Description. Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-x86.c | 55 ++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c index 5e6716564dba..356b8d326219 100644 --- a/drivers/firmware/efi/cper-x86.c +++ b/drivers/firmware/efi/cper-x86.c @@ -57,6 +57,20 @@ #define CHECK_BUS_TIME_OUT BIT_ULL(32) #define CHECK_BUS_ADDR_SPACE(check) (((check) & GENMASK_ULL(34, 33)) >> 33) +#define CHECK_VALID_MS_ERR_TYPE BIT_ULL(0) +#define CHECK_VALID_MS_PCC BIT_ULL(1) +#define CHECK_VALID_MS_UNCORRECTED BIT_ULL(2) +#define CHECK_VALID_MS_PRECISE_IP BIT_ULL(3) +#define CHECK_VALID_MS_RESTARTABLE_IP BIT_ULL(4) +#define CHECK_VALID_MS_OVERFLOW BIT_ULL(5) + +#define CHECK_MS_ERR_TYPE(check) (((check) & GENMASK_ULL(18, 16)) >> 16) +#define CHECK_MS_PCC BIT_ULL(19) +#define CHECK_MS_UNCORRECTED BIT_ULL(20) +#define CHECK_MS_PRECISE_IP BIT_ULL(21) +#define CHECK_MS_RESTARTABLE_IP BIT_ULL(22) +#define CHECK_MS_OVERFLOW BIT_ULL(23) + enum err_types { ERR_TYPE_CACHE = 0, ERR_TYPE_TLB, @@ -111,17 +125,56 @@ static const char * const ia_check_bus_addr_space_strs[] = { "Other Transaction", }; +static const char * const ia_check_ms_error_type_strs[] = { + "No Error", + "Unclassified", + "Microcode ROM Parity Error", + "External Error", + "FRC Error", + "Internal Unclassified", +}; + 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"); } +static void print_err_info_ms(const char *pfx, u16 validation_bits, u64 check) +{ + if (validation_bits & CHECK_VALID_MS_ERR_TYPE) { + u8 err_type = CHECK_MS_ERR_TYPE(check); + + printk("%sError Type: %u, %s\n", pfx, err_type, + err_type < ARRAY_SIZE(ia_check_ms_error_type_strs) ? + ia_check_ms_error_type_strs[err_type] : "unknown"); + } + + if (validation_bits & CHECK_VALID_MS_PCC) + print_bool("Processor Context Corrupt", pfx, check, CHECK_MS_PCC); + + if (validation_bits & CHECK_VALID_MS_UNCORRECTED) + print_bool("Uncorrected", pfx, check, CHECK_MS_UNCORRECTED); + + if (validation_bits & CHECK_VALID_MS_PRECISE_IP) + print_bool("Precise IP", pfx, check, CHECK_MS_PRECISE_IP); + + if (validation_bits & CHECK_VALID_MS_RESTARTABLE_IP) + print_bool("Restartable IP", pfx, check, CHECK_MS_RESTARTABLE_IP); + + if (validation_bits & CHECK_VALID_MS_OVERFLOW) + print_bool("Overflow", pfx, check, CHECK_MS_OVERFLOW); +} + static void print_err_info(const char *pfx, u8 err_type, u64 check) { u16 validation_bits = CHECK_VALID_BITS(check); + /* + * The MS Check structure varies a lot from the others, so use a + * separate function for decoding. + */ if (err_type == ERR_TYPE_MS) - return; + return print_err_info_ms(pfx, validation_bits, check); if (validation_bits & CHECK_VALID_TRANS_TYPE) { u8 trans_type = CHECK_TRANS_TYPE(check); From patchwork Fri May 4 05:59:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134952 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp438484lji; Thu, 3 May 2018 23:03:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo4+0YgoHTvj2u6kVgDryJnjaCUxP+LZ1Ix+79lqMUhP+pv6Y+9wUyKfvgOYRj1K45jJyNl X-Received: by 2002:a63:6d8b:: with SMTP id i133-v6mr21493692pgc.268.1525413782938; Thu, 03 May 2018 23:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413782; cv=none; d=google.com; s=arc-20160816; b=UO2MIZa3MNM2P5KqtIOw6VeSDza9jYsRq1RuDHsNQkaiHntN61k9EMNjNdrUq4T0jc FvULwc5l+4V9Bwoyxu1hdXhKGCiV7kJO04ioZfjwx+r1jLbzFRLHpU0AEsz9RT9akVtm Sv6CNcJuJ06wp2AEf8lp63cJMR36I9Gs9dxYoYOqtlGkoPsVQsdptFomWey4Bx4VXDGK m6hMR/DeGGJFDZyKjjWbQmltMQ2iKJXdh0Ctw/TJ5/4LyHFuGCOLX3zJnIqOTF3c+Z1j P5KjnPnpdd3kK2XtcRhn/BzIXHbsSK4tVhYxAT1u/adbpBTROILV7RT2b3VCN88d3qdP woGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=sh4YVFRw2/+o8lExuE/Ryw+Zqd/USN5S4QasrIDqD3s=; b=w3Ixl8vuOsy4vK0PUAElm22OH1g1r+ijc7l8pvcN7VVBLcWVD5HYwN0zgEvfsE6RG7 UFClNm5X0P5nJqRWCOp3yyanHFkcjGSH/IVsTjz9BNGjKke9PboQcGZOikeNjl0fGRmG cTMzOWTQ6Cv+4Vr4OgQBe7wD3fJqFBZc+UAdwx/++T6UGy4LEsTKSalsUTC1SVZDt4sv TgtK7hj+hXCnQMHsNRL6Mqqh4remCTi3ZAHxmZ3zdTriXU7vGyoVfrY3WHJIRGMB6/yV kdvhpvBKOw60FVsYVRz/hZlVzeahqPoyDGO3Mj9i7VBQNl4mqBsfgTTpdpBhPDWPYGwS krYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bhoIMWPn; 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 k75si14696835pfk.369.2018.05.03.23.03.02; Thu, 03 May 2018 23:03:02 -0700 (PDT) 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=bhoIMWPn; 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 S1751913AbeEDGDB (ORCPT + 29 others); Fri, 4 May 2018 02:03:01 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38980 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbeEDGBW (ORCPT ); Fri, 4 May 2018 02:01:22 -0400 Received: by mail-wr0-f195.google.com with SMTP id q3-v6so19759162wrj.6 for ; Thu, 03 May 2018 23:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sh4YVFRw2/+o8lExuE/Ryw+Zqd/USN5S4QasrIDqD3s=; b=bhoIMWPnOV7Nkg44YE++r762e1O0wgV3iu4kZENl6y+GBzmST0RBEZ2QBT8pJ4mIIW wljIBdRp4+F6DHKBzWnAAqsAoy5w4v1c6Fvuhyhtg7PIPUFHu5UiNwPSg7fed/JyIoSn Nez620pBi+c3Crhp2UzcUgtjVa2WO5SDFgmiE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sh4YVFRw2/+o8lExuE/Ryw+Zqd/USN5S4QasrIDqD3s=; b=A9H1xwLJxbMxGtcj8O3Tx0qUrAHrV++nRtzduiwlDld9IPE8llX2XXLCy4GVJZkOsr pwAnu0yy89AnEBGgn+lAC5VE6BZ+Oc8QRZhPs/HowqARbEW+ciFzvy2LfbODefopDfYF w1nDyIbN+jU5B74+suSQueLb5e3afrovGASCv03ITD/TeTZk3GYpfz07Y3VKDumh4hDh AFoSXcetx2iJ8g2qzKGMvdpff7kxXCPG98SL5y5F2JoDxw0o/J3zgoHAaAZxO0RXqJQ5 JCb/JH1VsIUUZmg0ouZD1NWpOl5nauaIuWhoqobGG5wdpSSLYjgFbjDow5owPvS3cos7 FByw== X-Gm-Message-State: ALQs6tAl8dZuuObcO4oMPfIGN/b4gOo/HpLhUK9v7FMom0Azpu+OZnYV HMFYKdSBukfOsZraKJ4/xfrQeA== X-Received: by 2002:adf:b067:: with SMTP id g36-v6mr19984395wra.128.1525413680844; Thu, 03 May 2018 23:01:20 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:20 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 10/17] efi: Decode IA32/X64 Context Info structure Date: Fri, 4 May 2018 07:59:56 +0200 Message-Id: <20180504060003.19618-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-x86.c | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 2.17.0 diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c index 356b8d326219..2531de49f56c 100644 --- a/drivers/firmware/efi/cper-x86.c +++ b/drivers/firmware/efi/cper-x86.c @@ -10,6 +10,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_CXT_INFO_NUM(bits) (((bits) & GENMASK_ULL(13, 8)) >> 8) #define INFO_ERR_STRUCT_TYPE_CACHE \ GUID_INIT(0xA55701F5, 0xE3EF, 0x43DE, 0xAC, 0x72, 0x24, 0x9B, \ @@ -71,6 +72,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, @@ -134,6 +138,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"); @@ -242,6 +257,7 @@ 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]; u8 err_type; @@ -305,4 +321,36 @@ 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_CXT_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); + + printk("%sRegister Context Type: %s\n", newpfx, + ctx_info->reg_ctx_type < ARRAY_SIZE(ia_reg_ctx_strs) ? + ia_reg_ctx_strs[ctx_info->reg_ctx_type] : "unknown"); + + 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); + + ctx_info = (struct cper_ia_proc_ctx *)((long)ctx_info + size); + } } From patchwork Fri May 4 05:59:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134945 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437071lji; Thu, 3 May 2018 23:01:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrPrdPyEll45bZSt+3ei7eQxVFffpfw1kKxcUmm/bSBxffMnsvlaucSj9xoNUY+IR/b7Ik8 X-Received: by 2002:a63:9854:: with SMTP id l20-v6mr20907189pgo.16.1525413690759; Thu, 03 May 2018 23:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413690; cv=none; d=google.com; s=arc-20160816; b=OHFsSricEhXmVQCSri6aq0d0V+fNGbSetCcLR2fKYjsx8ijDfk1MDmr/m9v7lfg1LM 4sKpT1G1xVeSN8U1wVwE3q1wAUf94JFYXnmFpM9r9dTp/A5Y0ru07PmjUsDx54s2NSuO FTeKHrFUHcLfyrMECIe0u15IMVjPd2O5x1ICPTNLsajUQsvZFDjCsICr2DLAVdaDeQmI 5wb1nZgUQhdO3yt7b4H9aL16GMQgGh6nIgZ0P0MwpaMOmSCi2eeJOuYmr0p0FtbocAz6 K0MZ0FnbKRsM2qnz29oLy/feVj8K4U5Qc6oXKZW4kWp6OtN1gTpmbfCFlrbZAx9rc4LT ubwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ZY6R1HVgqPE8nGVVuw9m0sfGbX4YD0n5QENH3/kQqNw=; b=hVfBOgfmT1H7PVSc/7zqFug4LlZjTKBCNh0aoPmIGii4q2+OmkFmr0m8lJFHpgqg69 RcvfheDYf5spRAQb6p7k2/BL+/IEjwnBmHKVMO/UtsPvimkuhv24eVQWWrAZ2N2IOrz1 u0vMiGEELfUEoicZKB/nhu3KfDWNZpFxZ2JI3bn87EPTjlYgO18bStK/Q9xQpWQKetCP L7hDpDrqouCTQ2cIpPMQ03ml//vnYL3/F4LtNP3Wai7WRWT4KKSPjfJW6UGKipk6o0rz dBwh7DvtwwKV4/vUDXaxo6gAbG4jLPkcK1nLvQNNleb2PxYhyO+CoRgvkq1CVTh9wQCQ Qwog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W4FQ/wH+; 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 h8si2812110pfh.278.2018.05.03.23.01.30; Thu, 03 May 2018 23:01:30 -0700 (PDT) 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=W4FQ/wH+; 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 S1751737AbeEDGB1 (ORCPT + 29 others); Fri, 4 May 2018 02:01:27 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53514 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751593AbeEDGBY (ORCPT ); Fri, 4 May 2018 02:01:24 -0400 Received: by mail-wm0-f66.google.com with SMTP id a67so2189077wmf.3 for ; Thu, 03 May 2018 23:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZY6R1HVgqPE8nGVVuw9m0sfGbX4YD0n5QENH3/kQqNw=; b=W4FQ/wH+0p5aJ1wKKja1E5SnzRnVa0k7YCzVGOnX4UuMmxJWLYkOJiL2gwjaj9CzDD n6KIujdCi4BagtydTJPr827cKiyQTWbf2tWWq3Z9OcmWxK9ByYtI3Wn7k8DmMmBIRPRD CWedoqgGEPCpV67HyCM52KqYJeO61DRaT1dCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZY6R1HVgqPE8nGVVuw9m0sfGbX4YD0n5QENH3/kQqNw=; b=c9SN2Oaho+anw8pn8vWj08+Snei73jsCh9yPWYOh8avvnvaBt5tadTZWDZm4q1raLa JGzf9SDz/YMY5zLWM2M/2+j44KuNoLThjur33Mg4Uf5bEzUKIIl0yMzdrJnficnvj7x3 1NUa72wHBxZsfnxvChwtmlJq/p37VAQrsCdkBSNoHnd23JiNbKTzJkliNlPbpYEAjXLj NeHs0LxmXfM6FOsyCo3NXYOST5Lmlo8X7J9PudC6szRe61xZU3H22P/D0iS6VZDvMvB4 YLbYIOMUmSkOsgvUrpg66DnnU2QxPu1vJaJStX6qbsTytibkuIszx1JDLBZ4oehcXL/O LoiA== X-Gm-Message-State: ALQs6tDuDgyxZ51ECsUnuxFVGQTZnPL4lOIun/MNAb0VjtWE3K4VdQga BRi67EHsvel3NXGIyVmoT04Up8X3oYE= X-Received: by 10.28.74.13 with SMTP id x13mr13542467wma.150.1525413682810; Thu, 03 May 2018 23:01:22 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:22 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Wei Yongjun , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 11/17] efi/libstub/tpm: Make function efi_retrieve_tpm2_eventlog_1_2() static Date: Fri, 4 May 2018 07:59:57 +0200 Message-Id: <20180504060003.19618-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Yongjun Fixes the following sparse warning: drivers/firmware/efi/libstub/tpm.c:62:6: warning: symbol 'efi_retrieve_tpm2_eventlog_1_2' was not declared. Should it be static? Signed-off-by: Wei Yongjun Reviewed-by: Jarkko Sakkinen Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.0 diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index 9d08cea3f1b0..caa37a6dd9d4 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -59,7 +59,7 @@ void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) #endif -void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) +static void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) { efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; From patchwork Fri May 4 05:59:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134949 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437762lji; Thu, 3 May 2018 23:02:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqnbg85ukNYg2EtKJzd9k2Z7Oq8ESQAjwBRtvNVABoSXNG+6uuihA3Dhe5Vu5H/Hzv7iJUs X-Received: by 2002:a63:af4b:: with SMTP id s11-v6mr5735541pgo.346.1525413733654; Thu, 03 May 2018 23:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413733; cv=none; d=google.com; s=arc-20160816; b=mqtccmxtcAVj6wXADtagsbxzM7CQsEcluTADZKwXjc77MdPKd0m1fCdizg7yWvbJyF tLeo4ocmZVzOacHjVVIOrdlWKKpFVDtTk4sFrkZRyFF+qYcDXLrPbnIYyWFDwYmpxn3E v1L4FNEbH7hn0+vqtVdXVtrqiJLcQa+AkpcHgrP1orASBnO4XFdckn5ZTgtCjGX0tIIS 2vrrDEj6wOH+VnNHs7xIYMhtfGEndWZaelPB4VEdz0jHEg0BWn8BGcVb9iCx7dTvyWNj +zFh9jWC6RHHKcjTwQWm4P0kew1iyZbuDm/g8sODPePpdFlh6WvXNJCCbdeOS0nyqpVR yEXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=6taZDPxxgrV3AxESikJkl6YD5t26n9jJPsjR8j6vi4U=; b=RwvAcVjcAR5448OHgc77vQ7dz/Vo3VmDMpyxhdrwieJBHa/cVp0zIIG/r2S6o9GlhY j5CCQHnw7199vTb081EllWPuTitqRgyy/j6kRiXFKscwEK2/xeFwW+dtvo8r2LfeCMng 1Ro9LNIKhfIX+VG8mrcGzwOOIBlEzC6Es3lLvdxtfu2NiSkaimdFjZkMp1yWybz+a11b lL62XPcEhWXFK/uvTheS0JQl+L8zZbQpcY9Q1/DXfqls/C1V87P7gpaPhQ1vsV3+P7yD vBNJqDp1uPA6uaSh0b/c2D01lOsoUB0vth6mLoRC+NrEdZjMMZm4PcaF4n+IRqC9mpLv aVRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HJWlORgc; 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 w16-v6si15270939plk.79.2018.05.03.23.02.13; Thu, 03 May 2018 23:02:13 -0700 (PDT) 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=HJWlORgc; 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 S1751774AbeEDGBc (ORCPT + 29 others); Fri, 4 May 2018 02:01:32 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35148 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbeEDGB1 (ORCPT ); Fri, 4 May 2018 02:01:27 -0400 Received: by mail-wm0-f67.google.com with SMTP id o78-v6so2576819wmg.0 for ; Thu, 03 May 2018 23:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6taZDPxxgrV3AxESikJkl6YD5t26n9jJPsjR8j6vi4U=; b=HJWlORgccgvDA6WE7XwPpxoJSKVYm2/SSffQrNDJOHUTfS5VkWzZLsn+g1uMQfanat F3lbTDX1Ucl/r1326LN65rki8AYEKJpcs9ij7YD9aW6v0tlzZO7RaBX39FKpDUeaV2eE i+NRej6+70PLV8GJWChHkxvNJ0ZISOf2H13Kk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6taZDPxxgrV3AxESikJkl6YD5t26n9jJPsjR8j6vi4U=; b=f4oWSz8HVCfGLMfKK0o3GkPUYzqzBS+p/Z1hubXi3teaohW2dlQsXSDVmWpqxnDvjF bvID/DO/sjBRJGT3m7NXIT2942b7Od9qjZvDlLYbhND3N9wkqSsB0ui7mWFQgbLUKFjB VCcpIyg8JxzMi800uWQ4Gqx8WJ8xV5TXag+CM8Ha26VAZIxKJpEv5AoWeImXM1TiaQnO HZpoZqgDCh7O8r1hFr+f3fZL+qZNiWClqHWyIiNkqZqyvUXORqVWQdJLAIzWNpU/K5UG y7+B7tnmS0mUCTDf+bhQvYsp1kp+v6P6ul6Py2hTmKc6vYJBaJ3d0c4C3vZxNulRqdKI dnSg== X-Gm-Message-State: ALQs6tAB8B3G8QbXNg/4GfCboGXvvnU2fV4JdNDSAS4TMooJQwjbE9JQ u39nK+0buVQW5NVP0fZLYlXZRHKjOR8= X-Received: by 10.28.51.201 with SMTP id z192mr14901785wmz.147.1525413686563; Thu, 03 May 2018 23:01:26 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:25 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 13/17] efi: align efi_pci_io_protocol typedefs to type naming convention Date: Fri, 4 May 2018 07:59:59 +0200 Message-Id: <20180504060003.19618-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use the helper macros that perform type mangling with the EFI PCI I/O protocol struct typedefs, align their Linux typenames with the convention we use for definitionns that originate in the UEFI spec, and add the trailing _t to each. Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 8 ++++---- include/linux/efi.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) -- 2.17.0 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 09f36c0d9d4f..3994f48c4043 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -109,7 +109,7 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) } static efi_status_t -__setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom) +__setup_efi_pci32(efi_pci_io_protocol_32_t *pci, struct pci_setup_rom **__rom) { struct pci_setup_rom *rom = NULL; efi_status_t status; @@ -176,7 +176,7 @@ static void setup_efi_pci32(struct boot_params *params, void **pci_handle, unsigned long size) { - efi_pci_io_protocol_32 *pci = NULL; + efi_pci_io_protocol_32_t *pci = NULL; efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; u32 *handles = (u32 *)(unsigned long)pci_handle; efi_status_t status; @@ -218,7 +218,7 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle, } static efi_status_t -__setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom) +__setup_efi_pci64(efi_pci_io_protocol_64_t *pci, struct pci_setup_rom **__rom) { struct pci_setup_rom *rom; efi_status_t status; @@ -284,7 +284,7 @@ static void setup_efi_pci64(struct boot_params *params, void **pci_handle, unsigned long size) { - efi_pci_io_protocol_64 *pci = NULL; + efi_pci_io_protocol_64_t *pci = NULL; efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; u64 *handles = (u64 *)(unsigned long)pci_handle; efi_status_t status; diff --git a/include/linux/efi.h b/include/linux/efi.h index 3016d8c456bc..56add823f190 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -397,7 +397,7 @@ typedef struct { u32 set_bar_attributes; u64 romsize; u32 romimage; -} efi_pci_io_protocol_32; +} efi_pci_io_protocol_32_t; typedef struct { u64 poll_mem; @@ -417,7 +417,7 @@ typedef struct { u64 set_bar_attributes; u64 romsize; u64 romimage; -} efi_pci_io_protocol_64; +} efi_pci_io_protocol_64_t; typedef struct { void *poll_mem; @@ -437,7 +437,7 @@ typedef struct { void *set_bar_attributes; uint64_t romsize; void *romimage; -} efi_pci_io_protocol; +} efi_pci_io_protocol_t; #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 From patchwork Fri May 4 06:00:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134946 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437222lji; Thu, 3 May 2018 23:01:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLr8HkwXYNt1q/NT2oUD8bHl6wL35r4yowX/WV9Cnx3lraF9gdUc9PTSnfsCEX+NljaiVg X-Received: by 2002:a17:902:784c:: with SMTP id e12-v6mr14825913pln.60.1525413699074; Thu, 03 May 2018 23:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413699; cv=none; d=google.com; s=arc-20160816; b=pBenqdG5VXS48CjbYBQF+jrUXiOtR16gA3xwHDR/kYltXv3uSmG/QcQm4a4MmyVfh5 sEnikZ+JfEEuLtc+knpQBX8njaw8IyjDoCwpwVZLpmxudVRRYhKb0DvZisU7+nR2DpAO hLDLVMENI4BCH8nS3SJulfI6yrKniKR5s0FC6jjnKl4iM6CvRnpjbF5/cWnDuLUU5Kq1 fxe5TaUZMOA1Nr/c+NXBa7JP0sETGDpdlYpVemBmX2PpD2/7czyqvDje5MBNUYzkfc7F /BuTz/slGmQnbjn3dZjycZcI4ejTkuXbg6Fbi+G4npGveIO1/sZTs0JjoGS8YyZNZ9pA mfmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3VOyyaPz5dqEYq5DBPkF4AI2EW707wdSPFitILkebtE=; b=UWSo0aWpnwLNItgjZ/2Dx3OMPfv1wx89vzwpI/4KyLIXTobiVAv+wCbdBaOQ10eIut qvnzkv6KTKHcbM3sMu7MhpURdP06R6fge1kMqBIwardOgH0GoUKvfsH9wZRx6ekjdD/s wColscZR19R5EK6Jjt9BH16+1mxOms94x8MZN0BwA+ovXtmwTG82pMtYEGWjth26yKgs GJNmI9Nih9gQyPN/pucmSxb9ubrlp6WSY2Ktd126jJmbkL6KFZjOdz7zGEcovwvxs2EK aqchhG0f2zkyuq6jS0ZOEaalYNxUgKcMV90ajOmuSTNMz84zq2uivGZvfZcKup2G8fwc G9BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bZriFtyh; 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 h8si2812110pfh.278.2018.05.03.23.01.38; Thu, 03 May 2018 23:01:39 -0700 (PDT) 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=bZriFtyh; 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 S1751799AbeEDGBe (ORCPT + 29 others); Fri, 4 May 2018 02:01:34 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:44465 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751689AbeEDGB3 (ORCPT ); Fri, 4 May 2018 02:01:29 -0400 Received: by mail-wr0-f193.google.com with SMTP id y15-v6so8040031wrg.11 for ; Thu, 03 May 2018 23:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3VOyyaPz5dqEYq5DBPkF4AI2EW707wdSPFitILkebtE=; b=bZriFtyhSR325nyXvIsSZVIqlvA93hpLE1NNYdT2SzDqvlX8dhB9QgcQGJye/u7zAk IAzT0iOd8BBSr+jAXGQgKN8AstGYjKMC1qpwckV5EMsdxoCfW1MykvSqD52TImGQuCK3 bIlfnazaX9gXqDjbzLKLawU4tTSmd9aTicFek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3VOyyaPz5dqEYq5DBPkF4AI2EW707wdSPFitILkebtE=; b=OC4tb4mVj17+YNbntx6oYVNG78SIfhMq4fAYl+tHd1BNEQHLNqRgKzEEmekWNpSBfu FK0mMBB2N4G4us/SjGZAOr4PfPXx+bCS+1u/Kh5bZ3er058AToX2WY4sucs2Mnu4EzBR kjJKcCWguiME+w/J+nf5jPNfmsBGEY8oq57hUxtTj/l+oWRgDh//VtwDoStlBn7PwN/N UZrBx9Q3fqonJ9Rf12OtqRN+k8krGJNCoydsvUoXahh6iXI2IAVTCNaVphMzj3kdU/Dg 4Nkx+d6DPDpu5NATFf+Q6/1otNS/vHi0rBrBDiR7phnXZD8irHKtVfuw+Cbqq1XLmggt 8Vkg== X-Gm-Message-State: ALQs6tDVjlbcdI+6SL6VzGubzIZ4Jt++mPL3JzQ0yNJFn1ErA6TKJi3h JxXaHjI+kXAPa8iLXRmORoQqqw== X-Received: by 2002:adf:e791:: with SMTP id n17-v6mr20490109wrm.225.1525413688514; Thu, 03 May 2018 23:01:28 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:27 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 14/17] efi/x86: fold __setup_efi_pci32 and __setup_efi_pci64 into one Date: Fri, 4 May 2018 08:00:00 +0200 Message-Id: <20180504060003.19618-15-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As suggested by Lukas, use his efi_call_proto() and efi_table_attr() macros to merge __setup_efi_pci32() and __setup_efi_pci64() into a single function, removing the need to duplicate changes made in subsequent patches across both. Cc: Lukas Wunner Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 107 ++++++++----------------------- 1 file changed, 25 insertions(+), 82 deletions(-) -- 2.17.0 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 3994f48c4043..dadf32312082 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -109,23 +109,27 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) } static efi_status_t -__setup_efi_pci32(efi_pci_io_protocol_32_t *pci, struct pci_setup_rom **__rom) +__setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) { struct pci_setup_rom *rom = NULL; efi_status_t status; unsigned long size; - uint64_t attributes; + uint64_t attributes, romsize; + void *romimage; - status = efi_early->call(pci->attributes, pci, - EfiPciIoAttributeOperationGet, 0, 0, - &attributes); + status = efi_call_proto(efi_pci_io_protocol, attributes, pci, + EfiPciIoAttributeOperationGet, 0, 0, + &attributes); if (status != EFI_SUCCESS) return status; - if (!pci->romimage || !pci->romsize) + romimage = (void *)(unsigned long)efi_table_attr(efi_pci_io_protocol, + romimage, pci); + romsize = efi_table_attr(efi_pci_io_protocol, romsize, pci); + if (!romimage || !romsize) return EFI_INVALID_PARAMETER; - size = pci->romsize + sizeof(*rom); + size = romsize + sizeof(*rom); status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom); if (status != EFI_SUCCESS) { @@ -141,30 +145,32 @@ __setup_efi_pci32(efi_pci_io_protocol_32_t *pci, struct pci_setup_rom **__rom) rom->pcilen = pci->romsize; *__rom = rom; - status = efi_early->call(pci->pci.read, pci, EfiPciIoWidthUint16, - PCI_VENDOR_ID, 1, &(rom->vendor)); + status = efi_call_proto(efi_pci_io_protocol, pci.read, pci, + EfiPciIoWidthUint16, PCI_VENDOR_ID, 1, + &rom->vendor); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to read rom->vendor\n"); goto free_struct; } - status = efi_early->call(pci->pci.read, pci, EfiPciIoWidthUint16, - PCI_DEVICE_ID, 1, &(rom->devid)); + status = efi_call_proto(efi_pci_io_protocol, pci.read, pci, + EfiPciIoWidthUint16, PCI_DEVICE_ID, 1, + &rom->devid); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to read rom->devid\n"); goto free_struct; } - status = efi_early->call(pci->get_location, pci, &(rom->segment), - &(rom->bus), &(rom->device), &(rom->function)); + status = efi_call_proto(efi_pci_io_protocol, get_location, pci, + &rom->segment, &rom->bus, &rom->device, + &rom->function); if (status != EFI_SUCCESS) goto free_struct; - memcpy(rom->romdata, (void *)(unsigned long)pci->romimage, - pci->romsize); + memcpy(rom->romdata, romimage, romsize); return status; free_struct: @@ -176,7 +182,7 @@ static void setup_efi_pci32(struct boot_params *params, void **pci_handle, unsigned long size) { - efi_pci_io_protocol_32_t *pci = NULL; + efi_pci_io_protocol_t *pci = NULL; efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; u32 *handles = (u32 *)(unsigned long)pci_handle; efi_status_t status; @@ -203,7 +209,7 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle, if (!pci) continue; - status = __setup_efi_pci32(pci, &rom); + status = __setup_efi_pci(pci, &rom); if (status != EFI_SUCCESS) continue; @@ -217,74 +223,11 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle, } } -static efi_status_t -__setup_efi_pci64(efi_pci_io_protocol_64_t *pci, struct pci_setup_rom **__rom) -{ - struct pci_setup_rom *rom; - efi_status_t status; - unsigned long size; - uint64_t attributes; - - status = efi_early->call(pci->attributes, pci, - EfiPciIoAttributeOperationGet, 0, - &attributes); - if (status != EFI_SUCCESS) - return status; - - if (!pci->romimage || !pci->romsize) - return EFI_INVALID_PARAMETER; - - size = pci->romsize + sizeof(*rom); - - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to alloc mem for rom\n"); - return status; - } - - rom->data.type = SETUP_PCI; - rom->data.len = size - sizeof(struct setup_data); - rom->data.next = 0; - rom->pcilen = pci->romsize; - *__rom = rom; - - status = efi_early->call(pci->pci.read, pci, EfiPciIoWidthUint16, - PCI_VENDOR_ID, 1, &(rom->vendor)); - - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to read rom->vendor\n"); - goto free_struct; - } - - status = efi_early->call(pci->pci.read, pci, EfiPciIoWidthUint16, - PCI_DEVICE_ID, 1, &(rom->devid)); - - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to read rom->devid\n"); - goto free_struct; - } - - status = efi_early->call(pci->get_location, pci, &(rom->segment), - &(rom->bus), &(rom->device), &(rom->function)); - - if (status != EFI_SUCCESS) - goto free_struct; - - memcpy(rom->romdata, (void *)(unsigned long)pci->romimage, - pci->romsize); - return status; - -free_struct: - efi_call_early(free_pool, rom); - return status; - -} - static void setup_efi_pci64(struct boot_params *params, void **pci_handle, unsigned long size) { - efi_pci_io_protocol_64_t *pci = NULL; + efi_pci_io_protocol_t *pci = NULL; efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; u64 *handles = (u64 *)(unsigned long)pci_handle; efi_status_t status; @@ -311,7 +254,7 @@ setup_efi_pci64(struct boot_params *params, void **pci_handle, if (!pci) continue; - status = __setup_efi_pci64(pci, &rom); + status = __setup_efi_pci(pci, &rom); if (status != EFI_SUCCESS) continue; From patchwork Fri May 4 06:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134947 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437277lji; Thu, 3 May 2018 23:01:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJmHNeQfdwOrQsmd7486NtA6seGViHLqeA0mvgQa4XOedu0bq1TGWbdRFD5kqt5Jkt2+aX X-Received: by 2002:a17:902:b60b:: with SMTP id b11-v6mr27052616pls.330.1525413702636; Thu, 03 May 2018 23:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413702; cv=none; d=google.com; s=arc-20160816; b=aJjeEii1sXw577oXwHe+4rtYuApaCnc95j4f0fHxtRUvGFY6xWijK93WnCWLvOPruB zbEpDV4zkbeNbEZshPtencKHqZ7RFHYzkmQdSyb2COuANDnep449ZcxuQjTTnOrCZYa/ D/OBkQMWrJaWFAdwfGYZ6NY8UyuUlOGDutXA1xqSHbol5eivsrXFb4KdTPQGOJX+TZhb W0UhtPCKxsAQuV18FMVW+4oX8fMo8CfZ3Aqim3Mrf9Il2JL2LMdBkOjKbBFNPUotE3a9 bBFiBHSX6Bg+eGLqW+OYBfNaERpyDFVUaPdoDC7LpCAGBKX53oiaj/5L992Wge8HE2Qt ccfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=AZ5hyy40YGjqulOkQ5yIunn8gsGWJdq/3zDTIgupWmU=; b=sjjCWViKj0y0ctXky40fHjcHzWhE6oKOv6jxfYa9KTkaalVT/eYB7Fx3AnhlGkCYdP 2jSyP4HKbcRJuXkpNbwPMc7ZNEa76SMmlUHickQOFfSx9itmgwg07MU3B2c79luzDkpg a+rA9WhEEIhMsPlxZOqGHue87ocDRkZt2UXcQMeF+IqU6Z/iyqeL8QFKCWpZOld/4los PNq1ss7LgORbgsTTGwqD9RTQqyR0d1ac0YUH9rzDvn33J5j4xLkt1LaCHQe7Rq60j22q +dO3REFhKL6HWq654Jrr5XxqGGHKtpovHkBgViYEyuxANWMvAqxbR9rX/57EPVgpuJ0I wn6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbGPvaVe; 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 m2-v6si12958816pgm.360.2018.05.03.23.01.42; Thu, 03 May 2018 23:01:42 -0700 (PDT) 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=SbGPvaVe; 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 S1751821AbeEDGBj (ORCPT + 29 others); Fri, 4 May 2018 02:01:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53552 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751742AbeEDGBf (ORCPT ); Fri, 4 May 2018 02:01:35 -0400 Received: by mail-wm0-f66.google.com with SMTP id a67so2189787wmf.3 for ; Thu, 03 May 2018 23:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AZ5hyy40YGjqulOkQ5yIunn8gsGWJdq/3zDTIgupWmU=; b=SbGPvaVemhJYNIsOtCpZVVHeLp1bFj/nWP4zyBv3D/ILB0DrsOJhRUx2yT+1/6cEHn gda0MhYh6E48mzZ1jH3lYDqCc9FhqHKrS3D5T4Po+gKJkaNUnEUUUqOgM3YYXmS7HxHg GCGzpK27ymRJaGfOPIxf6ND3XBlrJNuw7+/dg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AZ5hyy40YGjqulOkQ5yIunn8gsGWJdq/3zDTIgupWmU=; b=Rsf3X3qQhoUtpkKBRUfeAFKV0Tl66t2zugrSnpVblXFkw2w6QOMifGT8fU2kuEWipL ymV7LS30cockrIgycAc9elp/z2LvwbZI5k1b5QOcBq7YM1PGahdP7EsSyLxDfqo1bNXB e1MFVvFI6u6wZMr0YtzruaatSo9or9IhrjlE5yjTRBfNIUDfrBI/Itkeo9zeOX5Gw1gc 29rQN2z8eJMsP4WeRQ9TVG6pt41N3U2RyD1bZC3sKV1Qi1z3G/4B2PGLh7aOTi8rXXtm ilSBgK5rso/J04iSiwPcXrb4jouVPff3Wic6Vo9a5P3ITRa29N8dPPn0n/XyB0TvBBQM zTkg== X-Gm-Message-State: ALQs6tC4LtkptGSmV89fiIR8A45nHiDXyrjERcm45f7UCA8+1/Hoxaou GZG96jHEVeIKRB1aVMmnHF6hUA== X-Received: by 10.28.18.71 with SMTP id 68mr15440975wms.74.1525413694524; Thu, 03 May 2018 23:01:34 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:33 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Mark Rutland , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 17/17] efi/libstub/arm64: handle randomized TEXT_OFFSET Date: Fri, 4 May 2018 08:00:03 +0200 Message-Id: <20180504060003.19618-18-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland When CONFIG_RANDOMIZE_TEXT_OFFSET is selected, TEXT_OFFSET is an arbitrary multiple of PAGE_SIZE in the interval [0, 2MB). The EFI stub does not account for the potential misalignment of TEXT_OFFSET relative to EFI_KIMG_ALIGN, and produces a randomized physical offset which is always a round multiple of EFI_KIMG_ALIGN. This may result in statically allocated objects whose alignment exceeds PAGE_SIZE to appear misaligned in memory. This has been observed to result in spurious stack overflow reports and failure to make use of the IRQ stacks, and theoretically could result in a number of other issues. We can OR in the low bits of TEXT_OFFSET to ensure that we have the necessary offset (and hence preserve the misalignment of TEXT_OFFSET relative to EFI_KIMG_ALIGN), so let's do that. Fixes: 6f26b3671184c36d ("arm64: kaslr: increase randomization granularity") Cc: # v4.7+ Reported-by: Kim Phillips Signed-off-by: Mark Rutland Tested-by: Kim Phillips [ardb: clarify commit log] Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/arm64-stub.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.17.0 diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c index b9bd827caa22..541b82fdc8a2 100644 --- a/drivers/firmware/efi/libstub/arm64-stub.c +++ b/drivers/firmware/efi/libstub/arm64-stub.c @@ -97,6 +97,13 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg, u32 offset = !IS_ENABLED(CONFIG_DEBUG_ALIGN_RODATA) ? (phys_seed >> 32) & mask : TEXT_OFFSET; + /* + * With CONFIG_RANDOMIZE_TEXT_OFFSET, TEXT_OFFSET may not be a + * multiple of EFI_KIMG_ALIGN, and we must ensure that we apply + * the offset below EFI_KIMG_ALIGN. + */ + offset |= (TEXT_OFFSET % EFI_KIMG_ALIGN); + /* * If KASLR is enabled, and we have some randomness available, * locate the kernel at a randomized offset in physical memory.