From patchwork Thu Jul 12 12:21:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 141826 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1445893ljj; Thu, 12 Jul 2018 05:22:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfwGw8Q0htd+t52nnKzIKzRaftLUBY2Rkal35EXSPAKWHKRneayxMWHwG4NyGmernZsjy01 X-Received: by 2002:a62:d39b:: with SMTP id z27-v6mr2230825pfk.182.1531398129418; Thu, 12 Jul 2018 05:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531398129; cv=none; d=google.com; s=arc-20160816; b=ev9xLPoXoon8drYhcoTO+a32O6Po9U2n6G20lZ1fDrfGcOXIw1CjO/PDFDivBIX5Sb qE47GD/8TGY6yeHqc9lug+3WUf03t9C/sTSBi3Ii9JfVM7jja0rqE9bUwiVcun/X2vzn v2VmagfIVI+Ks+O6kyntB2ipotWo26ytXJuEg2EQHQVSXsT8YSlPDxlrZmy0Lu+UbJIY 7VxWRn7Wb+rc50mYkRWm8EvAoeNGHIyQtzppyrTs4DSUfJF6uMcSzVoFO3HR/hGcqd8/ QMqiipxXBxE0Asedo+gCAHVuH90+57CMFTeIPJ5ETDzvsJD/mOCcXYm1ZdHP/q4tmXJG iXfg== 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=8TxoZuggYj8RZ7qKULFIbQsL5pAiRJVxLYlaN7L14JM=; b=mXwgXjcSZwygOtKTT2Xh82gtEOAPtsZmpcSmpAyKoTu3WxTEA48MLq0AM+ce3UPu4p gJ/MnwkoWwLo3ARdXzLziDVbAQfcayhFpVSa+OZONCawLRNrkx5g+oiBHSw1oG1fH3FH 12N9VdaZWjM02qJTDEJv6h5XnXTSOHYyvL5GcncbM1DPp0KGvbLH0pllCxJ4N3836lTq rVldvcczbeRDhQQB32fMgH+Ur4NghokB5lE1cLmOCnrBB0DSMtaWlnN2oauW4GBLszSP NZSIaCTrvXEY0ng3kCrF8DK1UKGtpQnpM8DImwP6hbBNcxFXfC2+v0UocX6gMacNzqTW ajeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jy3Afy41; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8-v6si7016131pff.248.2018.07.12.05.22.09; Thu, 12 Jul 2018 05:22:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jy3Afy41; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbeGLMb2 (ORCPT + 3 others); Thu, 12 Jul 2018 08:31:28 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46323 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727006AbeGLMb1 (ORCPT ); Thu, 12 Jul 2018 08:31:27 -0400 Received: by mail-wr1-f66.google.com with SMTP id s11-v6so21492017wra.13 for ; Thu, 12 Jul 2018 05:22:07 -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=cVyQ/JUzlmp8ewnQhL+UUUcp7O1/aplvmkaHEWVk55s=; b=jy3Afy41Ir6Ehy2fLVB3GihNTfrQ9Ir6cbnM9t28oqWuDsRp4ivTcp22OUAj8YiGsJ 5ojLF8OGjmFmOPAk594hf1OR95Y7DPBEgVXSmf2rZBOlLidXytJIYYSn60wrYj69qUgn sU45AH0UTK1NZ+44nKXbIm1KuUeeJrmKW2f10= 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=cVyQ/JUzlmp8ewnQhL+UUUcp7O1/aplvmkaHEWVk55s=; b=XFj+gx52fnCm+bk0/AF/Qchug4nMV8oDrttz1Yqc7UQQb/BSyBnnDxIvB+B9C4Yyud 2akTm8EhNY7EW1DClCggfq8677d+JNMrJ0QClcdgAsMcTTmGnfMlNl5MStgSKiO3miJj WLyYL55EEjDczejEV6ADwVspN67FNeO3lAzfwiO9X2MH0KZQceu3k9S2n+JUzUyFjQnW ECh0989PRvGNL/f7TWQJWBwoORH4GgD1RbgaWLmOstPuCGdga4Rfk6prmYi2dSuUd7DX iWmRxACpjDA7PlPw+J9vOcVeF5EvPm6kyjBFpjV9xyzKHTLTwFmKgPolcTMfX9ohStjc zYow== X-Gm-Message-State: AOUpUlHDjkZp7/Y92Uq9CfF9g4u4dqrT7AS4Zdb2r2XBlTAwb8N4f2jW C1yLx48VtGtfGNiO+uem/jWgXOol7mg= X-Received: by 2002:adf:ee4e:: with SMTP id w14-v6mr1684413wro.63.1531398126723; Thu, 12 Jul 2018 05:22:06 -0700 (PDT) Received: from localhost.localdomain (33.153.69.91.rev.sfr.net. [91.69.153.33]) by smtp.gmail.com with ESMTPSA id y3-v6sm3551246wmd.24.2018.07.12.05.22.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 05:22:06 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: sai.praneeth.prakhya@intel.com, mingo@kernel.org, hdegoede@redhat.com, lukas@wunner.de, Ard Biesheuvel Subject: [PATCH 6/6] efi/x86: replace references to efi_early->is64 with efi_is_64bit() Date: Thu, 12 Jul 2018 14:21:54 +0200 Message-Id: <20180712122154.13819-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180712122154.13819-1-ard.biesheuvel@linaro.org> References: <20180712122154.13819-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@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. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 92b573fd239c..b492fba230ea 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -98,7 +98,7 @@ static inline efi_status_t __open_volume64(void *__image, void **__fh) efi_status_t efi_open_volume(efi_system_table_t *sys_table, void *__image, void **__fh) { - if (efi_early->is64) + if (efi_is_64bit()) return __open_volume64(__image, __fh); return __open_volume32(__image, __fh); @@ -467,7 +467,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); @@ -746,8 +746,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; @@ -768,7 +767,7 @@ 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; + priv.is64 = efi_is_64bit(); /* Might as well exit boot services now */ status = efi_exit_boot_services(sys_table, handle, &map, &priv, @@ -803,13 +802,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; @@ -817,7 +814,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); @@ -873,7 +870,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;