From patchwork Sun Jun 25 09:56:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112539 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6827908vqr; Sun, 25 Jun 2023 03:03:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yHsyglTg09MiOugdGv4NcPrUWMNfl6FsoDbIwptQilmj2J5D371Z6BhNYHMjGA1FBXnaU X-Received: by 2002:a05:6808:614c:b0:3a0:3a17:a146 with SMTP id dl12-20020a056808614c00b003a03a17a146mr15160875oib.57.1687687404925; Sun, 25 Jun 2023 03:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687404; cv=none; d=google.com; s=arc-20160816; b=AOb8EU1A5Xewk/l1ZwWak/faIAUNHy1jrgsK9ZVbDVlTh00p3fnDnN0V84KRI2WrMC 64mRFFp0d9M0WOFEiDo6r5nF1UgeNxKQB7A9O4ykZapNL8YvY194Cwu+au4HrsXJLsvS rjmJ/3clVLz80xrptUmef2nscl/wYfJGsXavoLfLFNaor9oSZ6DGI/N9tv5Cs9rrWzxD hLAzyiZLq4Z/XAhhVXS2MFgCBVcc65DbvLRDEhdn3uPJjdAQV8r2aB+/EoAswb01w8qu aUPcya7UdzgiIA4Y+xzbzLCz4UZb8wJcS/hSZ29K6ELzn86hxd12ozONdpFA4LUInufo llNA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kFRo+kiT4MgRmDPPUMHK0nZcKxHLJF8GkcwJipyr5Cw=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=G0L3OVfVG9DH3Ui9NgXt9sG6kSGTm2TNvHm3oecqgl1fGxgacHDZq8x433bkLH5fKf 4dsfObOlOKHHDWkzEHMfkeD7YBn7NpeR2Xo73TraL+6Z3rqI8GRYUGI6vKmk6i/G0fNS B1mteEsOEydp9BlEhd0+ttDtIGxc99SWfhLbI4wP2YnEMCXiqq8l6rHu0f6TBfHtMIct MZonhN4JfBGQpEZs6BO3i5lITnwo1wq0mf0r3y7ezGcKut7m9pf55AL9aZOE5Impt6Xj 1juasa85ipxnljJQJPdLk3k8RQhmAwW4SNM8Wuc4NZ21Pzd8VM2Iwcg3qCNZWjB1xXZJ GxsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=qtdTPfBe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170902dad100b001ae6948b4a0si3108249plx.501.2023.06.25.03.03.11; Sun, 25 Jun 2023 03:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=qtdTPfBe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231375AbjFYJ5A (ORCPT + 99 others); Sun, 25 Jun 2023 05:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjFYJ46 (ORCPT ); Sun, 25 Jun 2023 05:56:58 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 950C9189; Sun, 25 Jun 2023 02:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687016; bh=UGMkiVgsD7TmU72TjAy44icKsVdzIhU52JRB8B10DPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qtdTPfBenqcOclDJxFgwaklagBTEt6IfXBrI3jZtiM8hvv2cXxN8l+W71y2/tzae8 A/Vzc2Fs/8C/4iXefzfUsLc2TBFNey8K3jZt0EH09+Q2vjA6SyHBv1eLticTEjHg6e Nn7tt+FN7On/I/nXjA7T4/1s0jlGxa/BRuQxdg+I= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id BC5CD6015B; Sun, 25 Jun 2023 17:56:55 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH v3 1/8] LoongArch: Calculate various sizes in the linker script Date: Sun, 25 Jun 2023 17:56:37 +0800 Message-Id: <20230625095644.3156349-2-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769668508047632635?= X-GMAIL-MSGID: =?utf-8?q?1769668508047632635?= From: WANG Rui Taking the address delta between symbols in different sections is not supported by the LLVM IAS. Instead, do this in the linker script, so the same data can be properly referenced in assembly. Signed-off-by: WANG Rui Signed-off-by: WANG Xuerui --- arch/loongarch/kernel/efi-header.S | 6 +++--- arch/loongarch/kernel/head.S | 8 ++++---- arch/loongarch/kernel/vmlinux.lds.S | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/arch/loongarch/kernel/efi-header.S b/arch/loongarch/kernel/efi-header.S index 8c1d229a2afa..5f23b85d78ca 100644 --- a/arch/loongarch/kernel/efi-header.S +++ b/arch/loongarch/kernel/efi-header.S @@ -24,7 +24,7 @@ .byte 0x02 /* MajorLinkerVersion */ .byte 0x14 /* MinorLinkerVersion */ .long __inittext_end - .Lefi_header_end /* SizeOfCode */ - .long _end - __initdata_begin /* SizeOfInitializedData */ + .long _kernel_vsize /* SizeOfInitializedData */ .long 0 /* SizeOfUninitializedData */ .long __efistub_efi_pe_entry - _head /* AddressOfEntryPoint */ .long .Lefi_header_end - _head /* BaseOfCode */ @@ -79,9 +79,9 @@ IMAGE_SCN_MEM_EXECUTE /* Characteristics */ .ascii ".data\0\0\0" - .long _end - __initdata_begin /* VirtualSize */ + .long _kernel_vsize /* VirtualSize */ .long __initdata_begin - _head /* VirtualAddress */ - .long _edata - __initdata_begin /* SizeOfRawData */ + .long _kernel_rsize /* SizeOfRawData */ .long __initdata_begin - _head /* PointerToRawData */ .long 0 /* PointerToRelocations */ diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index 0d8180153ec0..53b883db0786 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -23,7 +23,7 @@ _head: .word MZ_MAGIC /* "MZ", MS-DOS header */ .org 0x8 .dword kernel_entry /* Kernel entry point */ - .dword _end - _text /* Kernel image effective size */ + .dword _kernel_asize /* Kernel image effective size */ .quad PHYS_LINK_KADDR /* Kernel image load offset from start of RAM */ .org 0x38 /* 0x20 ~ 0x37 reserved */ .long LINUX_PE_MAGIC @@ -32,9 +32,9 @@ _head: pe_header: __EFI_PE_HEADER -SYM_DATA(kernel_asize, .long _end - _text); -SYM_DATA(kernel_fsize, .long _edata - _text); -SYM_DATA(kernel_offset, .long kernel_offset - _text); +SYM_DATA(kernel_asize, .long _kernel_asize); +SYM_DATA(kernel_fsize, .long _kernel_fsize); +SYM_DATA(kernel_offset, .long _kernel_offset); #endif diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S index 0c7b041be9d8..79f238df029e 100644 --- a/arch/loongarch/kernel/vmlinux.lds.S +++ b/arch/loongarch/kernel/vmlinux.lds.S @@ -136,6 +136,13 @@ SECTIONS DWARF_DEBUG ELF_DETAILS + /* header symbols */ + _kernel_asize = _end - _text; + _kernel_fsize = _edata - _text; + _kernel_offset = kernel_offset - _text; + _kernel_vsize = _end - __initdata_begin; + _kernel_rsize = _edata - __initdata_begin; + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) From patchwork Sun Jun 25 09:56:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112541 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6828237vqr; Sun, 25 Jun 2023 03:04:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7r1osAiASD59/tEcMwICDd2I8WC2YPOqzqmcYinsduKGQ+6lFGqVWx5Qv6Hka3huoWiX56 X-Received: by 2002:a17:90a:6f44:b0:25b:e747:103 with SMTP id d62-20020a17090a6f4400b0025be7470103mr20579332pjk.26.1687687451115; Sun, 25 Jun 2023 03:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687451; cv=none; d=google.com; s=arc-20160816; b=kIIM5dfd4YLynaSYg1eNabasOE8Fb52ybK5KvJD+QIEACYUtj+QgjPEPbm8vd2QWMw v/H3lgo87vsxKWN27PpRr2HZNUscCtoVrnCVfwPZzVNAwMF6bLbCpOC3unZ0wADFszXg 7o6S3uxJLa/zpV9KS8PcegpInK1WLDVwlbYlcTHYttnAo3oMpsZWN+KZhYfI/4w7BNT8 D2ugpZmT6DyRDYHW2rdHHuCtuLxSJtq5Ui/0s99vSoKo6l5mxs/zVtqWFdtfa7SeTljJ 6lgYl7QVOxFXQmZv7VZNif/2seGkDvxELe62glT5SMqBOSLz/mcN6wV6zThMDLNhJSCd F15A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pw/aO+zjIDQHPXZ7UrwBB2yvJLJSGY/XUQtK2SgNxyc=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=XjGB+q5rZ4Zki+cE62knWJvqX/uF2kX3eZ7Kmx3Lp5Me7RiBq71C+lGL66Q7CVug+5 KWX54w3Qn4YfiElAWOv/jb3UoJMHzgDG0rXkcSOXYOJ0n3a6ph/+SH1OwPAykcrOZK87 IrI8EB1a+pyrXst9cZpj7xMUlQ7wDBElwCbtJuCZOdaRlMd7nRx/76FV0F87ImZGHVrg IcslLzU5yoGv/C+DxK7cH2fp4eaMXXpkvfv73gHaj4j1T9yrj3bkHxMgN0bWrm8bCsOO CBibD/1SgX/l2vLIwzeJZYYBOOIVKRKIdWyaXQwymkNE11mYvvF1IpM2Q/mW2TQwhM/L YB8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=b91wTEqG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv192-20020a632ec9000000b005578c6a7641si2676625pgb.242.2023.06.25.03.03.58; Sun, 25 Jun 2023 03:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=b91wTEqG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231960AbjFYJ5F (ORCPT + 99 others); Sun, 25 Jun 2023 05:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbjFYJ5B (ORCPT ); Sun, 25 Jun 2023 05:57:01 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D835D189; Sun, 25 Jun 2023 02:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687019; bh=/Ae3yGesaN7INKQfcIHyYeenAVct9PlZ6PKdEfJO/pk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b91wTEqGbu5j4mfF648hJJyZjWCNM9Kb0SVrz+kgPalEJ+cfyepf9W9Ww/fCnkDa4 fj4FR96hbNqBSzyhlwsCFrnH/Kh65zNJV5nhb6PRM2UHFPaJN7hHQqJ00pkzDsWjtM HzBanSiVsTKH0px8SfmW50Ml6jZGoWqsZA3gSJR8= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 1AD5A600B5; Sun, 25 Jun 2023 17:56:59 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH v3 2/8] LoongArch: extable: Also recognize ABI names of registers Date: Sun, 25 Jun 2023 17:56:38 +0800 Message-Id: <20230625095644.3156349-3-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769668556401680701?= X-GMAIL-MSGID: =?utf-8?q?1769668556401680701?= From: WANG Rui When the kernel is compiled with LLVM, the register names being handled during exception fixup building are ABI names instead of bare $rNN style. Add mapping for the ABI names for LLVM compatibility. Signed-off-by: WANG Rui Signed-off-by: WANG Xuerui --- arch/loongarch/include/asm/gpr-num.h | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/loongarch/include/asm/gpr-num.h b/arch/loongarch/include/asm/gpr-num.h index e0941af20c7e..996038da806d 100644 --- a/arch/loongarch/include/asm/gpr-num.h +++ b/arch/loongarch/include/asm/gpr-num.h @@ -9,6 +9,22 @@ .equ .L__gpr_num_$r\num, \num .endr + /* ABI names of registers */ + .equ .L__gpr_num_$ra, 1 + .equ .L__gpr_num_$tp, 2 + .equ .L__gpr_num_$sp, 3 + .irp num,0,1,2,3,4,5,6,7 + .equ .L__gpr_num_$a\num, 4 + \num + .endr + .irp num,0,1,2,3,4,5,6,7,8 + .equ .L__gpr_num_$t\num, 12 + \num + .endr + .equ .L__gpr_num_$s9, 22 + .equ .L__gpr_num_$fp, 22 + .irp num,0,1,2,3,4,5,6,7,8 + .equ .L__gpr_num_$s\num, 23 + \num + .endr + #else /* __ASSEMBLY__ */ #define __DEFINE_ASM_GPR_NUMS \ @@ -16,6 +32,20 @@ " .irp num,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31\n" \ " .equ .L__gpr_num_$r\\num, \\num\n" \ " .endr\n" \ +" .equ .L__gpr_num_$ra, 1\n" \ +" .equ .L__gpr_num_$tp, 2\n" \ +" .equ .L__gpr_num_$sp, 3\n" \ +" .irp num,0,1,2,3,4,5,6,7\n" \ +" .equ .L__gpr_num_$a\\num, 4 + \\num\n" \ +" .endr\n" \ +" .irp num,0,1,2,3,4,5,6,7,8\n" \ +" .equ .L__gpr_num_$t\\num, 12 + \\num\n" \ +" .endr\n" \ +" .equ .L__gpr_num_$s9, 22\n" \ +" .equ .L__gpr_num_$fp, 22\n" \ +" .irp num,0,1,2,3,4,5,6,7,8\n" \ +" .equ .L__gpr_num_$s\\num, 23 + \\num\n" \ +" .endr\n" \ #endif /* __ASSEMBLY__ */ From patchwork Sun Jun 25 09:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6828967vqr; Sun, 25 Jun 2023 03:06:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67rJku/PJoMjv6ziubY4VA6KX8dudpBztedKdr9SbTchGfqoJ20ZKM1+dVEajnMqGVLUKL X-Received: by 2002:a17:902:bd86:b0:1b5:2fdf:5bd8 with SMTP id q6-20020a170902bd8600b001b52fdf5bd8mr4387445pls.8.1687687568101; Sun, 25 Jun 2023 03:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687568; cv=none; d=google.com; s=arc-20160816; b=UGUGTH+DeKkWrMzVA52dOfA7r2Bae1g4aF1TPP7XhGJSVhgcUwx1uPQyT7SB5gPoR+ w18+259kL7hIIcFdZ03apDviOnByh9vraQdXzGAMl/YQCOPCdQ2tdBNv8FMl50BMHxl9 Z72J2wbMPUrdm3CMii+6D8fSqG4oYrRhE8S27MxxuXWi8cqWxJfiCn121BPkLQsta3xp cfI1716tOmONrs26qi/HqWfsFG4iBranq1jLiHCFPCGdIYfE+lh4TAhCKLQvk4iTiT/7 yf59+m1iv7ey+SxHtucNr0PmsUqTOkZy0q4pxZk+Y7JJ2/1pEZvzTew+8wnGUFsvAA4K Yi3Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BNOa6KUqmUx9uB6fR2YZQjaDTT63knseKFi1dIqAvjM=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=EaaThAH+oe18RfOWbbvIIKHLKLgaRTo2e9WNpo9XGPbtpR1EG2zAG9NOSoHjL8Hxzv LSY9cwJBLt1mKnr0xGxKWxDyoL3pfKf6pfPIUDpQLYdLktnlI38PkymrNS5SjjJR7Acc U5WEYonICRy/iS7xuWa9SbOJeKD9tDGUAst+ubCzik+X6lTj3TnzgyekcPMlSyfFCyU8 T4wRIjV4xdb5xeKt2RufexcwEdd0IVqGDQ1N8qsples3f79KwRgA92X+zQakqAskh5Z4 JCfJKLqm2S/rplEu8IcWpd8rjSQe/CTV7oU4tkpE4jscyqgB9E3rvbJhoqhHplbFEvMw OX6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=QyuMDzl+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020a1709027d9000b001b3d27c4f48si2856958plm.57.2023.06.25.03.05.55; Sun, 25 Jun 2023 03:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=QyuMDzl+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231932AbjFYJ5L (ORCPT + 99 others); Sun, 25 Jun 2023 05:57:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbjFYJ5E (ORCPT ); Sun, 25 Jun 2023 05:57:04 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87D95122; Sun, 25 Jun 2023 02:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687021; bh=NOCcPZczdsomiPtC0nBfEgK1XfX0lPqE5Cxg6R5R4g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QyuMDzl+qZJTtAqG8alPlL2kyJVPBA+9zbR7KXmQXTev/Pq+GAjEsvF8qAvSxk9Vm JLuCmxj3iXT70ZB9kFoK9lYrgLQXHLb4X1IVlEEQgDMRP2aTPh0cpEnrAWqD1OQKFR zT2yyhhHtnCvzhNf3KIApx9QHKcX3oKV20uiwtK4= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id EAE9D6015C; Sun, 25 Jun 2023 17:57:00 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH v3 3/8] LoongArch: Prepare for assemblers with proper FCSR class support Date: Sun, 25 Jun 2023 17:56:39 +0800 Message-Id: <20230625095644.3156349-4-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769668679344124397?= X-GMAIL-MSGID: =?utf-8?q?1769668679344124397?= From: WANG Xuerui The GNU assembler (as of 2.40) mis-treats FCSR operands as GPRs, but the LLVM IAS does not. Probe for this and refer to FCSRs as "$fcsrNN" if support is present. Signed-off-by: WANG Xuerui --- arch/loongarch/Kconfig | 3 +++ arch/loongarch/include/asm/fpregdef.h | 7 +++++++ arch/loongarch/include/asm/loongarch.h | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 743d87655742..ac3564935281 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -242,6 +242,9 @@ config SCHED_OMIT_FRAME_POINTER config AS_HAS_EXPLICIT_RELOCS def_bool $(as-instr,x:pcalau12i \$t0$(comma)%pc_hi20(x)) +config AS_HAS_FCSR_CLASS + def_bool $(as-instr,x:movfcsr2gr \$t0$(comma)\$fcsr0) + config CC_HAS_LSX_EXTENSION def_bool $(cc-option,-mlsx) diff --git a/arch/loongarch/include/asm/fpregdef.h b/arch/loongarch/include/asm/fpregdef.h index b6be527831dd..3eb7ff9e1d8e 100644 --- a/arch/loongarch/include/asm/fpregdef.h +++ b/arch/loongarch/include/asm/fpregdef.h @@ -40,6 +40,12 @@ #define fs6 $f30 #define fs7 $f31 +#ifdef CONFIG_AS_HAS_FCSR_CLASS +#define fcsr0 $fcsr0 +#define fcsr1 $fcsr1 +#define fcsr2 $fcsr2 +#define fcsr3 $fcsr3 +#else /* * Current binutils expects *GPRs* at FCSR position for the FCSR * operation instructions, so define aliases for those used. @@ -48,5 +54,6 @@ #define fcsr1 $r1 #define fcsr2 $r2 #define fcsr3 $r3 +#endif #endif /* _ASM_FPREGDEF_H */ diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h index ac83e60c60d1..ff4482fd8ad7 100644 --- a/arch/loongarch/include/asm/loongarch.h +++ b/arch/loongarch/include/asm/loongarch.h @@ -1445,11 +1445,18 @@ __BUILD_CSR_OP(tlbidx) #define EXCCODE_INT_START 64 #define EXCCODE_INT_END (EXCCODE_INT_START + EXCCODE_INT_NUM - 1) -/* FPU register names */ +/* FPU Status Register Names */ +#ifdef CONFIG_AS_HAS_FCSR_CLASS +#define LOONGARCH_FCSR0 $fcsr0 +#define LOONGARCH_FCSR1 $fcsr1 +#define LOONGARCH_FCSR2 $fcsr2 +#define LOONGARCH_FCSR3 $fcsr3 +#else #define LOONGARCH_FCSR0 $r0 #define LOONGARCH_FCSR1 $r1 #define LOONGARCH_FCSR2 $r2 #define LOONGARCH_FCSR3 $r3 +#endif /* FPU Status Register Values */ #define FPU_CSR_RSVD 0xe0e0fce0 From patchwork Sun Jun 25 09:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6830008vqr; Sun, 25 Jun 2023 03:09:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59rCYSARauQacZSnM+3LKSIVylLJNcEyJfMpN9HujqEOIiWFMuozaITXIrelkv9QxdhO54 X-Received: by 2002:a17:903:32d2:b0:1b6:c229:c350 with SMTP id i18-20020a17090332d200b001b6c229c350mr5753189plr.18.1687687740355; Sun, 25 Jun 2023 03:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687740; cv=none; d=google.com; s=arc-20160816; b=ZvnPCzSSXbzyjNy6ki6X1CPDjW6Z1za2cKyVPXRxhcN2sAXze2GG40d77X0uy+RLXv +NYM0+ByjwHsfzRs0M1ADmiCk0ryZfM7vPCdusEACKn7/kBkjEwCcvGuq8EuCKrYaJTU m2ICwp+W+G4and335W8mzL1DOgrc6pDoI63lD1vgxmIdP/x2uHUgMOSWQW0p4VyxS9bd Tp3iCVCcRi5cdJQd5GKgfypfHpzRvtd7NfCLI2ru7MIUqX0QwW+nuvAT3DEGFeO7fqTW PV52eVpDOqdr0VQJZcQr+kvCBCyIDfY0/TIfuE1ZTJz+kIGCimPOxLXlrFKEswNxcU8p XHpw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w81LoC0iJVzu7fwxbBI2jndHUS2msXo6iLYNgR7rdds=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=iCRWZvLEvlWoA8aVvxPvsTRX1BTwEbSWQAQNDhjqRHe8APAA29kjXPeQppJNT58a4U 7A0aROLXmbp9FsXz388wZPAIEYVVN/Q5uMQ+heTB9uey0Ytd208PizeyMA+PzpuvSY9A TVxmfy8cUECHghxspdl9O+6Xxu+2+u2vL3WihMj3XFw0u1wBvvIVzfi2oqzEq7P5VygI A9M2/KmTttzIYneCU1rmssqZ0dehDGJOx3lu2Uia+E5SF274f3p/ff9Hm2EhkeVK6BQF bItEHiHoASN/m6VAbkRX+h2Mp4Tu6VXAEs/nLoPNI8p9u4EDGk3YexnI3/ZOhymsa0w1 gXYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=ZXCCQDPC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a17090311cf00b001a97a54c3a2si3105322plh.197.2023.06.25.03.08.47; Sun, 25 Jun 2023 03:09:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=ZXCCQDPC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232003AbjFYJ6I (ORCPT + 99 others); Sun, 25 Jun 2023 05:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbjFYJ6F (ORCPT ); Sun, 25 Jun 2023 05:58:05 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F047E7E; Sun, 25 Jun 2023 02:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687051; bh=BXNnPllwj84a104F1iNvGfssoVE+iM2IRJn2CMbkaXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZXCCQDPCUkyZw0zfaC+Oj1SyUTXSUmFwcJhKCYxzLrf2U1K90lD9UxleMK+e3ZHg3 1iZkN25nC0cSbrzaEP9n6apHRmCGrXT2u9oAKsr5RKPg9evazoTyyf5fJrmMoc26bZ yBB8Gd3afnDj3Lkho2wOXD34QSCqhxTodxgelxZM= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 8D65E600B5; Sun, 25 Jun 2023 17:57:31 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH v3 4/8] LoongArch: Make the CPUCFG and CSR ops simple aliases of compiler built-ins Date: Sun, 25 Jun 2023 17:56:40 +0800 Message-Id: <20230625095644.3156349-5-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769668860029379732?= X-GMAIL-MSGID: =?utf-8?q?1769668860029379732?= From: WANG Xuerui In addition to less visual clutter, this also makes Clang happy regarding the const-ness of arguments. In the original approach, all Clang gets to see is the incoming arguments whose const-ness cannot be proven without first being inlined; so Clang errors out here while GCC is fine. While at it, tweak several printk format strings because the return type of csr_read64 becomes effectively unsigned long, instead of unsigned long long. Signed-off-by: WANG Xuerui --- arch/loongarch/include/asm/loongarch.h | 63 +++++--------------------- arch/loongarch/kernel/traps.c | 2 +- arch/loongarch/lib/dump_tlb.c | 6 +-- 3 files changed, 15 insertions(+), 56 deletions(-) diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h index ff4482fd8ad7..ea8d1e82369d 100644 --- a/arch/loongarch/include/asm/loongarch.h +++ b/arch/loongarch/include/asm/loongarch.h @@ -56,10 +56,7 @@ __asm__(".macro parse_r var r\n\t" #undef _IFC_REG /* CPUCFG */ -static inline u32 read_cpucfg(u32 reg) -{ - return __cpucfg(reg); -} +#define read_cpucfg(reg) __cpucfg(reg) #endif /* !__ASSEMBLY__ */ @@ -207,56 +204,18 @@ static inline u32 read_cpucfg(u32 reg) #ifndef __ASSEMBLY__ /* CSR */ -static __always_inline u32 csr_read32(u32 reg) -{ - return __csrrd_w(reg); -} - -static __always_inline u64 csr_read64(u32 reg) -{ - return __csrrd_d(reg); -} - -static __always_inline void csr_write32(u32 val, u32 reg) -{ - __csrwr_w(val, reg); -} - -static __always_inline void csr_write64(u64 val, u32 reg) -{ - __csrwr_d(val, reg); -} - -static __always_inline u32 csr_xchg32(u32 val, u32 mask, u32 reg) -{ - return __csrxchg_w(val, mask, reg); -} - -static __always_inline u64 csr_xchg64(u64 val, u64 mask, u32 reg) -{ - return __csrxchg_d(val, mask, reg); -} +#define csr_read32(reg) __csrrd_w(reg) +#define csr_read64(reg) __csrrd_d(reg) +#define csr_write32(val, reg) __csrwr_w(val, reg) +#define csr_write64(val, reg) __csrwr_d(val, reg) +#define csr_xchg32(val, mask, reg) __csrxchg_w(val, mask, reg) +#define csr_xchg64(val, mask, reg) __csrxchg_d(val, mask, reg) /* IOCSR */ -static __always_inline u32 iocsr_read32(u32 reg) -{ - return __iocsrrd_w(reg); -} - -static __always_inline u64 iocsr_read64(u32 reg) -{ - return __iocsrrd_d(reg); -} - -static __always_inline void iocsr_write32(u32 val, u32 reg) -{ - __iocsrwr_w(val, reg); -} - -static __always_inline void iocsr_write64(u64 val, u32 reg) -{ - __iocsrwr_d(val, reg); -} +#define iocsr_read32(reg) __iocsrrd_w(reg) +#define iocsr_read64(reg) __iocsrrd_d(reg) +#define iocsr_write32(val, reg) __iocsrwr_w(val, reg) +#define iocsr_write64(val, reg) __iocsrwr_d(val, reg) #endif /* !__ASSEMBLY__ */ diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c index 22179cf6f33c..8fb5e7a77145 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -999,7 +999,7 @@ asmlinkage void cache_parity_error(void) /* For the moment, report the problem and hang. */ pr_err("Cache error exception:\n"); pr_err("csr_merrctl == %08x\n", csr_read32(LOONGARCH_CSR_MERRCTL)); - pr_err("csr_merrera == %016llx\n", csr_read64(LOONGARCH_CSR_MERRERA)); + pr_err("csr_merrera == %016lx\n", csr_read64(LOONGARCH_CSR_MERRERA)); panic("Can't handle the cache error!"); } diff --git a/arch/loongarch/lib/dump_tlb.c b/arch/loongarch/lib/dump_tlb.c index c2cc7ce343c9..0b886a6e260f 100644 --- a/arch/loongarch/lib/dump_tlb.c +++ b/arch/loongarch/lib/dump_tlb.c @@ -20,9 +20,9 @@ void dump_tlb_regs(void) pr_info("Index : 0x%0x\n", read_csr_tlbidx()); pr_info("PageSize : 0x%0x\n", read_csr_pagesize()); - pr_info("EntryHi : 0x%0*llx\n", field, read_csr_entryhi()); - pr_info("EntryLo0 : 0x%0*llx\n", field, read_csr_entrylo0()); - pr_info("EntryLo1 : 0x%0*llx\n", field, read_csr_entrylo1()); + pr_info("EntryHi : 0x%0*lx\n", field, read_csr_entryhi()); + pr_info("EntryLo0 : 0x%0*lx\n", field, read_csr_entrylo0()); + pr_info("EntryLo1 : 0x%0*lx\n", field, read_csr_entrylo1()); } static void dump_tlb(int first, int last) From patchwork Sun Jun 25 09:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112538 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6826780vqr; Sun, 25 Jun 2023 03:01:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7AUQ8NUtKaAycLkPGQ9NKvasZEB9hHQJo8KBmSULSVMhMjUo0TLRDOEO3tX+JqWlswvxyF X-Received: by 2002:a05:6e02:806:b0:343:9a7e:9f1a with SMTP id u6-20020a056e02080600b003439a7e9f1amr15276018ilm.1.1687687267979; Sun, 25 Jun 2023 03:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687267; cv=none; d=google.com; s=arc-20160816; b=yg/SZ0VQxIWMfx1Wlqere7LgPBDOUcuiuRiqOnvWoKd7eKJaZDbfUjJ3MBWGx6rp5N g8APrry51o4q0OC877gOpKMSl/+BrQ5X+wLsftApNQddch10ww7CISAXhB0/mh8HVjs4 WQabmJ426nKx1eaNtnagH0hWxeIaNZe6qgvixr8l1g+1FW87Ncr40HOjncM2XbJzvpi+ Kd22ATizzd7KlWH3SP0Q8vaCzr4Gsz0tqRmG5JdrqzjzOHNxCujYIezRQo2FtL7dfLN3 38OaC++1lOQTNO3romCjzv0hdYmJbJ8lh12RWKGCvSngRLzWFORdrXfftLc0B9M6kUXA TnkA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QlQ2XxHYZgYLcRQn1HlvWKV8O5QrfRUfnkgd/PHciw8=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=nyxIbdeEf+pFBXDi85Z6KpARCPy8PcBq62C4YQm720T2ihdVQcRkchijgJFt4CU+oo sNXRUtUcl+ioDQipSrKKjMRCX9zXcEP9Ty9bnE9fXnA6sUCcTjXWuf4jFtjDMyXaHeW6 f14u1G4fa2K6AHgd6zkstz4TDiHNXCBCm9A+aXTH945+zTvybtP0KKQ4OhQboNcpfx4N CZfJ+lloDC5TdPypD0i5lvlW9nKnyndTLrXtaG74jn71q6S/LRAGrun72EjyEQlRQ/li C4EO2lgoOK9yIcoJZAYubQNqPCXm6DVh6x7ucpWDsJlMulHOylE7L7qbZJtKyl6Fqc6O HJXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=mAbA173V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a63140a000000b0053f33ec5635si2935683pgl.865.2023.06.25.03.00.53; Sun, 25 Jun 2023 03:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=mAbA173V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231993AbjFYJ6M (ORCPT + 99 others); Sun, 25 Jun 2023 05:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbjFYJ6H (ORCPT ); Sun, 25 Jun 2023 05:58:07 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A0210F2; Sun, 25 Jun 2023 02:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687057; bh=Wpug7va/Sehn1qLVf771ez1BHcOrsgYtBJSQBEXO3Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAbA173VM6FsH8b5N0w1Op2tmRffDFtS5hCc0prq+aUfP9SDHAHE1jrBpI2Qn1mBA Gt5ktfjdYkmAj64mk9W1lTcFZz0win/LyFVNfwrXeh/KtVu1EuzPmK+UTwNX3CUg8/ 2zVhSw+hfBAaMaCSf2v0FV0LD4VlNm1CL0PzXywg= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 533B06015B; Sun, 25 Jun 2023 17:57:37 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH v3 5/8] LoongArch: Simplify the invtlb wrappers Date: Sun, 25 Jun 2023 17:56:41 +0800 Message-Id: <20230625095644.3156349-6-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769668364675848801?= X-GMAIL-MSGID: =?utf-8?q?1769668364675848801?= From: WANG Xuerui The invtlb instruction has been supported by upstream LoongArch toolchains from day one, so ditch the raw opcode trickery and just use plain inline asm for it. While at it, also make the invtlb asm statements barriers, for proper modeling of the side effects. The functions are also marked as __always_inline instead of just "inline", because they cannot work at all if not inlined: the op argument will not be compile-time const in that case, thus failing to satisfy the "i" constraint. The signature of the other more specific invtlb wrappers contain unused arguments right now, but these are not removed right away in order for the patch to be focused. In the meantime, assertions are added to ensure no accidental misuse happens before the refactor. (The more specific wrappers cannot re-use the generic invtlb wrapper, because the ISA manual says $zero shall be used in case a particular op does not take the respective argument: re-using the generic wrapper would mean losing control over the register usage.) Signed-off-by: WANG Xuerui --- arch/loongarch/include/asm/tlb.h | 43 ++++++++++++++------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/arch/loongarch/include/asm/tlb.h b/arch/loongarch/include/asm/tlb.h index 0dc9ee2b05d2..da7a3b5b9374 100644 --- a/arch/loongarch/include/asm/tlb.h +++ b/arch/loongarch/include/asm/tlb.h @@ -88,52 +88,47 @@ enum invtlb_ops { INVTLB_GID_ADDR = 0x16, }; -/* - * invtlb op info addr - * (0x1 << 26) | (0x24 << 20) | (0x13 << 15) | - * (addr << 10) | (info << 5) | op - */ -static inline void invtlb(u32 op, u32 info, u64 addr) +static __always_inline void invtlb(u32 op, u32 info, u64 addr) { __asm__ __volatile__( - "parse_r addr,%0\n\t" - "parse_r info,%1\n\t" - ".word ((0x6498000) | (addr << 10) | (info << 5) | %2)\n\t" - : - : "r"(addr), "r"(info), "i"(op) + "invtlb %0, %1, %2\n\t" : + : "i"(op), "r"(info), "r"(addr) + : "memory" ); } -static inline void invtlb_addr(u32 op, u32 info, u64 addr) +static __always_inline void invtlb_addr(u32 op, u32 info, u64 addr) { + BUILD_BUG_ON(!__builtin_constant_p(info) || info != 0); __asm__ __volatile__( - "parse_r addr,%0\n\t" - ".word ((0x6498000) | (addr << 10) | (0 << 5) | %1)\n\t" - : - : "r"(addr), "i"(op) + "invtlb %0, $zero, %1\n\t" : + : "i"(op), "r"(addr) + : "memory" ); } -static inline void invtlb_info(u32 op, u32 info, u64 addr) +static __always_inline void invtlb_info(u32 op, u32 info, u64 addr) { + BUILD_BUG_ON(!__builtin_constant_p(addr) || addr != 0); __asm__ __volatile__( - "parse_r info,%0\n\t" - ".word ((0x6498000) | (0 << 10) | (info << 5) | %1)\n\t" - : - : "r"(info), "i"(op) + "invtlb %0, %1, $zero\n\t" : + : "i"(op), "r"(info) + : "memory" ); } -static inline void invtlb_all(u32 op, u32 info, u64 addr) +static __always_inline void invtlb_all(u32 op, u32 info, u64 addr) { + BUILD_BUG_ON(!__builtin_constant_p(info) || info != 0); + BUILD_BUG_ON(!__builtin_constant_p(addr) || addr != 0); __asm__ __volatile__( - ".word ((0x6498000) | (0 << 10) | (0 << 5) | %0)\n\t" + "invtlb %0, $zero, $zero\n\t" : : "i"(op) - : + : "memory" ); } From patchwork Sun Jun 25 09:56:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6833138vqr; Sun, 25 Jun 2023 03:17:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6mBd/ldS3i0fhqQuxPgSrAygpIkA3ogTffIVqBgTTZHJOFg6zfyBXNl+YnCJdrjm8gtY1L X-Received: by 2002:a05:6808:8ef:b0:3a0:5802:1b0a with SMTP id d15-20020a05680808ef00b003a058021b0amr12232492oic.25.1687688275697; Sun, 25 Jun 2023 03:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687688275; cv=none; d=google.com; s=arc-20160816; b=PZGYyiqm69qVc7C0uVwat3JO7rGCusFEyyZ1ET7rxLUwRirBxipeiuB/4677WwOpb1 cQJqj222r+M7QBLdOX+R0q1alms6rNHhHmPHJVX5qRjtPCHzzdKHyK8c3bmlyDEfECZ/ mO9Uct6Wx6alyfZUMCMq1rnEx4wPcrC3g/qq3SEtdyHpEteNBFIiOWulrCM3u9X5PTdV 9ZUZi72jBepbGv9Tfoker5GSSR48WLc8qhjcfyEuCoe8voc0/4wZBYSm+GWJZ799k8cj iayA6KPv3uCPqbFXwWmx4/PAgwa/E+DlEe8S6wYxjN07IB5VKYlhlDRucjbA9KWz3BA4 1hCQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RbZXIt8qzOaX/PdK18vmES76NalWUfTDkqVEDS4d8hE=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=YcPKEHkZvwz4n/HW1aGEgDtFc/QeUBFWLnC8yb9ZVArUFDbBS2qMDsh1adk2syZgBc llpEG9fpq3877SozaT+AhVANB77Sf1vwDjND3QPBH6X6X155Q1+QoNZ7QwdlPYyDgtPd zo6NwmWZiA3E09bbq0Kv78bhiTwmMmYUPCkmJxKG5QO0XA94NbV0LQfzE+44hD4NG6qG pKR36dvSTERBVlEAqQDUByo+VwNv5ydAGgnx/zr9lxhp95vZrLh3iWEGttXCixIjf4vO eYiSiylv8LSCZtIKhDWCNdqmpjPbhCKuth5t3e3doo+Mkukz+2xxF9ToNh7RmkLxa4PF Dq2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=vC7QKvMc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i62-20020a638741000000b005443ff97149si3209987pge.331.2023.06.25.03.17.43; Sun, 25 Jun 2023 03:17:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=vC7QKvMc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232076AbjFYJ6T (ORCPT + 99 others); Sun, 25 Jun 2023 05:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbjFYJ6I (ORCPT ); Sun, 25 Jun 2023 05:58:08 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11D3710D3; Sun, 25 Jun 2023 02:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687058; bh=YtsXJvNsH4YXyvvEvCiNoOEuYFmBZqVboByxYB2/yFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vC7QKvMcWWP/npTqVBCyEAAKdJx6W4J1EEp2eWfzw58Swuc5KkXh6ww0TsihpaDaX +EnSH7VhqZtR00IzzrmbnLd9f/oU/nVkMCglwcf9ZouAqXjy5Gh5Y+OpgrzCp/KTA9 vCOOeNnysuT6tRycEtk3yp5oqCee8hC+d7tTxsYY= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id B22036015C; Sun, 25 Jun 2023 17:57:38 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH v3 6/8] LoongArch: Tweak CFLAGS for Clang compatibility Date: Sun, 25 Jun 2023 17:56:42 +0800 Message-Id: <20230625095644.3156349-7-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769669421572197461?= X-GMAIL-MSGID: =?utf-8?q?1769669421572197461?= From: WANG Xuerui Now the arch code is mostly ready for LLVM/Clang consumption, it is time to re-organize the CFLAGS a little to actually enable the LLVM build. Namely, all -G0 switches from CFLAGS are removed, and -mexplicit-relocs and -mdirect-extern-access are now wrapped with cc-option (with the related asm/percpu.h definition guarded against toolchain combos that are known to not work). A build with !RELOCATABLE && !MODULE is confirmed working within a QEMU environment; support for the two features are currently blocked on LLVM/Clang, and will come later. Why -G0 can be removed: In GCC, -G stands for "small data threshold", that instructs the compiler to put data smaller than the specified threshold in a dedicated "small data" section (called .sdata on LoongArch and several other arches). However, benefiting from this would require ABI cooperation, which is not the case for LoongArch; and current GCC behave the same whether -G0 (equal to disabling this optimization) is given or not. So, remove -G0 from CFLAGS altogether for one less thing to care about. This also benefits LLVM/Clang compatibility where the -G switch is not supported. Why -mexplicit-relocs can now be conditionally applied without regressions: Originally -mexplicit-relocs is unconditionally added to CFLAGS in case of CONFIG_AS_HAS_EXPLICIT_RELOCS, because not having it (i.e. old GCC + new binutils) would not work: modules will have R_LARCH_ABS_* relocs inside, but given the rarity of such toolchain combo in the wild, it may not be worthwhile to support it, so support for such relocs in modules were not added back when explicit relocs support was upstreamed, and -mexplicit-relocs is unconditionally added to fail the build early. Now that Clang compatibility is desired, given Clang is behaving like -mexplicit-relocs from day one but without support for the CLI flag, we must ensure the flag is not passed in case of Clang. However, explicit compiler flavor checks can be more brittle than feature detection: in this case what actually matters is support for __attribute__((model)) when building modules. Given neither older GCC nor current Clang support this attribute, probing for the attribute support and #error'ing out would allow proper UX without checking for Clang, and also automatically work when Clang support for the attribute is to be added in the future. Why -mdirect-extern-access is now conditionally applied: This is actually a nice-to-have optimization that can reduce GOT accesses, but not having it is harmless either. Because Clang does not support the option currently, but might do so in the future, conditional application via cc-option ensures compatibility with both current and future Clang versions. Suggested-by: Xi Ruoyao # cc-option changes Signed-off-by: WANG Xuerui --- arch/loongarch/Makefile | 21 +++++++++++++-------- arch/loongarch/include/asm/percpu.h | 6 +++++- arch/loongarch/vdso/Makefile | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index a27e264bdaa5..a63683da3bcf 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -46,8 +46,8 @@ ld-emul = $(64bit-emul) cflags-y += -mabi=lp64s endif -cflags-y += -G0 -pipe -msoft-float -LDFLAGS_vmlinux += -G0 -static -n -nostdlib +cflags-y += -pipe -msoft-float +LDFLAGS_vmlinux += -static -n -nostdlib # When the assembler supports explicit relocation hint, we must use it. # GCC may have -mexplicit-relocs off by default if it was built with an old @@ -56,13 +56,18 @@ LDFLAGS_vmlinux += -G0 -static -n -nostdlib # When the assembler does not supports explicit relocation hint, we can't use # it. Disable it if the compiler supports it. # -# If you've seen "unknown reloc hint" message building the kernel and you are -# now wondering why "-mexplicit-relocs" is not wrapped with cc-option: the -# combination of a "new" assembler and "old" compiler is not supported. Either -# upgrade the compiler or downgrade the assembler. +# The combination of a "new" assembler and "old" GCC is not supported, given +# the rarity of this combo and the extra complexity needed to make it work. +# Either upgrade the compiler or downgrade the assembler; the build will error +# out if it is the case (by probing for the model attribute; all supported +# compilers in this case would have support). +# +# Also, -mdirect-extern-access is useful in case of building with explicit +# relocs, for avoiding unnecessary GOT accesses. It is harmless to not have +# support though. ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS -cflags-y += -mexplicit-relocs -KBUILD_CFLAGS_KERNEL += -mdirect-extern-access +cflags-y += $(call cc-option,-mexplicit-relocs) +KBUILD_CFLAGS_KERNEL += $(call cc-option,-mdirect-extern-access) else cflags-y += $(call cc-option,-mno-explicit-relocs) KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel diff --git a/arch/loongarch/include/asm/percpu.h b/arch/loongarch/include/asm/percpu.h index ad8d88494554..b9f567e66016 100644 --- a/arch/loongarch/include/asm/percpu.h +++ b/arch/loongarch/include/asm/percpu.h @@ -14,7 +14,11 @@ * loaded. Tell the compiler this fact when using explicit relocs. */ #if defined(MODULE) && defined(CONFIG_AS_HAS_EXPLICIT_RELOCS) -#define PER_CPU_ATTRIBUTES __attribute__((model("extreme"))) +# if __has_attribute(model) +# define PER_CPU_ATTRIBUTES __attribute__((model("extreme"))) +# else +# error compiler support for the model attribute is necessary when a recent assembler is used +# endif #endif /* Use r21 for fast access */ diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile index 4c859a0e4754..ee4abcf5642e 100644 --- a/arch/loongarch/vdso/Makefile +++ b/arch/loongarch/vdso/Makefile @@ -25,7 +25,7 @@ endif cflags-vdso := $(ccflags-vdso) \ -isystem $(shell $(CC) -print-file-name=include) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ - -O2 -g -fno-strict-aliasing -fno-common -fno-builtin -G0 \ + -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector) From patchwork Sun Jun 25 09:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6832895vqr; Sun, 25 Jun 2023 03:17:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tgsdrVC5qLH8XKw0NDkW9/cSe3I4yidasrUEcKpQxbvUsEZz4G7SxcqqNiy7l2fMbBpJZ X-Received: by 2002:a05:6808:6396:b0:398:43a7:e9fe with SMTP id ec22-20020a056808639600b0039843a7e9femr25693207oib.20.1687688228233; Sun, 25 Jun 2023 03:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687688228; cv=none; d=google.com; s=arc-20160816; b=OlOqh+7dAaImFfAkVcKK2P2Z3HpEtUApiE8+aHaQp7mTa74uIc+Zw+N+LB4j1XPhDu vXLTHYQa1+pfDm6Sy/ptfmDCzGjhJfxmWnYZpTKBq8PrWMrNDHbC21YwuFkl3LOX4g5P 8wgxzgRhXXgWPe8m8j3vRlVRxTioym8y4z34+N0zCGcjfp4d+M1ip9cCiMwlqjR3oFf8 FY7jeFlqN1yF7jQOqCA3+mHrql4YW+cfODyt9SMDwFHyXDbgzJDtewpmoLAFfRIsTkqd WkodzAaY0WTpFRnMsqMov2Fix9mQ+4Yz/iOZ/RaHGu0z3rE3lBSjIkQxfpGgxPpHf+fh XL5A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IMd/SUKmlWVpC4P0XrhitOnqAd0zXMtWnK5o0dkm3sA=; fh=cOkhPHs+QQbxcIFG9XL5O7NpzAYOWU9SlXvAO44hRCk=; b=cucKYUXaot6AgexYTKFFwPV3zErh7VNWCRCyBL9q/5cEJVy4mELE/U8MEY4Fuu3yYb RdSH5sSXsCvkQyhHb/6opvK5opHHTC8OLkdLFwqEij6/9YUfcsB5tjKnlwWRgyoUKnFg bVl+TCg+mYDH05h6sG2YiOyZCPC86IaLr//ucKFYiagHpTQvKAjPbzlkS04q/RuyWH2+ mLELIpPlAfVtX/Gre7XWuIDGPoLkCSXkOyvUjD5RCouKnCN2drEJUR0Ox4IzfUBLFsjj vOcfT2z/ry5LHJ17lHfxbmQZt2o1Bgbvqvx9gpsJzLZZeee5uIXS7ma2dxy70qrC1K0N s+Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=fHnuVqWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a630b15000000b0055390839e3dsi2901047pgl.528.2023.06.25.03.16.56; Sun, 25 Jun 2023 03:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=fHnuVqWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjFYJ61 (ORCPT + 99 others); Sun, 25 Jun 2023 05:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbjFYJ6L (ORCPT ); Sun, 25 Jun 2023 05:58:11 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F41721B9; Sun, 25 Jun 2023 02:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687078; bh=f9UodCze65MUHVrQj48fTjyEJzJh37WtI+PaqIa5H+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHnuVqWNo63965Jjvx1FcKAfbuDWLk9u8rMHzZOqUMYp5ttLIAg6H/vKIkVK/8t4N O9bicTpW8khT3DY2zPhZKiMqzyh3HXoigWp7s3dWVNjkGhrCVjDq+0oJiFSRGKXIes D5DMQjNia5R0U3HSoQSfbttFeEFZafzyY5vDOnak= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 5E3B060164; Sun, 25 Jun 2023 17:57:58 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui , Nick Desaulniers Subject: [PATCH v3 7/8] LoongArch: Mark Clang LTO as working Date: Sun, 25 Jun 2023 17:56:43 +0800 Message-Id: <20230625095644.3156349-8-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769669371525910412?= X-GMAIL-MSGID: =?utf-8?q?1769669371525910412?= From: WANG Xuerui Confirmed working with QEMU system emulation. Signed-off-by: WANG Xuerui Acked-by: Nick Desaulniers --- arch/loongarch/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index ac3564935281..ed9a148cdcde 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -51,6 +51,8 @@ config LOONGARCH select ARCH_SUPPORTS_ACPI select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_HUGETLBFS + select ARCH_SUPPORTS_LTO_CLANG + select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_SUPPORTS_NUMA_BALANCING select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF From patchwork Sun Jun 25 09:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 112542 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6828279vqr; Sun, 25 Jun 2023 03:04:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41wthjDf9bk7Cwa4sOLYCJneNFqDM/5juk+jVzBvg4PtlzKBV5UU6SD8UmHYumuj8OJcPB X-Received: by 2002:a05:6808:4291:b0:39a:bc60:adf9 with SMTP id dq17-20020a056808429100b0039abc60adf9mr21339286oib.7.1687687457089; Sun, 25 Jun 2023 03:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687457; cv=none; d=google.com; s=arc-20160816; b=xNnm4R7XisaSwAfUw2HE4d+nlSD1Yi+9LBdXmP6GcjcUPGHY7OWXVD695G3eyZz+JW 2vSqgysn4JbZ5pl/BgxWrv+LRfYx1Vd6lMp4sU5+QMRK13S6tqFcZtxzYfIwgVizucUb vbDJ0wMde5TrQadxhL/7dHgVaFfXhueYqU4AmExpRaGRL0/Dqol6YacV+cNPngiMpR3y 6LlRL4vRIWNnR8NaEC6mHlgzgMLdKMXQ2gtLNEimUKG5K3jVpLy1G73ERi3G+fXjRJkn qytsNULdS7v3F8zWfFmUYCDenJtJf7rFpeGEWUFxN0bOrCJXIP+nuhcfy2P8hMhdUlIG xWtA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YTz8C84pk81C0o2NjwFBBo9+aKEe1lQCS+FEea4oIOU=; fh=cOkhPHs+QQbxcIFG9XL5O7NpzAYOWU9SlXvAO44hRCk=; b=aTdlQFaWSstAb8zXG9GgsEf1bpyy4TquyuJLHcIlhN519c8ns73jYTVVJQcesbN+SD vfOlqlVDqnoLD9NpJmM75ts2bxFhycdAVj6/DxNvVX4x1aReD7XYYTvU/6HTm3PPFayx nxetqogI8Mn6Ov6RnpZJfmDh9LnSuZjIZrirvqVJTaK5zyJGmDKh7sMiT7Qfb65qopTY Ux+B3/E7HN7BCZPMEV/63CwraSTj/E9jEi/ACJ3PVh67gAiwFh81eDr6sUymGr1WPNUW aox0CejU4xG1MPcdTdmBUZNgy/eoBTv1gchTRkPRR7qSY+b9yM5LHxxBa2RuXjILw7Lf svDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=sHDre7+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v34-20020a634822000000b005533f251ea7si2984474pga.122.2023.06.25.03.04.04; Sun, 25 Jun 2023 03:04:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=sHDre7+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231969AbjFYJ6X (ORCPT + 99 others); Sun, 25 Jun 2023 05:58:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbjFYJ6L (ORCPT ); Sun, 25 Jun 2023 05:58:11 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3075E78; Sun, 25 Jun 2023 02:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687079; bh=H4NWls1bUMGdPdN2OveQqxUMkhksKubc1e0oOz7s4Zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHDre7+MIxe4WQ9QS0lzPx9Dumw9urre45a1mvqRpkjtJDoLDxkzHMPjfE2HZVtFf D42CXGxQnJjuBmQwADvU4RY2meRUwyzlTkSahMQ7vkFUu+mEA0m/eFxMh77v/zMZdY uYXa4Y64sAkFaB33r0rvJAsQ818oKanHu7sbiNeA= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 44E61605E5; Sun, 25 Jun 2023 17:57:59 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui , Nick Desaulniers Subject: [PATCH v3 8/8] Makefile: Add loongarch target flag for Clang compilation Date: Sun, 25 Jun 2023 17:56:44 +0800 Message-Id: <20230625095644.3156349-9-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-1-kernel@xen0n.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769668563053376921?= X-GMAIL-MSGID: =?utf-8?q?1769668563053376921?= From: WANG Xuerui The LoongArch kernel is 64-bit and built with the soft-float ABI, hence the loongarch64-linux-gnusf target. (The "libc" part can affect the codegen of libcalls: other arches do not use a bare-metal target, and currently the only fully supported libc on LoongArch is glibc anyway.) See: https://lore.kernel.org/loongarch/CAKwvOdnimxv8oJ4mVY74zqtt1x7KTMrWvn2_T9x22SFDbU6rHQ@mail.gmail.com/ Signed-off-by: WANG Xuerui Reviewed-by: Nick Desaulniers --- scripts/Makefile.clang | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang index 058a4c0f864e..6c23c6af797f 100644 --- a/scripts/Makefile.clang +++ b/scripts/Makefile.clang @@ -4,6 +4,7 @@ CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl +CLANG_TARGET_FLAGS_loongarch := loongarch64-linux-gnusf CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu