From patchwork Wed Mar 1 19:05:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94737 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1954216qgi; Wed, 1 Mar 2017 11:15:25 -0800 (PST) X-Received: by 10.99.164.18 with SMTP id c18mr10710700pgf.40.1488395725422; Wed, 01 Mar 2017 11:15:25 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c195si5335692pga.289.2017.03.01.11.15.25; Wed, 01 Mar 2017 11:15:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; 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 S1753316AbdCATPY (ORCPT + 25 others); Wed, 1 Mar 2017 14:15:24 -0500 Received: from mail-wr0-f176.google.com ([209.85.128.176]:34685 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbdCATOd (ORCPT ); Wed, 1 Mar 2017 14:14:33 -0500 Received: by mail-wr0-f176.google.com with SMTP id l37so37061809wrc.1 for ; Wed, 01 Mar 2017 11:14:18 -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:in-reply-to:references; bh=oP0CBm0bXD57aaQH1+rlsiN2dXC2V5uai5nMF/Q3+4A=; b=TjQX+m8jRXs4rW0X2LOtvQlpu9W1UIy2uNwrZKBgNeQ9skhYgsyVV1qn2EAk1k1QSe RrWQoTaCxlQqCLDJsM0MC0VlZCRPtNtmcyCtz+emoDVdjHxScFsI4DlGOPdhV2qBc25G T+YtZB8OTGG5YrUVUz/UIicmyjVfgGaNhqalE= 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=oP0CBm0bXD57aaQH1+rlsiN2dXC2V5uai5nMF/Q3+4A=; b=Xi+K5/qK3Prc2/PZyV9Mq3Uv4AdFTIe7qgRlCkmVdU9zn0s6lSjDoKhiRNKyjkETOq FNccJkGAE7wfftFk609XKNC4a2C6CyCU2LxFref7d0/r9/hiKx1IckFWGNvtXIGakKFz 7XrqY6u9viu2mfkmLaZSKsTREFpYQQphYQaI7l6VHPcVtlNGuaZ5u8EI01zhmTjZDhZ7 Ukuxs6OoWNwwmeRUO4KoVgEZLbuzWdMzVjEuWXX9m92CS0yi/JXbKdaLqpJTj//5sC1w Or2jrvTgIbQBX83UZ2C/rwsN1BFuiNlMWToIYkMQBm40lYZ8jhpRMqonEuAzddbcWrHj bC/A== X-Gm-Message-State: AMke39mKtLsu1ocgD52FOWIMGi/RgWKHcF0Jk9qXYDgVaRHXY3cuvDc5lbuZ20gpeDx5UJgp X-Received: by 10.223.160.162 with SMTP id m31mr8952301wrm.54.1488395172131; Wed, 01 Mar 2017 11:06:12 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id u41sm7741620wrc.24.2017.03.01.11.06.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Mar 2017 11:06:11 -0800 (PST) From: Ard Biesheuvel To: matt@codeblueprint.co.uk, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH 2/2] efi: arm: Fix boot crash with CONFIG_CPUMASK_OFFSTACK=y Date: Wed, 1 Mar 2017 19:05:54 +0000 Message-Id: <1488395154-29786-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395076-29712-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488395076-29712-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 on ARM 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. Cc: Matt Fleming Cc: # v4.5+ Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/arm-runtime.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 349dc3e1e52e..974c5a31a005 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -65,6 +65,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;