From patchwork Thu Sep 27 08:50:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 147695 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1727215lji; Thu, 27 Sep 2018 01:52:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61S1jaWMzutaR7pozduZq2d4yGZ9myppHseTvixhkzqGzaGXz+t3lgq9OhqOHdNZZHPR1T3 X-Received: by 2002:a17:902:b595:: with SMTP id a21-v6mr9484966pls.329.1538038328158; Thu, 27 Sep 2018 01:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538038328; cv=none; d=google.com; s=arc-20160816; b=P34BJNFhbZ0i99tAiR9snFGTPijx3PIKAROG91jcQB8tBaJ77SHsRfxX+b8f+6eQVH ind7/Oo/67fI1sDolQRAU+jh0yQEmG/5Bwd4YFPoO3qdVOnaqpSVv1U9EGcNhVMRziTJ cwXwEJvGiR/HyXoZlq/JNDxWziNqPaC3JKJPwPU8z8FY6imGWbmxxD+FZZrswZog6ocZ 3qpw8iGcNjmpHL/2UQgMnu/VnWuDoYR7Z7Afo3cQwWyA5qiDNyTRJqmJPrJ3aPZnZn8e hJmgciOUYHYNHuU1uZvH/hvh9DLG4LtCk+F+ApoZCukRtn5GN0Vv6+b8ulrcuSMYDctH yZ+Q== 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; bh=ffkuDpNBfwdcvOz+/QFFGB2qN+kuprFwPCetGXqXDvo=; b=f9lf7jiABWAmzWlE62CZfMRKxg5SFQTTS4AplYXQd4HxeXGX8OxKqlZSBoAxEAsO+4 dKLHV+EuaMxk6DIVOxggxcGwA3rvMwOxETEalaaXbw44KkEp/m1aL9NkAcaLUlX0wg04 m4n9LiuCbfDMIJvIMsPtH90wGmBAw4n0Dwa/3lraB9rXYzhoJI/OBOZd5TOdQX4CLcJV Awia+mTi5QzUViVRN6lpyC0jyhQfo7dZF1vZwIlFRwhmnnxh1v6F3jBf8+6NxSgj4aMc j43eCq47sOzWxVDx3LUHsD8XKb2vA/R2Z71ZPnMctSOi9GYPiECSB3ECzYxsbkFIMIsa DFMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXYpuvfj; 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 p83-v6si1606423pfa.180.2018.09.27.01.52.07; Thu, 27 Sep 2018 01:52:08 -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=NXYpuvfj; 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 S1727281AbeI0PIJ (ORCPT + 32 others); Thu, 27 Sep 2018 11:08:09 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34548 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbeI0PII (ORCPT ); Thu, 27 Sep 2018 11:08:08 -0400 Received: by mail-wr1-f66.google.com with SMTP id z4-v6so286808wrb.1 for ; Thu, 27 Sep 2018 01:50: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=ffkuDpNBfwdcvOz+/QFFGB2qN+kuprFwPCetGXqXDvo=; b=NXYpuvfjVfvGDfKvcFzsqhfoZxbZh6uUyiF4tlEMs6UaniHzdsbXtC8B5wk1uDhj98 TQHp0JQrnCffiOTjDSjABSrHPhxtkbX93pvOd/liNxZtzbGLFivKuWpNnyo+XOLWfaWL fjc7qvSq5h98gKpG/Db2iG1jt+xScVrAfOFBo= 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=ffkuDpNBfwdcvOz+/QFFGB2qN+kuprFwPCetGXqXDvo=; b=Ed79JRI+9Eqroa0SPVZKJ/2mpaPi/uemGIJo1dxRGwiHJMLaOo9a7gthilUBGrg2RR cxql1IJDnehJaQIB3nlO1S591IK8nQOTaMgogkDwOLiPo6nwB5MxNFDvunrjBUoZZ7WS vM4R5KiZ0VTYLNT9iCsWLaiNONatawvF7HrUY5VA91MVHi/Q9qrCl0KDO5xwBNBi54fk QaLMTtiXQJ5tuPVU2F6/mBrvPjVr93JhINp1vaiQ7fk0P8lze1C3zJAZACJSQP7lK3zK QbGbumC26pDAqP0uS3gO5f1CnRR87pgfjl4AuchVl5q1Ql6hHPKS11jgxtxlJNaTW4u5 DZxQ== X-Gm-Message-State: ABuFfogcPawbxZroVfAGFgQpYNoc+jQABJ7w8b7eVJaUfC3WyJ5EScPd Dt41Be/79BxqstvkusRJg4lmYXWEx1M= X-Received: by 2002:adf:9244:: with SMTP id 62-v6mr757724wrj.130.1538038257358; Thu, 27 Sep 2018 01:50:57 -0700 (PDT) Received: from rev03.home ([2a01:cb1d:112:6f00:546e:3c44:5966:2f5e]) by smtp.gmail.com with ESMTPSA id p11-v6sm1304055wrd.74.2018.09.27.01.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 01:50:56 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, Aaron Ma , Alistair Strachan , Ben Hutchings , Bhupesh Sharma , Hans de Goede , Ivan Hu , Jeremy Linton , Marc Zyngier , Matt Fleming , Peter Robinson , Sai Praneeth Prakhya , Sebastian Andrzej Siewior , Stefan Agner Subject: [PATCH 01/11] efi: honour memory reservations passed via a linux specific config table Date: Thu, 27 Sep 2018 10:50:28 +0200 Message-Id: <20180927085039.8391-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180927085039.8391-1-ard.biesheuvel@linaro.org> References: <20180927085039.8391-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 allow the OS to reserve memory persistently across a kexec, introduce a Linux-specific UEFI configuration table that points to the head of a linked list in memory, allowing each kernel to add list items describing memory regions that the next kernel should treat as reserved. This is useful, e.g., for GICv3 based ARM systems that cannot disable DMA access to the LPI tables, forcing them to reuse the same memory region again after a kexec reboot. Tested-by: Jeremy Linton Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 27 ++++++++++++++++++++++++++- include/linux/efi.h | 8 ++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) -- 2.18.0 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 2a29dd9c986d..688132ac8a0a 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -52,7 +52,8 @@ struct efi __read_mostly efi = { .properties_table = EFI_INVALID_TABLE_ADDR, .mem_attr_table = EFI_INVALID_TABLE_ADDR, .rng_seed = EFI_INVALID_TABLE_ADDR, - .tpm_log = EFI_INVALID_TABLE_ADDR + .tpm_log = EFI_INVALID_TABLE_ADDR, + .mem_reserve = EFI_INVALID_TABLE_ADDR, }; EXPORT_SYMBOL(efi); @@ -484,6 +485,7 @@ static __initdata efi_config_table_type_t common_tables[] = { {EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi.mem_attr_table}, {LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &efi.rng_seed}, {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log}, + {LINUX_EFI_MEMRESERVE_TABLE_GUID, "MEMRESERVE", &efi.mem_reserve}, {NULL_GUID, NULL, NULL}, }; @@ -591,6 +593,29 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, early_memunmap(tbl, sizeof(*tbl)); } + if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) { + unsigned long prsv = efi.mem_reserve; + + while (prsv) { + struct linux_efi_memreserve *rsv; + + /* reserve the entry itself */ + memblock_reserve(prsv, sizeof(*rsv)); + + rsv = early_memremap(prsv, sizeof(*rsv)); + if (rsv == NULL) { + pr_err("Could not map UEFI memreserve entry!\n"); + return -ENOMEM; + } + + if (rsv->size) + memblock_reserve(rsv->base, rsv->size); + + prsv = rsv->next; + early_memunmap(rsv, sizeof(*rsv)); + } + } + return 0; } diff --git a/include/linux/efi.h b/include/linux/efi.h index 401e4b254e30..a5cb580472c5 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -672,6 +672,7 @@ void efi_native_runtime_setup(void); #define LINUX_EFI_LOADER_ENTRY_GUID EFI_GUID(0x4a67b082, 0x0a4c, 0x41cf, 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f) #define LINUX_EFI_RANDOM_SEED_TABLE_GUID EFI_GUID(0x1ce1e5bc, 0x7ceb, 0x42f2, 0x81, 0xe5, 0x8a, 0xad, 0xf1, 0x80, 0xf5, 0x7b) #define LINUX_EFI_TPM_EVENT_LOG_GUID EFI_GUID(0xb7799cb0, 0xeca2, 0x4943, 0x96, 0x67, 0x1f, 0xae, 0x07, 0xb7, 0x47, 0xfa) +#define LINUX_EFI_MEMRESERVE_TABLE_GUID EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5, 0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2) typedef struct { efi_guid_t guid; @@ -957,6 +958,7 @@ extern struct efi { unsigned long mem_attr_table; /* memory attributes table */ unsigned long rng_seed; /* UEFI firmware random seed */ unsigned long tpm_log; /* TPM2 Event Log table */ + unsigned long mem_reserve; /* Linux EFI memreserve table */ efi_get_time_t *get_time; efi_set_time_t *set_time; efi_get_wakeup_time_t *get_wakeup_time; @@ -1662,4 +1664,10 @@ extern int efi_tpm_eventlog_init(void); /* Workqueue to queue EFI Runtime Services */ extern struct workqueue_struct *efi_rts_wq; +struct linux_efi_memreserve { + phys_addr_t next; + phys_addr_t base; + phys_addr_t size; +}; + #endif /* _LINUX_EFI_H */ From patchwork Thu Sep 27 08:50:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 147687 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1726280lji; Thu, 27 Sep 2018 01:51:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV632eAPDuvgczTzYMXkiUvUd+9Wi5ysaXg7VOF6Im6KFHctqWRvtQ+ZBbJ6W0UmBqqIAoFYo X-Received: by 2002:a63:380d:: with SMTP id f13-v6mr9196535pga.124.1538038266711; Thu, 27 Sep 2018 01:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538038266; cv=none; d=google.com; s=arc-20160816; b=avp18r3BocNEHcTocqxC4Ow+uHuXSmgIbQjWPbUGyJT51tXHJ3plTvIGDyM0QYEai1 oz3c99BQMk8sJPnzRuHqNHzkGDBbOdsJ6692OF7qPuVC068U8GyVG2coffSqmTcMsm38 ghzGgYEND873/cPrKlpmqja2v5Gvw46/FcS4sKfdiHnEI03BuLF0NtBxXsUbbPfHoprC 2M39mojKglnRQcq5LMwkEfQ1VBF+POBsv2neqPu4vp5kt3nn3Doj7smH2VDEISl3vhiq izjrnYldO+WXi3UFETdSnnSmdhIBW0VHEAFwL6hCbA3etWMyAHJKcqSepoKC3DGkNIxn t+Sw== 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; bh=f8rCgirc+Q/Pjj+hezpx+WshLqF7c604zeE4cCjQ4cU=; b=nYKgaS+8XY5MYGe7bVz7c7aImQkrvdB0FR+SLfDeULxTHCeNjXDG7YUZpwFFexjJtC G0VQ5yLM8kvmYVYPOo4n8SmHwazX78MVJzOvHQSGJtE21Wo7+4AonFGXmTk1CYL4XtOu KJDqGvAeDAHQjVsJwWHr2Rr0mNkNLnNPjfrTFlFV7mo9/ObSoL9mhK7Tz/H93eXJV+mP gXmeIuInCuyWSXzjt4TULF82hGkrUD8bXB7A7+kPyuVi+X/wcvXlds7dvyKsIL/A96qw U95Kdp+Um86TVOvjznm4xmcSaRQmN33LBKgQCP9mTYTDdkAlRyYr6jj0sqMnfq8Gk0M0 hJfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bovG80Cm; 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 t65-v6si1498251pgt.248.2018.09.27.01.51.06; Thu, 27 Sep 2018 01:51:06 -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=bovG80Cm; 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 S1727340AbeI0PIL (ORCPT + 32 others); Thu, 27 Sep 2018 11:08:11 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51165 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbeI0PIL (ORCPT ); Thu, 27 Sep 2018 11:08:11 -0400 Received: by mail-wm1-f67.google.com with SMTP id s12-v6so5032584wmc.0 for ; Thu, 27 Sep 2018 01:51:01 -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=f8rCgirc+Q/Pjj+hezpx+WshLqF7c604zeE4cCjQ4cU=; b=bovG80CmbjL84b5Zsj4eHC7ELIy3ILRfjn7nny+sOwsD9OQLDif7BtAPKn1cmccbAj CD313OwFymTWeSWL4w7q/j8EPuOxM2JEzK63Mk76d/1b7GDHa3zPkBDuVJf17EC+OFX1 fFHfqSiPqdljW9o7Gi73hRRYpGRCiY3yNMjSc= 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=f8rCgirc+Q/Pjj+hezpx+WshLqF7c604zeE4cCjQ4cU=; b=XTQcimw5kNk6u5OZEtZWjL+W99Vq6h0pXcNrWc4R8On50FTTi1hHX4TizunOhplKDX UzxxOM/whaGOgqTD7raUW/5wK2noGkcWvQMw8faOljpS4mPQbRSMmSmlpE25kjy3o70y GhsULyG7f9tbvkNIaYh9xH/y1aRNvp5mCtj1tX+DsLGQW6wA95BkghEyT+UUYVIzSooW 4MVK4ZADJPKK3DgkS3JeK7cPsTKnnnhPn7ILChGLxXQj3DSBHwMOJJMuyWPprJgMsAzX hPMp1ra9oi7mo2H0NV53IYugUWYBemCpgihtvyQTRLBoDy1ZE8maYB3CH/drExkH0ogF cP3g== X-Gm-Message-State: ABuFfoipX+e/XYTl5AcZROtsphrv783+0mwfP4+7zzM1Z8HW73CeC07o eDUZ/laSjCAgJ8sYjjktHh7WujUPk9g= X-Received: by 2002:a1c:8a55:: with SMTP id m82-v6mr6884527wmd.70.1538038260353; Thu, 27 Sep 2018 01:51:00 -0700 (PDT) Received: from rev03.home ([2a01:cb1d:112:6f00:546e:3c44:5966:2f5e]) by smtp.gmail.com with ESMTPSA id p11-v6sm1304055wrd.74.2018.09.27.01.50.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 01:50:59 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, Aaron Ma , Alistair Strachan , Ben Hutchings , Bhupesh Sharma , Hans de Goede , Ivan Hu , Jeremy Linton , Marc Zyngier , Matt Fleming , Peter Robinson , Sai Praneeth Prakhya , Sebastian Andrzej Siewior , Stefan Agner Subject: [PATCH 03/11] efi: add API to reserve memory persistently across kexec reboot Date: Thu, 27 Sep 2018 10:50:30 +0200 Message-Id: <20180927085039.8391-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180927085039.8391-1-ard.biesheuvel@linaro.org> References: <20180927085039.8391-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add kernel plumbing to reserve memory regions persistently on a EFI system by adding entries to the MEMRESERVE linked list. Tested-by: Jeremy Linton Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 32 ++++++++++++++++++++++++++++++++ include/linux/efi.h | 1 + 2 files changed, 33 insertions(+) -- 2.18.0 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 688132ac8a0a..249eb70691b0 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -962,6 +962,38 @@ bool efi_is_table_address(unsigned long phys_addr) return false; } +static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock); + +int efi_mem_reserve_persistent(phys_addr_t addr, u64 size) +{ + struct linux_efi_memreserve *rsv, *parent; + + if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR) + return -ENODEV; + + rsv = kmalloc(sizeof(*rsv), GFP_KERNEL); + if (!rsv) + return -ENOMEM; + + parent = memremap(efi.mem_reserve, sizeof(*rsv), MEMREMAP_WB); + if (!parent) { + kfree(rsv); + return -ENOMEM; + } + + rsv->base = addr; + rsv->size = size; + + spin_lock(&efi_mem_reserve_persistent_lock); + rsv->next = parent->next; + parent->next = __pa(rsv); + spin_unlock(&efi_mem_reserve_persistent_lock); + + memunmap(parent); + + return 0; +} + #ifdef CONFIG_KEXEC static int update_efi_random_seed(struct notifier_block *nb, unsigned long code, void *unused) diff --git a/include/linux/efi.h b/include/linux/efi.h index a5cb580472c5..22e4de9d3700 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1043,6 +1043,7 @@ extern int __init efi_uart_console_only (void); extern u64 efi_mem_desc_end(efi_memory_desc_t *md); extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md); extern void efi_mem_reserve(phys_addr_t addr, u64 size); +extern int efi_mem_reserve_persistent(phys_addr_t addr, u64 size); extern void efi_initialize_iomem_resources(struct resource *code_resource, struct resource *data_resource, struct resource *bss_resource); extern void efi_reserve_boot_services(void); From patchwork Thu Sep 27 08:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 147688 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1726319lji; Thu, 27 Sep 2018 01:51:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV63z7jfsS15DUBWg2Ps05oqmdIMYTPASk0KjObrY4a4ZBQqSF5RSinlHL5/VWpFPlrKGPG1Z X-Received: by 2002:a63:7419:: with SMTP id p25-v6mr9271318pgc.395.1538038268821; Thu, 27 Sep 2018 01:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538038268; cv=none; d=google.com; s=arc-20160816; b=zvchOxlljqjLWUroJPtNB9fqtvsr/dJNJSR6Jb1E1ZSUQQ0j9E58V5uLv8mrx9PbqW dG/lIe/02aODBsgLV/CP3rXFxE85e/1BowQIJ5ct0v6+2M1g0Ix97FWR5I/I569virTt 8ssIGnCk1ty72xbuXmpAPV/Fo0Oy/2yAz08lBBizt1uisfZIr7r9oF8BfB/F/soiS6iH 0RaQM0rtx0yoh1sLRlLhOXeZFShOLiFnKzyx8W7H9VjQcyOsSPmhc0nHa0NoUG5+IVTf 835myGOiM9z4Kqjx6GyyvCihd54Hnh6joIrH9NWAcrRKo41zrEzMAMDAPnGb2YEXtbQZ yNNw== 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; bh=e0MW/cO/rHunfkzsEHUdpPLgA85W8krihEUCPuzlC88=; b=NN2nHBZUHp6RF1/QzDaSp9GYToheNEFhP1udKCitaN4WP3Tl8u4NhpPB+IDbBx5E8x SAs7MaAoBEvs+b/pY2t9/q+Ju43v0yNy+oaOaN3K6r3nGZgH9pB7yE6LeqlJ4mOHdLX1 q9jMwI6hSbaEQgXz1jDB7o65jOOqkj3hOVtSni0fueI18jKhb3EExE5A1gySnHyw+nzN AQHXGczmggWccd9lNPE611X87yUmkUUBRTEIHnDZ6HyUehvHEj7EGgcfgFzdQKCOng3s yZhGbYsFX9hccM9O6KlXNLLwovac+Yr+5n2eC+i048eMN4g6qPFatxAob92146Q03OuC Fb+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGgdhQcj; 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 l15-v6si1430170pgh.593.2018.09.27.01.51.08; Thu, 27 Sep 2018 01:51:08 -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=bGgdhQcj; 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 S1727388AbeI0PIO (ORCPT + 32 others); Thu, 27 Sep 2018 11:08:14 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40374 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727342AbeI0PIN (ORCPT ); Thu, 27 Sep 2018 11:08:13 -0400 Received: by mail-wm1-f65.google.com with SMTP id o2-v6so5067806wmh.5 for ; Thu, 27 Sep 2018 01:51:04 -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=e0MW/cO/rHunfkzsEHUdpPLgA85W8krihEUCPuzlC88=; b=bGgdhQcjPRB3zwnlm4BsD6QNoc7DoaayYxqXj3tpGnCxA4BFot+1qmklGZkf8vt0f8 FUZ9h7MlEKozRybDDRiH5Rnowhy8H+LwMW+SzPKg/XYkL7G9rdxHf+zLGAVgk60moYnt RHe5qMGqHcSGij07vTPWKQB2USWjUmIc+avkc= 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=e0MW/cO/rHunfkzsEHUdpPLgA85W8krihEUCPuzlC88=; b=Ii6XiSS8nDQAlnG1cI4c/aknaebrN35MW1ZM0QOMXO4MncumC67Bxdiwc8xaj5hd/D 9dFF4aGs3Q0tbaclLTV8Af56GEbfIhv535w9f7NfVbRydX0dG1Zp/NPmla2UUmPvEQNq DLzO9ar25N63RbQVAlMC5RNBOXSqTtE/4lkFq/ayUV1ntABMyQT5YPagsdJhTMuZ8P3H Q1nm8Qf08rcSvxT01evpaRwdc1DwrjkWqnVrMF1iToZrJHk581ek0ImQfyKtxXU6smDS Et4D9Tsd8ke4B4tdvrK1AdmkyP5r3e10KcdaCbP7IgrU8zCZyRUjAiwJNgVBQq+3fBM9 jaeg== X-Gm-Message-State: ABuFfogbKAGEYcTLZam/WCU8DpgY81kKg3VYNIE5bY4p2n8/TSi3OzQ6 kv8+AoE8i+fSRo2SSG507tSKlT6Rtlw= X-Received: by 2002:a1c:4d09:: with SMTP id o9-v6mr6766505wmh.134.1538038263329; Thu, 27 Sep 2018 01:51:03 -0700 (PDT) Received: from rev03.home ([2a01:cb1d:112:6f00:546e:3c44:5966:2f5e]) by smtp.gmail.com with ESMTPSA id p11-v6sm1304055wrd.74.2018.09.27.01.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 01:51:02 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, Aaron Ma , Alistair Strachan , Ben Hutchings , Bhupesh Sharma , Hans de Goede , Ivan Hu , Jeremy Linton , Marc Zyngier , Matt Fleming , Peter Robinson , Sai Praneeth Prakhya , Sebastian Andrzej Siewior , Stefan Agner Subject: [PATCH 05/11] efi/efi_test: add exporting ResetSystem runtime service Date: Thu, 27 Sep 2018 10:50:32 +0200 Message-Id: <20180927085039.8391-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180927085039.8391-1-ard.biesheuvel@linaro.org> References: <20180927085039.8391-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: Ivan Hu Add exporting the UEFI runtime service ResetSystem for upper application or test tools to use. Signed-off-by: Ivan Hu Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/test/efi_test.c | 27 +++++++++++++++++++++++++++ drivers/firmware/efi/test/efi_test.h | 10 ++++++++++ 2 files changed, 37 insertions(+) -- 2.18.0 diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c index 41c48a1e8baa..769640940c9f 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c @@ -542,6 +542,30 @@ static long efi_runtime_get_nexthighmonocount(unsigned long arg) return 0; } +static long efi_runtime_reset_system(unsigned long arg) +{ + struct efi_resetsystem __user *resetsystem_user; + struct efi_resetsystem resetsystem; + void *data = NULL; + + resetsystem_user = (struct efi_resetsystem __user *)arg; + if (copy_from_user(&resetsystem, resetsystem_user, + sizeof(resetsystem))) + return -EFAULT; + if (resetsystem.data_size != 0) { + data = memdup_user((void *)resetsystem.data, + resetsystem.data_size); + if (IS_ERR(data)) + return PTR_ERR(data); + } + + efi.reset_system(resetsystem.reset_type, resetsystem.status, + resetsystem.data_size, (efi_char16_t *)data); + + kfree(data); + return 0; +} + static long efi_runtime_query_variableinfo(unsigned long arg) { struct efi_queryvariableinfo __user *queryvariableinfo_user; @@ -682,6 +706,9 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd, case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES: return efi_runtime_query_capsulecaps(arg); + + case EFI_RUNTIME_RESET_SYSTEM: + return efi_runtime_reset_system(arg); } return -ENOTTY; diff --git a/drivers/firmware/efi/test/efi_test.h b/drivers/firmware/efi/test/efi_test.h index 9812c6a02b40..5f4818bf112f 100644 --- a/drivers/firmware/efi/test/efi_test.h +++ b/drivers/firmware/efi/test/efi_test.h @@ -81,6 +81,13 @@ struct efi_querycapsulecapabilities { efi_status_t *status; } __packed; +struct efi_resetsystem { + int reset_type; + efi_status_t status; + unsigned long data_size; + efi_char16_t *data; +} __packed; + #define EFI_RUNTIME_GET_VARIABLE \ _IOWR('p', 0x01, struct efi_getvariable) #define EFI_RUNTIME_SET_VARIABLE \ @@ -108,4 +115,7 @@ struct efi_querycapsulecapabilities { #define EFI_RUNTIME_QUERY_CAPSULECAPABILITIES \ _IOR('p', 0x0A, struct efi_querycapsulecapabilities) +#define EFI_RUNTIME_RESET_SYSTEM \ + _IOW('p', 0x0B, struct efi_resetsystem) + #endif /* _DRIVERS_FIRMWARE_EFI_TEST_H_ */ From patchwork Thu Sep 27 08:50:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 147693 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1726440lji; Thu, 27 Sep 2018 01:51:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV62sn66pJA7Sw+Hcpq313CRC4RAhRtTVGNJr1mnkYhxvD04LJB5T4J+ADjZDGUv3Wvu+RMPO X-Received: by 2002:a17:902:344:: with SMTP id 62-v6mr9986354pld.164.1538038277365; Thu, 27 Sep 2018 01:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538038277; cv=none; d=google.com; s=arc-20160816; b=QcqaBKXEhR9DDXGBPMTZkqEryLJnYh1dTbUVHDd3w2ku+om+mqNQVURR1jXlr2fCDR rE3D33Y49b0NypIarBEU6g/bvI2/MSpNT37pHGSZQ/YEv5Ck2+wtWG3OaX/5QoLSUTC7 Pt1kyaA+iDGmTlg3lid+8EOJWy5f7w7X0Zt9cZlmxhv2OQYqPXiVy7pM8Ac/Uxfug3Cz jdB3d6c+I4tXVFDaUecr/t75TFcW3OU3N+QBHJD9//e1EviusHVk1kC2GobllztE0bzG /ysCC/AKxsKgj7F/Ercu8HOqywF/z/QCfZKhjalhFNvxJvZFs9JTWuFhwXV/a3YaqKJx iLsA== 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; bh=AsXgWn/5EH4o89e3p8kGpDNY5N+XM/ydDKBocV+pJDQ=; b=0MN1xJiWdity+V9o8zAoFmj+Z5bcUGqlks6Su6win50LdW0Nc5weja1A7NiEVQUOTg dCiMzibZBvJ9anMRr3E65h+8juiVgFgVuZJXto3FSA5imvK2P8bi0+JyInSpH/QxRXd8 a+nh5Bpgc1XZnjZ3F7a0/rv5S7cZZeH4yziHWIMJXxor8aMfPgoGgV69XmyrBbihECHU CZ+jvMUE1kiT2oST04YAQyQlIxqwecNp6hlJL9j3Zr6xKa5GC0HJFQyuUdhJLpjw1/7z Fz/j+G50z5TUeMtHyTBRLO1UaABAJquLShBGhGX2TTDvvvCpEyrZ+YBMf69zLiv1GT4X Zmsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VwZuEh+H; 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 n13-v6si1259522pgd.280.2018.09.27.01.51.17; Thu, 27 Sep 2018 01:51:17 -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=VwZuEh+H; 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 S1727499AbeI0PIX (ORCPT + 32 others); Thu, 27 Sep 2018 11:08:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44391 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727458AbeI0PIV (ORCPT ); Thu, 27 Sep 2018 11:08:21 -0400 Received: by mail-wr1-f65.google.com with SMTP id v16-v6so1639985wro.11 for ; Thu, 27 Sep 2018 01:51: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=AsXgWn/5EH4o89e3p8kGpDNY5N+XM/ydDKBocV+pJDQ=; b=VwZuEh+HHm/qu9eI3ww/1j57RkEa2/295JWTMV2PmQIwqDtmgBXcFmr8Av4NUrpNI9 plP/GvIoxmKqZ1VG671jDKl06ckGuNDV5Ijp3LpRD7WF3nk9R9i7Sbw/nQMlpyTki1Gv Mzz5dxJteq2vM4AbVJMmAUFJ3Iqe+nMPYDOuc= 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=AsXgWn/5EH4o89e3p8kGpDNY5N+XM/ydDKBocV+pJDQ=; b=pa2guMAuQTRvvVsjKsPQXME+QR/hJFUjLQLbDF9rZQ2rg2P3LqwNDx7MzXYoBdr6q1 Dui6MwFOG5fpth7gmqqlvw9h0RNxcukbTxC6xvm5cq4lKwOP3lmuV6Bnp6wrX3QTn0Eh n/sxyqzZ4EEINcR8z6fC3FUSeX7UtQwKdHRZDJsQI0b3ARsEpONwjJXPolDThKuHV9ov XWm0RJKm9bnx6pTUibhne0P+wtM/H9FIyCx7qjLqHbKwd/eT4JiwSH51m4/X71fU8Bzk fEfeqvYbJvG9qrbGdtaeYE4VndUAil9OdRu+Y37LecLV33SpQ0q/RdQA73oxcYyUg51a Gw3Q== X-Gm-Message-State: ABuFfojmQqLMAN6kfKUQ2AwtgS+Q9X5bLLCDTZ7R0zhcNdzmiC4Q3oEV 5TzUA8PCKj7HY3dDvJBqIGNWYEU5K48= X-Received: by 2002:a5d:50cf:: with SMTP id f15-v6mr8271923wrt.128.1538038270936; Thu, 27 Sep 2018 01:51:10 -0700 (PDT) Received: from rev03.home ([2a01:cb1d:112:6f00:546e:3c44:5966:2f5e]) by smtp.gmail.com with ESMTPSA id p11-v6sm1304055wrd.74.2018.09.27.01.51.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 01:51:10 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, Aaron Ma , Alistair Strachan , Ben Hutchings , Bhupesh Sharma , Hans de Goede , Ivan Hu , Jeremy Linton , Marc Zyngier , Matt Fleming , Peter Robinson , Sai Praneeth Prakhya , Sebastian Andrzej Siewior , Stefan Agner Subject: [PATCH 10/11] efi/x86: Call efi_parse_options() from efi_main() Date: Thu, 27 Sep 2018 10:50:37 +0200 Message-Id: <20180927085039.8391-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180927085039.8391-1-ard.biesheuvel@linaro.org> References: <20180927085039.8391-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: Hans de Goede Before this commit we were only calling efi_parse_options() from make_boot_params(), but make_boot_params() only gets called if the kernel gets booted directly as an EFI executable. So when booted through e.g. grub we ended up not parsing the commandline in the boot code. This makes the drivers/firmware/efi/libstub code ignore the "quiet" commandline argument resulting in the following message being printed: "EFI stub: UEFI Secure Boot is enabled." Despite the quiet request. This commits adds an extra call to efi_parse_options() to efi_main() to make sure that the options are always processed. This fixes quiet not working. This also fixes the libstub code ignoring nokaslr and efi=nochunk. Reported-by: Peter Robinson Signed-off-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.18.0 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 1458b1700fc7..8b4c5e001157 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -738,6 +738,7 @@ efi_main(struct efi_config *c, struct boot_params *boot_params) struct desc_struct *desc; void *handle; efi_system_table_t *_table; + unsigned long cmdline_paddr; efi_early = c; @@ -755,6 +756,15 @@ efi_main(struct efi_config *c, struct boot_params *boot_params) else setup_boot_services32(efi_early); + /* + * make_boot_params() may have been called before efi_main(), in which + * case this is the second time we parse the cmdline. This is ok, + * parsing the cmdline multiple times does not have side-effects. + */ + cmdline_paddr = ((u64)hdr->cmd_line_ptr | + ((u64)boot_params->ext_cmd_line_ptr << 32)); + efi_parse_options((char *)cmdline_paddr); + /* * If the boot loader gave us a value for secure_boot then we use that, * otherwise we ask the BIOS.