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;