Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2647272iof; Wed, 8 Jun 2022 09:08:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWxJqRggaPuB/k5KiDeCSSb0r8AHCPOv5siGR0+3GKcbMz2QQMNUE4WkCJ7S6yfqCT9Gt0 X-Received: by 2002:a65:4809:0:b0:3fc:878:49df with SMTP id h9-20020a654809000000b003fc087849dfmr30101610pgs.557.1654704521410; Wed, 08 Jun 2022 09:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654704521; cv=none; d=google.com; s=arc-20160816; b=RI2dilysPGlebx5TVU39tMQ5KieDNllIvY1biSptZG16WuNy1vDxIddVrMCR6R4Ji1 I6l1KYTTcc6rPEu42pE5pKzAfb3GvKUBH21XLhf1d50AGl5Xx/HwdKx+aVRPX4a+ezj4 JFdBSjqbivdlobCgHm4CS3jwnaQ6JJkJ6sjojMTgNZBujgSMsKcSCM4O1d/lh5w2Jmig p50avCkG9WrSGkcm9SgYO3OZK3Br48VUwFofoF50PtSYbiND77lVNfBO13ldPR6Se5ct JoS/30qzF5nkmF3FAvy5MCGqj2AvQ1tDQPFnr8t4E42kxX7QEc9zx0cLrE5BQ8ncXubc HRrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TylPGkSCNU+09Lgi9J882JQAiv5UywDsMfokUzIwV2k=; b=Y7ouK/Sm36bFaRZQZb6C8jtq3LipjeXVMBYTvPa4cqqa8YjSjmsXTXv27SNz+uJEm0 wJeFKa+XBda18mY9JmtsXoRfCl6G9ZKa2PuvVeXz/AKbj+buGTaqHvyYZE+yCtd3s0yy bm2+cWdgH6/5TEX8W+kpg6SgSDK9Ymyz3RdTxDOSpIlbdBjwsjHl2KHZjlAcQ/VhOIE3 D6xkQA70vba9RGQR6F6caKWBtGa4C9XNHcVFdYO1NWk3GqQ55uoRrm9uLDVV08C0sJ4k 1QD6mWJGzTxpzSB7PN1F40bH3DsqoVUzE4SPQMxv3geCv0g4OYa2C15Q532rOVX8827N 3AuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S5pzktxw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o8-20020a056a0015c800b0051c33bc0b65si8843279pfu.206.2022.06.08.09.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:08:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S5pzktxw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9995A1D684F; Wed, 8 Jun 2022 08:41:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244490AbiFHPkv (ORCPT + 99 others); Wed, 8 Jun 2022 11:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244495AbiFHPkr (ORCPT ); Wed, 8 Jun 2022 11:40:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 144921D4DCA for ; Wed, 8 Jun 2022 08:40:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A277661660 for ; Wed, 8 Jun 2022 15:40:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F52DC34116; Wed, 8 Jun 2022 15:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654702845; bh=GsWVqc7XzgmQHs4ZWCcfzxRQCgs9g36OS+NZTt7px0k=; h=From:To:Cc:Subject:Date:From; b=S5pzktxw6sdwCGR9T8aNjCxMkWwPC//aWub0AoSR980/v99s8J7jljm6QgqaIOYn9 K2bBXzI2fnQaiH+a8gswIjirpuYxYncGu2vHlvsMiFkFEfOqAp65U6qRuveaiS7V8o rfh9PmUmAksDUqW65UeRtvQbnZGUA6e+YTFLltrXmU2pYyiHFvlqxfo3PjP3rJi1dw gQL6Yd9hyg1GifzkepBmKwY/y9EiELm68g/7TErrmlxUguDl8GCjyHRo93RSFaOPU/ drZjcGWP6KQh4kahgn+PfaMHO3yY+6+YS35Ho1AADEjbh+PMw5uNgEvW29ZVEFEL1S 0u89WxZC/fU7A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Andrew Cooper , jiangshanlai@gmail.com, bp@suse.de, brgerst@gmail.com, Joe Damato Subject: [PATCH] x86/mm: Fix RESERVE_BRK() for older binutils Date: Wed, 8 Jun 2022 08:40:42 -0700 Message-Id: X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With binutils 2.26, RESERVE_BRK() causes a build failure: /tmp/ccnGOKZ5.s: Assembler messages: /tmp/ccnGOKZ5.s:98: Error: missing ')' /tmp/ccnGOKZ5.s:98: Error: missing ')' /tmp/ccnGOKZ5.s:98: Error: missing ')' /tmp/ccnGOKZ5.s:98: Error: junk at end of line, first unrecognized character is `U' The problem is this line: RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE) Specifically, the INIT_PGT_BUF_SIZE macro which (via PAGE_SIZE's use _AC()) has a "1UL", which makes older versions of the assembler unhappy. Unfortunately the _AC() macro doesn't work for inline asm. Fix it (and further simplify RESERVE_BRK) by taking a completely different approach. Instead of specifying the "nobits" at compile-time, do so at link-time. Then the variable can just be allocated in C. Note this changes the name of the variable from .brk.##name to __brk_##name. The variable names aren't actually used anywhere, so it's harmless. Reported-by: Joe Damato Fixes: a1e2c031ec39 ("x86/mm: Simplify RESERVE_BRK()") Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/setup.h | 35 +++++++++++++++++------------------ arch/x86/kernel/vmlinux.lds.S | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index 7590ac2570b9..ef9bb6caad8c 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h @@ -108,19 +108,11 @@ extern unsigned long _brk_end; void *extend_brk(size_t size, size_t align); /* - * Reserve space in the brk section. The name must be unique within the file, - * and somewhat descriptive. The size is in bytes. - * - * The allocation is done using inline asm (rather than using a section - * attribute on a normal variable) in order to allow the use of @nobits, so - * that it doesn't take up any space in the vmlinux file. + * Reserve space in the .brk section. The size is in bytes. */ -#define RESERVE_BRK(name, size) \ - asm(".pushsection .brk_reservation,\"aw\",@nobits\n\t" \ - ".brk." #name ":\n\t" \ - ".skip " __stringify(size) "\n\t" \ - ".size .brk." #name ", " __stringify(size) "\n\t" \ - ".popsection\n\t") +#define RESERVE_BRK(name, size) \ + __section(".brk_reservation") __aligned(1) __used \ + static char __brk_##name[size] extern void probe_roms(void); #ifdef __i386__ @@ -133,12 +125,19 @@ asmlinkage void __init x86_64_start_reservations(char *real_mode_data); #endif /* __i386__ */ #endif /* _SETUP */ -#else -#define RESERVE_BRK(name,sz) \ - .pushsection .brk_reservation,"aw",@nobits; \ -.brk.name: \ -1: .skip sz; \ - .size .brk.name,.-1b; \ + +#else /* __ASSEMBLY */ + +.macro __RESERVE_BRK name, size + .pushsection .brk_reservation, "aw" +SYM_DATA_START(__brk_\name) + .skip \size +SYM_DATA_END(__brk_\name) .popsection +.endm + +#define RESERVE_BRK(name, size) __RESERVE_BRK name, size + #endif /* __ASSEMBLY__ */ + #endif /* _ASM_X86_SETUP_H */ diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index f5f6dc2e8007..9b63f8a00b4f 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -385,7 +385,7 @@ SECTIONS __end_of_kernel_reserve = .; . = ALIGN(PAGE_SIZE); - .brk : AT(ADDR(.brk) - LOAD_OFFSET) { + .brk (NOLOAD) : AT(ADDR(.brk) - LOAD_OFFSET) { __brk_base = .; . += 64 * 1024; /* 64k alignment slop space */ *(.brk_reservation) /* areas brk users have reserved */ -- 2.34.3