From patchwork Thu Feb 23 19:26:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94415 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp361682qgi; Thu, 23 Feb 2017 11:26:58 -0800 (PST) X-Received: by 10.84.210.46 with SMTP id z43mr57512124plh.11.1487878018477; Thu, 23 Feb 2017 11:26:58 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si5097175plk.239.2017.02.23.11.26.58; Thu, 23 Feb 2017 11:26:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751308AbdBWT06 (ORCPT + 2 others); Thu, 23 Feb 2017 14:26:58 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37757 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751170AbdBWT05 (ORCPT ); Thu, 23 Feb 2017 14:26:57 -0500 Received: by mail-wm0-f51.google.com with SMTP id v77so8260614wmv.0 for ; Thu, 23 Feb 2017 11:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=XBdj44xwsnqx5Fz8ZqRhKNYTNuNRsjs72IDZrbJI7Wg=; b=SnwpDYgWr6DWV5ek90oMnA6T9QK31vTQGfQZ0nxwQwtiAzYVpQEwtwvM719aTWy3qb 0/twifSP/iIIJ2AczFi62qHRibjNbRZNC7UhEK/MDRUKqMInbqDHRJlnzkK7f11lPggI P4SiYznodhlUG8vSR2kLGvHblckWNVrsfSBr0= 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; bh=XBdj44xwsnqx5Fz8ZqRhKNYTNuNRsjs72IDZrbJI7Wg=; b=cvk0CH3OHUXqB8vtl4UeHGLT1ght5m1r85O2yifM6E1erF08Evjos5YCXv5oWDrP3l 7VCe9kYQBSMc9n4ID+5LYSeOaY+dJPYhHWtaI5vMvW1T22lU1gqMP4szpGeA6zJxb7ci 8DbeQ1dnm1zyHhMZWrGSEgn/VOwjNO3GLiF3XwPEPkjT5U5cycm448LFP/Uz3//AynlP 27mK0L8JMkJGlr3UnE7HY5DFsB8if1omiLNSeUcJHTqZT//eSBtILYYPIajNliglul8M rZSw2Psxnf3mlMj9LLjahjm/eLa3bkNx+Rb2Wv5K8bfO+hidvKuLXoGRwS9UI7cWSAfD 2oig== X-Gm-Message-State: AMke39kSeOJfvHG5IHybkKbhvfGpwaPDfMApyils6a2KBJS99MPFkwHo5lSWyANKHJlR02JT X-Received: by 10.28.61.84 with SMTP id k81mr6258340wma.27.1487878015677; Thu, 23 Feb 2017 11:26:55 -0800 (PST) Received: from localhost.localdomain ([105.149.201.216]) by smtp.gmail.com with ESMTPSA id e74sm7612360wmd.2.2017.02.23.11.26.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Feb 2017 11:26:54 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, kraxel@redhat.com Cc: matt@codeblueprint.co.uk, lersek@redhat.com, Ard Biesheuvel Subject: [PATCH] efi: ARM/arm64: fix boot crash with CONFIG_CPUMASK_OFFSTACK=y Date: Thu, 23 Feb 2017 19:26:48 +0000 Message-Id: <1487878008-10413-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org On ARM and arm64, we use a dedicated mm_struct to map the UEFI Runtime Services regions, which allows us to map those regions on demand, and in a way that is guaranteed to be compatible with incoming kernels across kexec. As it turns out, we don't fully initialize the mm_struct in the same way as process mm_structs are initialized on fork(), which results in the following crash if CONFIG_CPUMASK_OFFSTACK is enabled: EFI Variables Facility v0.08 2004-May-17 Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0204000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#1] SMP ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.8.6-300.fc25.armv7hl #1 Hardware name: Generic DT based system task: ee90d700 task.stack: ee904000 PC is at __memzero+0x60/0x7c LR is at check_and_switch_context+0x22c/0x494 pc : [] lr : [] psr: 000c0093 sp : ee905e18 ip : 00000004 fp : 00000000 r10: 00000000 r9 : c0e8e718 r8 : c0e38f70 r7 : 00000000 r6 : 00000005 r5 : c0e390d8 r4 : c0d87098 r3 : 00000000 r2 : 00000000 r1 : 00000004 r0 : 00000000 Flags: nzcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none Control: 10c5383d Table: 4020406a DAC: 00000051 Process swapper/0 (pid: 1, stack limit = 0xee904220) Stack: (0xee905e18 to 0xee906000) ... [] (__memzero) from [] (check_and_switch_context+0x22c/0x494) [] (check_and_switch_context) from [] (virt_efi_get_next_variable+0x28/0x8c) [] (virt_efi_get_next_variable) from [] (efivar_init+0x94/0x2d4) [] (efivar_init) from [] (efivars_sysfs_init+0x8c/0x1e8) [] (efivars_sysfs_init) from [] (do_one_initcall+0x130/0x158) [] (do_one_initcall) from [] (kernel_init_freeable+0x210/0x25c) This is due to a missing call to mm_init_cpumask(), so add it. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/arm-runtime.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index c394b81fe452..b4dd8b5ad516 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -45,6 +45,7 @@ static bool __init efi_virtmap_init(void) bool systab_found; efi_mm.pgd = pgd_alloc(&efi_mm); + mm_init_cpumask(&efi_mm); init_new_context(NULL, &efi_mm); systab_found = false;