From patchwork Tue Jan 31 13:21:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 92986 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1924084qgi; Tue, 31 Jan 2017 05:28:34 -0800 (PST) X-Received: by 10.84.194.37 with SMTP id g34mr39669757pld.105.1485869314563; Tue, 31 Jan 2017 05:28:34 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si15952408pfj.150.2017.01.31.05.28.34; Tue, 31 Jan 2017 05:28:34 -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 S1752272AbdAaN22 (ORCPT + 2 others); Tue, 31 Jan 2017 08:28:28 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37958 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752064AbdAaN0A (ORCPT ); Tue, 31 Jan 2017 08:26:00 -0500 Received: by mail-wm0-f42.google.com with SMTP id r141so79328838wmg.1 for ; Tue, 31 Jan 2017 05:25:50 -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=Gda1hGQaQ8mqYVbo6fVpD9K3p+EcmIDiuhk3NVPywrs=; b=ElRkqYOdd/+1WdjJQGZOknqdZlET1/1+G8zSAgC4UUzN4yxVItUfAAFqaeHawV1jPs FSBf42h6aLpYVBSdk6bAkW/TjZB89OkmFUJ1Nd6NGEsljiidoDsh15Xd5+pHu3vx/nor CZb4qVmh7bz9ue6BMBAlU7sIak4yCBhEvilsw= 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=Gda1hGQaQ8mqYVbo6fVpD9K3p+EcmIDiuhk3NVPywrs=; b=E4KYaoEcYl0+1wSccJDAKqCzdlK8crGNnUO+wjxwyiBQtBXyBu7GmhOwuOX8G8aBRI ZOBOuNhtfoRLEfRZabQVStfCHr0HgQdEyp1RVKHKt4ZLytmVEEV8Jsi0f8/VrED0eXOY u757lnDvUyjz3xbNN2JF0Inw1+tVAvhi5PuROJtoFwPIyUXW5volQyEtedvhNPql9G+L xmGjCO2BDRtjV4cFMVotYSyjEguOlVS30RUoN2e1wGJMRVa9M6J6ilCnCYzdAsD2yiF0 JDFldrtdg+X+67QGXm7I+EndeXEq+zCKF2nXdiHj6doaRscSu0NQsLR+6kyTjeC2yxEL adRg== X-Gm-Message-State: AIkVDXJGRf64m4otUu3XNELMib8adDqU51frOVgBm7Bqbu9PmRA5YPX/urofRH4ZMdpiwt/9 X-Received: by 10.223.134.253 with SMTP id 58mr28162962wry.46.1485869149251; Tue, 31 Jan 2017 05:25:49 -0800 (PST) Received: from localhost.localdomain ([105.130.17.13]) by smtp.gmail.com with ESMTPSA id i73sm23961714wmd.11.2017.01.31.05.25.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 05:25:48 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Lukas Wunner , Ard Biesheuvel , linux-efi@vger.kernel.org, Matt Fleming Subject: [PATCH 01/10] efi: Deduplicate efi_file_size() / _read() / _close() Date: Tue, 31 Jan 2017 13:21:33 +0000 Message-Id: <1485868902-20401-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> References: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Lukas Wunner There's one ARM, one x86_32 and one x86_64 version which can be folded into a single shared version by masking their differences with the shiny new efi_call_proto() macro. No functional change intended. Signed-off-by: Lukas Wunner Cc: Ard Biesheuvel Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 148 ------------------------- drivers/firmware/efi/libstub/arm-stub.c | 69 ------------ drivers/firmware/efi/libstub/efi-stub-helper.c | 63 +++++++++++ drivers/firmware/efi/libstub/efistub.h | 8 -- 4 files changed, 63 insertions(+), 225 deletions(-) -- 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/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index ff01c8fc76f7..f1cf284d631e 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -38,154 +38,6 @@ static void setup_boot_services##bits(struct efi_config *c) \ BOOT_SERVICES(32); BOOT_SERVICES(64); -void efi_char16_printk(efi_system_table_t *, efi_char16_t *); - -static efi_status_t -__file_size32(void *__fh, efi_char16_t *filename_16, - void **handle, u64 *file_sz) -{ - efi_file_handle_32_t *h, *fh = __fh; - efi_file_info_t *info; - efi_status_t status; - efi_guid_t info_guid = EFI_FILE_INFO_ID; - u32 info_sz; - - status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16, - EFI_FILE_MODE_READ, (u64)0); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to open file: "); - efi_char16_printk(sys_table, filename_16); - efi_printk(sys_table, "\n"); - return status; - } - - *handle = h; - - info_sz = 0; - status = efi_early->call((unsigned long)h->get_info, h, &info_guid, - &info_sz, NULL); - if (status != EFI_BUFFER_TOO_SMALL) { - efi_printk(sys_table, "Failed to get file info size\n"); - return status; - } - -grow: - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, - info_sz, (void **)&info); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to alloc mem for file info\n"); - return status; - } - - status = efi_early->call((unsigned long)h->get_info, h, &info_guid, - &info_sz, info); - if (status == EFI_BUFFER_TOO_SMALL) { - efi_call_early(free_pool, info); - goto grow; - } - - *file_sz = info->file_size; - efi_call_early(free_pool, info); - - if (status != EFI_SUCCESS) - efi_printk(sys_table, "Failed to get initrd info\n"); - - return status; -} - -static efi_status_t -__file_size64(void *__fh, efi_char16_t *filename_16, - void **handle, u64 *file_sz) -{ - efi_file_handle_64_t *h, *fh = __fh; - efi_file_info_t *info; - efi_status_t status; - efi_guid_t info_guid = EFI_FILE_INFO_ID; - u64 info_sz; - - status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16, - EFI_FILE_MODE_READ, (u64)0); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to open file: "); - efi_char16_printk(sys_table, filename_16); - efi_printk(sys_table, "\n"); - return status; - } - - *handle = h; - - info_sz = 0; - status = efi_early->call((unsigned long)h->get_info, h, &info_guid, - &info_sz, NULL); - if (status != EFI_BUFFER_TOO_SMALL) { - efi_printk(sys_table, "Failed to get file info size\n"); - return status; - } - -grow: - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, - info_sz, (void **)&info); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to alloc mem for file info\n"); - return status; - } - - status = efi_early->call((unsigned long)h->get_info, h, &info_guid, - &info_sz, info); - if (status == EFI_BUFFER_TOO_SMALL) { - efi_call_early(free_pool, info); - goto grow; - } - - *file_sz = info->file_size; - efi_call_early(free_pool, info); - - if (status != EFI_SUCCESS) - efi_printk(sys_table, "Failed to get initrd info\n"); - - return status; -} -efi_status_t -efi_file_size(efi_system_table_t *sys_table, void *__fh, - efi_char16_t *filename_16, void **handle, u64 *file_sz) -{ - if (efi_early->is64) - return __file_size64(__fh, filename_16, handle, file_sz); - - return __file_size32(__fh, filename_16, handle, file_sz); -} - -efi_status_t -efi_file_read(void *handle, unsigned long *size, void *addr) -{ - unsigned long func; - - if (efi_early->is64) { - efi_file_handle_64_t *fh = handle; - - func = (unsigned long)fh->read; - return efi_early->call(func, handle, size, addr); - } else { - efi_file_handle_32_t *fh = handle; - - func = (unsigned long)fh->read; - return efi_early->call(func, handle, size, addr); - } -} - -efi_status_t efi_file_close(void *handle) -{ - if (efi_early->is64) { - efi_file_handle_64_t *fh = handle; - - return efi_early->call((unsigned long)fh->close, handle); - } else { - efi_file_handle_32_t *fh = handle; - - return efi_early->call((unsigned long)fh->close, handle); - } -} - static inline efi_status_t __open_volume32(void *__image, void **__fh) { efi_file_io_interface_t *io; diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index b4f7d78f9e8b..6fca48c9e054 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -91,75 +91,6 @@ efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, return status; } -efi_status_t efi_file_close(void *handle) -{ - efi_file_handle_t *fh = handle; - - return fh->close(handle); -} - -efi_status_t -efi_file_read(void *handle, unsigned long *size, void *addr) -{ - efi_file_handle_t *fh = handle; - - return fh->read(handle, size, addr); -} - - -efi_status_t -efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, - efi_char16_t *filename_16, void **handle, u64 *file_sz) -{ - efi_file_handle_t *h, *fh = __fh; - efi_file_info_t *info; - efi_status_t status; - efi_guid_t info_guid = EFI_FILE_INFO_ID; - unsigned long info_sz; - - status = fh->open(fh, &h, filename_16, EFI_FILE_MODE_READ, (u64)0); - if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "Failed to open file: "); - efi_char16_printk(sys_table_arg, filename_16); - efi_printk(sys_table_arg, "\n"); - return status; - } - - *handle = h; - - info_sz = 0; - status = h->get_info(h, &info_guid, &info_sz, NULL); - if (status != EFI_BUFFER_TOO_SMALL) { - efi_printk(sys_table_arg, "Failed to get file info size\n"); - return status; - } - -grow: - status = sys_table_arg->boottime->allocate_pool(EFI_LOADER_DATA, - info_sz, (void **)&info); - if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "Failed to alloc mem for file info\n"); - return status; - } - - status = h->get_info(h, &info_guid, &info_sz, - info); - if (status == EFI_BUFFER_TOO_SMALL) { - sys_table_arg->boottime->free_pool(info); - goto grow; - } - - *file_sz = info->file_size; - sys_table_arg->boottime->free_pool(info); - - if (status != EFI_SUCCESS) - efi_printk(sys_table_arg, "Failed to get initrd info\n"); - - return status; -} - - - void efi_char16_printk(efi_system_table_t *sys_table_arg, efi_char16_t *str) { diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 757badc1debb..6ee9164251a9 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -338,6 +338,69 @@ void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, efi_call_early(free_pages, addr, nr_pages); } +static efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, + efi_char16_t *filename_16, void **handle, + u64 *file_sz) +{ + efi_file_handle_t *h, *fh = __fh; + efi_file_info_t *info; + efi_status_t status; + efi_guid_t info_guid = EFI_FILE_INFO_ID; + unsigned long info_sz; + + status = efi_call_proto(efi_file_handle, open, fh, &h, filename_16, + EFI_FILE_MODE_READ, (u64)0); + if (status != EFI_SUCCESS) { + efi_printk(sys_table_arg, "Failed to open file: "); + efi_char16_printk(sys_table_arg, filename_16); + efi_printk(sys_table_arg, "\n"); + return status; + } + + *handle = h; + + info_sz = 0; + status = efi_call_proto(efi_file_handle, get_info, h, &info_guid, + &info_sz, NULL); + if (status != EFI_BUFFER_TOO_SMALL) { + efi_printk(sys_table_arg, "Failed to get file info size\n"); + return status; + } + +grow: + status = efi_call_early(allocate_pool, EFI_LOADER_DATA, + info_sz, (void **)&info); + if (status != EFI_SUCCESS) { + efi_printk(sys_table_arg, "Failed to alloc mem for file info\n"); + return status; + } + + status = efi_call_proto(efi_file_handle, get_info, h, &info_guid, + &info_sz, info); + if (status == EFI_BUFFER_TOO_SMALL) { + efi_call_early(free_pool, info); + goto grow; + } + + *file_sz = info->file_size; + efi_call_early(free_pool, info); + + if (status != EFI_SUCCESS) + efi_printk(sys_table_arg, "Failed to get initrd info\n"); + + return status; +} + +static efi_status_t efi_file_read(void *handle, unsigned long *size, void *addr) +{ + return efi_call_proto(efi_file_handle, read, handle, size, addr); +} + +static efi_status_t efi_file_close(void *handle) +{ + return efi_call_proto(efi_file_handle, close, handle); +} + /* * Parse the ASCII string 'cmdline' for EFI options, denoted by the efi= * option, e.g. efi=nochunk. diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 0e2a96b12cb3..71c4d0e3c4ed 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -29,14 +29,6 @@ void efi_char16_printk(efi_system_table_t *, efi_char16_t *); efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image, void **__fh); -efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, - efi_char16_t *filename_16, void **handle, - u64 *file_sz); - -efi_status_t efi_file_read(void *handle, unsigned long *size, void *addr); - -efi_status_t efi_file_close(void *handle); - unsigned long get_dram_base(efi_system_table_t *sys_table_arg); efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, From patchwork Tue Jan 31 13:21:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 92990 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1924177qgi; Tue, 31 Jan 2017 05:28:51 -0800 (PST) X-Received: by 10.99.173.14 with SMTP id g14mr30557070pgf.176.1485869331519; Tue, 31 Jan 2017 05:28:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a87si15946026pfk.200.2017.01.31.05.28.51; Tue, 31 Jan 2017 05:28:51 -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 S1752098AbdAaN2h (ORCPT + 2 others); Tue, 31 Jan 2017 08:28:37 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37984 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072AbdAaN0A (ORCPT ); Tue, 31 Jan 2017 08:26:00 -0500 Received: by mail-wm0-f42.google.com with SMTP id r141so79330045wmg.1 for ; Tue, 31 Jan 2017 05:25:52 -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=IY2/WXGrIPW4laOYTOYTKz/gdHrEGpK1j6+9vM3e/BY=; b=dt2DPROt2Ao6L1kMD52jW1oBti9RM1O65a/FmLkE5jTvz0Ei6W3b6TmRS4yfUicCNQ gtwlLgeJ9aoCuws43SaqhtqUv9ZWn8pfkYXaMwO6p82kYR/paTWjm3QFIS335mWcQp6T JPOSnbVxxFhs6uHwhZxACpLsX4LnyJ6OvgGNg= 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=IY2/WXGrIPW4laOYTOYTKz/gdHrEGpK1j6+9vM3e/BY=; b=dHukR7RS/aMS+egOthSP/EIHpMHXJH4TzgZ2xSpmQdDP8KexpCMgN5lJq/0z/9wf6P 7qSjNXNcqANFcAEmNMlNWhkn1g4wWKeC+HofGC4lV+1dk9VZXJ8r1WIEfdBrJaNTLuRo CJ8T87syW9RrR1Qm76DflC18V9x2AaPYWzOWAaFuzdifP0+QZiLby9R2dJi5vgM6+xPN tfm2h8T4UItYTB83Q2K6wBcqaUXC8pCgg9oDB1mVwQhlNVU2fdfJJcbabPzdtzR2ylOZ Lvq5mxTs/ZbPhXp/TGu/puvvekH+pbnUqi+xMFpT3AkL+Kcyz008jW9udaLSFypTfXIl 44qQ== X-Gm-Message-State: AIkVDXJGBwWUsyxXNgqCJjLZQkmpVmmRUAkhXAwDAzWLlMLAy905cjrE+8Rjs+9zDfpw1HsT X-Received: by 10.223.164.66 with SMTP id e2mr23333274wra.47.1485869151184; Tue, 31 Jan 2017 05:25:51 -0800 (PST) Received: from localhost.localdomain ([105.130.17.13]) by smtp.gmail.com with ESMTPSA id i73sm23961714wmd.11.2017.01.31.05.25.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 05:25:50 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Lukas Wunner , Ard Biesheuvel , linux-efi@vger.kernel.org, Matt Fleming Subject: [PATCH 02/10] x86/efi: Deduplicate efi_char16_printk() Date: Tue, 31 Jan 2017 13:21:34 +0000 Message-Id: <1485868902-20401-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> References: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Lukas Wunner Eliminate the separate 32 bit and 64 bit code paths by way of the shiny new efi_call_proto() macro. No functional change intended. Signed-off-by: Lukas Wunner Cc: Ard Biesheuvel Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 26 ++------------------------ include/linux/efi.h | 8 ++++---- 2 files changed, 6 insertions(+), 28 deletions(-) -- 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/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index f1cf284d631e..6d3aeabbce68 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -101,30 +101,8 @@ efi_open_volume(efi_system_table_t *sys_table, void *__image, void **__fh) void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) { - unsigned long output_string; - size_t offset; - - if (efi_early->is64) { - struct efi_simple_text_output_protocol_64 *out; - u64 *func; - - offset = offsetof(typeof(*out), output_string); - output_string = efi_early->text_output + offset; - out = (typeof(out))(unsigned long)efi_early->text_output; - func = (u64 *)output_string; - - efi_early->call(*func, out, str); - } else { - struct efi_simple_text_output_protocol_32 *out; - u32 *func; - - offset = offsetof(typeof(*out), output_string); - output_string = efi_early->text_output + offset; - out = (typeof(out))(unsigned long)efi_early->text_output; - func = (u32 *)output_string; - - efi_early->call(*func, out, str); - } + efi_call_proto(efi_simple_text_output_protocol, output_string, + efi_early->text_output, str); } static efi_status_t diff --git a/include/linux/efi.h b/include/linux/efi.h index 5b1af30ece55..6642c4d9d11d 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1240,17 +1240,17 @@ struct efivar_entry { bool deleting; }; -struct efi_simple_text_output_protocol_32 { +typedef struct { u32 reset; u32 output_string; u32 test_string; -}; +} efi_simple_text_output_protocol_32_t; -struct efi_simple_text_output_protocol_64 { +typedef struct { u64 reset; u64 output_string; u64 test_string; -}; +} efi_simple_text_output_protocol_64_t; struct efi_simple_text_output_protocol { void *reset; From patchwork Tue Jan 31 13:21:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 92989 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1924092qgi; Tue, 31 Jan 2017 05:28:35 -0800 (PST) X-Received: by 10.98.74.84 with SMTP id x81mr29018875pfa.172.1485869315264; Tue, 31 Jan 2017 05:28:35 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si15952408pfj.150.2017.01.31.05.28.35; Tue, 31 Jan 2017 05:28:35 -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 S1752551AbdAaN2d (ORCPT + 2 others); Tue, 31 Jan 2017 08:28:33 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:34974 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbdAaN0A (ORCPT ); Tue, 31 Jan 2017 08:26:00 -0500 Received: by mail-wm0-f47.google.com with SMTP id b65so79135430wmf.0 for ; Tue, 31 Jan 2017 05:25: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:in-reply-to:references; bh=b06rMXHp1y6ZUDivhdmHbFIS4N95db+VGoEDNKADRnk=; b=BjsvDWFuTzWrCaeRw6WFaQnwGeoSPJAUvU9Oj4H+F0D8d8ZBg0MZq6Ddu+1OHLTbxJ cB75DTS6vHZjOYY9A/D0bDwQ8zY2jVtq+FCrVbZ8Uk7AfLJpICz98EciovCkj/tjXFFj 7XoxN9jWFOE954OxTfAaJ3Qx13qT9igYPgnL4= 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=b06rMXHp1y6ZUDivhdmHbFIS4N95db+VGoEDNKADRnk=; b=qqU/Uc39n0ytu1n48BbUfIXuqHu+JdxEn1A9xhkrGpeksmdmKX7DSJY6tc9s1g2M64 O/LXePcHOR3dvcefvinHjcW4TH4FehE5iwUgM5LcucnTgvOYTVEusVl6NJ4JpqQGe7dC lzASR7oM/i826LCjr67+ZlxUjN2KrqxyPcIBetffzerErEARu/xMH58bGbokZeb7Kn1w KKU0vWhJcO63JwlREq7o3C88qOLY5nFa+/h4QSRCRxOp0BpEv+d4113D3eB3upSdIrII 7Hq2rq+RfSeBtesheWVN1NVklOP5MhbTKnvyAQznFQmiZRZTu4OJYZ64mH80P97R147A YwJQ== X-Gm-Message-State: AIkVDXLpXixQFqNYxUutMqcWb4sRRjhw4CNGfG9FemoDSgASXuQ7jnhD/I+Vibn8CnYdGa2C X-Received: by 10.223.176.142 with SMTP id i14mr28198820wra.4.1485869155424; Tue, 31 Jan 2017 05:25:55 -0800 (PST) Received: from localhost.localdomain ([105.130.17.13]) by smtp.gmail.com with ESMTPSA id i73sm23961714wmd.11.2017.01.31.05.25.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 05:25:53 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Sai Praneeth , Ard Biesheuvel , linux-efi@vger.kernel.org, Borislav Petkov , Ricardo Neri , Ravi Shankar , Fenghua Yu , Matt Fleming Subject: [PATCH 03/10] efi: Make EFI_MEMORY_ATTRIBUTES_TABLE initialization common across all architectures Date: Tue, 31 Jan 2017 13:21:35 +0000 Message-Id: <1485868902-20401-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> References: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Sai Praneeth Since EFI_PROPERTIES_TABLE and EFI_MEMORY_ATTRIBUTES_TABLE deal with updating memory region attributes, it makes sense to call EFI_MEMORY_ATTRIBUTES_TABLE initialization function from the same place as EFI_PROPERTIES_TABLE. This also moves the EFI_MEMORY_ATTRIBUTES_TABLE initialization code to a more generic efi initialization path rather than ARM specific efi initialization. This is important because EFI_MEMORY_ATTRIBUTES_TABLE will be supported by x86 as well. Signed-off-by: Sai Praneeth Prakhya Reviewed-by: "Lee, Chun-Yi" Cc: Borislav Petkov Cc: Ricardo Neri Cc: Ard Biesheuvel Cc: Ravi Shankar Cc: Fenghua Yu Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/arm-init.c | 1 - drivers/firmware/efi/efi.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) -- 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-init.c b/drivers/firmware/efi/arm-init.c index f853ad2c4ca0..1027d7b44358 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -250,7 +250,6 @@ void __init efi_init(void) } reserve_regions(); - efi_memattr_init(); efi_esrt_init(); efi_memmap_unmap(); diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 92914801e388..e7d404059b73 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -529,6 +529,8 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, } } + efi_memattr_init(); + /* Parse the EFI Properties table if it exists */ if (efi.properties_table != EFI_INVALID_TABLE_ADDR) { efi_properties_table_t *tbl; From patchwork Tue Jan 31 13:21:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 92988 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1924090qgi; Tue, 31 Jan 2017 05:28:35 -0800 (PST) X-Received: by 10.98.24.14 with SMTP id 14mr29618725pfy.73.1485869315079; Tue, 31 Jan 2017 05:28:35 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si15952408pfj.150.2017.01.31.05.28.34; Tue, 31 Jan 2017 05:28:35 -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 S1752549AbdAaN2c (ORCPT + 2 others); Tue, 31 Jan 2017 08:28:32 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36246 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752106AbdAaN0A (ORCPT ); Tue, 31 Jan 2017 08:26:00 -0500 Received: by mail-wm0-f51.google.com with SMTP id c85so260981979wmi.1 for ; Tue, 31 Jan 2017 05:25:59 -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=mm9NBh0MhINLN45iLrm9lItPlPfaimbNkOb4CUIu+KU=; b=cSiDKybM1Abv872N7nIzsYfdG7yCUohDDBlhk5d1hVeGZTq1QYP1bb3OZiGnHcEQPu dWTK/Wxvr8MBRJvODp+nhPFRAVfz9t9ohMAzslGdMm/DpHqQD8KwHVWQog18fh3EEUhp 7kFRIItM3Esq9vUmw+6f9pFioOlcIQNFHqeBI= 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=mm9NBh0MhINLN45iLrm9lItPlPfaimbNkOb4CUIu+KU=; b=RpmAu7MT4c0hAlP2ujm5zurXOIIXBc6fSFusU9ovLsNdBJHKsY+Q/DaRTY/lZpbku6 fyUnWwqgb7iQeLqh5fuwA1q7VnYADAL+54xOM0VQ4HSIqVlf4YVKB655jdl5yUhm/+pq TGPRPX7kNV/OFXV/roktZswtjYorE9cvro2Qdm5xt0JHBDko5rbC6K8HEASdyYYXqQOz 0BMAW/HEFWn7hHkdndHCTE+zFEKBNjRENvLFezgAjhH7R9HdSSna6mna3BD7sx5JJuFU iMQUJfh8XGdauETmJvlT7NY/J7ZgzjXDkll9JAi8OKE74vEsPMr2mE+4O178FwXGMNl3 TK+A== X-Gm-Message-State: AIkVDXJL3Xn9fDrv3ev0yjf0LMAtFOUaBFc4tBn05YVHUjpVFSJkGvW34wsSQi68DGRvpjLJ X-Received: by 10.223.133.164 with SMTP id 33mr24245640wrt.39.1485869158281; Tue, 31 Jan 2017 05:25:58 -0800 (PST) Received: from localhost.localdomain ([105.130.17.13]) by smtp.gmail.com with ESMTPSA id i73sm23961714wmd.11.2017.01.31.05.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 05:25:57 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Sai Praneeth , Ard Biesheuvel , linux-efi@vger.kernel.org, Borislav Petkov , Ricardo Neri , Ravi Shankar , Fenghua Yu , Matt Fleming Subject: [PATCH 04/10] efi: Introduce EFI_MEM_ATTR bit and set it from memory attributes table Date: Tue, 31 Jan 2017 13:21:36 +0000 Message-Id: <1485868902-20401-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> References: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Sai Praneeth UEFI v2.6 introduces a configuration table called EFI_MEMORY_ATTRIBUTES_TABLE which provides additional information about efi runtime regions. Currently this table describes memory protections that may be applied to EFI Runtime code and data regions by kernel. Allocate a EFI_XXX bit to keep track of whether this feature is published by firmware or not. Signed-off-by: Sai Praneeth Prakhya Reviewed-by: "Lee, Chun-Yi" Cc: Borislav Petkov Cc: Ricardo Neri Cc: Ard Biesheuvel Cc: Ravi Shankar Cc: Fenghua Yu Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/memattr.c | 1 + include/linux/efi.h | 1 + 2 files changed, 2 insertions(+) -- 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/memattr.c b/drivers/firmware/efi/memattr.c index 236004b9a50d..402197460507 100644 --- a/drivers/firmware/efi/memattr.c +++ b/drivers/firmware/efi/memattr.c @@ -43,6 +43,7 @@ int __init efi_memattr_init(void) tbl_size = sizeof(*tbl) + tbl->num_entries * tbl->desc_size; memblock_reserve(efi.mem_attr_table, tbl_size); + set_bit(EFI_MEM_ATTR, &efi.flags); unmap: early_memunmap(tbl, sizeof(*tbl)); diff --git a/include/linux/efi.h b/include/linux/efi.h index 6642c4d9d11d..b17f73113bd2 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1065,6 +1065,7 @@ extern int __init efi_setup_pcdp_console(char *); #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? */ +#define EFI_MEM_ATTR 10 /* Did firmware publish EFI_MEMORY_ATTRIBUTES table? */ #ifdef CONFIG_EFI /* From patchwork Tue Jan 31 13:21:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 92980 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1923334qgi; Tue, 31 Jan 2017 05:26:30 -0800 (PST) X-Received: by 10.84.176.1 with SMTP id u1mr39314057plb.71.1485869190565; Tue, 31 Jan 2017 05:26:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si10801575pgd.294.2017.01.31.05.26.30; Tue, 31 Jan 2017 05:26:30 -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 S1752330AbdAaN00 (ORCPT + 2 others); Tue, 31 Jan 2017 08:26:26 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:37020 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752220AbdAaN0G (ORCPT ); Tue, 31 Jan 2017 08:26:06 -0500 Received: by mail-wm0-f43.google.com with SMTP id v77so93364724wmv.0 for ; Tue, 31 Jan 2017 05:26:05 -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=ZZke4etvapEowh1Z4IVIWU7YtcoZvz6d068RuujjCqU=; b=dAR5HqH6jlU3/G3qcy4WVRf5DPT9Le5zCmvF2d8w9qxeOUGhkPiC4UiwPm2PkvDxKW 9BY1YugLZzYpXQ981WE/XHIXWh1INk01P1xXHAEq3TWjq0NyheTvP9oHP3kw1DVI19At 61bCWMRkb1zu0TyNa8eDPXqYDlU/Hb6o8OxJc= 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=ZZke4etvapEowh1Z4IVIWU7YtcoZvz6d068RuujjCqU=; b=op0q9cNYJ6pt4oBFMEZYImTsYWjcRBk4RZSyQr52Zv3eFjCiDda0WOO9RKOKQRIxL2 +VKDG+JAe7oCHIqMSr3LFbeHbX/SmHEfjp+duolB0wRxAeCQiQbzli4v7v2HExF/1Dle 1ZWv0nPaLGFILusvhZ3Pz3bTjubHK3fXlNjAxezKmyeaiN8RsjHdO7vB6hhHYtdpMSJu bUMSou5G0PaCUoc34jEUzxU0VJJhdgz4iX/1t/iSf4perxOVhlegwfROJEOdyT6rMDfT lyklrDjlaxirSoOhid70w0PTMY5OR6jXiIyjOXIFtKAC/CshR9nhciGRoqBdWtd8a2si vUsA== X-Gm-Message-State: AIkVDXKCsFzFp06Lu56eGUFVZWsmjhRoi0vVSv13aUZjGC/lG7m6AdrEjdVpEht1jPkxsH5D X-Received: by 10.223.172.107 with SMTP id v98mr23743850wrc.77.1485869164622; Tue, 31 Jan 2017 05:26:04 -0800 (PST) Received: from localhost.localdomain ([105.130.17.13]) by smtp.gmail.com with ESMTPSA id i73sm23961714wmd.11.2017.01.31.05.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 05:26:04 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-efi@vger.kernel.org Subject: [PATCH 07/10] efi: Use typed function pointers for runtime services table Date: Tue, 31 Jan 2017 13:21:39 +0000 Message-Id: <1485868902-20401-8-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> References: <1485868902-20401-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Instead of using void pointers, and casting them to correctly typed function pointers upon use, declare the runtime services pointers as function pointers using their respective prototypes, for which typedefs are already available. Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- include/linux/efi.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) -- 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/include/linux/efi.h b/include/linux/efi.h index b17f73113bd2..8c6e007a5408 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -509,24 +509,6 @@ typedef struct { u64 query_variable_info; } efi_runtime_services_64_t; -typedef struct { - efi_table_hdr_t hdr; - void *get_time; - void *set_time; - void *get_wakeup_time; - void *set_wakeup_time; - void *set_virtual_address_map; - void *convert_pointer; - void *get_variable; - void *get_next_variable; - void *set_variable; - void *get_next_high_mono_count; - void *reset_system; - void *update_capsule; - void *query_capsule_caps; - void *query_variable_info; -} efi_runtime_services_t; - typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); typedef efi_status_t efi_set_time_t (efi_time_t *tm); typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, @@ -561,6 +543,24 @@ typedef efi_status_t efi_query_variable_store_t(u32 attributes, unsigned long size, bool nonblocking); +typedef struct { + efi_table_hdr_t hdr; + efi_get_time_t *get_time; + efi_set_time_t *set_time; + efi_get_wakeup_time_t *get_wakeup_time; + efi_set_wakeup_time_t *set_wakeup_time; + efi_set_virtual_address_map_t *set_virtual_address_map; + void *convert_pointer; + efi_get_variable_t *get_variable; + efi_get_next_variable_t *get_next_variable; + efi_set_variable_t *set_variable; + efi_get_next_high_mono_count_t *get_next_high_mono_count; + efi_reset_system_t *reset_system; + efi_update_capsule_t *update_capsule; + efi_query_capsule_caps_t *query_capsule_caps; + efi_query_variable_info_t *query_variable_info; +} efi_runtime_services_t; + void efi_native_runtime_setup(void); /*