From patchwork Thu Apr 30 18:28:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Sankar X-Patchwork-Id: 206365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4995C4724C for ; Thu, 30 Apr 2020 18:29:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 930092082E for ; Thu, 30 Apr 2020 18:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbgD3S2t (ORCPT ); Thu, 30 Apr 2020 14:28:49 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:43657 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgD3S2s (ORCPT ); Thu, 30 Apr 2020 14:28:48 -0400 Received: by mail-qk1-f194.google.com with SMTP id i136so2664370qke.10; Thu, 30 Apr 2020 11:28:46 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=fzOcH/m5zVvfS8Ajxoe5u2BiH2fwXioZ/jPs2mokyCI=; b=eSNm+45ZOm/agiD7TFn60lu67QtJGjnS5YXo17RpcHVNBPtBilJnSx3d2nlraDrpgk NbQzb+SkpBtP/txYzY6CJbxXYsaSd08m1sRSclRwRKpVra0aMjUk4OupFuRnnfrLsdtT RpArSK8BNygnJveucnon5f11PTiIFDiwxWZn+Znw4gMeSUJic09Py7wjgaLyjo3ahWrR rKAccfkEyxbkneoPJibBQokj8+B/x+PwNMeIIO+tpBJ4gUCa0EBIPd5gjU0P2gku5ru/ J4AzM2402c4KsVc+7Kd1ZxoXK+fZYsZOYqoYNViNyplkEGP6BzbMs9N7tD09m/2nuke+ 5AIQ== X-Gm-Message-State: AGi0PubAeDn9iI5dDq+6QyDDSrPDVDJ2BVWDc1h8hnhboxFrDDu2MMVY FN2de7d7OH91EkR9E6IfqSY= X-Google-Smtp-Source: APiQypK3SdIIc2NkvJeAZt7bA9IFLrtVFdXX3J0GwvvGnZ0Se8oD3IETW73STBOW1eJd5UKtAsDm9g== X-Received: by 2002:a37:e54:: with SMTP id 81mr4363648qko.284.1588271325839; Thu, 30 Apr 2020 11:28:45 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id v27sm449785qtb.35.2020.04.30.11.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 11:28:45 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/11] efi/x86: Use correct size for boot_params Date: Thu, 30 Apr 2020 14:28:33 -0400 Message-Id: <20200430182843.2510180-2-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200430182843.2510180-1-nivedita@alum.mit.edu> References: <20200429174120.1497212-1-nivedita@alum.mit.edu> <20200430182843.2510180-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org struct boot_params is only 4096 bytes, not 16384. Fix this by using sizeof(struct boot_params) instead of hardcoding the incorrect value. Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/x86-stub.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 597793fe8d22..d4bafd7f6f9f 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -379,13 +379,14 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, image_base = efi_table_attr(image, image_base); image_offset = (void *)startup_32 - image_base; - status = efi_allocate_pages(0x4000, (unsigned long *)&boot_params, ULONG_MAX); + status = efi_allocate_pages(sizeof(struct boot_params), + (unsigned long *)&boot_params, ULONG_MAX); if (status != EFI_SUCCESS) { efi_printk("Failed to allocate lowmem for boot params\n"); efi_exit(handle, status); } - memset(boot_params, 0x0, 0x4000); + memset(boot_params, 0x0, sizeof(struct boot_params)); hdr = &boot_params->hdr; @@ -439,7 +440,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, fail2: efi_free(options_size, (unsigned long)cmdline_ptr); fail: - efi_free(0x4000, (unsigned long)boot_params); + efi_free(sizeof(struct boot_params), (unsigned long)boot_params); efi_exit(handle, status); } From patchwork Wed Apr 29 17:41:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Sankar X-Patchwork-Id: 206372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2217C83009 for ; Wed, 29 Apr 2020 17:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC06B20B1F for ; Wed, 29 Apr 2020 17:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727105AbgD2Rl5 (ORCPT ); Wed, 29 Apr 2020 13:41:57 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:44135 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbgD2Rl0 (ORCPT ); Wed, 29 Apr 2020 13:41:26 -0400 Received: by mail-qt1-f194.google.com with SMTP id c23so2558652qtp.11; Wed, 29 Apr 2020 10:41:26 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=P15viJAU+0RM8Psz28V6qOX0pe0sVwfTgVh2E8+aZ1I=; b=W1lTv6GXfQd2qlyQppJZXG9l9O8AjfNisolBqNhiBd8w83xd/0/bZ1J4VbYNiMPS3p 24N4O/dDfsftmozwMK7dErXkvQPxbotqHCfY5CubdNExO/hnUTx/3ypmttvlhCQkGAfp cnGJbmwRZmz7oUL6ZYkpSbsQCtZn5kneWBJUc/G6I06hDQCP3U1NycNr/EJ2fnrcFulY jVpUNEZA4iUaXBhUzASVL3uHTRpAEW4v7mvk6P5uLnmTtN7BcI4ati724B+V04CrVBeA zzgMRQFpYGDycztBj29UQFqAlfZDFIt+NAeH0aF5M495ulRQsvFEiNLdQ90TVAI5ly+d QxFg== X-Gm-Message-State: AGi0PuYihttB6Mzdb4Y5x/bwH9OrL7+P3Ir9YbsXhLPaNYabCNJVPsDj s1AXlGdRBaZYWd2fWKJwtt3njBatjsM= X-Google-Smtp-Source: APiQypLe+4jpQ+qS7PKJk8e2VSQm1eSPxJm5vUVmnMPPmL/uBVwecsnO45tZQkGoMUEeoekbZgJ/Bw== X-Received: by 2002:ac8:5048:: with SMTP id h8mr35932906qtm.189.1588182084129; Wed, 29 Apr 2020 10:41:24 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id z1sm14766448qkz.3.2020.04.29.10.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:41:23 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/10] efi/libstub: Add a helper function to split 64-bit values Date: Wed, 29 Apr 2020 13:41:12 -0400 Message-Id: <20200429174120.1497212-4-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429174120.1497212-1-nivedita@alum.mit.edu> References: <20200429174120.1497212-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org In several places 64-bit values need to be split up into two 32-bit fields, in order to be backward-compatible with the old 32-bit ABIs. Instead of open-coding this, add a helper function to set a 64-bit value as two 32-bit fields. Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/efistub.h | 7 ++++++ drivers/firmware/efi/libstub/gop.c | 6 ++--- drivers/firmware/efi/libstub/x86-stub.c | 32 +++++++++++-------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 5ff63230a1f1..e8aa70ba08d5 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -87,6 +87,13 @@ extern const efi_system_table_t *efi_system_table; ((handle = efi_get_handle_at((array), i)) || true); \ i++) +static inline +void efi_set_u64_split(u64 data, u32 *lo, u32 *hi) +{ + *lo = lower_32_bits(data); + *hi = upper_32_bits(data); +} + /* * Allocation types for calls to boottime->allocate_pages. */ diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index 216327d0b034..64cee0febae0 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -422,7 +422,6 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto, efi_graphics_output_protocol_t *gop; efi_graphics_output_protocol_mode_t *mode; efi_graphics_output_mode_info_t *info; - efi_physical_addr_t fb_base; gop = find_gop(proto, size, handles); @@ -442,9 +441,8 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto, si->lfb_width = info->horizontal_resolution; si->lfb_height = info->vertical_resolution; - fb_base = efi_table_attr(mode, frame_buffer_base); - si->lfb_base = lower_32_bits(fb_base); - si->ext_lfb_base = upper_32_bits(fb_base); + efi_set_u64_split(efi_table_attr(mode, frame_buffer_base), + &si->lfb_base, &si->ext_lfb_base); if (si->ext_lfb_base) si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE; diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index d4bafd7f6f9f..677b5a1e0543 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -408,9 +408,8 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, if (!cmdline_ptr) goto fail; - hdr->cmd_line_ptr = (unsigned long)cmdline_ptr; - /* Fill in upper bits of command line address, NOP on 32 bit */ - boot_params->ext_cmd_line_ptr = (u64)(unsigned long)cmdline_ptr >> 32; + efi_set_u64_split((u64)cmdline_ptr, + &hdr->cmd_line_ptr, &boot_params->ext_cmd_line_ptr); hdr->ramdisk_image = 0; hdr->ramdisk_size = 0; @@ -427,10 +426,10 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, ULONG_MAX); if (status != EFI_SUCCESS) goto fail2; - hdr->ramdisk_image = ramdisk_addr & 0xffffffff; - hdr->ramdisk_size = ramdisk_size & 0xffffffff; - boot_params->ext_ramdisk_image = (u64)ramdisk_addr >> 32; - boot_params->ext_ramdisk_size = (u64)ramdisk_size >> 32; + efi_set_u64_split(ramdisk_addr, &hdr->ramdisk_image, + &boot_params->ext_ramdisk_image); + efi_set_u64_split(ramdisk_size, &hdr->ramdisk_size, + &boot_params->ext_ramdisk_size); } } @@ -639,17 +638,14 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map, : EFI32_LOADER_SIGNATURE; memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32)); - p->efi->efi_systab = (unsigned long)efi_system_table; + efi_set_u64_split((u64)efi_system_table, + &p->efi->efi_systab, &p->efi->efi_systab_hi); p->efi->efi_memdesc_size = *map->desc_size; p->efi->efi_memdesc_version = *map->desc_ver; - p->efi->efi_memmap = (unsigned long)*map->map; + efi_set_u64_split((u64)*map->map, + &p->efi->efi_memmap, &p->efi->efi_memmap_hi); p->efi->efi_memmap_size = *map->map_size; -#ifdef CONFIG_X86_64 - p->efi->efi_systab_hi = (unsigned long)efi_system_table >> 32; - p->efi->efi_memmap_hi = (unsigned long)*map->map >> 32; -#endif - return EFI_SUCCESS; } @@ -785,10 +781,10 @@ unsigned long efi_main(efi_handle_t handle, status = efi_load_initrd_dev_path(&addr, &size, ULONG_MAX); if (status == EFI_SUCCESS) { - hdr->ramdisk_image = (u32)addr; - hdr->ramdisk_size = (u32)size; - boot_params->ext_ramdisk_image = (u64)addr >> 32; - boot_params->ext_ramdisk_size = (u64)size >> 32; + efi_set_u64_split(addr, &hdr->ramdisk_image, + &boot_params->ext_ramdisk_image); + efi_set_u64_split(size, &hdr->ramdisk_size, + &boot_params->ext_ramdisk_size); } else if (status != EFI_NOT_FOUND) { efi_printk("efi_load_initrd_dev_path() failed!\n"); goto fail; From patchwork Wed Apr 29 17:41:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Sankar X-Patchwork-Id: 206376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1E3AC83000 for ; Wed, 29 Apr 2020 17:41:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B890920BED for ; Wed, 29 Apr 2020 17:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbgD2Rl0 (ORCPT ); Wed, 29 Apr 2020 13:41:26 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:46737 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgD2RlZ (ORCPT ); Wed, 29 Apr 2020 13:41:25 -0400 Received: by mail-qk1-f193.google.com with SMTP id g74so2842913qke.13; Wed, 29 Apr 2020 10:41:25 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=esudLbF50xrd3X4yxmF75Z7c/P/j5/QO+86gC+Ihm+I=; b=eUPSb8OFFq2IV5RKikfia5EhsCnYUn92dttz/3vF4dTo0UPhO4jAdIaEv/h+EqBdpE YGJudFBcPqc59oHVCxpNbFgKtN7aIJbJtD/QHDjxRqljfVGkuw/NCEVDChjKwl0Rbz/k p8Sje/A1dcpTz6feGCwpROBy/QqeYGdDVQy7zc12vs3Aif4t4k+IdGPt/NRf1JLOQtI4 TGnpBg/z/nHVjwNWJzy0B6x5rHtisJ78L/XZ3VJ1fTJtig2x3yFBNnqHviBAdX8+51kV 8/mT8ezXfg6+biDNGBY67X2/i9A+tD+YQC4r05ufeP+x50Kwup18VKACXOB3rKkt8+gI Qutg== X-Gm-Message-State: AGi0PuZ4ROJrGYY0wl6PffYdZthSRILzgHG7KlwlOl6j1oBdhRnQyzMB P+cu8F0L8ddJCur9Ev3BsIxfBjVImyM= X-Google-Smtp-Source: APiQypInkqTX0HfGThjHulH7Fu43Los2Js/u4CzOAROOk1tAxlCH2E1pnmDqUe3E0o0i+/k5rUsQ3A== X-Received: by 2002:ae9:ed04:: with SMTP id c4mr35152020qkg.367.1588182084734; Wed, 29 Apr 2020 10:41:24 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id z1sm14766448qkz.3.2020.04.29.10.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:41:24 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/10] efi/x86: Use pr_efi_err for error messages Date: Wed, 29 Apr 2020 13:41:13 -0400 Message-Id: <20200429174120.1497212-5-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429174120.1497212-1-nivedita@alum.mit.edu> References: <20200429174120.1497212-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Use pr_efi_err instead of bare efi_printk for error messages. Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/x86-stub.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 677b5a1e0543..933205772d8c 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -49,7 +49,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size, (void **)&rom); if (status != EFI_SUCCESS) { - efi_printk("Failed to allocate memory for 'rom'\n"); + pr_efi_err("Failed to allocate memory for 'rom'\n"); return status; } @@ -65,7 +65,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) PCI_VENDOR_ID, 1, &rom->vendor); if (status != EFI_SUCCESS) { - efi_printk("Failed to read rom->vendor\n"); + pr_efi_err("Failed to read rom->vendor\n"); goto free_struct; } @@ -73,7 +73,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) PCI_DEVICE_ID, 1, &rom->devid); if (status != EFI_SUCCESS) { - efi_printk("Failed to read rom->devid\n"); + pr_efi_err("Failed to read rom->devid\n"); goto free_struct; } @@ -118,7 +118,7 @@ static void setup_efi_pci(struct boot_params *params) (void **)&pci_handle); if (status != EFI_SUCCESS) { - efi_printk("Failed to allocate memory for 'pci_handle'\n"); + pr_efi_err("Failed to allocate memory for 'pci_handle'\n"); return; } @@ -172,7 +172,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) return; if (efi_table_attr(p, version) != 0x10000) { - efi_printk("Unsupported properties proto version\n"); + pr_efi_err("Unsupported properties proto version\n"); return; } @@ -185,7 +185,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) size + sizeof(struct setup_data), (void **)&new); if (status != EFI_SUCCESS) { - efi_printk("Failed to allocate memory for 'properties'\n"); + pr_efi_err("Failed to allocate memory for 'properties'\n"); return; } @@ -372,7 +372,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, status = efi_bs_call(handle_protocol, handle, &proto, (void **)&image); if (status != EFI_SUCCESS) { - efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); + pr_efi_err("Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); efi_exit(handle, status); } @@ -382,7 +382,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, status = efi_allocate_pages(sizeof(struct boot_params), (unsigned long *)&boot_params, ULONG_MAX); if (status != EFI_SUCCESS) { - efi_printk("Failed to allocate lowmem for boot params\n"); + pr_efi_err("Failed to allocate lowmem for boot params\n"); efi_exit(handle, status); } @@ -749,7 +749,7 @@ unsigned long efi_main(efi_handle_t handle, hdr->kernel_alignment, LOAD_PHYSICAL_ADDR); if (status != EFI_SUCCESS) { - efi_printk("efi_relocate_kernel() failed!\n"); + pr_efi_err("efi_relocate_kernel() failed!\n"); goto fail; } /* @@ -786,7 +786,7 @@ unsigned long efi_main(efi_handle_t handle, efi_set_u64_split(size, &hdr->ramdisk_size, &boot_params->ext_ramdisk_size); } else if (status != EFI_NOT_FOUND) { - efi_printk("efi_load_initrd_dev_path() failed!\n"); + pr_efi_err("efi_load_initrd_dev_path() failed!\n"); goto fail; } } @@ -813,13 +813,13 @@ unsigned long efi_main(efi_handle_t handle, status = exit_boot(boot_params, handle); if (status != EFI_SUCCESS) { - efi_printk("exit_boot() failed!\n"); + pr_efi_err("exit_boot() failed!\n"); goto fail; } return bzimage_addr; fail: - efi_printk("efi_main() failed!\n"); + pr_efi_err("efi_main() failed!\n"); efi_exit(handle, status); } From patchwork Wed Apr 29 17:41:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Sankar X-Patchwork-Id: 206373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E845DC83004 for ; Wed, 29 Apr 2020 17:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB21421707 for ; Wed, 29 Apr 2020 17:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgD2Rlw (ORCPT ); Wed, 29 Apr 2020 13:41:52 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:35429 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbgD2Rl1 (ORCPT ); Wed, 29 Apr 2020 13:41:27 -0400 Received: by mail-qk1-f195.google.com with SMTP id c63so2900254qke.2; Wed, 29 Apr 2020 10:41:26 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=gNcbFcBqpcuqFq869O2rJKX45xd3G8ARmUjKz33/zqw=; b=F2eZMJjns1F3zNykCXKsi3Z6VupLI3mvnRu8EwGxd7H8jJg9VOgpPra/hDN7ie/XYG eGAfevAf3ciHEBBhEjCAbTIRC4IXHtw/b4gbIuJvtL6adhx2oWXfAn9RKWD5xxZP5Wj1 SW3WxHWgjDO3cHchgztWwjvNPuFk3QI9k4qEY2ab5zDhCjFq3S9URS0EcY0A0e1+PDO5 fXSnA1260OUjoZG46p37x0yURyXfKIm0tI8XRYAM8+SotEOZ+MwdWcNPMk11n4o3t4+Z fC57xgmASNr8eF4XQxYOE/oH0q5Fm5AtNPkd4138S11yQNGmIwwZk6CnBkOKxZXXeYoX KJeg== X-Gm-Message-State: AGi0PubokkgafaTKMzEuewxm2+E2MAA+GocCz+OCiyHlXZO/1P6osZQv 2gqO/n8sJ15MfDTXoMA/p2iZf0cClHk= X-Google-Smtp-Source: APiQypKTW2hHx8g1COTK3HONNfuPE920a4LtjOiRXSx3Vb+HF8SQ04prPnlHzQYqye/9WDbwXTPi0g== X-Received: by 2002:a37:a9c7:: with SMTP id s190mr33631397qke.75.1588182086301; Wed, 29 Apr 2020 10:41:26 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id z1sm14766448qkz.3.2020.04.29.10.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:41:25 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/10] efi/tpm: Use pr_efi_err for error messages Date: Wed, 29 Apr 2020 13:41:15 -0400 Message-Id: <20200429174120.1497212-7-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429174120.1497212-1-nivedita@alum.mit.edu> References: <20200429174120.1497212-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Use pr_efi_err instead of bare efi_printk for error messages. Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index 1d59e103a2e3..8a16983fad98 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -119,7 +119,7 @@ void efi_retrieve_tpm2_eventlog(void) sizeof(*log_tbl) + log_size, (void **)&log_tbl); if (status != EFI_SUCCESS) { - efi_printk("Unable to allocate memory for event log\n"); + pr_efi_err("Unable to allocate memory for event log\n"); return; } From patchwork Wed Apr 29 17:41:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Sankar X-Patchwork-Id: 206375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72D77C83004 for ; Wed, 29 Apr 2020 17:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D99520B80 for ; Wed, 29 Apr 2020 17:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgD2Rla (ORCPT ); Wed, 29 Apr 2020 13:41:30 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44266 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbgD2Rl3 (ORCPT ); Wed, 29 Apr 2020 13:41:29 -0400 Received: by mail-qk1-f195.google.com with SMTP id h124so2846984qke.11; Wed, 29 Apr 2020 10:41:28 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=17khpAR6nkDRxD5BLjB1TLshrcrm8CQXqW4S+007WC0=; b=e4hkMRX36wCSBXDbOwrAHlQ0+3+UzKDaDoQlDEal0TDtXSL2ktd/gwMf2tOa+BKvq2 AnNrtXk1r3uDJeivjypEbnVKF6jDrt8fjskJQaa9MjkqBeauKjFT5GRFrK4ySW3BPKLB BXXTOzvTnMqU7WCcm8ilIm/gozPrOo7kyD0PS9aug3UZqqv4x7Ftk8UXfhNH+1v09Aa7 +8cVI42w1P/wdm32OaV4De1xv8Da8Sqiy3rS2BqFSuhNeyQnEcE26mk6U+QvY4oU2y16 tcyLfoQAWKJQTkightZZfLavrwCgt/qkk8Me4e/O69Km5JlW9m3KQ+D2JANNW93Yrcft Rg8Q== X-Gm-Message-State: AGi0PubnZPMcdCMsFG8pLorJlRuQ7GjWvI4EuqTev5Db+TTxDwGALa+z Eb0JVMhUcKvL2fQhaPyNejFXJtpE0pY= X-Google-Smtp-Source: APiQypId6FRdVQ5rgZXwMpyyulkPIOzJTkZLhESAX7kwc7wuAwALRTKjXYLTR2upv59PaLhOzDs7yw== X-Received: by 2002:a37:ad0d:: with SMTP id f13mr13462804qkm.7.1588182087926; Wed, 29 Apr 2020 10:41:27 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id z1sm14766448qkz.3.2020.04.29.10.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:41:27 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/10] efi/libstub: Unify initrd loading across architectures Date: Wed, 29 Apr 2020 13:41:17 -0400 Message-Id: <20200429174120.1497212-9-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429174120.1497212-1-nivedita@alum.mit.edu> References: <20200429174120.1497212-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Factor out the initrd loading into a common function that can be called both from the generic efi-stub.c and the x86-specific x86-stub.c. Signed-off-by: Arvind Sankar --- .../firmware/efi/libstub/efi-stub-helper.c | 46 +++++++++++++++++-- drivers/firmware/efi/libstub/efi-stub.c | 12 +---- drivers/firmware/efi/libstub/efistub.h | 21 ++------- drivers/firmware/efi/libstub/x86-stub.c | 13 +----- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 1c92ac231f94..2c0c2c34b4cc 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -331,6 +331,7 @@ static const struct { * %EFI_OUT_OF_RESOURCES if memory allocation failed * %EFI_LOAD_ERROR in all other cases */ +static efi_status_t efi_load_initrd_dev_path(unsigned long *load_addr, unsigned long *load_size, unsigned long max) @@ -343,9 +344,6 @@ efi_status_t efi_load_initrd_dev_path(unsigned long *load_addr, efi_handle_t handle; efi_status_t status; - if (!load_addr || !load_size) - return EFI_INVALID_PARAMETER; - dp = (efi_device_path_protocol_t *)&initrd_dev_path; status = efi_bs_call(locate_device_path, &lf2_proto_guid, &dp, &handle); if (status != EFI_SUCCESS) @@ -375,3 +373,45 @@ efi_status_t efi_load_initrd_dev_path(unsigned long *load_addr, *load_size = initrd_size; return EFI_SUCCESS; } + +static +efi_status_t efi_load_initrd_cmdline(efi_loaded_image_t *image, + unsigned long *load_addr, + unsigned long *load_size, + unsigned long soft_limit, + unsigned long hard_limit) +{ + if (!IS_ENABLED(CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER) || + (IS_ENABLED(CONFIG_X86) && (!efi_is_native() || image == NULL))) { + *load_addr = *load_size = 0; + return EFI_SUCCESS; + } + + return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2, + soft_limit, hard_limit, + load_addr, load_size); +} + +efi_status_t efi_load_initrd(efi_loaded_image_t *image, + unsigned long *load_addr, + unsigned long *load_size, + unsigned long soft_limit, + unsigned long hard_limit) +{ + efi_status_t status; + + if (!load_addr || !load_size) + return EFI_INVALID_PARAMETER; + + status = efi_load_initrd_dev_path(load_addr, load_size, hard_limit); + if (status == EFI_SUCCESS) { + pr_efi("Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path\n"); + } else if (status == EFI_NOT_FOUND) { + status = efi_load_initrd_cmdline(image, load_addr, load_size, + soft_limit, hard_limit); + if (status == EFI_SUCCESS && *load_size > 0) + pr_efi("Loaded initrd from command line option\n"); + } + + return status; +} diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index ee225b323687..d8f24f5c91bd 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -265,16 +265,8 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg) if (!efi_noinitrd) { max_addr = efi_get_max_initrd_addr(dram_base, image_addr); - status = efi_load_initrd_dev_path(&initrd_addr, &initrd_size, - max_addr); - if (status == EFI_SUCCESS) { - pr_efi("Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path\n"); - } else if (status == EFI_NOT_FOUND) { - status = efi_load_initrd(image, &initrd_addr, &initrd_size, - ULONG_MAX, max_addr); - if (status == EFI_SUCCESS && initrd_size > 0) - pr_efi("Loaded initrd from command line option\n"); - } + status = efi_load_initrd(image, &initrd_addr, &initrd_size, + ULONG_MAX, max_addr); if (status != EFI_SUCCESS) pr_efi_err("Failed to load initrd!\n"); } diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index e8aa70ba08d5..dfdd7954bf58 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -677,21 +677,10 @@ static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image, ULONG_MAX, ULONG_MAX, load_addr, load_size); } -static inline efi_status_t efi_load_initrd(efi_loaded_image_t *image, - unsigned long *load_addr, - unsigned long *load_size, - unsigned long soft_limit, - unsigned long hard_limit) -{ - if (!IS_ENABLED(CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER)) - return EFI_SUCCESS; - - return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2, - soft_limit, hard_limit, load_addr, load_size); -} - -efi_status_t efi_load_initrd_dev_path(unsigned long *load_addr, - unsigned long *load_size, - unsigned long max); +efi_status_t efi_load_initrd(efi_loaded_image_t *image, + unsigned long *load_addr, + unsigned long *load_size, + unsigned long soft_limit, + unsigned long hard_limit); #endif diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index ee4241df4f29..1d3f94f1dafa 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -755,17 +755,8 @@ unsigned long efi_main(efi_handle_t handle, if (!efi_noinitrd) { unsigned long addr, size; - status = efi_load_initrd_dev_path(&addr, &size, ULONG_MAX); - if (status == EFI_NOT_FOUND) { - if (efi_is_native() && image != NULL) { - status = efi_load_initrd(image, &addr, &size, - hdr->initrd_addr_max, - ULONG_MAX); - } else { - addr = size = 0; - status = EFI_SUCCESS; - } - } + status = efi_load_initrd(image, &addr, &size, + hdr->initrd_addr_max, ULONG_MAX); if (status != EFI_SUCCESS) { pr_efi_err("Failed to load initrd!\n"); From patchwork Wed Apr 29 17:41:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Sankar X-Patchwork-Id: 206374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09E5CC83006 for ; Wed, 29 Apr 2020 17:41:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E204F20757 for ; Wed, 29 Apr 2020 17:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727848AbgD2Rlk (ORCPT ); Wed, 29 Apr 2020 13:41:40 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:46747 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbgD2Rla (ORCPT ); Wed, 29 Apr 2020 13:41:30 -0400 Received: by mail-qk1-f196.google.com with SMTP id g74so2843141qke.13; Wed, 29 Apr 2020 10:41:29 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=Eri9nbMjJY+WMCJY05yR1IDSTdT6azrjQssNo0Q1FLI=; b=SzGzFB3jbWw9Ls67YVOY8rkXaK+nTR5xMpthx94BP8b1iU9nhoWeYtJB/MiH0bICdh snpMkG2RRZ03XmVvwiuXOrsdvZfzj+HpEpiig2BfDuSHG0LdWovBcBsfKM376NDdDvGW uxQFDGuk5BmvasPG0LMcSKxiP3u34edO3Ne8fxDcrBPyVmPTmgjIDvFQfmpcQSUJ4lVb 03I3+S/6AvnOgqh5gLX1miQrpyHyNaZ5gsc1OiW+PVqS6bkN8J00UTdYJtlij0ya9HF1 4vYhDUMwDAPSQgXjJfiHF+Th4t+d3tbI9QzjTXHUbC6ozrP/Vyp+T5O/5+KXLtrhguDQ amBA== X-Gm-Message-State: AGi0PubUWn1aNlSEozxe4rf/TsfWbwCiJ5tgDGDu41KPFAeBu2EyJKlV RJrz7blj3F6uEgHFgxwrFy2iORbt8w0= X-Google-Smtp-Source: APiQypKR4NOK+vPTtwvLiryqpDhyhnZmAhRJoEH2xksLBlvbg5LfIR9ZZS+65jr5WdPLze7mVwq8FA== X-Received: by 2002:a05:620a:16b0:: with SMTP id s16mr34414127qkj.204.1588182088734; Wed, 29 Apr 2020 10:41:28 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id z1sm14766448qkz.3.2020.04.29.10.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:41:28 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/10] efi/x86: Drop soft_limit for x86 initrd loading Date: Wed, 29 Apr 2020 13:41:18 -0400 Message-Id: <20200429174120.1497212-10-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429174120.1497212-1-nivedita@alum.mit.edu> References: <20200429174120.1497212-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Currently the EFI stub attempts to load initrd(s) specified on the command line below hdr->initrd_addr_max (2G) and if that fails, falls back to allocating at an unrestricted address. The only case when loading at a low address helps is for the 32-bit kernel, where the initrd must be copied by the kernel into lowmem if it's not there already. The limit specified in hdr->initrd_addr_max is insufficient to ensure this in any case, since lowmem by default will extend to about 0.9G rather than 2G, and we don't attempt to load the initrd in lowmem at all for the new device-path based initrd. Simplify the code by dropping this optimization for the command line initrd(s) as well. Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/efi-stub-helper.c | 14 +++++--------- drivers/firmware/efi/libstub/efi-stub.c | 3 +-- drivers/firmware/efi/libstub/efistub.h | 8 +++----- drivers/firmware/efi/libstub/file.c | 13 ++----------- drivers/firmware/efi/libstub/x86-stub.c | 3 +-- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 2c0c2c34b4cc..32768fa04b32 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -378,8 +378,7 @@ static efi_status_t efi_load_initrd_cmdline(efi_loaded_image_t *image, unsigned long *load_addr, unsigned long *load_size, - unsigned long soft_limit, - unsigned long hard_limit) + unsigned long max) { if (!IS_ENABLED(CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER) || (IS_ENABLED(CONFIG_X86) && (!efi_is_native() || image == NULL))) { @@ -388,27 +387,24 @@ efi_status_t efi_load_initrd_cmdline(efi_loaded_image_t *image, } return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2, - soft_limit, hard_limit, - load_addr, load_size); + max, load_addr, load_size); } efi_status_t efi_load_initrd(efi_loaded_image_t *image, unsigned long *load_addr, unsigned long *load_size, - unsigned long soft_limit, - unsigned long hard_limit) + unsigned long max) { efi_status_t status; if (!load_addr || !load_size) return EFI_INVALID_PARAMETER; - status = efi_load_initrd_dev_path(load_addr, load_size, hard_limit); + status = efi_load_initrd_dev_path(load_addr, load_size, max); if (status == EFI_SUCCESS) { pr_efi("Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path\n"); } else if (status == EFI_NOT_FOUND) { - status = efi_load_initrd_cmdline(image, load_addr, load_size, - soft_limit, hard_limit); + status = efi_load_initrd_cmdline(image, load_addr, load_size, max); if (status == EFI_SUCCESS && *load_size > 0) pr_efi("Loaded initrd from command line option\n"); } diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index d8f24f5c91bd..930302d9415a 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -265,8 +265,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg) if (!efi_noinitrd) { max_addr = efi_get_max_initrd_addr(dram_base, image_addr); - status = efi_load_initrd(image, &initrd_addr, &initrd_size, - ULONG_MAX, max_addr); + status = efi_load_initrd(image, &initrd_addr, &initrd_size, max_addr); if (status != EFI_SUCCESS) pr_efi_err("Failed to load initrd!\n"); } diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index dfdd7954bf58..1ba0887818d9 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -663,8 +663,7 @@ efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, efi_status_t handle_cmdline_files(efi_loaded_image_t *image, const efi_char16_t *optstr, int optstr_size, - unsigned long soft_limit, - unsigned long hard_limit, + unsigned long max, unsigned long *load_addr, unsigned long *load_size); @@ -674,13 +673,12 @@ static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image, unsigned long *load_size) { return handle_cmdline_files(image, L"dtb=", sizeof(L"dtb=") - 2, - ULONG_MAX, ULONG_MAX, load_addr, load_size); + ULONG_MAX, load_addr, load_size); } efi_status_t efi_load_initrd(efi_loaded_image_t *image, unsigned long *load_addr, unsigned long *load_size, - unsigned long soft_limit, - unsigned long hard_limit); + unsigned long max); #endif diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c index 50aaf15f9ad5..7dee3c5d81fb 100644 --- a/drivers/firmware/efi/libstub/file.c +++ b/drivers/firmware/efi/libstub/file.c @@ -124,8 +124,7 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len, efi_status_t handle_cmdline_files(efi_loaded_image_t *image, const efi_char16_t *optstr, int optstr_size, - unsigned long soft_limit, - unsigned long hard_limit, + unsigned long max, unsigned long *load_addr, unsigned long *load_size) { @@ -181,15 +180,7 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image, round_up(alloc_size, EFI_ALLOC_ALIGN)) { unsigned long old_addr = alloc_addr; - status = EFI_OUT_OF_RESOURCES; - if (soft_limit < hard_limit) - status = efi_allocate_pages(alloc_size + size, - &alloc_addr, - soft_limit); - if (status == EFI_OUT_OF_RESOURCES) - status = efi_allocate_pages(alloc_size + size, - &alloc_addr, - hard_limit); + status = efi_allocate_pages(alloc_size + size, &alloc_addr, max); if (status != EFI_SUCCESS) { pr_efi_err("Failed to allocate memory for files\n"); goto err_close_file; diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 1d3f94f1dafa..85a924fecc87 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -755,8 +755,7 @@ unsigned long efi_main(efi_handle_t handle, if (!efi_noinitrd) { unsigned long addr, size; - status = efi_load_initrd(image, &addr, &size, - hdr->initrd_addr_max, ULONG_MAX); + status = efi_load_initrd(image, &addr, &size, ULONG_MAX); if (status != EFI_SUCCESS) { pr_efi_err("Failed to load initrd!\n");