Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3547089pxb; Mon, 16 Nov 2020 18:41:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyf2HWgWNCtRqIQeY2tNBfaXTs1m19sf1DIXy3T9X2R9YnJK5VFeSbwJiQWamNcCzRZ5h0W X-Received: by 2002:a05:6402:b28:: with SMTP id bo8mr19505396edb.57.1605580911620; Mon, 16 Nov 2020 18:41:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605580911; cv=none; d=google.com; s=arc-20160816; b=pT4NsizNoEQxXzAxeCr1vkNz0PCYHC99AzAXt9HTTHxXEzCXpRlPFxvnnv+4v3BIco oHWyR92zB1YMf3jnRQ5B6wDABgPNiptSqO/vFssZUGCIXyXXW46+zOs7edP6fGTz/8jl ZwBPn62L32h9PQXBCVxejhigIBXsjH6XXxaxZ1ZcsRp4+3HSBrkKzrYAFjyWjiGMElmd lJSTMPHOSpMF0JGJH9JlbcFNvHM2gt3e6K2J5qGqU1clRCkHdmyJmgdImplJvXqO0sXG 1+n6s5A6M9hgkS3ZzCYe0BDeUJAzHQalhPNA/YIXkyDnX4jmNW/Aa+h5FYqcFvGM+ktB iiAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=cUwDNYk9lrKRqwceLJkP3XcP/q8L/2Z1kszygFqoP/s=; b=wPy6paiG6Uoc0nvMQxAO9LjGVHx9Gb7rx0V+UQyuT8O8LUQ/VDcFLsOA7Iaf1eflg5 ebD21Arj3h0r3qQnvCMNNZ3NFS9QFV5yLZ1/X2n0kLXzhZnD7y2+XrmwaaPc0aFMesNH tdWzB+VDzRnYsEnTxQ7Pq1RgqEFh2IWWgc2I5kzg2CQFRciahbUSiCF4K6+NzRK3Qw85 wAjloHerfnM+2rgR+XCXGkCr2IN/GoPJ5g4xsuy4/VIDXmMqT7cyrzjbqn55QLpX2k9Q z2LnZPN3rPA2NIKUJyXx7gCoQ/ksx1SBkK1BBfvz68oOnOiaEplOoqOxJPuBPb+pssSw 5OdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AsiNCDIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id d18si13390001edx.345.2020.11.16.18.41.28; Mon, 16 Nov 2020 18:41:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AsiNCDIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730552AbgKQAha (ORCPT + 99 others); Mon, 16 Nov 2020 19:37:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgKQAh3 (ORCPT ); Mon, 16 Nov 2020 19:37:29 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D543DC0613CF for ; Mon, 16 Nov 2020 16:37:27 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id z130so12834507pgz.19 for ; Mon, 16 Nov 2020 16:37:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:cc; bh=cUwDNYk9lrKRqwceLJkP3XcP/q8L/2Z1kszygFqoP/s=; b=AsiNCDIr9bl8emtZqAWSCHJdcFwB0X83Mn0+L8clxjlY3a+s2HZw6BGz4YZC/6fere TE5g1Lh6BlD2AlLjMPskQnspETRr8TcbxHP8CU/NxPyJD5QVBdEQUps0R7cQ4OPE4Yhw Rg95Er8uEVFre5jGvKg15j4LVoPFUEhOi8KjVK01MSek92NTaQox9j9/5mXLS9tEE45A eYpSwQ1SoSZLnPL+WmwB/VQe8vKzS+n/CXqPmkQFF7v+LddEykk1yHofLpaJPdPtGgsn 1aY0xFx5LqjtiwzjQfKveT9jv6007PLN5OFbMybpvAh7qpNo+dYJXCB41xi7jID8/nCi 68YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:cc; bh=cUwDNYk9lrKRqwceLJkP3XcP/q8L/2Z1kszygFqoP/s=; b=nQOtbUgpzGYReEpy4LHgDewIHp0C+mgk92KedzshM5cy3+K2bMG3sLjVxHwIDZTSqg TmuYKkXC8VePUzGrH692wmktkikJeKeX+HLZrhlpWRW2yTo/prvvpm9g88GjaVN6i/eP /gxEbHqbmpI57ZpL7fPlsmog89J7S6seYuMUE+cUYc2K3eENc2fkFmpTEgfngt5ItwBH FUYFmGf2nmJt1qJVekeoVhr2sl/0i4rPJ2Soc8jLACEqSmpGGY9dLTdfhOO8B02/usW6 65NtaUvqF6P/zK99ZYa1Q70/8aXhTc4zGFh+y/k73agovGAiU+GAKCk6nJv4y00I+uWn 8SVQ== X-Gm-Message-State: AOAM530zCJce+haYNnmWuGrgMKuVbKl5mN7/uoDBvvRNbtqWLFQKF2O9 D7oXasRQ/wofS1/gjePPLFQuz9UgQeRj Sender: "jiancai via sendgmr" X-Received: from jiancai.svl.corp.google.com ([2620:15c:2ce:0:f693:9fff:fef4:238b]) (user=jiancai job=sendgmr) by 2002:aa7:8c4f:0:b029:18b:f361:4aa3 with SMTP id e15-20020aa78c4f0000b029018bf3614aa3mr16501083pfd.73.1605573447322; Mon, 16 Nov 2020 16:37:27 -0800 (PST) Date: Mon, 16 Nov 2020 16:37:21 -0800 In-Reply-To: <20201112200718.2747316-1-jiancai@google.com> Message-Id: <20201117003724.2381423-1-jiancai@google.com> Mime-Version: 1.0 References: <20201112200718.2747316-1-jiancai@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH v4] Make iwmmxt.S support Clang's integrated assembler From: Jian Cai Cc: ndesaulniers@google.com, ardb@kernel.org, manojgupta@google.com, llozano@google.com, clang-built-linux@googlegroups.com, Jian Cai , Russell King , Nathan Chancellor , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch replaces 6 IWMMXT instructions Clang's integrated assembler does not support in iwmmxt.S using macros, while making sure GNU assembler still emit the same instructions. This should be easier than providing full IWMMXT support in Clang. This is one of the last bits of kernel code that could be compiled but not assembled with clang. Once all of it works with IAS, we no longer need to special-case 32-bit Arm in Kbuild, or turn off CONFIG_IWMMXT when build-testing. "Intel Wireless MMX Technology - Developer Guide - August, 2002" should be referenced for the encoding schemes of these extensions. Link: https://github.com/ClangBuiltLinux/linux/issues/975 Suggested-by: Nick Desaulniers Suggested-by: Ard Biesheuvel Acked-by: Ard Biesheuvel Signed-off-by: Jian Cai --- Changes v3 -> v4: Forgot to include iwmmxt.h in v3. arch/arm/kernel/iwmmxt.S | 89 ++++++++++++++++++++-------------------- arch/arm/kernel/iwmmxt.h | 47 +++++++++++++++++++++ 2 files changed, 92 insertions(+), 44 deletions(-) create mode 100644 arch/arm/kernel/iwmmxt.h diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S index 0dcae787b004..d2b4ac06e4ed 100644 --- a/arch/arm/kernel/iwmmxt.S +++ b/arch/arm/kernel/iwmmxt.S @@ -16,6 +16,7 @@ #include #include #include +#include "iwmmxt.h" #if defined(CONFIG_CPU_PJ4) || defined(CONFIG_CPU_PJ4B) #define PJ4(code...) code @@ -113,33 +114,33 @@ concan_save: concan_dump: - wstrw wCSSF, [r1, #MMX_WCSSF] - wstrw wCASF, [r1, #MMX_WCASF] - wstrw wCGR0, [r1, #MMX_WCGR0] - wstrw wCGR1, [r1, #MMX_WCGR1] - wstrw wCGR2, [r1, #MMX_WCGR2] - wstrw wCGR3, [r1, #MMX_WCGR3] + wstrw wCSSF, r1, MMX_WCSSF + wstrw wCASF, r1, MMX_WCASF + wstrw wCGR0, r1, MMX_WCGR0 + wstrw wCGR1, r1, MMX_WCGR1 + wstrw wCGR2, r1, MMX_WCGR2 + wstrw wCGR3, r1, MMX_WCGR3 1: @ MUP? wRn tst r2, #0x2 beq 2f - wstrd wR0, [r1, #MMX_WR0] - wstrd wR1, [r1, #MMX_WR1] - wstrd wR2, [r1, #MMX_WR2] - wstrd wR3, [r1, #MMX_WR3] - wstrd wR4, [r1, #MMX_WR4] - wstrd wR5, [r1, #MMX_WR5] - wstrd wR6, [r1, #MMX_WR6] - wstrd wR7, [r1, #MMX_WR7] - wstrd wR8, [r1, #MMX_WR8] - wstrd wR9, [r1, #MMX_WR9] - wstrd wR10, [r1, #MMX_WR10] - wstrd wR11, [r1, #MMX_WR11] - wstrd wR12, [r1, #MMX_WR12] - wstrd wR13, [r1, #MMX_WR13] - wstrd wR14, [r1, #MMX_WR14] - wstrd wR15, [r1, #MMX_WR15] + wstrd wR0, r1, MMX_WR0 + wstrd wR1, r1, MMX_WR1 + wstrd wR2, r1, MMX_WR2 + wstrd wR3, r1, MMX_WR3 + wstrd wR4, r1, MMX_WR4 + wstrd wR5, r1, MMX_WR5 + wstrd wR6, r1, MMX_WR6 + wstrd wR7, r1, MMX_WR7 + wstrd wR8, r1, MMX_WR8 + wstrd wR9, r1, MMX_WR9 + wstrd wR10, r1, MMX_WR10 + wstrd wR11, r1, MMX_WR11 + wstrd wR12, r1, MMX_WR12 + wstrd wR13, r1, MMX_WR13 + wstrd wR14, r1, MMX_WR14 + wstrd wR15, r1, MMX_WR15 2: teq r0, #0 @ anything to load? reteq lr @ if not, return @@ -147,30 +148,30 @@ concan_dump: concan_load: @ Load wRn - wldrd wR0, [r0, #MMX_WR0] - wldrd wR1, [r0, #MMX_WR1] - wldrd wR2, [r0, #MMX_WR2] - wldrd wR3, [r0, #MMX_WR3] - wldrd wR4, [r0, #MMX_WR4] - wldrd wR5, [r0, #MMX_WR5] - wldrd wR6, [r0, #MMX_WR6] - wldrd wR7, [r0, #MMX_WR7] - wldrd wR8, [r0, #MMX_WR8] - wldrd wR9, [r0, #MMX_WR9] - wldrd wR10, [r0, #MMX_WR10] - wldrd wR11, [r0, #MMX_WR11] - wldrd wR12, [r0, #MMX_WR12] - wldrd wR13, [r0, #MMX_WR13] - wldrd wR14, [r0, #MMX_WR14] - wldrd wR15, [r0, #MMX_WR15] + wldrd wR0, r0, MMX_WR0 + wldrd wR1, r0, MMX_WR1 + wldrd wR2, r0, MMX_WR2 + wldrd wR3, r0, MMX_WR3 + wldrd wR4, r0, MMX_WR4 + wldrd wR5, r0, MMX_WR5 + wldrd wR6, r0, MMX_WR6 + wldrd wR7, r0, MMX_WR7 + wldrd wR8, r0, MMX_WR8 + wldrd wR9, r0, MMX_WR9 + wldrd wR10, r0, MMX_WR10 + wldrd wR11, r0, MMX_WR11 + wldrd wR12, r0, MMX_WR12 + wldrd wR13, r0, MMX_WR13 + wldrd wR14, r0, MMX_WR14 + wldrd wR15, r0, MMX_WR15 @ Load wCx - wldrw wCSSF, [r0, #MMX_WCSSF] - wldrw wCASF, [r0, #MMX_WCASF] - wldrw wCGR0, [r0, #MMX_WCGR0] - wldrw wCGR1, [r0, #MMX_WCGR1] - wldrw wCGR2, [r0, #MMX_WCGR2] - wldrw wCGR3, [r0, #MMX_WCGR3] + wldrw wCSSF, r0, MMX_WCSSF + wldrw wCASF, r0, MMX_WCASF + wldrw wCGR0, r0, MMX_WCGR0 + wldrw wCGR1, r0, MMX_WCGR1 + wldrw wCGR2, r0, MMX_WCGR2 + wldrw wCGR3, r0, MMX_WCGR3 @ clear CUP/MUP (only if r1 != 0) teq r1, #0 diff --git a/arch/arm/kernel/iwmmxt.h b/arch/arm/kernel/iwmmxt.h new file mode 100644 index 000000000000..fb627286f5bb --- /dev/null +++ b/arch/arm/kernel/iwmmxt.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __IWMMXT_H__ +#define __IWMMXT_H__ + +.irp b, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 +.set .LwR\b, \b +.set .Lr\b, \b +.endr + +.set .LwCSSF, 0x2 +.set .LwCASF, 0x3 +.set .LwCGR0, 0x8 +.set .LwCGR1, 0x9 +.set .LwCGR2, 0xa +.set .LwCGR3, 0xb + +.macro wldrd, reg:req, base:req, offset:req +.inst 0xedd00100 | (.L\reg << 12) | (.L\base << 16) | (\offset >> 2) +.endm + +.macro wldrw, reg:req, base:req, offset:req +.inst 0xfd900100 | (.L\reg << 12) | (.L\base << 16) | (\offset >> 2) +.endm + +.macro wstrd, reg:req, base:req, offset:req +.inst 0xedc00100 | (.L\reg << 12) | (.L\base << 16) | (\offset >> 2) +.endm + +.macro wstrw, reg:req, base:req, offset:req +.inst 0xfd800100 | (.L\reg << 12) | (.L\base << 16) | (\offset >> 2) +.endm + +#ifdef __clang__ + +#define wCon c1 + +.macro tmrc, dest:req, control:req +mrc p1, 0, \dest, \control, c0, 0 +.endm + +.macro tmcr, control:req, src:req +mcr p1, 0, \src, \control, c0, 0 +.endm +#endif + +#endif -- 2.29.2.299.gdc1121823c-goog