Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp97255lqt; Wed, 5 Jun 2024 19:10:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNcg195nOICSSQS8PPsBJPi+7ueOxPOzhQl92Uop1RKiODF/fJqMKebTT1tLYOam3G6OyMEd/76CwBe/CYpkqXgHjOk0yue0s2Euq/8w== X-Google-Smtp-Source: AGHT+IEwnVUKCwwdjpZmGSl/cDRxxYR2O5XhdbLG4DfuHbpkQmlE7wjhhuzNPy0HB89pqYtflBfM X-Received: by 2002:a17:902:d506:b0:1f4:466f:8ca4 with SMTP id d9443c01a7336-1f6a58676b2mr50718085ad.0.1717639837516; Wed, 05 Jun 2024 19:10:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717639837; cv=pass; d=google.com; s=arc-20160816; b=OStyxm9kHas1/MB28tommjzpYO8zqAA9PM5XuS8B6k6gb4SvWD+EeohW7CRGtiC2I3 E7t3TBNRmdJPDUD7DjYyrIeGQp776sEkCJOpwSXT+ow8OnxKkPPFu2yiJ7luOHH+c4Pu 911J5vjylwovqE47t9JDELB+YZmKOYlt3bVScgfzb429LVvy0lUfKOrpfyEaREBqDPTG UNNyNWVdJBVKFG79uvzogmg0YvZFBa0TD27uqrvGYfFbJeOrtXC73hjKiLb+txKfEPM0 w945HEG9ueh22Ek4kI7gJ0onXJ0GG9rvHhm7cr+JRbjGgQZgmhdpAc4lOKJVtXNirdlG KQkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-language:content-transfer-encoding:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=i+NWoMLaB3X7QCuPIM+FkG1IGw4Z0UWPbxcwaLzIXaw=; fh=mwRL44bA+DE/f1UP9cV1obMyw4XCHUqy5rvezUdsesA=; b=028u8IkuHg437ldJsy0pEjSAZVEBmuclZ5TRDnC/ZnZqHzNQowxo0DrdPPP5S3xbaX ufWgvYH5jdM/44oit+Fr6pXd59r9gCj0nw/7q58zpmm0PuTi7W79aUdwyGrgr+julYRW FWAt5+p7eM1w9K8V3hJkgOAyEPM3Y0bEqVf+3erD4xJWDaX8OSKDSIveUPmby7GLUgP4 yTB9QAOsBbGfAZbBaLcpQFqbupEjo1OJlJKLBsdNlHyh9xUXWq7QEb4avHhUyA2TRw0C aCNQBNrwrKR848Rg4crl5oO0prLOF+TIwQLysU6VwNbG/OF33Z+0Htnx69ojiiufp4lg Ft5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-203522-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203522-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd760d51si3251955ad.107.2024.06.05.19.10.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 19:10:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203522-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-203522-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203522-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 832F8B23C37 for ; Thu, 6 Jun 2024 02:10:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D8E8175AB; Thu, 6 Jun 2024 02:10:17 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27FCD1640B for ; Thu, 6 Jun 2024 02:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717639816; cv=none; b=L+l/WwY4lMq1yuH6PvC0DbSXVMhZeW5LXZo7M9CQYS4uV91tgEwzXKCGTTAraGGj6kdxCYKhGyUz0+6+UtpOSViXkxl/NMXz6GySEwMEXgjMVDUi06MWtpJUYVKgvV0rEhZkLr0wE6rQMgjxmUwLqQezKF5AE7Gc5m6AjPyr9G0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717639816; c=relaxed/simple; bh=Z0CYkHleD15nnISvbRfPMD7qgij7i9JhEyEYYx5DE2E=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=IDY8i4xXS7jOEuAHdalpYDGMvVlNaiabDcU1CYKFcQ7b1YJW0st/5IE6jDUoYGoiiwKILaufk4lYGxqYSq4a4w6VIc/KTk1m87zGqJPMMOWSaKV2EfPsFB0Nsra7MF2BAFNribD4G9ZrCrxSV1uUmv1CJYYgLdhxRuPVJdXoXh0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8DxFPCDGmFmkgwEAA--.17399S3; Thu, 06 Jun 2024 10:10:11 +0800 (CST) Received: from [10.136.12.26] (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axw8R9GmFmaV4WAA--.45165S3; Thu, 06 Jun 2024 10:10:10 +0800 (CST) Subject: Re: [PATCH] loongarch: Only select HAVE_OBJTOOL and allow ORC unwinder if the inline assembler supports R_LARCH_{32,64}_PCREL To: Xi Ruoyao , Nathan Chancellor , Peter Zijlstra Cc: Huacai Chen , WANG Xuerui , Tiezhu Yang , Nick Desaulniers , Bill Wendling , Justin Stitt , Youling Tang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mengqinggang@loongson.cn, cailulu@loongson.cn, wanglei@loongson.cn, luweining@loongson.cn, Yujie Liu , Heng Qi , Tejun Heo References: <20240604150741.30252-1-xry111@xry111.site> <20240605054328.GA279426@thelio-3990X> <20240605062548.GF279426@thelio-3990X> <444ec2031ef6ca016cbfa8dfedc51bddc8529ba7.camel@xry111.site> <82b7e6ea-c2cb-6364-ebe9-bff928028408@loongson.cn> <1c132209a612e2e8953f0b458fc01853120db9a9.camel@xry111.site> From: Jinyang He Message-ID: <2bf11cd2-8449-acda-f5ad-659c38cb018e@loongson.cn> Date: Thu, 6 Jun 2024 10:10:05 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <1c132209a612e2e8953f0b458fc01853120db9a9.camel@xry111.site> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8Axw8R9GmFmaV4WAA--.45165S3 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxGFW3Aw17Xw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v67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU2-VyUUUUU On 2024-06-06 03:05, Xi Ruoyao wrote: > On Wed, 2024-06-05 at 23:47 +0800, Jinyang He wrote: >> In our 419 repo this func has been renamed arch_update_insn_state (, now it >> should be arch_update_cfi_state) and give some actions to deal with the >> frame pointer case. If we support it we may deal with some case but for >> clang... >> >> .global test >> .type test,@function >> test: >> >> addi.d  $sp,$sp,-448 >> st.d    $ra,$sp,440 >> st.d    $fp,$sp,432 >> addi.d  $fp,$sp,448 >> >> # do something  <- not change $sp > This is simplified. In the real code $sp is changed, something like: > > bstrins.d $sp, $zero, 5, 0 > > $fp is needed to allow restoring $sp after realigning $sp for some local > over-aligned variables, as demonstrated by this example: > > struct x { _Alignas(64) char buf[128]; }; > > void f(struct x *p); > void g() > { > struct x x = { .buf = "1145141919810" }; > f(&x); > } > > GCC does not align $sp, it produces the aligned address for x from an > unaligned $sp instead: > > addi.d $a0, $sp, 63 > srli.d $a0, $a0, 6 > slli.d $a0, $a0, 6 > > thus there's no need to use $fp. > > /* snip */ > >> <- restore regs from non-cfa ? >>          ld.d    $ra, $sp, 8                     # 8-byte Folded Reload > /* snip */ > >> Maybe Clang have anything wrong? > I don't think we must restore regs based on $fp just because CFA is > based on $fp. You are right. > The .cfi directives only provides *one* possible way to > restore the regs. What I just confused is that there is no ".cfi_*" in the eplogue by clang, which may cause wrong backtrace if gdb set breakpoint there and backtrace. (But this is out of this topic.) > This way is convenient to the unwinder, but not > necessarily convenient to the CPU thus the real instruction sequence can > use a different way. They only need to be "equivalent", not necessarily > "exactly same." > > Also note that .cfi_* directives are completely irrelevant for objtool. > THe objtool synthesizes the ORC unwind info from the machine > instructions, not the DWARF unwind info coded with .cfi_*. > The entire point of ORC is avoiding DWARF. It's even named ORC because > ORC and DWARF are sworn enemies in some tales. Yes. The yestorday attachment has something wrong. Enmmmm.... (It seems I'm careless.) diff is,                 switch (op->src.type) {                 case OP_SRC_ADD:                         if (op->dest.reg == CFI_SP && op->src.reg == CFI_SP) { -                               /* addi.d sp, sp, imm */ -                               cfi->stack_size -= op->src.offset; -                               if (cfa->base == CFI_SP)                                 /* addi.d sp, sp, imm */                                 cfi->stack_size -= op->src.offset;                                 if (cfa->base == CFI_SP) Or you can get the tmp fix by [1]. [1]: https://github.com/MQ-mengqing/linux/commit/c1f7df3eb2a2bb7a1c10c2aa6e0e3d585b457352