From patchwork Wed Feb 17 12:36:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 62102 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2256859lbl; Wed, 17 Feb 2016 04:36:38 -0800 (PST) X-Received: by 10.66.122.3 with SMTP id lo3mr1713542pab.25.1455712597678; Wed, 17 Feb 2016 04:36:37 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id on6si1768197pac.30.2016.02.17.04.36.37; Wed, 17 Feb 2016 04:36:37 -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; 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; dkim=pass header.i=@codeblueprint-co-uk.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422845AbcBQMgd (ORCPT + 30 others); Wed, 17 Feb 2016 07:36:33 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:34571 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161523AbcBQMgW (ORCPT ); Wed, 17 Feb 2016 07:36:22 -0500 Received: by mail-wm0-f54.google.com with SMTP id b205so153758152wmb.1 for ; Wed, 17 Feb 2016 04:36:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeblueprint-co-uk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yaISBvDdLVCZvPQ+BEzc4gPbqT8X/jPBAKxP/bqXVoc=; b=Dvw2LN+60S63O1yagMZTNOnSdy1FvRFGNb9L9vMBSKvDNMFurGfbsWJr3wn8JxDYtt O7JIS9Tu11xApeY2nwHRMQSj4+cw/B+h8qpvn11vqDR6/U0IN0mjyyF7vY00fMq0mhW/ 2PLNzhjvAmb6ANn08UtqR4wqmrM7EQGoi+zFck2gy6WmTeWZGp6h9KBCLI+UAJnFwMQE 9L8MCu81hrbB0BKn7GJsyJ0wraA7HfGLzOwlm47W/hfGxiuvrk4Jp2NtZGAvWSGRiYtc 4KZHdLA4T9o8eoMcWKWA8xKQZGgjGkdNG90dlp5gDNpA/6E4OqOuoCRUI0cGtO5xlbm8 ANbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yaISBvDdLVCZvPQ+BEzc4gPbqT8X/jPBAKxP/bqXVoc=; b=Mm3CmUQ+o0d5cXwfr+TNLK/F2HZXzmf+3uXNNGUdlBm7V1W8ZH7hnxShttF4x8xrbW /g2J5/rtaZssukYx14MVY6rM1H5da2Y09hZ1Bi5tNHFNQoU7BOgUayP5a0ngeUlxCO9I t5kE1YKQWLAqNQphKiWbBG8VN4EoYubrJLvA/Ivmk1gUVK7hl0ZCkp3EG4sKxmnpc6/o umr9+ykKs/LjYG343qz0c+gYob4z8tGLn0lWskK5mU4EGbwGRgsREEmGxpVLGqm3E8NE rwvpQ1yfwpahMIVGNjWmM5/UJVl6utGypj5Ra0LTo/nHM1WYGvRCZA8bpY6jZq9r3BWW xxdQ== X-Gm-Message-State: AG10YORqMVnwMBSSmaE1i7VS6xQ8JiVmLso7bAApNmk0tmK8RPjCVsmQAS+p319upWUz4A== X-Received: by 10.28.88.81 with SMTP id m78mr3595748wmb.58.1455712581174; Wed, 17 Feb 2016 04:36:21 -0800 (PST) Received: from localhost (5ec16434.skybroadband.com. [94.193.100.52]) by smtp.gmail.com with ESMTPSA id s2sm1291056wjs.39.2016.02.17.04.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Feb 2016 04:36:20 -0800 (PST) From: Matt Fleming To: Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Matt Fleming , Mark Rutland Subject: [PATCH 07/13] efi/arm-init: Use read-only early mappings Date: Wed, 17 Feb 2016 12:36:00 +0000 Message-Id: <1455712566-16727-8-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1455712566-16727-1-git-send-email-matt@codeblueprint.co.uk> References: <1455712566-16727-1-git-send-email-matt@codeblueprint.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel The early mappings of the EFI system table contents and the UEFI memory map are read-only from the OS point of view. So map them read-only to protect them from inadvertent modification. Acked-by: Mark Rutland Tested-by: Mark Rutland Signed-off-by: Ard Biesheuvel Signed-off-by: Matt Fleming --- drivers/firmware/efi/arm-init.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.6.2 diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index 9e15d571b53c..aa1f743152a2 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -61,8 +61,8 @@ static int __init uefi_init(void) char vendor[100] = "unknown"; int i, retval; - efi.systab = early_memremap(efi_system_table, - sizeof(efi_system_table_t)); + efi.systab = early_memremap_ro(efi_system_table, + sizeof(efi_system_table_t)); if (efi.systab == NULL) { pr_warn("Unable to map EFI system table.\n"); return -ENOMEM; @@ -86,8 +86,8 @@ static int __init uefi_init(void) efi.systab->hdr.revision & 0xffff); /* Show what we know for posterity */ - c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor), - sizeof(vendor) * sizeof(efi_char16_t)); + c16 = early_memremap_ro(efi_to_phys(efi.systab->fw_vendor), + sizeof(vendor) * sizeof(efi_char16_t)); if (c16) { for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i) vendor[i] = c16[i]; @@ -100,8 +100,8 @@ static int __init uefi_init(void) efi.systab->hdr.revision & 0xffff, vendor); table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables; - config_tables = early_memremap(efi_to_phys(efi.systab->tables), - table_size); + config_tables = early_memremap_ro(efi_to_phys(efi.systab->tables), + table_size); if (config_tables == NULL) { pr_warn("Unable to map EFI config table array.\n"); retval = -ENOMEM; @@ -185,7 +185,7 @@ void __init efi_init(void) efi_system_table = params.system_table; memmap.phys_map = params.mmap; - memmap.map = early_memremap(params.mmap, params.mmap_size); + memmap.map = early_memremap_ro(params.mmap, params.mmap_size); if (memmap.map == NULL) { /* * If we are booting via UEFI, the UEFI memory map is the only