From patchwork Fri Jul 20 01:47:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 142398 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2392021ljj; Thu, 19 Jul 2018 18:47:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfALQnjpEgmKn1Su4wfwBL2eS7aLIU9oBt2QadhaQO45GN4Vhnb8hZX8Mge/PrzX8nXQ6GL X-Received: by 2002:a63:1546:: with SMTP id 6-v6mr78814pgv.271.1532051276132; Thu, 19 Jul 2018 18:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532051276; cv=none; d=google.com; s=arc-20160816; b=oiaO7+IiSX+76h86ji2PRMzf1YDW5gbLxZCI+lr72Xl604H1B7Fbs420+uelm/yYYH +1H5B/Ww8RNPrL4TB7OiE1eZ96ZYUqEKbO5kO4VudmkoPKzwbtir4sFhBbElg+WN2PFe +98r2oHE8ZV0CAlKVbdOtPMIevE62C6BwPgvC1tcjBCFIaCXdlrNVyURUoDk4anWN21/ P54d7Y0+7sYv//6WZS53KeiNV6KuhSHsYyVgq5lRGgbk2j2+o2j+d07E60ZYsfcjhd9P mSXXwpmLTW51WIQ1B1ZLIPvGHqHBfi9Of72w8Y/3+ASjxsqZ2Lx/AS6jW7gD3CZBGMBT +cnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=b1HwyUAnJF2NFfT/pD4cNVn1pcnD0HmMCE+nI0tO3hM=; b=s3gDqPctMRIrZj3YwAW6C3krO7Z3yUactY+tYmIvNC/RQlOk1O9iDq8GTEvv8VBok0 W2JSXS7Pdti/RJVWCigfxJLeVgGEi+PPc75yc7uW9IUv7g4hrM6yjF8LU+E6N7Wuo1vc lq9wxUuB8WJQAnHomvjT/1h4NR0BWEDoW5qvsuHLEtkUsGxn7pUoahpuCc8y1hmtO97b 2+WNuyMy/j3IgBCMv0B/vvnaC7Deow7swopLdfS2uqAoaReOkC6CYLP6oSOswRtwcWBt 6bdDzf6oux2QFlYsbkR3Yuxc8FxaNBkbNfTgyNiUGelaa1DnitFGf5blVR3XPtXnqRzh g7aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KetIWsL8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1-v6si603911plo.241.2018.07.19.18.47.55; Thu, 19 Jul 2018 18:47:56 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KetIWsL8; 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 S1731140AbeGTCdn (ORCPT + 31 others); Thu, 19 Jul 2018 22:33:43 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43738 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730266AbeGTCdm (ORCPT ); Thu, 19 Jul 2018 22:33:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id v13-v6so5364533pgr.10 for ; Thu, 19 Jul 2018 18:47:52 -0700 (PDT) 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=b1HwyUAnJF2NFfT/pD4cNVn1pcnD0HmMCE+nI0tO3hM=; b=KetIWsL8Xgtgvr4CU0JJOsTlhb0wTqV8abhmvPA5nzD1Tk4HfA8YQ6ZeTPtFiZpR3v CKp3dJA+Pw8Dry6lRGssaheA9D/r/w3P2qh7/HyawCFbHchMubVypTQBJTML3btVrXug XfOF0cjcLi0ScdTFFQL2b+EuWSnNRvDfIaxiM= 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=b1HwyUAnJF2NFfT/pD4cNVn1pcnD0HmMCE+nI0tO3hM=; b=Iwg5DUF1M/R/lcnQQ6SVjRPS6taXBVFwP6Gafpsu32FKJ3EMRzPV3ALFl3xT3F+8cF aCJzggkRPpVhdRSq2x9Mt94mR8OeMMypC9YROByATGzP/h/+JOO5PP+BYIp/P/YI+kwN Ybrl0CVCVmMFB4lJygIsewv5wE3x6AUNmXtgh37pCkM4NOhc+znYvjbCRqyO+ke5/+6s mppVYAxArYldYySvD8ekwwBtpnj8bulNZhsC+D1LqmODOJ9tf2KmOsQNBsowAa4GaRFb gxu8OMarX1mVorvv4yWSFGHU4rGeMZhxy/5PRCyx4so7Sf6g7a8hv4/9qI+/o0gvgsRO 3Vqg== X-Gm-Message-State: AOUpUlEm9rMlcHjO1YNHVVVeQzoc/4ryXuf9PS4O/A48Li1AyGV9v3uh JetNxE+TxV8Hg5WKzhd6drf1xw== X-Received: by 2002:a62:d98f:: with SMTP id b15-v6mr107430pfl.1.1532051272160; Thu, 19 Jul 2018 18:47:52 -0700 (PDT) Received: from localhost.localdomain (fs76eedbeb.tkyc508.ap.nuro.jp. [118.238.219.235]) by smtp.gmail.com with ESMTPSA id 203-v6sm475868pgb.14.2018.07.19.18.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 18:47:51 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Shevchenko , Hans de Goede , Lukas Wunner Subject: [PATCH 2/9] efi/x86: merge setup_efi_pci32 and setup_efi_pci64 routines Date: Fri, 20 Jul 2018 10:47:19 +0900 Message-Id: <20180720014726.24031-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720014726.24031-1-ard.biesheuvel@linaro.org> References: <20180720014726.24031-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After merging the 32-bit and 64-bit versions of the code that invokes the PCI I/O protocol methods to preserve PCI ROM images in commit 2c3625cb9fa2 ("efi/x86: Fold __setup_efi_pci32() and __setup_efi_pci64() ...") there are still separate code paths for 32-bit and 64-bit, where the only difference is the size of a EFI_HANDLE. So let's parameterize a single implementation for that difference only, and get rid of the two copies of the code. While at it, rename __setup_efi_pci() to preserve_pci_rom_image() to better reflect its purpose. Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 123 ++++++++----------------------- 1 file changed, 32 insertions(+), 91 deletions(-) -- 2.17.1 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 9f6813493945..c72550783c16 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -111,7 +111,7 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) } static efi_status_t -__setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) +preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) { struct pci_setup_rom *rom = NULL; efi_status_t status; @@ -181,92 +181,6 @@ __setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) return status; } -static void -setup_efi_pci32(struct boot_params *params, void **pci_handle, unsigned long size) -{ - efi_pci_io_protocol_t *pci = NULL; - efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; - u32 *handles = (u32 *)(unsigned long)pci_handle; - efi_status_t status; - unsigned long nr_pci; - struct setup_data *data; - int i; - - data = (struct setup_data *)(unsigned long)params->hdr.setup_data; - - while (data && data->next) - data = (struct setup_data *)(unsigned long)data->next; - - nr_pci = size / sizeof(u32); - for (i = 0; i < nr_pci; i++) { - struct pci_setup_rom *rom = NULL; - u32 h = handles[i]; - - status = efi_call_early(handle_protocol, h, - &pci_proto, (void **)&pci); - - if (status != EFI_SUCCESS) - continue; - - if (!pci) - continue; - - status = __setup_efi_pci(pci, &rom); - if (status != EFI_SUCCESS) - continue; - - if (data) - data->next = (unsigned long)rom; - else - params->hdr.setup_data = (unsigned long)rom; - - data = (struct setup_data *)rom; - } -} - -static void -setup_efi_pci64(struct boot_params *params, void **pci_handle, unsigned long size) -{ - efi_pci_io_protocol_t *pci = NULL; - efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; - u64 *handles = (u64 *)(unsigned long)pci_handle; - efi_status_t status; - unsigned long nr_pci; - struct setup_data *data; - int i; - - data = (struct setup_data *)(unsigned long)params->hdr.setup_data; - - while (data && data->next) - data = (struct setup_data *)(unsigned long)data->next; - - nr_pci = size / sizeof(u64); - for (i = 0; i < nr_pci; i++) { - struct pci_setup_rom *rom = NULL; - u64 h = handles[i]; - - status = efi_call_early(handle_protocol, h, - &pci_proto, (void **)&pci); - - if (status != EFI_SUCCESS) - continue; - - if (!pci) - continue; - - status = __setup_efi_pci(pci, &rom); - if (status != EFI_SUCCESS) - continue; - - if (data) - data->next = (unsigned long)rom; - else - params->hdr.setup_data = (unsigned long)rom; - - data = (struct setup_data *)rom; - } -} - /* * There's no way to return an informative status from this function, * because any analysis (and printing of error messages) needs to be @@ -282,6 +196,9 @@ static void setup_efi_pci(struct boot_params *params) void **pci_handle = NULL; efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; unsigned long size = 0; + unsigned long nr_pci; + struct setup_data *data; + int i; status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, @@ -305,10 +222,34 @@ static void setup_efi_pci(struct boot_params *params) if (status != EFI_SUCCESS) goto free_handle; - if (efi_early->is64) - setup_efi_pci64(params, pci_handle, size); - else - setup_efi_pci32(params, pci_handle, size); + data = (struct setup_data *)(unsigned long)params->hdr.setup_data; + + while (data && data->next) + data = (struct setup_data *)(unsigned long)data->next; + + nr_pci = size / (efi_is_64bit() ? sizeof(u64) : sizeof(u32)); + for (i = 0; i < nr_pci; i++) { + efi_pci_io_protocol_t *pci = NULL; + struct pci_setup_rom *rom; + + status = efi_call_early(handle_protocol, + efi_is_64bit() ? ((u64 *)pci_handle)[i] + : ((u32 *)pci_handle)[i], + &pci_proto, (void **)&pci); + if (status != EFI_SUCCESS || !pci) + continue; + + status = preserve_pci_rom_image(pci, &rom); + if (status != EFI_SUCCESS) + continue; + + if (data) + data->next = (unsigned long)rom; + else + params->hdr.setup_data = (unsigned long)rom; + + data = (struct setup_data *)rom; + } free_handle: efi_call_early(free_pool, pci_handle); From patchwork Fri Jul 20 01:47:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 142401 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2392119ljj; Thu, 19 Jul 2018 18:48:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcU3YBBqZRO5k46A6gz6NPjjvf58xkKI29QRODavqQ/8sTCb/68k5PjEZB//w1LLCMRmAC2 X-Received: by 2002:a63:f:: with SMTP id 15-v6mr98331pga.430.1532051284544; Thu, 19 Jul 2018 18:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532051284; cv=none; d=google.com; s=arc-20160816; b=MmKQleWV2pZ2BafK2tGaaUpdKpqE1uMYE5yxQJlaHUsTX4wOATfYby0GuC8Uc2cC/K hEYCMyYacfzXPj7NZaivGvluUiCoHunEyvMto3aCPLusFmkzYhcSOQr1eAVcyVdI3/iZ 3KqQxt3whbh+plmV0RZiPiVvZmo9Jh7qtmCdHKI6bb79xL33r8XUzCn4ymDvkDJJ98ji ZLZsfjPQiO7pnLngAz2qWXZBjX9oy1Oq6pEC2d9YeZxRoctn6oWdbCTxlei2BE92tam/ jJmLZjZgNfrRUIE7C+91Pw84CCyJXTj/H4/0xPTv/K14Id/j+T/BaJORgJd/gUnTEJMH ryxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=qOa+Lf5zVsBgxcSLC3sLa0St+7nZBpqptye8Lhy5gjc=; b=PoQA/NYArFlRR8tjJIYS1fLv6K/OvRPS1a/ovwjLP7E7TiFLZuEzf7Pu/uj01Y3NCA 2Y3pjik87fBpmkbLbTfqgS/Qd608x6WmMlanARCmXQXxgYgjYBQokEk7BF79cpXDAhTn iiztL18WT9uhxlwqaQNuPZD8C1lWZZHols9qvxzVCvYUeVLF2H2dTVTw8TXf3Ne+5Qqn es/7aAxh0UpfnorR5TiauoE5x3Mr6dYsZXGk1CELFZreeGhdoaTnDpwuZ8lEM1eohOTX Cfi3umlKHzTXim5CKX8/w91Lp11XSBOCZ+4c8MXcHZH1YHfqfiH3BrD2SlSMUSCf4qUY 259g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/ow4tfM"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m23-v6si659247pgb.420.2018.07.19.18.48.04; Thu, 19 Jul 2018 18:48:04 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/ow4tfM"; 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 S1731336AbeGTCdw (ORCPT + 31 others); Thu, 19 Jul 2018 22:33:52 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:41594 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731283AbeGTCdv (ORCPT ); Thu, 19 Jul 2018 22:33:51 -0400 Received: by mail-pl0-f67.google.com with SMTP id w8-v6so4433415ply.8 for ; Thu, 19 Jul 2018 18:48:01 -0700 (PDT) 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=qOa+Lf5zVsBgxcSLC3sLa0St+7nZBpqptye8Lhy5gjc=; b=V/ow4tfMcm7/tJ4XYhJoEg0EbNiF2+5ac6quOFS6yBhn3RXipv0DpjMCvq8ny98wSN cFAB408AMzo9ZWP0ZOa1wzGbBo0JuLC5paV8SSx3VH0SC8swIBR5MQrwGnf3/U+JANb/ OZ5N2huf84e8PG55MWHAbHWM9PzAWdAR8K/jc= 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=qOa+Lf5zVsBgxcSLC3sLa0St+7nZBpqptye8Lhy5gjc=; b=E4mSESsE+vX1DWZ3AnKqiZDZZAuxk6hTGgxTs8pcFSeeuE68FAoePWflXJtNtWVN3o 0z1TJpeYqPcYByWQGf5qprZd9YOZGi9HxlC7uDay22HfYI/Y5pkCjQ9fSHq8jS634C92 vtbQNs2wBlmmZGdOWxRrwIe6uVaDWzUmXvqEJbvGzCz/JpTGRWgB9TvNIcTCZfaUJCEx 3in+YhLjFsjz/v6dLjo4A3OweScs8qjbJeQv+TG4hCeWqmwDM/0MtZCC+EN3zcj+kx0t qzWkhfd1tRRWI/O+tzaPfbw0H3kwld4Pg0K+xcxMbZVyUYBgKfRjuUNk49uR/lVIqtN8 M8tA== X-Gm-Message-State: AOUpUlGhs7ool4l2Hr0eo/UbHyxINmvyMMBY1mans6DIicgKiKIxwgY/ wVs/UKgem1tcsq54oXhHQvisAg== X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr71797pld.289.1532051279783; Thu, 19 Jul 2018 18:47:59 -0700 (PDT) Received: from localhost.localdomain (fs76eedbeb.tkyc508.ap.nuro.jp. [118.238.219.235]) by smtp.gmail.com with ESMTPSA id 203-v6sm475868pgb.14.2018.07.19.18.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 18:47:59 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Shevchenko , Hans de Goede , Lukas Wunner Subject: [PATCH 5/9] efi/x86: add missing NULL initialization in UGA draw protocol discovery Date: Fri, 20 Jul 2018 10:47:22 +0900 Message-Id: <20180720014726.24031-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720014726.24031-1-ard.biesheuvel@linaro.org> References: <20180720014726.24031-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The UGA draw protocol discovery routine looks for a EFI handle that has both the UGA draw protocol and the PCI I/O protocol installed. It checks for the latter by calling handle_protocol() and pass it a PCI I/O protocol pointer variable by reference, but fails to initialize it to NULL, which means the non-NULL check later on in the code could produce false positives, given that the return code of the handle_protocol() call is ignored entirely. So add the missing initialization. Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index ac8e442db71f..92b573fd239c 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -359,6 +359,7 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size) if (status != EFI_SUCCESS) continue; + pciio = NULL; efi_call_early(handle_protocol, handle, &pciio_proto, &pciio); status = efi_call_proto(efi_uga_draw_protocol, get_mode, uga, From patchwork Fri Jul 20 01:47:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 142402 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2392140ljj; Thu, 19 Jul 2018 18:48:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcB+PW/X0R5P9J7UJMHQE36iNoLXqhYDvB58VooFMsZgljnY/WWbIoXM4TiNZK9WJw7f/X7 X-Received: by 2002:a17:902:7b97:: with SMTP id w23-v6mr132823pll.66.1532051286747; Thu, 19 Jul 2018 18:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532051286; cv=none; d=google.com; s=arc-20160816; b=yf3qY55mjtWLoE56rcevpyiVTYh/l1fCuIwncNJNCy00+1AyBwdU+jNKvLA1DP2cCr QeHdNB6ldCt3hmiC4S3DVraXxydQU2CnkTj5Em9v01G2AW5l7DaybQeELXf+b4gg+ztb JqK+Eac4HHpjSMVn5dwZXy9nMxbcxqbyGqI0KlOxP0HvboFfdQW8L1NInjEjLJHXnwYJ x6nTMlxCwnMvmVu8mrWpABv3KuhoozlrsMgHLCfEwYzTjol3kgf4hJL4/UWmfW/2uwXu AVI7y992wWsrjNxEkpT0RRFh6AAZSasio13ovXomkslMBrahiDcTDCMNVyLYnMTG8/1C yuOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dSo7lbMCHtV+QcLt2NYBnYRSjnrOTI0xQ6xgFbe8mNI=; b=F+gjvz5gACLCF3awlQFh54v0zozDU9CgfGlqsWrN9G+Kwgv+PVWpshfXWulnO4jafh j+TcWmRdcDhBIomDpHsaNSq8UwAmm1PUDBaESv+Jvvn6wQ8XyEmBmA58eAanPYTgah4A VmziQyfea/MIf6iL9vsjf5woZioekez64vf6gWvGAaT1Zj1nA1ODmET+R21sfaXB2FrZ BR57oi3hzdgQKkW9Y24cY7e58d+azhruw1wx+PI6xcgCead5MrtR7JFd5l3+BVQAto40 cnnvcMKw2AhWT5WAjpd7vpliPBj3saT126PDGc1tJ8dkJZriTP+hZKQJc3aCbp5XtKgg UfZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DLR0gVko; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9-v6si648433pgn.164.2018.07.19.18.48.06; Thu, 19 Jul 2018 18:48:06 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DLR0gVko; 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 S1731392AbeGTCdy (ORCPT + 31 others); Thu, 19 Jul 2018 22:33:54 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42634 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731283AbeGTCdx (ORCPT ); Thu, 19 Jul 2018 22:33:53 -0400 Received: by mail-pg1-f194.google.com with SMTP id y4-v6so5359254pgp.9 for ; Thu, 19 Jul 2018 18:48:02 -0700 (PDT) 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=dSo7lbMCHtV+QcLt2NYBnYRSjnrOTI0xQ6xgFbe8mNI=; b=DLR0gVkoK7aju/CMQHxu2iR6FN0Bl775xfbKgjh4PWN3YRVlSMIPn1qvIgdzkGyoqL 6aNQBgSOcX+v4vAYq/aJ+tKIsXUhiJAIpZTxmhI7s7uTPhkZPUrJSYBc6IAVDBjvFeIZ pm6v/xxcUADvuMwqR26r/90SF8oeJqZJh9OZs= 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=dSo7lbMCHtV+QcLt2NYBnYRSjnrOTI0xQ6xgFbe8mNI=; b=Y8W3A724CocmH/RTO2eXu1FiKpfPSMsNK4ZdW0NI7WOL4xlf7vQ9Su52UTf6l4/dNr TP/QNKOKaDNhp37Ihinpc9LtJ/lcBbXksysDlMEoMSkrCuHiLDu0/lzDN67xbOKs3fnL fztd9jnbRxq2QK2aSfQqjcEam12f3NEdj5hsql3QvV7rFtyUMcfQnKevA/OTqEEhDk02 /Ax0efFVp2gOFZStENstP5UPPCda5RQh+r5DNfcn1sxhL6fgnk0Y8z6W3Il0ryA658vv 7oQPvmj6nT19fYzVHVydPiRzEqlojkh8dnCufaIK9NLCoEgeZAz5nMqcyrdFMp75UyB9 NQDg== X-Gm-Message-State: AOUpUlEZ4s4Wn5bEvA7iOObcFJmQPgb8IJQv1z/mQPKjhMAe6MQn163m C5S507CyoDYaVfiTA1bRIfTUow== X-Received: by 2002:a63:df04:: with SMTP id u4-v6mr99537pgg.434.1532051282533; Thu, 19 Jul 2018 18:48:02 -0700 (PDT) Received: from localhost.localdomain (fs76eedbeb.tkyc508.ap.nuro.jp. [118.238.219.235]) by smtp.gmail.com with ESMTPSA id 203-v6sm475868pgb.14.2018.07.19.18.47.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 18:48:01 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Shevchenko , Hans de Goede , Lukas Wunner Subject: [PATCH 6/9] efi: Deduplicate efi_open_volume() Date: Fri, 20 Jul 2018 10:47:23 +0900 Message-Id: <20180720014726.24031-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720014726.24031-1-ard.biesheuvel@linaro.org> References: <20180720014726.24031-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner There's one ARM, one x86_32 and one x86_64 version of efi_open_volume() which can be folded into a single shared version by masking their differences with the efi_call_proto() macro introduced by commit 3552fdf29f01 ("efi: Allow bitness-agnostic protocol calls"). To be able to dereference the device_handle attribute from the efi_loaded_image_t table in an arch- and bitness-agnostic manner, introduce the efi_table_attr() macro (which already exists for x86) to arm and arm64. No functional change intended. Signed-off-by: Lukas Wunner Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/efi.h | 3 + arch/arm64/include/asm/efi.h | 3 + arch/x86/boot/compressed/eboot.c | 63 ------------------- drivers/firmware/efi/libstub/arm-stub.c | 25 -------- .../firmware/efi/libstub/efi-stub-helper.c | 31 ++++++++- drivers/firmware/efi/libstub/efistub.h | 3 - include/linux/efi.h | 10 +++ 7 files changed, 45 insertions(+), 93 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 17f1f1a814ff..38badaae8d9d 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h @@ -58,6 +58,9 @@ void efi_virtmap_unload(void); #define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__) #define efi_is_64bit() (false) +#define efi_table_attr(table, attr, instance) \ + ((table##_t *)instance)->attr + #define efi_call_proto(protocol, f, instance, ...) \ ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index 192d791f1103..7ed320895d1f 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -87,6 +87,9 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base, #define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__) #define efi_is_64bit() (true) +#define efi_table_attr(table, attr, instance) \ + ((table##_t *)instance)->attr + #define efi_call_proto(protocol, f, instance, ...) \ ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 92b573fd239c..915c64edbe8e 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -41,69 +41,6 @@ static void setup_boot_services##bits(struct efi_config *c) \ BOOT_SERVICES(32); BOOT_SERVICES(64); -static inline efi_status_t __open_volume32(void *__image, void **__fh) -{ - efi_file_io_interface_t *io; - efi_loaded_image_32_t *image = __image; - efi_file_handle_32_t *fh; - efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; - efi_status_t status; - void *handle = (void *)(unsigned long)image->device_handle; - unsigned long func; - - status = efi_call_early(handle_protocol, handle, - &fs_proto, (void **)&io); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to handle fs_proto\n"); - return status; - } - - func = (unsigned long)io->open_volume; - status = efi_early->call(func, io, &fh); - if (status != EFI_SUCCESS) - efi_printk(sys_table, "Failed to open volume\n"); - - *__fh = fh; - - return status; -} - -static inline efi_status_t __open_volume64(void *__image, void **__fh) -{ - efi_file_io_interface_t *io; - efi_loaded_image_64_t *image = __image; - efi_file_handle_64_t *fh; - efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; - efi_status_t status; - void *handle = (void *)(unsigned long)image->device_handle; - unsigned long func; - - status = efi_call_early(handle_protocol, handle, - &fs_proto, (void **)&io); - if (status != EFI_SUCCESS) { - efi_printk(sys_table, "Failed to handle fs_proto\n"); - return status; - } - - func = (unsigned long)io->open_volume; - status = efi_early->call(func, io, &fh); - if (status != EFI_SUCCESS) - efi_printk(sys_table, "Failed to open volume\n"); - - *__fh = fh; - - return status; -} - -efi_status_t -efi_open_volume(efi_system_table_t *sys_table, void *__image, void **__fh) -{ - if (efi_early->is64) - return __open_volume64(__image, __fh); - - return __open_volume32(__image, __fh); -} - void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str) { efi_call_proto(efi_simple_text_output_protocol, output_string, diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index c98b1856fc3d..6920033de6d4 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -40,31 +40,6 @@ static u64 virtmap_base = EFI_RT_VIRTUAL_BASE; -efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, - void *__image, void **__fh) -{ - efi_file_io_interface_t *io; - efi_loaded_image_t *image = __image; - efi_file_handle_t *fh; - efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; - efi_status_t status; - void *handle = (void *)(unsigned long)image->device_handle; - - status = sys_table_arg->boottime->handle_protocol(handle, - &fs_proto, (void **)&io); - if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); - return status; - } - - status = io->open_volume(io, &fh); - if (status != EFI_SUCCESS) - efi_printk(sys_table_arg, "Failed to open volume\n"); - - *__fh = fh; - 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 50a9cab5a834..e94975f4655b 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -413,6 +413,34 @@ static efi_status_t efi_file_close(void *handle) return efi_call_proto(efi_file_handle, close, handle); } +static efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, + efi_loaded_image_t *image, + efi_file_handle_t **__fh) +{ + efi_file_io_interface_t *io; + efi_file_handle_t *fh; + efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; + efi_status_t status; + void *handle = (void *)(unsigned long)efi_table_attr(efi_loaded_image, + device_handle, + image); + + status = efi_call_early(handle_protocol, handle, + &fs_proto, (void **)&io); + if (status != EFI_SUCCESS) { + efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); + return status; + } + + status = efi_call_proto(efi_file_io_interface, open_volume, io, &fh); + if (status != EFI_SUCCESS) + efi_printk(sys_table_arg, "Failed to open volume\n"); + else + *__fh = fh; + + return status; +} + /* * Parse the ASCII string 'cmdline' for EFI options, denoted by the efi= * option, e.g. efi=nochunk. @@ -563,8 +591,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, /* Only open the volume once. */ if (!i) { - status = efi_open_volume(sys_table_arg, image, - (void **)&fh); + status = efi_open_volume(sys_table_arg, image, &fh); if (status != EFI_SUCCESS) goto free_files; } diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index f59564b72ddc..32799cf039ef 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -36,9 +36,6 @@ extern int __pure is_quiet(void); 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); - 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, diff --git a/include/linux/efi.h b/include/linux/efi.h index e190652f5ef9..401e4b254e30 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -894,6 +894,16 @@ typedef struct _efi_file_handle { void *flush; } efi_file_handle_t; +typedef struct { + u64 revision; + u32 open_volume; +} efi_file_io_interface_32_t; + +typedef struct { + u64 revision; + u64 open_volume; +} efi_file_io_interface_64_t; + typedef struct _efi_file_io_interface { u64 revision; int (*open_volume)(struct _efi_file_io_interface *, From patchwork Fri Jul 20 01:47:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 142403 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2392178ljj; Thu, 19 Jul 2018 18:48:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeH4Pm6idDrFAddmzXen6E2XFQcr2c4qnp741Q//ETBOrfjZZFoMr+xUNvOE1C5hL2Too+N X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr99905plc.11.1532051289812; Thu, 19 Jul 2018 18:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532051289; cv=none; d=google.com; s=arc-20160816; b=hbE1023VzwtC2vBPXV4cX83+ZnEWqoOjSppHX11YXawW+sdmF21e89PPsG1fsdwkeH WMiz2qsgaZogvW/V64EoW9uRjwwUBv6l+SJ7qkUxYAnJRELMNoOoE3XhqP8QfTE5OzOg qx0tGcOJBz1XRu2ep+FZVBh8FEjArUdxerUgua3lmFDBhAZGHL6mD3fAwKx/4FUVv38S 0B20yVfyvM3y8Ce0rH29gs8zD3L7kfs4HTXZgvC/uFx6imE+0GqUXYWTG05+XGj8VBza ROXykhHqmu5DJGZ/oJqdJWaJLDFEhu/JBbZeqhssByV5Q3dbGrhl38nbQ8KgJwfwyUk4 wVWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Yoyda7tE3ZXI3EzTFdmwpnsA+ke28+fu6v2r36tSZn8=; b=LY0FA037oOFjJAAWscyvE6kirQKSvg55LesfcJRsWAuaQOLfKBYB2Hq+wyq1QxfJu9 GA1lW0zYsjaxO8LXNZkAJZShxLpAitx1NaZdDuF1U8AHFoes0y+T3SOIwcUNuaBjBCg5 Rpnx0sp6t7eQoz0GOWmsb81yWNMbi+zDhMlGVuFtroqQeWFxDXyBRy0GYh3+Y5t5ZHxg 91voJYiiCpkkBMK3b+A3h58Ct63R+x5jCu/ehGNtbFtTEKy8TI0MtfrDOHF0kiKPhXo2 yRxe4cqRwoEveZJlCGhumywIUk6bOHBvJ0aIDnar40FPQMD28rDytJTXCqmpZudAa2Ha lawg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hOWDBkn7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si624647pgm.584.2018.07.19.18.48.09; Thu, 19 Jul 2018 18:48:09 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hOWDBkn7; 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 S1731443AbeGTCd5 (ORCPT + 31 others); Thu, 19 Jul 2018 22:33:57 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39311 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731283AbeGTCd4 (ORCPT ); Thu, 19 Jul 2018 22:33:56 -0400 Received: by mail-pl0-f65.google.com with SMTP id p23-v6so4436817plo.6 for ; Thu, 19 Jul 2018 18:48:05 -0700 (PDT) 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=Yoyda7tE3ZXI3EzTFdmwpnsA+ke28+fu6v2r36tSZn8=; b=hOWDBkn7y1xbe8J1W1daJ6z79VPwpPGerpyrLjU6bBVAJYHVdZo3nFX0s7Lj2+XzAh 0H+1URxvT+qUKXhZ+C9XqMJhNBVk5nBDxJnGdZdUpWaEmGN3cJk5NzBx10Yy1RuGZncl W8BZEyk7jgGNgqW96n9kq1XtthXOOoVkc0gi0= 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=Yoyda7tE3ZXI3EzTFdmwpnsA+ke28+fu6v2r36tSZn8=; b=sH/Z2MpD4IwoRwmWxAcS5/rcq3REtfbuEEMNENlv23ibddO5ix7jt7Xi5kHeJ/ODe/ SvR82zX20Js+P9vj7vNhAYjkrriQEOOVx8oVECM1chs+cdK7AZ32z7VUoO31FmeZIvPh +Wcw4kEiaXYZu+dEOP+HIxxgmn7Qv05HjUs285RqIky8eJEdCsQf6BnXX1t9EcX2MoKO qnqYCgGsX2S5Vq7egYpUxPiP7xbhILUjfiynfkZIS10e0rLIgkrbLEm8PUXEkkUozAnE RZBqx1KBbIBDVrdrrVges3aGarHs5EYRr+Uy3hVaul/7dm819oXQRGzhUiqXn0A88H7L +/cQ== X-Gm-Message-State: AOUpUlGeSzJrZC08iV9cIi8WgqnLqJzJMkkGfhGVge+kp8QjVsOu1nn2 PCtCAm87RFlP7rTw0gUz0o+dRg== X-Received: by 2002:a17:902:8309:: with SMTP id bd9-v6mr68116plb.321.1532051285127; Thu, 19 Jul 2018 18:48:05 -0700 (PDT) Received: from localhost.localdomain (fs76eedbeb.tkyc508.ap.nuro.jp. [118.238.219.235]) by smtp.gmail.com with ESMTPSA id 203-v6sm475868pgb.14.2018.07.19.18.48.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 18:48:04 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Shevchenko , Hans de Goede , Lukas Wunner Subject: [PATCH 7/9] efi/x86: replace references to efi_early->is64 with efi_is_64bit() Date: Fri, 20 Jul 2018 10:47:24 +0900 Message-Id: <20180720014726.24031-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720014726.24031-1-ard.biesheuvel@linaro.org> References: <20180720014726.24031-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are a couple of places in the x86 EFI stub code where we select between 32-bit and 64-bit versions of the support routines based on the value of efi_early->is64. Referencing that field directly is a bad idea, since it prevents the compiler from inferring that this field can never be true on a 32-bit build, and can only become false on a 64-bit build if support for mixed mode is compiled in. This results in dead code to be retained in the uncompressed part of the kernel image, which is wasteful. So switch to the efi_is_64bit() helper, which will resolve to a constant boolean unless building for 64-bit with mixed mode support. Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 915c64edbe8e..1458b1700fc7 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -404,7 +404,7 @@ struct boot_params *make_boot_params(struct efi_config *c) if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) return NULL; - if (efi_early->is64) + if (efi_is_64bit()) setup_boot_services64(efi_early); else setup_boot_services32(efi_early); @@ -639,7 +639,6 @@ struct exit_boot_struct { struct efi_info *efi; struct setup_data *e820ext; __u32 e820ext_size; - bool is64; }; static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, @@ -666,7 +665,8 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, first = false; } - signature = p->is64 ? EFI64_LOADER_SIGNATURE : EFI32_LOADER_SIGNATURE; + signature = efi_is_64bit() ? EFI64_LOADER_SIGNATURE + : EFI32_LOADER_SIGNATURE; memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32)); p->efi->efi_systab = (unsigned long)sys_table_arg; @@ -683,8 +683,7 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, return EFI_SUCCESS; } -static efi_status_t exit_boot(struct boot_params *boot_params, - void *handle, bool is64) +static efi_status_t exit_boot(struct boot_params *boot_params, void *handle) { unsigned long map_sz, key, desc_size, buff_size; efi_memory_desc_t *mem_map; @@ -705,7 +704,6 @@ static efi_status_t exit_boot(struct boot_params *boot_params, priv.efi = &boot_params->efi_info; priv.e820ext = NULL; priv.e820ext_size = 0; - priv.is64 = is64; /* Might as well exit boot services now */ status = efi_exit_boot_services(sys_table, handle, &map, &priv, @@ -740,13 +738,11 @@ efi_main(struct efi_config *c, struct boot_params *boot_params) struct desc_struct *desc; void *handle; efi_system_table_t *_table; - bool is64; efi_early = c; _table = (efi_system_table_t *)(unsigned long)efi_early->table; handle = (void *)(unsigned long)efi_early->image_handle; - is64 = efi_early->is64; sys_table = _table; @@ -754,7 +750,7 @@ efi_main(struct efi_config *c, struct boot_params *boot_params) if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) goto fail; - if (is64) + if (efi_is_64bit()) setup_boot_services64(efi_early); else setup_boot_services32(efi_early); @@ -810,7 +806,7 @@ efi_main(struct efi_config *c, struct boot_params *boot_params) hdr->code32_start = bzimage_addr; } - status = exit_boot(boot_params, handle, is64); + status = exit_boot(boot_params, handle); if (status != EFI_SUCCESS) { efi_printk(sys_table, "exit_boot() failed!\n"); goto fail; From patchwork Fri Jul 20 01:47:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 142405 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2392237ljj; Thu, 19 Jul 2018 18:48:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdSQm+TCFGYIizuIDlfSmgSyrUtvzdGLFv3mQ2cNA3NqyWU5SNAiakUYYl7eHoWPyGXHHET X-Received: by 2002:a62:c218:: with SMTP id l24-v6mr86316pfg.185.1532051294650; Thu, 19 Jul 2018 18:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532051294; cv=none; d=google.com; s=arc-20160816; b=OzlMQcJG5J6AAmN0LywDjRQj5PFB0XIlXM3vhTvIrlyBOMpuSb7OtFBBUF8YiNaUKr pRx4crkFKIsxrPoRSxx37MHwTi2euClzODne1mgqswwd5W1jE/Zp9sktI+ry7/MpGTGK oHnxC+Ac04uj9UYVwyzz2h8Dm6u9aX2jukTLwDq4CuEpDX9DCY9IL6JJs932i+4kCXvB TreyMpBB2hPAVsNSl+dG1Zw4c5RfotS8E73JbFBRMNnP/A37wXZh5UxMeauu2x6MJPKc yPEKnUncj9NaRD+IZQ0SrFIp/n/IJSELh40XQRxUyFUt0S3Tu0400GuURDXbH3u3lb2E AQmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=TK1WDbeXxDnAkoiR4N4slQI5HJBht91mInwgn17IrQ0=; b=rQqF2SEHPm15dSB3EEqi9vbCf3sHuUvQD+nteTQBBvjEFhF3aEkf8cHr7Xtji+JN8g wNQVhpTaZ8YcrAA3mR4mahbxLRloVNYAu+//8Z3CtyvYs+BToE+FXhB53CwLuRlzOSpv oEmuknlYxY1QCJcMcRZJz858mSIJjeWlcHjjmH8KZRSbt/HpwzZhH/l82x/YAjAZTDkL s5FuLSrBmZYfjqyRPzbHLWME/4VqkNPKbIPfb8RvbyQbi8U7V20MU07CVHP/Ij311s7e EFrlZ1XWVhLNES3uM4Me5rk8ijIbgTfmwAC8oa4LdxW5l3sOwFG6vN9/Yu9H9LHuqFgR DUPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VZ8Nnv6B; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v37-v6si610005plg.486.2018.07.19.18.48.14; Thu, 19 Jul 2018 18:48:14 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VZ8Nnv6B; 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 S1731557AbeGTCeC (ORCPT + 31 others); Thu, 19 Jul 2018 22:34:02 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40285 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731446AbeGTCeA (ORCPT ); Thu, 19 Jul 2018 22:34:00 -0400 Received: by mail-pg1-f196.google.com with SMTP id x5-v6so5358422pgp.7 for ; Thu, 19 Jul 2018 18:48:10 -0700 (PDT) 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=TK1WDbeXxDnAkoiR4N4slQI5HJBht91mInwgn17IrQ0=; b=VZ8Nnv6BZ94a23iQ0zH0JXowN4YBd3UQvKDC+65woEeUzIrnGOPiTVJUHqB+41bviu 0mccSQjfmELIkbnUsVSI5vUR9jlVuMOGhNTSO2/OMIOMpsgbWRiCn85TAoppIqRLmpo3 x6nbwOfmyPAxN34pAhVCll1MlqqlRknOc9LQk= 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=TK1WDbeXxDnAkoiR4N4slQI5HJBht91mInwgn17IrQ0=; b=BynnKoyi+9Q+X4VDt2xufqy87TrU5LEGAn4Q9766fs8glUA8dfQj1ff4o9xWNBxote I2REEzqVTcr8XxYHDBWsKkSGcqg5Z5Fd/8eySrkDERww6fuQlv+Oc2+mWq4IVRs2kOUy wG0QiqveKofrqSleu4FAzX1RdgP25rCFkA3LvprddVMsL2k7bgrO1EqnQK47xNoSEm7z cDiTeg5PMh9S3EXb8TwpZ+TJCljBBhMZzlM4tmToL2SWQmG4NYBZ3F7h7ntrVDbVCLm1 WMztWNBD9nWsaBSWZey4pM+mkNwz+7z+Bv6sJpW5OJXR6KX3V5asZzMnUf/MynQ9VZsD pNIQ== X-Gm-Message-State: AOUpUlEizoUoPA3FTdmJzGHLQH5Oqf9wPpOK8Srerz2rltSnycI9e2zr GHKVusrhmpXnVHsQXktV4VsEdA== X-Received: by 2002:a63:b349:: with SMTP id x9-v6mr73318pgt.337.1532051290075; Thu, 19 Jul 2018 18:48:10 -0700 (PDT) Received: from localhost.localdomain (fs76eedbeb.tkyc508.ap.nuro.jp. [118.238.219.235]) by smtp.gmail.com with ESMTPSA id 203-v6sm475868pgb.14.2018.07.19.18.48.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 18:48:09 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Shevchenko , Hans de Goede , Lukas Wunner Subject: [PATCH 9/9] efivars: Call guid_parse() against guid_t type of variable Date: Fri, 20 Jul 2018 10:47:26 +0900 Message-Id: <20180720014726.24031-10-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720014726.24031-1-ard.biesheuvel@linaro.org> References: <20180720014726.24031-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko uuid_le_to_bin() is deprecated API and take into consideration that variable, to where we store parsed data, is type of guid_t we switch to guid_parse() for sake of consistency. While here, add error checking to it. Signed-off-by: Andy Shevchenko Signed-off-by: Ard Biesheuvel --- fs/efivarfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 71fccccf317e..8c6ab6c95727 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -86,7 +86,9 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry, /* length of the variable name itself: remove GUID and separator */ namelen = dentry->d_name.len - EFI_VARIABLE_GUID_LEN - 1; - uuid_le_to_bin(dentry->d_name.name + namelen + 1, &var->var.VendorGuid); + err = guid_parse(dentry->d_name.name + namelen + 1, &var->var.VendorGuid); + if (err) + goto out; if (efivar_variable_is_removable(var->var.VendorGuid, dentry->d_name.name, namelen))