Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4836174ybp; Mon, 7 Oct 2019 14:55:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2TMmhshEYKIaqtjD+4fwJBGrMA/7L/s3g+DiDFwTMR73COHyuofoN85WtiitSEP0ZGIwx X-Received: by 2002:a17:906:3746:: with SMTP id e6mr24979364ejc.238.1570485310280; Mon, 07 Oct 2019 14:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485310; cv=none; d=google.com; s=arc-20160816; b=GKbJnEIWY8Wn+/zrUn6xiMS8hoFwchbF4NzGTk4Qt+rGIfuHaLKcusK6oeKQVj03pv PHl5iDG7FB7TpIPhXaxHxGBJL4E926ccUCLtyNWUyM8Tgv0Fe8yfPxUbCbmYnnH83gjp UYnNeYg6M6tDmoG/i4vw1vhlleSyZtpUgPXvlgn2pthC05xcHFsYzNcHKTwMJr1WZhIF HbKXJTiJcWwqZ18rpDz+EKW6vSCkY8OSyvKpyGnXBdMWK0rCLeb17siwsOoSCUzUjePz L0Mb6JUrujIiHL/jYGovLPwnSzHX3GdHtY+H87DQRpElqTajcEBvymCBM3xG6P2HYCAJ V51w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=Yj0XbGw7Bq6WSvRBmShSEs1vB7x0y/JZH0AJjB3HNM4=; b=YlQf/BcYWgvEkspC4+GXGUJDT0zXdiUz6zlTDZq7DYvPKC70l0hUhaFREuGLcLSEb+ Ba5TYYtCiSIbPgDP5wvs2c4lVFqR3AC0eEXyx1B184EaJ+vygHchj7h4IScaYhk6ty98 lSTysz51DvrYR0EvE2VMFnh66vfAhfQQaAWWYl9p+zHKJ/BDqHe5NiFPzg1UHnQk4KUM 7wp51Yp0bGWO6MVg/iOQkTINWgqsN9TMbq9JZuvbwi/+rQzxOx1fiEcEYp1VPjEh11Rl xOWp3WvH45oHzbBndxMMobTR3p6gU6z7Ahv4IyK6YfkrnuITUGboyjSJqouMznAZV/Xu OaNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SUSSXO9K; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si6707784ejc.432.2019.10.07.14.54.47; Mon, 07 Oct 2019 14:55:10 -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=fail header.i=@gmail.com header.s=20161025 header.b=SUSSXO9K; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729415AbfJGVwR (ORCPT + 99 others); Mon, 7 Oct 2019 17:52:17 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44079 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728422AbfJGVwR (ORCPT ); Mon, 7 Oct 2019 17:52:17 -0400 Received: by mail-qk1-f195.google.com with SMTP id u22so14212776qkk.11 for ; Mon, 07 Oct 2019 14:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Yj0XbGw7Bq6WSvRBmShSEs1vB7x0y/JZH0AJjB3HNM4=; b=SUSSXO9Kbm7ScAYZMq+gQtLASIjyXgtc+v9aX0vYvOfWSQvAF3eCa05cuUv9HJZow7 QgyNZor+gjGJan36835UwAiizPKqi4JCqwPiIQSmiyN4u+vZSfyRAvbl5VPnx6FcPBUE eTzfB78WiaT6oUn8dzMsOVZUWsrafdThSGh0DrJl28fgnoR3RVoXVtpdePE6rUhpGBZQ qROfKMDGTo707VFSu+4wbB1LtrsbFFQv1XKVc2taups4e2IE1LyhxUE//7/B7pkvcSMG CdBPTXRqjuG0FAC1yvjVIofRT4AqdHtVsiXFCcd/olcPjA4uUSnD2+pc2F+/iNH01KyF N10g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Yj0XbGw7Bq6WSvRBmShSEs1vB7x0y/JZH0AJjB3HNM4=; b=HAGQrbnsvQRW1wCNeXXBkvTJuJwsPUQaOiXYED5f1fet7RX11PmL/bo6E7VltIwH9c zB3O3637lh5+Q1VkiZsNCCoWFJRhvs9S4qKDVXDMCEi+QBCRELREH+7Dm7j6lWm5/JBe Gw+KUuPJddSKuUQYtDIE3wA0HazcGpSMLDGeyxj8VGBFaBgvkbAxx7szv5IudxCcso/H Pl6FYjLvUDX+JZFRq1eBkXJgzFb9af1ZZzgT+Q6bkXNNSoCX2DwswZKz1DF0p5yw0snj qGS34pUkKy2fnZSWRI/YEREGMqrcBOfQf7pysdV7IBszj4T/qWEcQesn/9xV9UNvkXbm eOnw== X-Gm-Message-State: APjAAAW2e+Y00J+cagLrssK09DwN7C4hZh6pdWLgfUTg7o2JhwhO447B 3U/MUHcsV6jreaeUuer8LJ8= X-Received: by 2002:a05:620a:15db:: with SMTP id o27mr3876369qkm.368.1570485135906; Mon, 07 Oct 2019 14:52:15 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id c18sm7012800qkk.17.2019.10.07.14.52.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:52:15 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Mon, 7 Oct 2019 17:52:13 -0400 To: Hans de Goede Cc: Nathan Chancellor , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Arvind Sankar , x86@kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] x86/purgatory: Make sure we fail the build if purgatory.ro has missing symbols Message-ID: <20191007215213.GA405660@rani.riverdale.lan> References: <20191007175546.3395-1-hdegoede@redhat.com> <20191007200529.GA716619@archlinux-threadripper> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 07, 2019 at 10:31:49PM +0200, Hans de Goede wrote: > HI, > > On 07-10-2019 22:05, Nathan Chancellor wrote: > > On Mon, Oct 07, 2019 at 07:55:46PM +0200, Hans de Goede wrote: > >> Since we link purgatory.ro with -r aka we enable "incremental linking" > >> no checks for unresolved symbols is done while linking purgatory.ro. > >> > >> Changes to the sha256 code has caused the purgatory in 5.4-rc1 to have > >> a missing symbol on memzero_explicit, yet things still happily build. > >> > >> This commit adds an extra check for unresolved symbols by calling ld > >> without -r before running bin2c to generate kexec-purgatory.c. > >> > >> This causes a build of 5.4-rc1 with this patch added to fail as it should: > >> > >> CHK arch/x86/purgatory/purgatory.ro > >> ld: arch/x86/purgatory/purgatory.ro: in function `sha256_transform': > >> sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit' > >> make[2]: *** [arch/x86/purgatory/Makefile:72: > >> arch/x86/purgatory/kexec-purgatory.c] Error 1 > >> make[1]: *** [scripts/Makefile.build:509: arch/x86/purgatory] Error 2 > >> make: *** [Makefile:1650: arch/x86] Error 2 > >> > >> This will help us catch missing symbols in the purgatory sooner. > >> > >> Note this commit also removes --no-undefined from LDFLAGS_purgatory.ro > >> as that has no effect. > >> > >> Signed-off-by: Hans de Goede > >> --- > >> arch/x86/purgatory/Makefile | 8 +++++++- > >> 1 file changed, 7 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile > >> index fb4ee5444379..0da0794ef1f0 100644 > >> --- a/arch/x86/purgatory/Makefile > >> +++ b/arch/x86/purgatory/Makefile > >> @@ -14,7 +14,7 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE > >> > >> CFLAGS_sha256.o := -D__DISABLE_EXPORTS > >> > >> -LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib > >> +LDFLAGS_purgatory.ro := -e purgatory_start -r -nostdlib -z nodefaultlib > >> targets += purgatory.ro > >> > >> KASAN_SANITIZE := n > >> @@ -60,10 +60,16 @@ $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE > >> > >> targets += kexec-purgatory.c > >> > >> +# Since we link purgatory.ro with -r unresolved symbols are not checked, > >> +# so we check this before generating kexec-purgatory.c instead > >> +quiet_cmd_check_purgatory = CHK $< > >> + cmd_check_purgatory = ld -e purgatory_start $< > > > > I think this should be $(LD) -e ... so that using a cross compile prefix > > (like x86_64-linux-) or an alternative linker like ld.lld works properly. > > Good point, also the ld command is actually outputting an a.out file > which is also something which we do not want. > > I will prepare a new version fixing both. > > Regards, > > Hans We could just use $(NM) -u, right?