Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2835421ybv; Mon, 24 Feb 2020 12:34:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzTWamDbfqqgly/KQyJd/CIxNVbcxWPjJKIT/M6OZeAJdnPUGpj0H2/P3k/bKh0DYibvetf X-Received: by 2002:aca:ab53:: with SMTP id u80mr698669oie.94.1582576468177; Mon, 24 Feb 2020 12:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582576466; cv=none; d=google.com; s=arc-20160816; b=iT0/RKVUd3ga5u1ZxKMiNZ0TlA9L6+i1ia4/2+oT5wu8u/YoGht8vTaebOEVHOcYnp 0G4UVqAA88kRb7qGnKCvJlQr7txlo3oQlMhfoEtGZ/1cBgLTzF1imNpMjViteASsvWof J+5C6lqZebYX9HsqDzF4A2lzVkhbgK3g+7AhULrM7B/Ig7Wi7aFGEHsd2KsGk0FvtbHB Je1QkmBDcHDShIyjKaBCJU1RL/0OW/YaAuNfjk7XBAfVTi1W5chkAHpIN/YQTKg7t4AY M8BWznsHB29R9qxxK9TWS4w193QNgU/eFi2qF3HhyDg8amQD8S86Ddtg3j5AES0KdUsB BhRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=76eCXvzOdkKqMOkLCtpzKfQrkjuAlYbntrCFv9FhTZo=; b=NGhbP1tfCDrS1FhCwV08dbYH3sa6wpeegkaikcSJUiCG6Xby3Z0n3i3EmW0F3YURNv 7b03xYevzO95gAfR/uN7vN5rnbWeVA/ZT25bjC0B6iIgpEw2JXvTfTp0+jwyYP2XfY7t Uj27zvOl5LfrS96n0cYM6KwYZY/RGLBfIsOCmgkVDT6ba+brHgHF8SvmSjmKiSV9txAA sF/AHSirQVd3vKGvuWQLBL9Fk+4wARfclJJqDhsQaDGZ0vZUeVjLIOUcNxg3S7qjMWIt Dm3S5OQays6CeI41bKjyIs3C2EpRJNec4lVBuzQt8lO+EShu9A7ZmnluCGQFMRpTqXtS 0LaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wAakMVhF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si6443992otc.104.2020.02.24.12.34.12; Mon, 24 Feb 2020 12:34:26 -0800 (PST) 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=@google.com header.s=20161025 header.b=wAakMVhF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbgBXUeB (ORCPT + 99 others); Mon, 24 Feb 2020 15:34:01 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:53318 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgBXUeB (ORCPT ); Mon, 24 Feb 2020 15:34:01 -0500 Received: by mail-pj1-f65.google.com with SMTP id n96so248715pjc.3 for ; Mon, 24 Feb 2020 12:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=76eCXvzOdkKqMOkLCtpzKfQrkjuAlYbntrCFv9FhTZo=; b=wAakMVhFkoCmCt1tybQW5/NwAyhLvRI5YITs4R8raHQP4WvmEEPwlfA/svks+GPJKI vpZi03GoPklfdSJNGIZHmnD1QruxiqrYl3UvXUH+Alr3NK0l9UK28Uqt563huHw8lVBS 6i6vAiraEiCe82svJH7Oq6XMxxE9aai2ymOPTWBgG6TLyligObYWIWTBDGMI3pjB6Smt idE4iNT61k42KKowi35oPPAhEfavrl/aFA4ZiyOnvGXI1uy1Fdmkh4aPQqQrAtNzlfoU qbFgw7YZ5ATlFUpn5OVVmDAf1NhOESmF7VLbPgtxhbEVgGKJ0yuogqXrINYN/W3XN03i kNpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=76eCXvzOdkKqMOkLCtpzKfQrkjuAlYbntrCFv9FhTZo=; b=Rtc/VoR5LK40gHdumQHF+hiRYmrdh7XT++V2b0TdtuX+zgtVFo87vBR740jJeuoK1K wC48LG8e21MZCRou02Syn5vPkn0Qd5TteigePgG6WlrOwpjHr+QoGX4AgJq2hD1V9kMM OpWK8XB4DMx6O6+DZpkq+owz7GuTsve1HFWpQItrqfVsLdBzGMLhZ0cnfIRWgYOeFVSG m73hjeyYY1Xc54iKG79ub0tOc5J6RjHIrHbmJ3gsbzqiHLuMKYtwDSQwWL1mPq6iZea6 6R9lF7Y+0z1e1h7HWe5zKR7kfZQhZI2OIt0u+q29COKN3H9R0SjHqJaOBkixbN/21Ihf cCOw== X-Gm-Message-State: APjAAAVlaVkKIOtat9/d94WDLEBilovR2ILXUwoM85EwnrhmKeQeMD4W OHNirUUmjpvMnm96yguFg6bXegzbWhbr/jpreDp3Xg== X-Received: by 2002:a17:902:760e:: with SMTP id k14mr49014175pll.119.1582576440335; Mon, 24 Feb 2020 12:34:00 -0800 (PST) MIME-Version: 1.0 References: <20200222235709.GA3786197@rani.riverdale.lan> <20200223193715.83729-2-nivedita@alum.mit.edu> In-Reply-To: <20200223193715.83729-2-nivedita@alum.mit.edu> From: Nick Desaulniers Date: Mon, 24 Feb 2020 12:33:49 -0800 Message-ID: Subject: Re: [PATCH 1/2] arch/x86: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections To: Arvind Sankar Cc: Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , clang-built-linux , Michael Matz , Fangrui Song , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 23, 2020 at 11:37 AM Arvind Sankar wrote: > > While discussing a patch to discard .eh_frame from the compressed > vmlinux using the linker script, Fangrui Song pointed out [1] that these > sections shouldn't exist in the first place because arch/x86/Makefile > uses -fno-asynchronous-unwind-tables. Another benefit is that -fno-asynchronous-unwind-tables may help reduce the size of .text! https://stackoverflow.com/a/26302715/1027966 > > It turns out this is because the Makefiles used to build the compressed > kernel redefine KBUILD_CFLAGS, dropping this flag. > > Add the flag to the Makefile for the compressed kernel, as well as the > EFI stub Makefile to fix this. > > Also add the flag to boot/Makefile and realmode/rm/Makefile so that the > kernel's boot code (boot/setup.elf) and realmode trampoline > (realmode/rm/realmode.elf) won't be compiled with .eh_frame sections, > since their linker scripts also just discard it. > > Signed-off-by: Arvind Sankar > Suggested-By: Fangrui Song > [1] https://lore.kernel.org/lkml/20200222185806.ywnqhfqmy67akfsa@google.com/ > --- > arch/x86/boot/Makefile | 1 + > arch/x86/boot/compressed/Makefile | 1 + > arch/x86/realmode/rm/Makefile | 1 + > drivers/firmware/efi/libstub/Makefile | 3 ++- > 4 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile > index 012b82fc8617..24f011e0adf1 100644 > --- a/arch/x86/boot/Makefile > +++ b/arch/x86/boot/Makefile > @@ -68,6 +68,7 @@ clean-files += cpustr.h > KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > GCOV_PROFILE := n > UBSAN_SANITIZE := n > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > index 26050ae0b27e..c33111341325 100644 > --- a/arch/x86/boot/compressed/Makefile > +++ b/arch/x86/boot/compressed/Makefile > @@ -39,6 +39,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) > KBUILD_CFLAGS += $(call cc-disable-warning, gnu) > KBUILD_CFLAGS += -Wno-pointer-sign > KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > GCOV_PROFILE := n > diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile > index 99b6332ba540..b11ec5d8f8ac 100644 > --- a/arch/x86/realmode/rm/Makefile > +++ b/arch/x86/realmode/rm/Makefile > @@ -71,5 +71,6 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE > KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \ > -I$(srctree)/arch/x86/boot > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > GCOV_PROFILE := n > UBSAN_SANITIZE := n > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index 98a81576213d..a1140c4ee478 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -12,7 +12,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ > -mno-mmx -mno-sse -fshort-wchar \ > -Wno-pointer-sign \ > $(call cc-disable-warning, address-of-packed-member) \ > - $(call cc-disable-warning, gnu) > + $(call cc-disable-warning, gnu) \ > + -fno-asynchronous-unwind-tables I think we want to add this flag a little lower, line 27 has: KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ so the `cflags-y` variable you modify in this hunk will only set -fno-asynchronous-unwind-tables for CONFIG_X86, which I don't think is intentional. Though when I run $ llvm-readelf -S drivers/firmware/efi/libstub/lib.a | grep eh_frame after doing an x86_64 defconfig, I don't get any hits. Do you observe .eh_frame sections on any of these objects in this dir? (I'm fine adding it to be safe, but I'm curious why I'm not seeing any .eh_frame) > > # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly > # disable the stackleak plugin > -- > 2.24.1 > -- Thanks, ~Nick Desaulniers