From patchwork Mon Oct 12 13:56:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 54760 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 416F022DB6 for ; Mon, 12 Oct 2015 13:58:06 +0000 (UTC) Received: by wijq8 with SMTP id q8sf34609315wij.1 for ; Mon, 12 Oct 2015 06:58:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=X28SeOa+tG8xCLCnLy3hYAbl0NEvlkaQP0PTvZwcd5Q=; b=DkIeMAREoRT+95W30xCBkvlzuARZ9Kd17GB8rTWWHRAmJ4wpsfvUG50J/chd9Plazr a1efLruLbsfYtVcNgyoUlWNEEoU0otAmNIN5VYzxpK2VTFkRjOEGfUloUxhfnjgJVq4C ko9Sik8/fA+Qbcxe2d5JZomI4IDEoN1WxuAZoFyAgh8r1df3EZUyxkby0Cfh6Ca9eTrV X7q6ib3ghGHCPhWlO+V0y+jEt8WdtwcHuB2FY+jIB1Z9hhuNbF+9XVACaRCq95qLh1LD 0c6RI0z/TGDPE7fSjDOL4DqUmzHaSwQfXNeADB87TQiAeIu53mf09Lu0lfICXFcv7TKd lZiQ== X-Gm-Message-State: ALoCoQkcWpQLA1OWksHm8JT4jqwu6IIU4IfV76gLT0kVcbVux8JDjy+ttMt2umhDQNIW5Nw+UxhB X-Received: by 10.180.189.49 with SMTP id gf17mr2899650wic.6.1444658285562; Mon, 12 Oct 2015 06:58:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.165.18 with SMTP id o18ls89783lfe.39.gmail; Mon, 12 Oct 2015 06:58:05 -0700 (PDT) X-Received: by 10.25.16.92 with SMTP id f89mr2053498lfi.1.1444658285369; Mon, 12 Oct 2015 06:58:05 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id l19si8444616lfg.34.2015.10.12.06.58.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 06:58:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbwr8 with SMTP id r8so142331037lbw.2 for ; Mon, 12 Oct 2015 06:58:04 -0700 (PDT) X-Received: by 10.25.38.9 with SMTP id m9mr8157423lfm.112.1444658284887; Mon, 12 Oct 2015 06:58:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1564456lbq; Mon, 12 Oct 2015 06:58:04 -0700 (PDT) X-Received: by 10.50.124.8 with SMTP id me8mr2789364igb.92.1444658283765; Mon, 12 Oct 2015 06:58:03 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si12130688ioe.85.2015.10.12.06.58.03; Mon, 12 Oct 2015 06:58: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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752746AbbJLN5s (ORCPT + 30 others); Mon, 12 Oct 2015 09:57:48 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:38143 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbbJLN43 (ORCPT ); Mon, 12 Oct 2015 09:56:29 -0400 Received: by wieq12 with SMTP id q12so21688236wie.1 for ; Mon, 12 Oct 2015 06:56:28 -0700 (PDT) X-Received: by 10.194.62.137 with SMTP id y9mr30143967wjr.136.1444658188400; Mon, 12 Oct 2015 06:56:28 -0700 (PDT) Received: from localhost ([90.203.240.153]) by smtp.gmail.com with ESMTPSA id jt3sm20030450wjc.12.2015.10.12.06.56.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 06:56:27 -0700 (PDT) From: Matt Fleming To: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Leif Lindholm , Matt Fleming Subject: [PATCH 08/11] efi: Introduce EFI_NX_PE_DATA bit and set it from properties table Date: Mon, 12 Oct 2015 14:56:11 +0100 Message-Id: <1444658174-23378-9-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1444658174-23378-1-git-send-email-matt@codeblueprint.co.uk> References: <1444658174-23378-1-git-send-email-matt@codeblueprint.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: matt@codeblueprint.co.uk X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ard Biesheuvel UEFI v2.5 introduces a runtime memory protection feature that splits PE/COFF runtime images into separate code and data regions. Since this may require special handling by the OS, allocate a EFI_xxx bit to keep track of whether this feature is currently active or not. Signed-off-by: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Matt Fleming --- drivers/firmware/efi/efi.c | 18 ++++++++++++++++++ include/linux/efi.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index c297d78f50fd..31fc864eb037 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -426,6 +426,24 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, } pr_cont("\n"); set_bit(EFI_CONFIG_TABLES, &efi.flags); + + /* Parse the EFI Properties table if it exists */ + if (efi.properties_table != EFI_INVALID_TABLE_ADDR) { + efi_properties_table_t *tbl; + + tbl = early_memremap(efi.properties_table, sizeof(*tbl)); + if (tbl == NULL) { + pr_err("Could not map Properties table!\n"); + return -ENOMEM; + } + + if (tbl->memory_protection_attribute & + EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) + set_bit(EFI_NX_PE_DATA, &efi.flags); + + early_memunmap(tbl, sizeof(*tbl)); + } + return 0; } diff --git a/include/linux/efi.h b/include/linux/efi.h index d6a9bee755f2..fa5106c2f9f5 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -973,6 +973,7 @@ extern int __init efi_setup_pcdp_console(char *); #define EFI_PARAVIRT 6 /* Access is via a paravirt interface */ #define EFI_ARCH_1 7 /* First arch-specific bit */ #define EFI_DBG 8 /* Print additional debug info at runtime */ +#define EFI_NX_PE_DATA 9 /* Can runtime data regions be mapped non-executable? */ #ifdef CONFIG_EFI /*