From patchwork Fri Jun 2 13:51:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101253 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp204862obc; Fri, 2 Jun 2017 06:54:58 -0700 (PDT) X-Received: by 10.99.113.78 with SMTP id b14mr7295772pgn.229.1496411698376; Fri, 02 Jun 2017 06:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411698; cv=none; d=google.com; s=arc-20160816; b=Kq8623RqQouwSP60g5JFy4a4U1OW+EqgeIsKaFdaxgvgEKPuCgmDtmbGDe2Spkagss eiO8a2gN/34icq5b8qjBS3ZbVpZ6ebTBdHD3x82jchFiX+TK/cfUw814n/qmUzSq/xYL nXQDWdJDq2K7q8e0yg3Tt0qkuaAJd9uUvrhRCapTVymb4scfX9ElOrP9ZThZaiyqUE1o Wm1KrYDpSNhxkrDjCABV6AYU0Fv15rLuySkPc0wSR3BxTgNNX77nw5ydzrdsX0Rdqj/M nJL6FXBeKWiLyViSOgCgkT5oMHQAs6JgT7Q424a+DuWETUEsgUHEaWD4pOPJ0BIV0aV3 eQQg== 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=Cxt9fM5mu6VSRL7FGE9yuct9/YyykkF5vTTr1LM6Y8Q=; b=lDT9xLyzK26Zokdi277oW9yKN5VwQiXkAkExs6tq8imOnZ6VC4rZuDt2o7Qu+Tf2jx KO9HjepKG8teIAuaLfWJfeaK8vw6SZ2w5Ucrbi+Nf64biWQCxFaW9OcJrwdzTcQ+KO4U Qi4O+NIM3QqvIJ1oUT1rqI+oGyxZBNdjrMAkAqJSD4nsoW+dVqb2y4QzdqykBaMKJ5I6 gFcZC3HmPRaxb2qTdLeJMEsAQYgxIfm3wbuVb+a9bnrSBaMa9qu/EkBTUBvLkwy5DVyE eu0uXTGq0z1QWIPr+vB9LAZer37ggnYfh7VDciH5JAoB2lnah5hebxuS6jKP5FEV9Acq lqmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 1si22752624pgu.95.2017.06.02.06.54.58; Fri, 02 Jun 2017 06:54:58 -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; 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 S1751475AbdFBNyt (ORCPT + 25 others); Fri, 2 Jun 2017 09:54:49 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38447 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbdFBNyq (ORCPT ); Fri, 2 Jun 2017 09:54:46 -0400 Received: by mail-wm0-f53.google.com with SMTP id n195so27626763wmg.1 for ; Fri, 02 Jun 2017 06:54:46 -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=Cxt9fM5mu6VSRL7FGE9yuct9/YyykkF5vTTr1LM6Y8Q=; b=iQM5LkOZB3P5+G+O8wwBWV1HEVhpFMraf3SAcKyz1r4ovIDn3qdY0eYKbhFHpT4L10 6kEGjYj12fFnxj1SjtWVfU0qGctaOJKc6qR4DRdZmeRvC4xBj5YLIjUJ1ob8iVnfRfUg wpia4ueU876G1QvyeBCAo6KTXRU04Hzh1JTLc= 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=Cxt9fM5mu6VSRL7FGE9yuct9/YyykkF5vTTr1LM6Y8Q=; b=WWlbLThga8/K4t9uNPoktqyUix4eYLqXvB7vszqXCHgyx5Tt0Yf9VRcZlNDgLzIZjv 46xz5xAXHsIU5q8pIe5o6FGLcqvkwToSqFfdFuoSTgc5dTBmKTxCK+Z8ViSHKRfu1KZi rwGepQA9ST6MvD1TnnciXhaE0m80SSqgrHqLRp7dlW5NQgFFcy1PYpL4OLYeINXw0svp gW44AiVYHHuKsEM/QxcsM8PfnOiESW8+3Rbq9T+hHzKaAmNOfb+NQK1mgb6tKalMNUyy hgXdXud3wl21dV1Z6GDeYaAqRj+tuTnhaNySR/laka1moC3iZpSXoVsLHF047h0J+iZ0 V79w== X-Gm-Message-State: AODbwcA/u3DcrfmA9288k7PIh0OmuD29zxZ4jfNfdMBB/7q0EiMf5iX6 yi6Jmpb0TDwoqpG5FNaWpg== X-Received: by 10.80.143.5 with SMTP id 5mr6247272edy.68.1496411685367; Fri, 02 Jun 2017 06:54:45 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.54.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:54:44 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Kiszka , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 02/13] efi/capsule: Fix return code on failing kmap/vmap Date: Fri, 2 Jun 2017 13:51:56 +0000 Message-Id: <20170602135207.21708-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-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: Jan Kiszka If kmap or vmap fail, it means we ran out of memory. There are no user-provided addressed involved that would justify EFAULT. Signed-off-by: Jan Kiszka Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 9ae6c116c474..91e91f7a8807 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -113,7 +113,7 @@ static ssize_t efi_capsule_submit_update(struct capsule_info *cap_info) VM_MAP, PAGE_KERNEL); if (!cap_hdr_temp) { pr_debug("%s: vmap() failed\n", __func__); - return -EFAULT; + return -ENOMEM; } ret = efi_capsule_update(cap_hdr_temp, cap_info->pages); @@ -185,7 +185,7 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, kbuff = kmap(page); if (!kbuff) { pr_debug("%s: kmap() failed\n", __func__); - ret = -EFAULT; + ret = -ENOMEM; goto failed; } kbuff += PAGE_SIZE - cap_info->page_bytes_remain; From patchwork Fri Jun 2 13:51:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101254 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp204866obc; Fri, 2 Jun 2017 06:54:58 -0700 (PDT) X-Received: by 10.84.215.23 with SMTP id k23mr52343pli.104.1496411698797; Fri, 02 Jun 2017 06:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411698; cv=none; d=google.com; s=arc-20160816; b=Szs23r6gmeCqx6tHf13HBtcPMiwVy3wv9mEqGQmFXwk6h/SiMIG87tw9YgZ0Ui0WQ+ RdzlspAGive1vsjV385b6FexXd97f9bSZGy0jPGLhE9WGKiUAIIQlezVb1wBuQdvcfec QI1Fcl23RM+NrON2PjTwWjG9O/PxSxTjmAMjI2jNpRsNaz/p1Ju39EnPleU8aURQ8hTd 2oOwWsndoL/SOZHHxyp/cq3Zjvlr1touTu4aZh92IDHw3Z09VEhkx6ekMU0WwRxIpjeT /ZVLHbhZ7dxqJPeQ9dylg0qEEwF7w/WqZazYNk58OMen1Vq0Gjnn2kGkXgRWNf21BONb u4NQ== 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=8Ar+FbdcuizBc2IKWTdd3fAv+3NWr2PFEuz8pC07ha0=; b=BPFyjNs13fdFLfpaOZwGe0giAVxRQhnScwzSZAl4rKMZ5GMjf0hQAGrNrtlcwI/vky CsgkTmPel6acF4y8hACJwxNDrApOHmy7Q6AOvjPG7SO0hjD3dVG+DHCn6fwGFdE7umgf jjC/bXOevzBUpk1v4v2Nxz3ub5pB8pbp2CDhqQpS/9WgmNNP/RFrMFp/VsT9jTKiaVA2 1kVp3F56DqFKabZx/kD3maL3slOL7FoZpHJU5E7XonDm/u6QTy/nJfLbltmZqiDFDoQc TBXUirjqYvKhqfCBidGzLp6/F9EXX2opg0M1qBvlBdfXaz9dcZGTXT5wgPMpAoLI2T3M eC7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 1si22752624pgu.95.2017.06.02.06.54.58; Fri, 02 Jun 2017 06:54:58 -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; 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 S1751514AbdFBNyy (ORCPT + 25 others); Fri, 2 Jun 2017 09:54:54 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:37008 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbdFBNyv (ORCPT ); Fri, 2 Jun 2017 09:54:51 -0400 Received: by mail-wm0-f43.google.com with SMTP id d127so27562486wmf.0 for ; Fri, 02 Jun 2017 06:54:51 -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=8Ar+FbdcuizBc2IKWTdd3fAv+3NWr2PFEuz8pC07ha0=; b=evG3WjaGCGCUc6jnsmQW2Lc4EFsGkEYbmSXcxbgfxoarlsxzgXLQmtXHnM/BYcY5XX IBV6MlkACeZ8EzWqTUdp0N5XTA4hYeDngLTVPORTIdPQ4UBimY6lmGf8/Km3nn0dOHtE HURTS8v424oOnNtppCxfOCFH5yzP1IPnPIrd8= 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=8Ar+FbdcuizBc2IKWTdd3fAv+3NWr2PFEuz8pC07ha0=; b=YTkCThmbpxmklhEtl3JDoKwAZpfJo81m28um42nmBHD3afYuExjJp5ZwJtfRXg29Yn IOmtHHxAmbj3oDc7vVBp9nsLZ6Sou/VIV9ArMHcqymzI4w9LrtrWlz55VWQZthaVplat oVNddyRl57w8rHEgn5iCzwuSyYCdjqO8WlaKZ5uCwGbOQ31VCj1jrtUUWqkgOBURauSx 7EIDEnxDQi03WaGbevF4pEULfw/bdxzvh5+Rc8JKafALfWFPbV/5r7CbLj6+YMpT+7ph n8eTAUp5HTw7eganbR4+RZvHy31h7DjsBaS8w5d7iSlLl9OIDUV3OyZPpy8NdMVuAh81 ThGQ== X-Gm-Message-State: AODbwcAhSg7OSAtg+DtNAn3DD27BSsbpp+kCj3Pq1mD0nUo3Mw42DOrU i3P2lzmDmmdQhfaJ X-Received: by 10.80.183.4 with SMTP id g4mr6140100ede.138.1496411690619; Fri, 02 Jun 2017 06:54:50 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.54.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:54:49 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Kiszka , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 04/13] efi/capsule: Clean up pr_err/info messages Date: Fri, 2 Jun 2017 13:51:58 +0000 Message-Id: <20170602135207.21708-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-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: Jan Kiszka Avoid __func__, improve the information provided by some of the messages. Signed-off-by: Jan Kiszka Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 7b57dda2417d..3fb91e1597a9 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -70,7 +70,7 @@ static ssize_t efi_capsule_setup_info(struct capsule_info *cap_info, pages_needed = ALIGN(cap_hdr->imagesize, PAGE_SIZE) >> PAGE_SHIFT; if (pages_needed == 0) { - pr_err("%s: pages count invalid\n", __func__); + pr_err("invalid capsule size"); return -EINVAL; } @@ -79,8 +79,7 @@ static ssize_t efi_capsule_setup_info(struct capsule_info *cap_info, cap_hdr->imagesize, &cap_info->reset_type); if (ret) { - pr_err("%s: efi_capsule_supported() failed\n", - __func__); + pr_err("capsule not supported\n"); return ret; } @@ -115,14 +114,14 @@ static ssize_t efi_capsule_submit_update(struct capsule_info *cap_info) ret = efi_capsule_update(cap_hdr_temp, cap_info->pages); vunmap(cap_hdr_temp); if (ret) { - pr_err("%s: efi_capsule_update() failed\n", __func__); + pr_err("capsule update failed\n"); return ret; } /* Indicate capsule binary uploading is done */ cap_info->index = NO_FURTHER_WRITE_ACTION; - pr_info("%s: Successfully upload capsule file with reboot type '%s'\n", - __func__, !cap_info->reset_type ? "RESET_COLD" : + pr_info("Successfully upload capsule file with reboot type '%s'\n", + !cap_info->reset_type ? "RESET_COLD" : cap_info->reset_type == 1 ? "RESET_WARM" : "RESET_SHUTDOWN"); return 0; @@ -207,8 +206,7 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, if (cap_info->header_obtained && cap_info->count >= cap_info->total_size) { if (cap_info->count > cap_info->total_size) { - pr_err("%s: upload size exceeded header defined size\n", - __func__); + pr_err("capsule upload size exceeded header defined size\n"); ret = -EINVAL; goto failed; } @@ -242,7 +240,7 @@ static int efi_capsule_flush(struct file *file, fl_owner_t id) struct capsule_info *cap_info = file->private_data; if (cap_info->index > 0) { - pr_err("%s: capsule upload not complete\n", __func__); + pr_err("capsule upload not complete\n"); efi_free_all_buff_pages(cap_info); ret = -ECANCELED; } @@ -321,8 +319,7 @@ static int __init efi_capsule_loader_init(void) ret = misc_register(&efi_capsule_misc); if (ret) - pr_err("%s: Failed to register misc char file note\n", - __func__); + pr_err("Unable to register capsule loader device\n"); return ret; } From patchwork Fri Jun 2 13:51:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101263 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205666obc; Fri, 2 Jun 2017 06:56:56 -0700 (PDT) X-Received: by 10.99.110.200 with SMTP id j191mr7457614pgc.236.1496411816853; Fri, 02 Jun 2017 06:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411816; cv=none; d=google.com; s=arc-20160816; b=Mo175r7+jLwd/B+0giu6jVF9Uy7mJBQvL+kTkJTiXZxJ0nBzhMGD6EwvO0BMpxjhFA MI4oYPVFc3GajTTZUWCny98YTaVKg8Om7A2nHReN71nmj+txD39Fh2W3RN35bPG9WvhE xol5F9NTHIYsrYs3mXJW3xXwf3FmBnRw76pSkKh5Xp999dijnVuU0hqNB5aavYz9JKnq 2AQH1UxXkOK2y8sjG3fKLTAv+DohFZqRtvQ9yo0tIMIPZadqL3bnMJERmnU6RHARikkk uy7Fvw8I3gNJlmMEEF1oAjbFe6qE6XFQQCFjQ4EtqQlIcPxN/48ajKOK7WNN5YMGD/go ckYA== 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=2LfVTPeOrblzGbTjlO4HcIL3boRxuUszk2cnXb9B+dg=; b=taYoN60VUbudkXSIF/uwjU+qUMPn7DCzi5FnCW/vF2ejaGfP6Mi0XfpH8jHYYxzwqj xcI4MpAsutUTYLxDnyVqX4Iog4NaeWbLnnnNmXripPWZIRyb5bz+hHSqJBxaKaoDJ6CA filkMQL4jGCaAXALfxx26rJTNu68eiCvMmbvSAFDdDuYrcGPJQMJquB6QpbJncOEYAf0 bT5AnWLT4hwUul9l8X3iBLxBOsmi/qUhIn87rRD0VeA7u1TGOa/oPkG6tmUK7tRAnS9K NBEBEWAzALWRxFN0OXZwwmsCfhvl4XaubdqTYecnUkN8MTQPcW38dmvgj+1LGT4gOS0S l0Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 q14si22581286pgc.97.2017.06.02.06.56.56; Fri, 02 Jun 2017 06:56:56 -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; 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 S1751735AbdFBN4R (ORCPT + 25 others); Fri, 2 Jun 2017 09:56:17 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:34964 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbdFBNzJ (ORCPT ); Fri, 2 Jun 2017 09:55:09 -0400 Received: by mail-wm0-f49.google.com with SMTP id b84so26394524wmh.0 for ; Fri, 02 Jun 2017 06:55:03 -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=2LfVTPeOrblzGbTjlO4HcIL3boRxuUszk2cnXb9B+dg=; b=PhE8kzfrDQcwBORfNXDzNXSMej3pUHB4Znc3KsKGHEjgmrSrQVKGQ3VcY5r2Fog/Lf h5Ot3JWFsu2vf8IhXhhyBizLT8gloItHMUwDwq4jExE0cpiwHYMU14W0lHZR4MI2id4r z6MZJD3dQfi51LYg6PzZmb9okdh9io6LF0vok= 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=2LfVTPeOrblzGbTjlO4HcIL3boRxuUszk2cnXb9B+dg=; b=qSk8dPpZEGEsshvjy8lP7jhSzeGmMawom5jZDjY/VGYJlc1r7SVM7UZSL/FTrvV87v f1uLSP9LMxuFmK9AWwFnRpF9AIJioUuNP0kAx3ybnyO1GoS1NpUtBvB94rWyjPCB3YDk ZCahJj60U3YhfgBUW9mm875Nxpt2M5huElwnrTMUwFi92tJmLMrEUI/MkqQo7vto1//h tNMz1OkuywMBfN5LTG3T+g3vMNdyIhXe54fP79VZ4iJk7kmPfEAArhFBb1ekU6KrcZRD bK/vxcadXvu7PnIKHLCf1LJK8FFn1wBHEhnm9EMAqmzt+QSw+osY2J+rBTKdGkuVeI2O ZQIg== X-Gm-Message-State: AODbwcCx79TZa2JPsGmF70B4wwCGVPQ7Nc6Ybu1GQEHGzZzMWrfVN6fV hT+b55otkGHL0yd7 X-Received: by 10.80.131.135 with SMTP id 7mr6075779edi.14.1496411692686; Fri, 02 Jun 2017 06:54:52 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.54.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:54:51 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Kiszka , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 05/13] efi/capsule: Adjust return type of efi_capsule_setup_info Date: Fri, 2 Jun 2017 13:51:59 +0000 Message-Id: <20170602135207.21708-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-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: Jan Kiszka We actually expect int at the caller and never return any size information. Signed-off-by: Jan Kiszka Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 3fb91e1597a9..37d3f6ec2d28 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -53,8 +53,8 @@ static void efi_free_all_buff_pages(struct capsule_info *cap_info) * @kbuff: a mapped first page buffer pointer * @hdr_bytes: the total received number of bytes for efi header **/ -static ssize_t efi_capsule_setup_info(struct capsule_info *cap_info, - void *kbuff, size_t hdr_bytes) +static int efi_capsule_setup_info(struct capsule_info *cap_info, + void *kbuff, size_t hdr_bytes) { efi_capsule_header_t *cap_hdr; size_t pages_needed; From patchwork Fri Jun 2 13:52:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101255 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp204895obc; Fri, 2 Jun 2017 06:55:04 -0700 (PDT) X-Received: by 10.99.114.72 with SMTP id c8mr7239730pgn.81.1496411703835; Fri, 02 Jun 2017 06:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411703; cv=none; d=google.com; s=arc-20160816; b=YmGj4Q1lHuHEBe98n/vGNmivdzAnzm2+MYsHZeoHNZb8P0S9sYVyu+J6Q7OuwUxZSR nPa2SqKI+51mI/BUxDAgL+oDSS7anCSzVa0ZGFVzpNzK9DNxmUkzHger6qM6NMO5+1m1 FDpp2LvQJ6/OgfT2eTNHPyZkrb3Mt+c2C2zvKXNXCmWbuWIOEnd8z8dWSFxpghzBfKWo w/7JiU+Xpi2Clr1QpYMN3lApcmZhmQgVu3+CUUnlXvZQe3IPINXeZK52nfIqZgrqarYv 9+52iizWboYEHuLOXgUtEuTsy4+zLaPufVDsW+joPL2IK/CSMahzfKVnlWSQ/84jWcR2 wV7A== 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=Hd3YQfQri7NEPN/Fl8JuahJQ8MZF8/5qb1WE3WMOmZE=; b=qZOdIDBLBQJwuisvxdRhVH2M3mylyJq+NXwQyvF56KGuK9/8Syx+Np09ZK1W1pSC5t QqBM2RIWCdKzkssKghIKb/nZm/Utkuo6V6nadNa9BXikUqValRBEkbYyFCXZZ7ugftas dfXF9/UZwq2CFoyKk3meUxigFGbeUFjg8upCGJUjyrW2nQdVZNRBFJAJhRTbWo3IBQzo s+A6BoTxRCJy8g0oVoRatHaG9O0uyVSzKSTa3ik1iDA92zRcJbJoRnbqptfLwUqQ8Si5 KGO5iotQ+pv+yWItNkk0I/CrwrWYI2ZuLszZV+8qMMNi+cCapLv/uxBL0W/1/6jSDIIh Ekpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 3si960203pfj.110.2017.06.02.06.55.03; Fri, 02 Jun 2017 06:55:03 -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; 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 S1751538AbdFBNy7 (ORCPT + 25 others); Fri, 2 Jun 2017 09:54:59 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:36604 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbdFBNy4 (ORCPT ); Fri, 2 Jun 2017 09:54:56 -0400 Received: by mail-wm0-f48.google.com with SMTP id 7so26352931wmo.1 for ; Fri, 02 Jun 2017 06:54:55 -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=Hd3YQfQri7NEPN/Fl8JuahJQ8MZF8/5qb1WE3WMOmZE=; b=jDeEloT65cPSHxhT6O106WXqzNJ6iU8LK4l0CDBbbRdGZAbilfKbj6doox0zQhj8It AvY3jou5ZyJzZSq4jLCq8oErSsEIBetqMT0qEMEEgXjw10Kr2mkh7rsj+s+8VKi1/DZF kWT3ESfjPgir61ENARnLcoLi8NGp8kG4O1bkw= 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=Hd3YQfQri7NEPN/Fl8JuahJQ8MZF8/5qb1WE3WMOmZE=; b=dIRdouKpPAMqxUHedcVj6OSZGKpjwBHKDG4UVAwDkA9yW76bTuLKdcyvh0h9C52TpF EZEZ8r/czdkLk0t+F/kkPW4+e8IPJla6bhYUKH2vUxxKMDx3Q9lKbqUupzDRruZnlo/C +1bYdwVg40WdNnVhG7Y0viiTSB9O54yU57NoP/FNToE4I2IaSIXkJacNAmRMSpmz5GVi YWHdpMyPYfAhBSUywMS5tjyRN6yMABQPQ2YL0W2G7bgqOZVuXMfyYjCZa5oWWU92AdF2 bb4LcfLRQtr3jsLt+YlO8220E63W9bSzqnnOAiNsZ4mNkMdjnaFWs+iByjLjeAWW2jFt 6Dlg== X-Gm-Message-State: AODbwcA4ZTZ4APBUcbIwuxJPSjnZE4yZP9x8oEmAOVy6i69ThyFwt/bO krGfcI3wMR5XJJUZ X-Received: by 10.80.144.118 with SMTP id z51mr6028941edz.143.1496411694958; Fri, 02 Jun 2017 06:54:54 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.54.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:54:54 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 06/13] efi/capsule-loader: Use a cached copy of the capsule header Date: Fri, 2 Jun 2017 13:52:00 +0000 Message-Id: <20170602135207.21708-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of kmapping the capsule data twice, copy the capsule header into the capsule info struct we keep locally. This is an improvement by itself, but will also enable handling of non-standard header formats more easily. Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 41 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 37d3f6ec2d28..5b012a467d7d 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -21,13 +21,13 @@ #define NO_FURTHER_WRITE_ACTION -1 struct capsule_info { - bool header_obtained; - int reset_type; - long index; - size_t count; - size_t total_size; - struct page **pages; - size_t page_bytes_remain; + efi_capsule_header_t header; + int reset_type; + long index; + size_t count; + size_t total_size; + struct page **pages; + size_t page_bytes_remain; }; /** @@ -56,7 +56,6 @@ static void efi_free_all_buff_pages(struct capsule_info *cap_info) static int efi_capsule_setup_info(struct capsule_info *cap_info, void *kbuff, size_t hdr_bytes) { - efi_capsule_header_t *cap_hdr; size_t pages_needed; int ret; void *temp_page; @@ -66,8 +65,9 @@ static int efi_capsule_setup_info(struct capsule_info *cap_info, return 0; /* Reset back to the correct offset of header */ - cap_hdr = kbuff - cap_info->count; - pages_needed = ALIGN(cap_hdr->imagesize, PAGE_SIZE) >> PAGE_SHIFT; + kbuff -= cap_info->count; + memcpy(&cap_info->header, kbuff, sizeof(cap_info->header)); + pages_needed = ALIGN(cap_info->header.imagesize, PAGE_SIZE) / PAGE_SIZE; if (pages_needed == 0) { pr_err("invalid capsule size"); @@ -75,15 +75,16 @@ static int efi_capsule_setup_info(struct capsule_info *cap_info, } /* Check if the capsule binary supported */ - ret = efi_capsule_supported(cap_hdr->guid, cap_hdr->flags, - cap_hdr->imagesize, + ret = efi_capsule_supported(cap_info->header.guid, + cap_info->header.flags, + cap_info->header.imagesize, &cap_info->reset_type); if (ret) { pr_err("capsule not supported\n"); return ret; } - cap_info->total_size = cap_hdr->imagesize; + cap_info->total_size = cap_info->header.imagesize; temp_page = krealloc(cap_info->pages, pages_needed * sizeof(void *), GFP_KERNEL | __GFP_ZERO); @@ -91,7 +92,6 @@ static int efi_capsule_setup_info(struct capsule_info *cap_info, return -ENOMEM; cap_info->pages = temp_page; - cap_info->header_obtained = true; return 0; } @@ -104,15 +104,8 @@ static int efi_capsule_setup_info(struct capsule_info *cap_info, static ssize_t efi_capsule_submit_update(struct capsule_info *cap_info) { int ret; - void *cap_hdr_temp; - cap_hdr_temp = vmap(cap_info->pages, cap_info->index, - VM_MAP, PAGE_KERNEL); - if (!cap_hdr_temp) - return -ENOMEM; - - ret = efi_capsule_update(cap_hdr_temp, cap_info->pages); - vunmap(cap_hdr_temp); + ret = efi_capsule_update(&cap_info->header, cap_info->pages); if (ret) { pr_err("capsule update failed\n"); return ret; @@ -192,7 +185,7 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, cap_info->page_bytes_remain -= write_byte; /* Setup capsule binary info structure */ - if (!cap_info->header_obtained) { + if (cap_info->header.headersize == 0) { ret = efi_capsule_setup_info(cap_info, kbuff, cap_info->count + write_byte); if (ret) @@ -203,7 +196,7 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, kunmap(page); /* Submit the full binary to efi_capsule_update() API */ - if (cap_info->header_obtained && + if (cap_info->header.headersize > 0 && cap_info->count >= cap_info->total_size) { if (cap_info->count > cap_info->total_size) { pr_err("capsule upload size exceeded header defined size\n"); From patchwork Fri Jun 2 13:52:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101256 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp204923obc; Fri, 2 Jun 2017 06:55:07 -0700 (PDT) X-Received: by 10.101.90.12 with SMTP id y12mr7548117pgs.226.1496411707448; Fri, 02 Jun 2017 06:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411707; cv=none; d=google.com; s=arc-20160816; b=gq9qfMY39amhOc4Z/OVcR01jgUc8sUoqe7mtVMSlTOQYCAe8EnEWthifT6Ap2vskw9 B21Vqvscn9gISvZyh/yjLXY7wAHvOS++Rak0tgo8plWpCqjTBNdSEW7vxrumDN44smHe TTsIj+PckyBl6yT3Pb2MzoOKJA8TvgXBQkMTqXEEKGD3+czpAkJha/ShfJHekDIFm/90 u8QPySHdThr3tPAWVXIjje2d2Zlw42dAS6gJ16gAXZOPmgwAtHrWqg7SDhWOsbICdgC5 /uXGf+fsLNpm0zYfbhe31CCcbprUdUySLLpBEk/UvsExbuvBHP15FjzPb4dM6hyDad7y OAuA== 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=IAkeNrXbWWnhCqVtzCIcH/U2l2WiXQJOywD/mRK4uQw=; b=J+Q3u9O3vy5CJiijDESdjkODOcNKfPlkm+An1A9NQIiBriJ14yStv65KdIBk0tKUMV 6+nffKeloYIuKcY3p4ENuPIwvh4jO8NOHeyJLOR3AmMtP8p0kHtdqonz6T+aWqwy72nK HoAvxW5AkAgxUBoDVWIxoxOCUpkKtlIZWtfV5vmqyk4uey44kv1fSkqY6F7fVnTIadiE di0jh/du7HiJ2OJHSmPIeulOHsw3onZJ39Rmqmb/MFoNqn/mZPrixfTk9jyYQFdg+BOU +7UsWxAZI54KDowmANiLto2Y8vtuFSzNxNNxybhgKZZiqTMsxYMkz6cy9QvluSo9WiVI 1+cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 e27si23536237pfj.41.2017.06.02.06.55.06; Fri, 02 Jun 2017 06:55:07 -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; 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 S1751558AbdFBNzD (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:03 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35010 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbdFBNy7 (ORCPT ); Fri, 2 Jun 2017 09:54:59 -0400 Received: by mail-wm0-f49.google.com with SMTP id b84so26396470wmh.0 for ; Fri, 02 Jun 2017 06:54:58 -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=IAkeNrXbWWnhCqVtzCIcH/U2l2WiXQJOywD/mRK4uQw=; b=bXZljOmQG/BvVPyil9EYtyou6lcDuMka7jWVx8AinFFaGSG1vTnucLlGyIqabYNGdK PeMbZGPXgDR6mLGxbJRkv8h69MF4Re4dVoIBG12ZQRvjBmACpTMk/DZ3rWXQAk9bkoRO pt7JW3b1mY12rRJc2BhcRLBs7tCJYR60/j++o= 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=IAkeNrXbWWnhCqVtzCIcH/U2l2WiXQJOywD/mRK4uQw=; b=Og+v8t+xdzC3P/OyaxN9HMruRQJ8afbBH5HNYa5Qk/gky4o+X3eyWb36TA3j9neXmh pUNh2Umv+OAe4KSZugHDY5qmSNXPxW9RCA3c9vIGRXBmOlXWphT8nU3G7+qlUKwQCZWh cPUXTIG76f0txQqh7nsLuzBzEhhFt/+BHWZgac+EUu3zOINlEbrzN2ibpqIg67HZKgif 7H6vZl0Rf5I3QxbopRfErD89apcqySDoVQtEQlHQCRlDttEOhApaG1AkckXMvWedDSwy pPcSaCkVsW6XM+nDMP5hDPeygEld/l05yW0CSub6CuOVwFiS/Zc/zNQasDjMXzVKWAJX 5+vQ== X-Gm-Message-State: AODbwcApZhVeI1I3or2pElrindi5Qj2VX835JUA6Pml2qcpxe7uJ3tek o6hg9aLzt3D+RUL1 X-Received: by 10.80.175.131 with SMTP id h3mr6052045edd.87.1496411697779; Fri, 02 Jun 2017 06:54:57 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.54.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:54:57 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Fabian Frederick , Ard Biesheuvel , linux-kernel@vger.kernel.org, Kweh Hock Leong , Matt Fleming Subject: [PATCH 07/13] efi/capsule: Remove NULL test on kmap() Date: Fri, 2 Jun 2017 13:52:01 +0000 Message-Id: <20170602135207.21708-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-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: Fabian Frederick kmap() can't fail. Signed-off-by: Fabian Frederick Cc: Ard Biesheuvel Cc: Kweh Hock Leong Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 4 ---- drivers/firmware/efi/capsule.c | 4 ---- 2 files changed, 8 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 5b012a467d7d..2357bcdcb44d 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -170,10 +170,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, page = cap_info->pages[cap_info->index - 1]; kbuff = kmap(page); - if (!kbuff) { - ret = -ENOMEM; - goto failed; - } kbuff += PAGE_SIZE - cap_info->page_bytes_remain; /* Copy capsule binary data from user space to kernel space buffer */ diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 6eedff45e6d7..e603ccf39d80 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -247,10 +247,6 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages) efi_capsule_block_desc_t *sglist; sglist = kmap(sg_pages[i]); - if (!sglist) { - rv = -ENOMEM; - goto out; - } for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) { u64 sz = min_t(u64, imagesize, PAGE_SIZE); From patchwork Fri Jun 2 13:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101258 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205132obc; Fri, 2 Jun 2017 06:55:41 -0700 (PDT) X-Received: by 10.84.217.222 with SMTP id d30mr56294plj.80.1496411741080; Fri, 02 Jun 2017 06:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411741; cv=none; d=google.com; s=arc-20160816; b=vxpxjCyg6thYfmo+0UjqmLwYr4af96MNfss2Us3Duz+RGMHguwXwwfYVkv0iiV42mM CQVBsyrB7qOnz0UTH7zIS7es0geBOl05weiDL84aJ/Y3NdpuNZtdwKi9xKQ0zfI59NDw 7UlvWQrbGvSWLJ9C7tq88ttBYPf5R+CqTmw7jSfakDWm9gzHz3B1Ebjaw+LBkSt8sM+M /mluc9fq5m2yTO3inh8BSnKmmFfgLNx+K/0XVDyLtTKjM0m77iYO3bZUKzDh+3iTY8hk mEQu2nlHjM1hs0Ob6A+DRMXcSErPjfu3J1eBiKT9vt2dZkP47fmHUjXKMU76Nu0TN/BG ycxQ== 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=OVqajGRdNBqJ2J2JvoZaWIUxgTkr1401/IW2fU8bKbY=; b=Voi1hib2Z+LsDIIgVd2jSPkx9r+3dv5mI/NFVA4FWejzTSRWm9Kw4SjW0bv7by+E/R 25eG3SP1OfZgCXZOmbLUE9wTjCkbV3Xpz5tp0RQ1gqJOEsji3BqkwKBMfH1EfC5gfZZw 4sGIwbOzNU/F5mmoSjE/f47Jm2F3Xvyw6jfQ2Q/H7oy0VyfjHx0RRGS7J8USPSqtE+Et N0YuiUO80zKs6VKCke9+DpaaUB+sDdNF389YRXLVHPOEw1DOp4zYLyMW8PkWB2B0nJ6R 1aTajRoKZCxGMk5hwA5ADZK+Dx18hI2cDjaqJ3OMO2oB+V20HzOd7A6LBOnsqeiFbCT0 QBug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 l17si3183385pgj.43.2017.06.02.06.55.40; Fri, 02 Jun 2017 06:55:41 -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; 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 S1751608AbdFBNzO (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:14 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:37086 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561AbdFBNzL (ORCPT ); Fri, 2 Jun 2017 09:55:11 -0400 Received: by mail-wm0-f50.google.com with SMTP id d127so27565974wmf.0 for ; Fri, 02 Jun 2017 06:55:00 -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=OVqajGRdNBqJ2J2JvoZaWIUxgTkr1401/IW2fU8bKbY=; b=aGMyLR0IM7P0un+Po5YXX/NcJFjhO++cqyOim8omw+7jm4M3E/04PdlPgGqvUFErJX wxlpy2CqieTGPs3Ms8yYClROgdzsvK8iJ+vzEYqi249PAioyJUiqNLgaVHU9mapK8xXe 4K8XguX2Y6F/l/K3+cj0fwj4n8UdvkNt0jyDU= 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=OVqajGRdNBqJ2J2JvoZaWIUxgTkr1401/IW2fU8bKbY=; b=Z0hOewjK7p5RSV3wNytGP4G1/fAhyZZSBaTuqmoRBpcQvSLYDANsaaAxqMVUFRkzDW 5ZygSp5ClkwUaHLeFemNMPG5XcKuIV18IQBIu0Ael6M3mLnboDAk0ksBaK6sIrBLdtbO S4nNEGKG5d6EeQshBxJMxBvTtHAVN54jfMx5ALhIpFOuI5gsj9Vv7zxK2t0+hsgyxGFC vYpycqtyy3U7mg2TwuKq6wdXKNrhJ7hHdta8q50LsmEtd9hv1y6T0RGIW4Gq0T4S8jgY Np564stmsA9ssvseBwfU9IRSF86TJ7UYrdktQIFRnrjE8yExZRRXiIH51mzisbeAR35B xwvg== X-Gm-Message-State: AODbwcA29/m0gtHhnJg7pR3kHWjhXcBmpMMGEyjKbOmQ2UFrHmke0PRP i6ZE5tuC0N1eyptm X-Received: by 10.80.169.161 with SMTP id n30mr6249187edc.43.1496411699928; Fri, 02 Jun 2017 06:54:59 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.54.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:54:59 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 08/13] efi/capsule-loader: Redirect calls to efi_capsule_setup_info via weak alias Date: Fri, 2 Jun 2017 13:52:02 +0000 Message-Id: <20170602135207.21708-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To allow platform specific code to hook into the capsule loading routines, indirect calls to efi_capsule_setup_info() via a weak alias of __efi_capsule_setup_info(), allowing platforms to redefine the former but still use the latter. Cc: Matt Fleming Tested-by: "Bryan O'Donoghue" Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 56 +++++++++++++++++------------------ include/linux/efi.h | 12 ++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 2357bcdcb44d..cbc3526953d5 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -20,16 +20,6 @@ #define NO_FURTHER_WRITE_ACTION -1 -struct capsule_info { - efi_capsule_header_t header; - int reset_type; - long index; - size_t count; - size_t total_size; - struct page **pages; - size_t page_bytes_remain; -}; - /** * efi_free_all_buff_pages - free all previous allocated buffer pages * @cap_info: pointer to current instance of capsule_info structure @@ -46,28 +36,13 @@ static void efi_free_all_buff_pages(struct capsule_info *cap_info) cap_info->index = NO_FURTHER_WRITE_ACTION; } -/** - * efi_capsule_setup_info - obtain the efi capsule header in the binary and - * setup capsule_info structure - * @cap_info: pointer to current instance of capsule_info structure - * @kbuff: a mapped first page buffer pointer - * @hdr_bytes: the total received number of bytes for efi header - **/ -static int efi_capsule_setup_info(struct capsule_info *cap_info, - void *kbuff, size_t hdr_bytes) +int __efi_capsule_setup_info(struct capsule_info *cap_info) { size_t pages_needed; int ret; void *temp_page; - /* Only process data block that is larger than efi header size */ - if (hdr_bytes < sizeof(efi_capsule_header_t)) - return 0; - - /* Reset back to the correct offset of header */ - kbuff -= cap_info->count; - memcpy(&cap_info->header, kbuff, sizeof(cap_info->header)); - pages_needed = ALIGN(cap_info->header.imagesize, PAGE_SIZE) / PAGE_SIZE; + pages_needed = ALIGN(cap_info->total_size, PAGE_SIZE) / PAGE_SIZE; if (pages_needed == 0) { pr_err("invalid capsule size"); @@ -84,7 +59,6 @@ static int efi_capsule_setup_info(struct capsule_info *cap_info, return ret; } - cap_info->total_size = cap_info->header.imagesize; temp_page = krealloc(cap_info->pages, pages_needed * sizeof(void *), GFP_KERNEL | __GFP_ZERO); @@ -97,6 +71,30 @@ static int efi_capsule_setup_info(struct capsule_info *cap_info, } /** + * efi_capsule_setup_info - obtain the efi capsule header in the binary and + * setup capsule_info structure + * @cap_info: pointer to current instance of capsule_info structure + * @kbuff: a mapped first page buffer pointer + * @hdr_bytes: the total received number of bytes for efi header + * + * Platforms with non-standard capsule update mechanisms can override + * this __weak function so they can perform any required capsule + * image munging. See quark_quirk_function() for an example. + **/ +int __weak efi_capsule_setup_info(struct capsule_info *cap_info, void *kbuff, + size_t hdr_bytes) +{ + /* Only process data block that is larger than efi header size */ + if (hdr_bytes < sizeof(efi_capsule_header_t)) + return 0; + + memcpy(&cap_info->header, kbuff, sizeof(cap_info->header)); + cap_info->total_size = cap_info->header.imagesize; + + return __efi_capsule_setup_info(cap_info); +} + +/** * efi_capsule_submit_update - invoke the efi_capsule_update API once binary * upload done * @cap_info: pointer to current instance of capsule_info structure @@ -182,7 +180,7 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, /* Setup capsule binary info structure */ if (cap_info->header.headersize == 0) { - ret = efi_capsule_setup_info(cap_info, kbuff, + ret = efi_capsule_setup_info(cap_info, kbuff - cap_info->count, cap_info->count + write_byte); if (ret) goto fail_unmap; diff --git a/include/linux/efi.h b/include/linux/efi.h index ec36f42a2add..a7379a2b5680 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -137,6 +137,18 @@ struct efi_boot_memmap { #define EFI_CAPSULE_POPULATE_SYSTEM_TABLE 0x00020000 #define EFI_CAPSULE_INITIATE_RESET 0x00040000 +struct capsule_info { + efi_capsule_header_t header; + int reset_type; + long index; + size_t count; + size_t total_size; + struct page **pages; + size_t page_bytes_remain; +}; + +int __efi_capsule_setup_info(struct capsule_info *cap_info); + /* * Allocation types for calls to boottime->allocate_pages. */ From patchwork Fri Jun 2 13:52:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101257 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205129obc; Fri, 2 Jun 2017 06:55:40 -0700 (PDT) X-Received: by 10.84.212.137 with SMTP id e9mr28713pli.115.1496411740722; Fri, 02 Jun 2017 06:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411740; cv=none; d=google.com; s=arc-20160816; b=V3/gb0kKGVUw5vdKLmz0uoc2/H9U5Pc1S0onpf2ttCFOBm401E2F9wkGVvcdfiXKU+ N4p5rWUj5ORVGajwU5jnwznDlQSn0G/a1XxXFMDWr41AnxNBJYkFXEVpR3fHL4d2cTyC jK26CSeZAfiXY518j2XnNbzHZ5ErHaC5P1U39RO3PrtQhW6WIJrzONcScqOXr7XVHXS0 heEuJn/Ni2Yn3/SsyupPI77GkMNICmkSPHfeWYyvEULqsS9Uo61OTzBHV1MWkl4vlOax qZQoM4y7BFQnLAqORjRlVRq6KQGCG0kFsHADG00gd4NsRZ2crBbRO0NdNrgvgAQnMejV nK5Q== 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=KMnQHuzOKmABhFS0kuifn2e3S7n9oJDZAGkdnt9K8Jg=; b=NKits77lLAalglpRzlNVqtg/P6HHNsZ0JcUTdOTh4Wlo/MXIWaGuF+OBnGtdTviVys sXwWea+KSuEcwefTRjsyE+b6eVKzjh2regDgxxJIKI/zA23j6w9XrGClhuwlYuuWGbqN vfrCS1+7Iuz7flBX0a2pWDTBoni5ZZcFNl8TmpOrxI4q5zmpR3wPQrQcM374K5UO5YHF xeEqoneJ2uP1v8SnDJfnaHdIMlRAoIOhJYHsaNsVvUoepD5c6Eiimi8XDWPlyPgbgbIG PggbEAtpWzcjvOY49/Dc43eAfDe/lLbZRcZym14BB/ftJeHHzIKcbhkSJwyJpQprLS/v EjKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 l17si3183385pgj.43.2017.06.02.06.55.40; Fri, 02 Jun 2017 06:55:40 -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; 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 S1751586AbdFBNzK (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:10 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36699 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561AbdFBNzG (ORCPT ); Fri, 2 Jun 2017 09:55:06 -0400 Received: by mail-wm0-f47.google.com with SMTP id 7so26356964wmo.1 for ; Fri, 02 Jun 2017 06:55:06 -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=KMnQHuzOKmABhFS0kuifn2e3S7n9oJDZAGkdnt9K8Jg=; b=L2czGv1zSrx7kS5p8SNaeYkedm0NEurnay5cve+lc3viRd8dnzf9RPUea9swyLUYbf gSZC1pXqvf/vI2vuoIJxiIEZPOPfM4YLsi9IElIUupaGqxvdPfgPqANL2itq5RTvqe8f WaC9DByF0oe8G+MsVl9OYOfAknKqMR+FQ0OKY= 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=KMnQHuzOKmABhFS0kuifn2e3S7n9oJDZAGkdnt9K8Jg=; b=XL/pDsaTAeVQ87DTOIPO4SHwG+PJbd2PbjJ/PIGDEN4Bt0eDfhpY6WOLxY25VGorop 7mkE03AWXRczqfSp/v73uR2cFPFlPncFy7t3x5ABw5uHA4QJ9yk4Wd/J1SY0ygDMg+pL DLlCzxhbrp11YdyVm6yeUkXEp6atYgH5aAPLwcHwm5Ao+khk42j7IvWhM2trHrR2BWvW sSr/YZLEcWv6hq67ZoWxZEPIVoNxdePci18BSkJRio8I278eQJVDB3Ns/uyxHwOiKkEm ukGlZihF+759rGbhSqsMgy0ffJfLRjaUH4yV/QmxLepOSS0qXREuOkjLIliQe/7v0ED5 hDPg== X-Gm-Message-State: AODbwcCl2u5Pcgtx0eELmlWtlmg87um1dp3a0bHncWw/uiVnhy3vuV46 h05LbdymAX226VzI X-Received: by 10.80.143.227 with SMTP id y90mr6281492edy.131.1496411705151; Fri, 02 Jun 2017 06:55:05 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.55.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:55:04 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Kiszka , Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 10/13] efi/capsule: Add support for Quark security header Date: Fri, 2 Jun 2017 13:52:04 +0000 Message-Id: <20170602135207.21708-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-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: Jan Kiszka The firmware for Quark X102x prepends a security header to the capsule which is needed to support the mandatory secure boot on this processor. The header can be detected by checking for the "_CSH" signature and - to avoid any GUID conflict - validating its size field to contain the expected value. Then we need to look for the EFI header right after the security header and pass the real header to __efi_capsule_setup_info. To be minimal invasive and maximal safe, the quirk version of efi_capsule_identify_image is only effective on Quark processors. Signed-off-by: Jan Kiszka Cc: Matt Fleming Tested-by: "Bryan O'Donoghue" Reviewed-by: Andy Shevchenko Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/quirks.c | 137 +++++++++++++++++++++++++++++++++++++++++ drivers/firmware/efi/Kconfig | 9 +++ 2 files changed, 146 insertions(+) -- 2.9.3 diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 26615991d69c..93867ee08eac 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -15,12 +15,66 @@ #include #include #include +#include #define EFI_MIN_RESERVE 5120 #define EFI_DUMMY_GUID \ EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9) +#define QUARK_CSH_SIGNATURE 0x5f435348 /* _CSH */ +#define QUARK_SECURITY_HEADER_SIZE 0x400 + +/* + * Header prepended to the standard EFI capsule on Quark systems the are based + * on Intel firmware BSP. + * @csh_signature: Unique identifier to sanity check signed module + * presence ("_CSH"). + * @version: Current version of CSH used. Should be one for Quark A0. + * @modulesize: Size of the entire module including the module header + * and payload. + * @security_version_number_index: Index of SVN to use for validation of signed + * module. + * @security_version_number: Used to prevent against roll back of modules. + * @rsvd_module_id: Currently unused for Clanton (Quark). + * @rsvd_module_vendor: Vendor Identifier. For Intel products value is + * 0x00008086. + * @rsvd_date: BCD representation of build date as yyyymmdd, where + * yyyy=4 digit year, mm=1-12, dd=1-31. + * @headersize: Total length of the header including including any + * padding optionally added by the signing tool. + * @hash_algo: What Hash is used in the module signing. + * @cryp_algo: What Crypto is used in the module signing. + * @keysize: Total length of the key data including including any + * padding optionally added by the signing tool. + * @signaturesize: Total length of the signature including including any + * padding optionally added by the signing tool. + * @rsvd_next_header: 32-bit pointer to the next Secure Boot Module in the + * chain, if there is a next header. + * @rsvd: Reserved, padding structure to required size. + * + * See also QuartSecurityHeader_t in + * Quark_EDKII_v1.2.1.1/QuarkPlatformPkg/Include/QuarkBootRom.h + * from https://downloadcenter.intel.com/download/23197/Intel-Quark-SoC-X1000-Board-Support-Package-BSP + */ +struct quark_security_header { + u32 csh_signature; + u32 version; + u32 modulesize; + u32 security_version_number_index; + u32 security_version_number; + u32 rsvd_module_id; + u32 rsvd_module_vendor; + u32 rsvd_date; + u32 headersize; + u32 hash_algo; + u32 cryp_algo; + u32 keysize; + u32 signaturesize; + u32 rsvd_next_header; + u32 rsvd[2]; +}; + static efi_char16_t efi_dummy_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 }; static bool efi_no_storage_paranoia; @@ -501,3 +555,86 @@ bool efi_poweroff_required(void) { return acpi_gbl_reduced_hardware || acpi_no_s5; } + +#ifdef CONFIG_EFI_CAPSULE_QUIRK_QUARK_CSH + +static int qrk_capsule_setup_info(struct capsule_info *cap_info, void **pkbuff, + size_t hdr_bytes) +{ + struct quark_security_header *csh = *pkbuff; + + /* Only process data block that is larger than the security header */ + if (hdr_bytes < sizeof(struct quark_security_header)) + return 0; + + if (csh->csh_signature != QUARK_CSH_SIGNATURE || + csh->headersize != QUARK_SECURITY_HEADER_SIZE) + return 1; + + /* Only process data block if EFI header is included */ + if (hdr_bytes < QUARK_SECURITY_HEADER_SIZE + + sizeof(efi_capsule_header_t)) + return 0; + + pr_debug("Quark security header detected\n"); + + if (csh->rsvd_next_header != 0) { + pr_err("multiple Quark security headers not supported\n"); + return -EINVAL; + } + + *pkbuff += csh->headersize; + cap_info->total_size = csh->headersize; + + /* + * Update the first page pointer to skip over the CSH header. + */ + cap_info->pages[0] += csh->headersize; + + return 1; +} + +#define ICPU(family, model, quirk_handler) \ + { X86_VENDOR_INTEL, family, model, X86_FEATURE_ANY, \ + (unsigned long)&quirk_handler } + +static const struct x86_cpu_id efi_capsule_quirk_ids[] = { + ICPU(5, 9, qrk_capsule_setup_info), /* Intel Quark X1000 */ + { } +}; + +int efi_capsule_setup_info(struct capsule_info *cap_info, void *kbuff, + size_t hdr_bytes) +{ + int (*quirk_handler)(struct capsule_info *, void **, size_t); + const struct x86_cpu_id *id; + int ret; + + if (hdr_bytes < sizeof(efi_capsule_header_t)) + return 0; + + cap_info->total_size = 0; + + id = x86_match_cpu(efi_capsule_quirk_ids); + if (id) { + /* + * The quirk handler is supposed to return + * - a value > 0 if the setup should continue, after advancing + * kbuff as needed + * - 0 if not enough hdr_bytes are available yet + * - a negative error code otherwise + */ + quirk_handler = (typeof(quirk_handler))id->driver_data; + ret = quirk_handler(cap_info, &kbuff, hdr_bytes); + if (ret <= 0) + return ret; + } + + memcpy(&cap_info->header, kbuff, sizeof(cap_info->header)); + + cap_info->total_size += cap_info->header.imagesize; + + return __efi_capsule_setup_info(cap_info); +} + +#endif diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 2e78b0b96d74..394db40ed374 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -112,6 +112,15 @@ config EFI_CAPSULE_LOADER Most users should say N. +config EFI_CAPSULE_QUIRK_QUARK_CSH + boolean "Add support for Quark capsules with non-standard headers" + depends on X86 && !64BIT + select EFI_CAPSULE_LOADER + default y + help + Add support for processing Quark X1000 EFI capsules, whose header + layout deviates from the layout mandated by the UEFI specification. + config EFI_TEST tristate "EFI Runtime Service Tests Support" depends on EFI From patchwork Fri Jun 2 13:52:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101261 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205140obc; Fri, 2 Jun 2017 06:55:42 -0700 (PDT) X-Received: by 10.84.212.2 with SMTP id d2mr66107pli.26.1496411742279; Fri, 02 Jun 2017 06:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411742; cv=none; d=google.com; s=arc-20160816; b=jSpb6jLSIgJSP7qsmpS/hL5yxJEl5ToXMlgr5zDRxCEJUh53fQeOI8fj3P0RBj+ezv kKfyz2+yMr6Rz1+iWgd67NKidtR7rQO0OWgKgk3ZU3UhJK9xzE/l4+gDP0AF/tQWVRJb rbQ2rYZYEhurx8nbZgxefYziRCKZ/rrzo478ehCM7C2iu22hl2xxNL2MEJae20xDepCp r3EwYjOas+ZuQ50evzofLBA16qweUG32pBuCmOq2OM+5TYvnt41qiP7CmvP9/Cac9BjU C6nj+/Wgg86lAyvre8se+9B7pMQgN56AwAe9U8Ruaiosht5Fq7YVKru1B3Pmq2fpfxEq iOLg== 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=yCqokJKIL55SHezFbhcx6v9MjiXiIwdHiWCCtvJRqdA=; b=Bs5ROaR9/mfhkv1jUlA2DsDMHp/6ilhUDyeE0rJZSqzREUivP0s3YDedWMeXFID/+W LBbZeQWAG7m2v3NKjOD7k3ELotMYv0zYamE3a3jkS4VKJlO3VWxY2DXwHjVMbCfRJIWN hd3puKSPcCswAtsICC6Eg75qh46yiPW35Q1sseunWVVnuZuLc0i7UJIMmQDHdFx2elxf 6XZllZZToV2J+c065d/XWuY05tGnsoNqzbCiSQ8kW/dTcED3Rk2n4p4bnumhnC713/QZ ebinJxTwfzovSl/CY5TqDxDvLQNX0rtWQhSeAfdasjjmzggTTSd/WBTbq3UMJre/AmDi 2ZOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 l17si3183385pgj.43.2017.06.02.06.55.41; Fri, 02 Jun 2017 06:55: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; 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 S1751651AbdFBNzZ (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:25 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:35123 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbdFBNzV (ORCPT ); Fri, 2 Jun 2017 09:55:21 -0400 Received: by mail-wm0-f52.google.com with SMTP id b84so26401360wmh.0 for ; Fri, 02 Jun 2017 06:55:11 -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=yCqokJKIL55SHezFbhcx6v9MjiXiIwdHiWCCtvJRqdA=; b=gusplvijOQxdHIqT7Vj7R6yUYu7S7rTX2hAFSIPAgjnEASd3Te7MNEQftqzfDyLRdx gozZ7fHEzAcNuRAfj7B4HDNKb26r/5u5zEKRCyTc/0iePmC6Hx1JarknA7lQK9fRfzNh JLMxWxFEd1p0O+rcbuPv32ZhzqeJLTnvnUyI8= 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=yCqokJKIL55SHezFbhcx6v9MjiXiIwdHiWCCtvJRqdA=; b=S0ff6G18M3oxJ56quuHj2ql+ZG4mzgztgjrr5cYqoR3SXyQidm1Ujrz7DUOB4L67Pk l49XEDdUKGRjxraug9TY53L/tCfAs6my0QPBWZG/R37sgU1/LZ4XbvWpDDuBFQAvbBPv LjOk2WMJ83OrWNW4i/y9Y+V0tqtCmS7tQzvyc8/+mtr6cXL5X5Ry+b3Fzb9W9tU4VrBY YHOlz66QMzDXlNkpzkWI7VF2lRjxgRJaH2Jl9JMhgsxIJ6C47dZ2hvshn8SOCtwb6amq ZGIo9B0W93bHl2dbS7Es6Gh9uvIoiE3VGkn3oyUM7XdiMKue057EofDR1MWYjrYyNE+M RYRA== X-Gm-Message-State: AODbwcAzpO1u17+xJQSHEZYx9J3GPU54tBp+JrHclkoQSkSMB7DGsIfN wiEsX1IxeDmPVYGo X-Received: by 10.80.168.102 with SMTP id j93mr6318298edc.32.1496411710265; Fri, 02 Jun 2017 06:55:10 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.55.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:55:09 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Sai Praneeth , Ard Biesheuvel , linux-kernel@vger.kernel.org, Borislav Petkov , Ricardo Neri , Ravi Shankar , Matt Fleming Subject: [PATCH 12/13] x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec Date: Fri, 2 Jun 2017 13:52:06 +0000 Message-Id: <20170602135207.21708-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-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: Sai Praneeth EFI_PGT_DUMP, as the name suggests dumps efi page tables to dmesg during kernel boot. This feature is very useful while debugging page faults/null pointer dereferences to efi related addresses. Presently, this feature is limited only to x86_64, so let's extend it to other efi configurations like kexec kernel, efi=old_map and to x86_32 as well. This doesn't effect normal boot path because this config option should be used only for debug purposes. Signed-off-by: Sai Praneeth Prakhya Cc: Borislav Petkov Cc: Ricardo Neri Cc: Ard Biesheuvel Cc: Ravi Shankar Signed-off-by: Matt Fleming --- arch/x86/platform/efi/efi.c | 3 ++- arch/x86/platform/efi/efi_32.c | 9 ++++++++- arch/x86/platform/efi/efi_64.c | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) -- 2.9.3 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index dc2da5e2c7e4..3cf8536e803b 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -1012,7 +1012,6 @@ static void __init __efi_enter_virtual_mode(void) * necessary relocation fixups for the new virtual addresses. */ efi_runtime_update_mappings(); - efi_dump_pagetable(); /* clean DUMMY object */ efi_delete_dummy_variable(); @@ -1027,6 +1026,8 @@ void __init efi_enter_virtual_mode(void) kexec_enter_virtual_mode(); else __efi_enter_virtual_mode(); + + efi_dump_pagetable(); } /* diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c index 403a987d06c7..fe18c5d32bf0 100644 --- a/arch/x86/platform/efi/efi_32.c +++ b/arch/x86/platform/efi/efi_32.c @@ -44,7 +44,14 @@ int __init efi_alloc_page_tables(void) } void efi_sync_low_kernel_mappings(void) {} -void __init efi_dump_pagetable(void) {} + +void __init efi_dump_pagetable(void) +{ +#ifdef CONFIG_EFI_PGT_DUMP + ptdump_walk_pgd_level(NULL, swapper_pg_dir); +#endif +} + int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) { return 0; diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 6fbf6c47e603..0d8180811445 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -528,7 +528,10 @@ void __init efi_runtime_update_mappings(void) void __init efi_dump_pagetable(void) { #ifdef CONFIG_EFI_PGT_DUMP - ptdump_walk_pgd_level(NULL, efi_pgd); + if (efi_enabled(EFI_OLD_MEMMAP)) + ptdump_walk_pgd_level(NULL, swapper_pg_dir); + else + ptdump_walk_pgd_level(NULL, efi_pgd); #endif } From patchwork Fri Jun 2 13:52:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101259 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205135obc; Fri, 2 Jun 2017 06:55:41 -0700 (PDT) X-Received: by 10.84.238.203 with SMTP id l11mr42061pln.17.1496411741615; Fri, 02 Jun 2017 06:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411741; cv=none; d=google.com; s=arc-20160816; b=md7NUKBy+W2OS9CbvY3bcuV2IsspXqYEBmSXnTSXtTNST5hu1qMVJmhmb+Y4DH3rNL YhDEicb4+Yjqa3vFGCoZHMHcFGDii/cfQdlbLHddaTwGrBr+Ed5+hz7cF1/dEoqmRNbP SEMWhg2xvCxmtK4396dhZiDry/1dJGl6Ul8Z8+CjdS673UoEmmDVx2wWU0de6TmtKvf1 IdtM8FjAxHb4CISsWfK0JH4aKCFbtYpbfn45xep2T12mD/tF+ojByoKRHKsraTJJ3oyr q1t5RRb8yZuJpnHk1qYZVPZeNByxI5QBMxWdabMI2wj3qaa3kT1SrZWBbSr5pMNEQrNc iopA== 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=bT6LesnTJwJpD0pkH2Wp0wRTMF+iplSJ0m2phDFk9u4=; b=dqrUEq3AkP6PIPfoPEb0BYewk3q9YwDFSWruV3Y8o+piYTDpKH5A88SWOZfRpf6sKW a2BjSEOW8aMC2ySnoLIHYkqNF3G/YfZfXMRdIQtnnb+tyBulr3+cZyXEkNK1UmxHNpAd zNN1C3JO2uKm/t1dtwe8sauUaab3srcaaa9jlEpZorLqMjCVsRBFcpruZmq1pYPNs7hp jLPpvhkZToB0XoyXbqX7AW21GfA6j90p9xcSn+itLCIiRA1ESvUpnKeWZAdY1SU3WNTp y4FybbKk+j5bIslpTgvKmnRLD0QXtgbdZ07K2KQQvGoLpqmXK5vIXDyEWSQEFbHHNxG/ saqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 l17si3183385pgj.43.2017.06.02.06.55.41; Fri, 02 Jun 2017 06:55:41 -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; 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 S1751630AbdFBNzT (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:19 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:38684 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbdFBNzO (ORCPT ); Fri, 2 Jun 2017 09:55:14 -0400 Received: by mail-wm0-f45.google.com with SMTP id n195so27636586wmg.1 for ; Fri, 02 Jun 2017 06:55: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=bT6LesnTJwJpD0pkH2Wp0wRTMF+iplSJ0m2phDFk9u4=; b=XCZZHdTVYyfElRDjZ9IoQQa9z6iMFHdNLGEv//HFZIthLzaVwj1MQ+kSHy/HnG60c4 FmcUwO1Ca/2gT8JN3j6NKh8jV/u7ATXadAqqrlfjboRdIUS5/46uGVEdr5fk2rgfhyrW 5FcYRAWpUYDlrPC4J0v279oj6KsJf4RHrd6nM= 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=bT6LesnTJwJpD0pkH2Wp0wRTMF+iplSJ0m2phDFk9u4=; b=tEw/0vgd9M4+h8FgzrrDN/Qbyr+GlUWpreBf5KDxedG+8zty9mwBqHNwcpCGkHqjMO 665ThIyZ4G7c8hYBb4oIeCoUCHGNe46KClaYqONeGF8doh0GLTkmK1Gt9S0ivkqRvmuW k62EbWS6APA4cFviKaRwuAlNXLTHtdLHRx08hf9FNeq5DGBp05N3bI9531sis3728iAj J1N2Frwe5WC5VCYMNPqg2w6fl8KY+0kR15OsAj04tBYi317M6zeg55Pka58p42kLXzyx g1LriYwnW0RiOKyrx0gI+EE+IABRmpHR5PHTi6LWorMqw2gQWEYca9e/tCYMxSyiEWpP 84ug== X-Gm-Message-State: AODbwcBcNtWAcrrfh687Ppd9E/M2WXcV8LiVLV0kTwxnULGenq75JWr+ 65Py2t12OK0brnEV X-Received: by 10.80.193.130 with SMTP id m2mr6193943edf.85.1496411712918; Fri, 02 Jun 2017 06:55:12 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.55.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:55:11 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 13/13] efi: arm: enable DMI/SMBIOS Date: Fri, 2 Jun 2017 13:52:07 +0000 Message-Id: <20170602135207.21708-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wire up the existing arm64 support for SMBIOS tables (aka DMI) for ARM as well, by moving the arm64 init code to drivers/firmware/efi/arm-runtime.c (which is shared between ARM and arm64), and adding a asm/dmi.h header to ARM that defines the mapping routines for the firmware tables. This allows userspace to access these tables to discover system information exposed by the firmware. It also sets the hardware name used in crash dumps, e.g., Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = ed3c0000 [00000000] *pgd=bf1f3835 Internal error: Oops: 817 [#1] SMP THUMB2 Modules linked in: CPU: 0 PID: 759 Comm: bash Not tainted 4.10.0-09601-g0e8f38792120-dirty #112 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 ^^^ NOTE: This does *NOT* enable or encourage the use of DMI quirks, i.e., the the practice of identifying the platform via DMI to decide whether certain workarounds for buggy hardware and/or firmware need to be enabled. This would require the DMI subsystem to be enabled much earlier than we do on ARM, which is non-trivial. Cc: Matt Fleming Acked-by: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/Kconfig | 17 +++++++++++++++++ arch/arm/include/asm/dmi.h | 19 +++++++++++++++++++ arch/arm64/kernel/efi.c | 15 --------------- drivers/firmware/efi/arm-runtime.c | 16 ++++++++++++++++ 4 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 arch/arm/include/asm/dmi.h -- 2.9.3 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4c1a35f15838..dabcaeb2ee3e 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -2061,6 +2061,23 @@ config EFI is only useful for kernels that may run on systems that have UEFI firmware. +config DMI + bool "Enable support for SMBIOS (DMI) tables" + depends on EFI + default y + help + This enables SMBIOS/DMI feature for systems. + + This option is only useful on systems that have UEFI firmware. + However, even with this option, the resultant kernel should + continue to boot on existing non-UEFI platforms. + + NOTE: This does *NOT* enable or encourage the use of DMI quirks, + i.e., the the practice of identifying the platform via DMI to + decide whether certain workarounds for buggy hardware and/or + firmware need to be enabled. This would require the DMI subsystem + to be enabled much earlier than we do on ARM, which is non-trivial. + endmenu menu "CPU Power Management" diff --git a/arch/arm/include/asm/dmi.h b/arch/arm/include/asm/dmi.h new file mode 100644 index 000000000000..df2d2ff06f5b --- /dev/null +++ b/arch/arm/include/asm/dmi.h @@ -0,0 +1,19 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_DMI_H +#define __ASM_DMI_H + +#include +#include + +#define dmi_early_remap(x, l) memremap(x, l, MEMREMAP_WB) +#define dmi_early_unmap(x, l) memunmap(x) +#define dmi_remap(x, l) memremap(x, l, MEMREMAP_WB) +#define dmi_unmap(x) memunmap(x) +#define dmi_alloc(l) kzalloc(l, GFP_KERNEL) + +#endif diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 5d17f377d905..82cd07592519 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -11,7 +11,6 @@ * */ -#include #include #include @@ -117,20 +116,6 @@ int __init efi_set_mapping_permissions(struct mm_struct *mm, set_permissions, md); } -static int __init arm64_dmi_init(void) -{ - /* - * On arm64, DMI depends on UEFI, and dmi_scan_machine() needs to - * be called early because dmi_id_init(), which is an arch_initcall - * itself, depends on dmi_scan_machine() having been called already. - */ - dmi_scan_machine(); - if (dmi_available) - dmi_set_dump_stack_arch_desc(); - return 0; -} -core_initcall(arm64_dmi_init); - /* * UpdateCapsule() depends on the system being shutdown via * ResetSystem(). diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 974c5a31a005..1cc41c3d6315 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -11,6 +11,7 @@ * */ +#include #include #include #include @@ -166,3 +167,18 @@ void efi_virtmap_unload(void) efi_set_pgd(current->active_mm); preempt_enable(); } + + +static int __init arm_dmi_init(void) +{ + /* + * On arm64/ARM, DMI depends on UEFI, and dmi_scan_machine() needs to + * be called early because dmi_id_init(), which is an arch_initcall + * itself, depends on dmi_scan_machine() having been called already. + */ + dmi_scan_machine(); + if (dmi_available) + dmi_set_dump_stack_arch_desc(); + return 0; +} +core_initcall(arm_dmi_init);