Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2872694ybv; Mon, 24 Feb 2020 13:22:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxKzl8lQ+hndn/unlZQ3plQ9BMt5jU1e7ycMlYvQKVD8FaGG4Jlhov7hd+fXHktJZgX5Pxf X-Received: by 2002:aca:90f:: with SMTP id 15mr885480oij.18.1582579375144; Mon, 24 Feb 2020 13:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582579375; cv=none; d=google.com; s=arc-20160816; b=b45EcI+xLl6EY8ZRQI6IMB2m/u2w2RlMnfaN2+CkMDytgHDTxBk3Gs456Bib8HLa42 Pm80YdL/zq0+qnK0OZMIvNCiye94Q6xByujocn3nBvQyo0bowSmqwqJoun772pivadq8 NoJsaWKyPNKVdXswTkHK4iL7rLSyKTceLsLhKkQSdFSjJfQRntCDKQFFdIJs8WJ0amI0 a5+iWNIk26lHNqWEp07o8Y6fd1dH4pylOUhQKLaZdNGN+qgM6HUTH4u4t87A0AYMogC0 /S1oO3WtWn5oxQnIS5JElWCQvnsfWEx002v5h2iOT2CWqoehlvvOgGYZ0aPGecaiVrxm zfEA== 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=bH6EploGU3w+XX+y+9X71Wyht2oE1L8WWitTABuRGD4=; b=r0gYEU+6I0NupdfkrR+h59oDbNXYq5gNgPwU9727SRYhxPEf9FQm9eDTZF4m+J8emY 7g/wEco+c3K3oju7btCHs+KMWTttYXV6VLiRrTVDGFzFQCcl2q06i+F7lvRyGe9M17Q3 GcvMAloN4G2uAUHoYkxj8ESspHd+DhdcP2/bFT/VpV4a22b4hh8EDRb+xWkyD8W/92o6 vSpl1ZqbopjpCsuL9jIkbp6pjdBgPMm8N+/sb+2GbrOSl/AJecGKyWUh3po4rFR5LyXU SQ/26YTbcGRtqSc8h2T3xI0GEmPeSvxLIDqUGdb9AW+MLlDTB9+0DxTOhki8b1p+88oL uR2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="JeKTqq/I"; 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 q19si6395740otm.221.2020.02.24.13.22.42; Mon, 24 Feb 2020 13:22:55 -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="JeKTqq/I"; 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 S1727554AbgBXVWX (ORCPT + 99 others); Mon, 24 Feb 2020 16:22:23 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45424 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbgBXVWW (ORCPT ); Mon, 24 Feb 2020 16:22:22 -0500 Received: by mail-pf1-f196.google.com with SMTP id 2so5981038pfg.12 for ; Mon, 24 Feb 2020 13:22:22 -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=bH6EploGU3w+XX+y+9X71Wyht2oE1L8WWitTABuRGD4=; b=JeKTqq/Ix2Z64h5hXGhO3BfyYx3eQN8cqoo3ojfGrKXDfsjPGtwJWiXv/pVA5KDLqA 1woYIXuC5x5EM0WpJUWj6rjG65W+uG3YNEnsX/4VAVWNYxwdmmKr76meSKAU3j/ul047 mZ/2gZEiXP4neMPeGMjbGdDKc6ZN/vQYxCAszbaO5CU7LQAC4Y7dGqHMydpGyr1gbzjG xF+oI+xVoXIuNjGwvk02TSUR41f/ZiQil54xotrFYZYY2WnbnYYBNwbu/cZb7sFay1OM fHEan28VIjkYh8sBwrIpGcxGXi4GeORcAOx2nbBFly9XwFpEsG4mBsdahZYcwuxByifp aYEw== 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=bH6EploGU3w+XX+y+9X71Wyht2oE1L8WWitTABuRGD4=; b=irerlqlJlK6DR6fMPo+aay9JnMn9UsouYT9akUu65EEhDBZYHCcaGW6zU1UfCBP1aN KuL2WDcMnUg0lPi6KVr0ug6657Ny0apBm/vUUT2oNByPG+9D8jmBJPQdkB+035iLgnqf rsOGmamI6USNeK7dJ/QGMdRTIkPJixAzUnyCNl6a3CIYl+Y3yOKO6AE3XpRmUAwtfdvq IQDM5W3/di5S6KUKOAvmm2dY5etpD5bs2Hg91I8FbDogeZlAGx9Hs052zHnskxG8b97N k3gjY8e2xIHV4h2BYk6B8X7Wwu2KvuwO31/RdSRg9WI/53Vv8UdwDy2r0JzpG7lCWrGe UTAg== X-Gm-Message-State: APjAAAWk55cC2AbjoyQ/xKp5wGTi/cL5xfqlKuNhK//j4u6cnkAlsLDM qVXyfrAMqnobOkLO77F55S7lj3h/6VOJl+FFbm61fA== X-Received: by 2002:a62:37c7:: with SMTP id e190mr53845033pfa.165.1582579341630; Mon, 24 Feb 2020 13:22:21 -0800 (PST) MIME-Version: 1.0 References: <20200222235709.GA3786197@rani.riverdale.lan> <20200223193715.83729-2-nivedita@alum.mit.edu> <20200224210522.GA409112@rani.riverdale.lan> <20200224211209.3snqf7atf5h4ywcr@google.com> In-Reply-To: From: Nick Desaulniers Date: Mon, 24 Feb 2020 13:22:10 -0800 Message-ID: Subject: Re: [PATCH 1/2] arch/x86: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections To: Fangrui Song Cc: Arvind Sankar , 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 , Kees Cook , Ard Biesheuvel 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 Mon, Feb 24, 2020 at 1:17 PM Nick Desaulniers wrote: > > On Mon, Feb 24, 2020 at 1:12 PM Fangrui Song wrote: > > > > On 2020-02-24, Arvind Sankar wrote: > > >On Mon, Feb 24, 2020 at 12:33:49PM -0800, Nick Desaulniers wrote: > > >> 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 > > > > > >Hm I don't see any change in .text size. > > >> > 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 > > > > > >It is intentional -- the other case is that we're building for ARM, > > >which only filters out the regular KBUILD_CFLAGS, so adding the flag for > > >it should not be necessary. The cflags for ARM are constructed by > > >manipulating KBUILD_CFLAGS. Besides it may or may not want unwind > > >tables. 32-bit ARM appears to have an option to enable -funwind-tables. > > Ah, right the `subst` from `KBUILD_CFLAGS`. > Are there other architectures that care about EFI beyond x86 and ARM? IA64? Looks like while IA64 supports CONFIG_EFI, it doesn't support CONFIG_EFI_STUB, which controls whether drivers/firmware/efi/libstub/ gets built or not. So that patch should be good to go. Reviewed-by: Nick Desaulniers > > > > > clang (as of today) has not implemented the > > -funwind-tables/-fasynchronous-unwind-tables distinction as GCC does.. > > (probably because not many people care..) > > Ah, thanks for the clarification. > > > > > >> > > >> $ 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) > > >> > > > > > >You mean before this patch, right? I see hits on every .o file in there > > >(compiling with gcc 9.2.0). > > > > > >> > > > >> > # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly > > >> > # disable the stackleak plugin > > >> > -- > > >> > 2.24.1 > > >> > > > > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers