From patchwork Thu Nov 2 21:46:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 10039337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C8CE76032D for ; Thu, 2 Nov 2017 21:46:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B018728A98 for ; Thu, 2 Nov 2017 21:46:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2FEF2928C; Thu, 2 Nov 2017 21:46:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF69B28A98 for ; Thu, 2 Nov 2017 21:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:Message-ID: In-Reply-To:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y1DFmQgasrqoQq9cDs2JQzSE8RUitHFJmqBIRcBEXmI=; b=j3bHed1CTv3RWJ 8TtdBrnh56DYEveUpMmh3YrWGRrGmXFuqWzHXZtLXOYOBChHStMTLaONIaBX0ydRtuacHKW8L1yQ9 YK+20dt7k8dLfjoE91Wibux6WTH28JhX3J0AzzwV2qHuTOeReVqm6ZyGbq3R3KUs5M89gaV/9yRLg mQ1iBteVYV0kzNuxud/5DoMdjw/5G8ScrlbJaGoW/xYAsOndmrJ7KJj4m5C4uXkMuLlMEAL62aDyN /pXUXZAvq2dsgZUxr3cIn+ocLJj6MgSM7bAQF3cohoNSag+Sad6i3uoanXvokwO5i4WfwOeP1j/Og DM738SiVpKc5l0LxORCw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eANK9-0001lP-Jz; Thu, 02 Nov 2017 21:46:53 +0000 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eANK4-0001Yn-OD for linux-arm-kernel@lists.infradead.org; Thu, 02 Nov 2017 21:46:51 +0000 Received: by mail-qt0-x242.google.com with SMTP id 8so1168970qtv.1 for ; Thu, 02 Nov 2017 14:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=2Xh1k9On1cvEpij+k0pVp1S6swKiGmb9/kNba+x+/4Y=; b=Phgd2vKOSoE5UJfvqyz2vj7wM+V2pqumyfPbT1iR/ey78miX5FaD0Fjh7lm8AUAfvo R3gKxoszCSGLc44yuG4gEj4e9LOXOXU6kMmT2IayrNy0pDCpY6xq0SgXEIiJiVwE9mhN ExV02ia59+How+QZKKiDk0UCsYnQsyaBauTp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=2Xh1k9On1cvEpij+k0pVp1S6swKiGmb9/kNba+x+/4Y=; b=K1hcSmzQyHS/nqgoN7ka8Oj16nWWNJtEGS8EJ5TugtrH0f/rP0V/eGZHKQmVyGr63N NGAkGhBnJkULbYfBUqKoFtE4EAiiyBZFkCs+9VZYIFz+z/GmgMdAkPjTN0gj5OWArq6v iZlbbQhi1Uw2pwH4BS9iZvQMT+YPOHRHes4UvC+8k0nMYLo9JhhC/TZTCZotTHHFG4M7 2Y7UY0sESmrVP4ybCHV6UULk5z/XSXAVXi/mUyxWq0dNJazJzYEQXzVQJecjSUSSjrha NPYETq9xrBDjm47qPMUihhbk6BuzCTleKyDz4rBUmcMqjjkH7kEquIbqGLOl+FBDUwbp 0qiA== X-Gm-Message-State: AMCzsaUGfSzY9awaWlrMmn08JQjjdMejrgeags8YA8stBPrbNRF2AfIo iArgUiFzp1tIFEeSp2Y1o1AtYg== X-Google-Smtp-Source: ABhQp+Q/eLkJmuKbE8QeodYt4NEPwGgWm7uJTp2XBcL3PsjqL5CF8DOIZvY3DQkJDXIaMFwH/FEGoA== X-Received: by 10.200.50.144 with SMTP id z16mr7338795qta.306.1509659186614; Thu, 02 Nov 2017 14:46:26 -0700 (PDT) Received: from xanadu.home (modemcable045.234-175-137.mc.videotron.ca. [137.175.234.45]) by smtp.gmail.com with ESMTPSA id p41sm3022961qkp.94.2017.11.02.14.46.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 14:46:26 -0700 (PDT) Date: Thu, 2 Nov 2017 17:46:25 -0400 (EDT) From: Nicolas Pitre To: Russell King - ARM Linux , Robin Murphy Subject: syntax unified, was Re: [PATCH 3/3] ARM: early_printk: use printascii() rather than printch() In-Reply-To: Message-ID: References: <20171102000945.GT9463@n2100.armlinux.org.uk> <20171102112041.GW9463@n2100.armlinux.org.uk> <20171102171018.GH9463@n2100.armlinux.org.uk> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171102_144648_989722_FEBB0116 X-CRM114-Status: GOOD ( 19.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Brandt , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 2 Nov 2017, Robin Murphy wrote: > On 02/11/17 17:10, Russell King - ARM Linux wrote: > > There is another solution to this: I augment the patch system with an > > ARM assembly parser that detects this before it gets accepted, > > rejecting patches that omit the # for constants. However, that is > > incomplete, because we now live in a world where ARM assembly gets > > added to the kernel via many different git trees. > > Or we could just enable unified syntax by default. AFAICT, binutils has > supported UAL for over 12 years now, and the minimal supported version > of 2.20 quoted in Documentation/process/ is considerably more recent > than that. You have a point here. So let's see in details... Documentation/process/changes.rst sais: |Upgrade to at **least** these software revisions before thinking you've |encountered a bug! If you're unsure what version you're currently |running, the suggested command should tell you. [...] |GNU C 3.2 gcc --version |GNU make 3.81 make --version |binutils 2.20 ld -v [...] On ARM we enforce these additional restrictions in arch/arm/kernel/asm-offsets.c: |/* | * GCC 3.0, 3.1: general bad code generation. | * GCC 3.2.0: incorrect function argument offset calculation. | * GCC 3.2.x: miscompiles NEW_AUX_ENT in fs/binfmt_elf.c | * (http://gcc.gnu.org/PR8896) and incorrect structure | * initialisation in fs/jffs2/erase.c | * GCC 4.8.0-4.8.2: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854 | * miscompiles find_get_entry(), and can result in EXT3 and EXT4 | * filesystem corruption (possibly other FS too). | */ |#ifdef __GNUC__ |#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3) |#error Your compiler is too buggy; it is known to miscompile kernels. |#error Known good compilers: 3.3, 4.x |#endif [...] It should be quite safe to assume that any gcc-3.3 installations came with at least binutils-2.20. So let's try that out: binutils-2.20.1]$ ./gas/as-new --version GNU assembler (GNU Binutils) 2.20.1.20100303 [...] binutils-2.20.1]$ echo "mov r0, '\r'" | ./gas/as-new - -o /tmp/t.o {standard input}: Assembler messages: {standard input}:1: Error: immediate expression requires a # prefix -- `mov r0,13' binutils-2.20.1]$ echo ".syntax unified; mov r0, '\r'" | ./gas/as-new - -o /tmp/t.o (nothing) binutils-2.20.1]$ ./binutils/objdump -d /tmp/t.o /tmp/t.o: file format elf32-littlearm Disassembly of section .text: 00000000 <.text>: 0: e3a0000d mov r0, #13 Digging into the binutils git repository, it looks like the unified syntax was indeed supported in 2005. Therefore every setup capable of compiling the latest linux kernel for ARM should be ".syntax unified" ready as Robin said. So... I think the best thing to do at this point is to enable the unified syntax unconditionally as suggested. This even has the side effect of removing a bunch of macros that cause trouble with LTO builds. I propose the following patch: diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7888c9803e..de1dd6e9cf 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1531,12 +1531,10 @@ config THUMB2_KERNEL bool "Compile the kernel in Thumb-2 mode" if !CPU_THUMBONLY depends on (CPU_V7 || CPU_V7M) && !CPU_V6 && !CPU_V6K default y if CPU_THUMBONLY - select ARM_ASM_UNIFIED select ARM_UNWIND help By enabling this option, the kernel will be compiled in - Thumb-2 mode. A compiler/assembler that understand the unified - ARM-Thumb syntax is needed. + Thumb-2 mode. If unsure, say N. @@ -1571,9 +1569,6 @@ config THUMB2_AVOID_R_ARM_THM_JUMP11 Unless you are sure your tools don't have this problem, say Y. -config ARM_ASM_UNIFIED - bool - config ARM_PATCH_IDIV bool "Runtime patch udiv/sdiv instructions into __aeabi_{u}idiv()" depends on CPU_32v7 && !XIP_KERNEL diff --git a/arch/arm/include/asm/unified.h b/arch/arm/include/asm/unified.h index a91ae49961..2c3b952be6 100644 --- a/arch/arm/include/asm/unified.h +++ b/arch/arm/include/asm/unified.h @@ -20,8 +20,10 @@ #ifndef __ASM_UNIFIED_H #define __ASM_UNIFIED_H -#if defined(__ASSEMBLY__) && defined(CONFIG_ARM_ASM_UNIFIED) +#if defined(__ASSEMBLY__) .syntax unified +#else +__asm__(".syntax unified"); #endif #ifdef CONFIG_CPU_V7M @@ -64,77 +66,4 @@ #endif /* CONFIG_THUMB2_KERNEL */ -#ifndef CONFIG_ARM_ASM_UNIFIED - -/* - * If the unified assembly syntax isn't used (in ARM mode), these - * macros expand to an empty string - */ -#ifdef __ASSEMBLY__ - .macro it, cond - .endm - .macro itt, cond - .endm - .macro ite, cond - .endm - .macro ittt, cond - .endm - .macro itte, cond - .endm - .macro itet, cond - .endm - .macro itee, cond - .endm - .macro itttt, cond - .endm - .macro ittte, cond - .endm - .macro ittet, cond - .endm - .macro ittee, cond - .endm - .macro itett, cond - .endm - .macro itete, cond - .endm - .macro iteet, cond - .endm - .macro iteee, cond - .endm -#else /* !__ASSEMBLY__ */ -__asm__( -" .macro it, cond\n" -" .endm\n" -" .macro itt, cond\n" -" .endm\n" -" .macro ite, cond\n" -" .endm\n" -" .macro ittt, cond\n" -" .endm\n" -" .macro itte, cond\n" -" .endm\n" -" .macro itet, cond\n" -" .endm\n" -" .macro itee, cond\n" -" .endm\n" -" .macro itttt, cond\n" -" .endm\n" -" .macro ittte, cond\n" -" .endm\n" -" .macro ittet, cond\n" -" .endm\n" -" .macro ittee, cond\n" -" .endm\n" -" .macro itett, cond\n" -" .endm\n" -" .macro itete, cond\n" -" .endm\n" -" .macro iteet, cond\n" -" .endm\n" -" .macro iteee, cond\n" -" .endm\n"); -#endif /* __ASSEMBLY__ */ - -#endif /* CONFIG_ARM_ASM_UNIFIED */ - #endif /* !__ASM_UNIFIED_H */