Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp185031rwl; Wed, 4 Jan 2023 17:28:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXspHC0jcuKhradASPQabBy7pGgzNOmjz2RN2XPl25ChyE/6SylAXs9cajkNy7bbkIBLldRP X-Received: by 2002:a17:906:3ec8:b0:846:cdd9:d23 with SMTP id d8-20020a1709063ec800b00846cdd90d23mr39477691ejj.19.1672882089146; Wed, 04 Jan 2023 17:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672882089; cv=none; d=google.com; s=arc-20160816; b=m9Ux+dCwmn6fSSKp/WO5aQkqdeH/76NPgM1q9Fu4jcTsiyYJ/qVO4zwsWa5fsCbH59 +3bDA415aJ9DS3kUfC9Kjt/VBz97BZq0fSoL2HmfbTd13heJwCEkJdZalILC+K/np5FK JVrD+l27aDXw/UFvyQuvV17uuAEYORRtFR6J5bhyRD2ggDstEzdUQbGEBwYfqxWnjE8w 0VtXj22s/IOlqW3xjXXnwmG9FJqJO8AQ93WnH3N3gTDfFV/1yPZXM5/ORzq0Ce6lyXl8 kI2QFGr0GIGMFkgMwqhBYNg5a9GY/yPt9I+hVz7MugxRyT4xbkzwGDI/87AzgyArQeBT By3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=2gkepRLBKQNNll2y1YK6q4FSMbyQXWd7pPOzOPlDBrc=; b=NHbj26Yo7pOHzbxgXl8G6TpEaoURvu2DIjj9Bxj4pd45F3GUKg9wCQSa6B69Jgzn+W aLoikNz8m++FEHISpNFtoRmq6wG6uTj1Vfky7ZkUVtBw2mhIoaJxm883GQT+1p/g4jll WZ/v5aNPLzUaLpkZiRDMAEOqWUfktoYMNt19aHfN5EUsnngSzHyXy5oFEqosf/W6eGFl NN8MW6NJwpODMIpHfLf0zNXCMeJ3GCAq+zCc0Ax0WUvowDaN1gvXFMhMqnEI/RFfdnAO 8/HjTjTpFcq9uLrutqwSUV1KMLEoNby+lAxdi+959cBnV2AxU0/UfjGEYN9LYW52Wj3H 44nA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go31-20020a1709070d9f00b0078266dc4b8csi34179242ejc.719.2023.01.04.17.27.55; Wed, 04 Jan 2023 17:28:09 -0800 (PST) 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; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjAEBDC (ORCPT + 58 others); Wed, 4 Jan 2023 20:03:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbjAEBCk (ORCPT ); Wed, 4 Jan 2023 20:02:40 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAAE012D35 for ; Wed, 4 Jan 2023 17:02:39 -0800 (PST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NnSR7612czRqtm; Thu, 5 Jan 2023 08:44:35 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 5 Jan 2023 08:46:08 +0800 Message-ID: <4062e65d-f411-bc01-d789-afee3c4b5b99@huawei.com> Date: Thu, 5 Jan 2023 08:46:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v5 7/9] riscv/kprobe: Prepare detour buffer for optimized kprobe To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Chen Guokai , , , , , , CC: , References: <20221224114315.850130-1-chenguokai17@mails.ucas.ac.cn> <20221224114315.850130-8-chenguokai17@mails.ucas.ac.cn> <87r0wcvmn1.fsf@all.your.base.are.belong.to.us> <088ed826-59a8-37a3-401e-2ed022a4a097@huawei.com> <87sfgqr7d4.fsf@all.your.base.are.belong.to.us> From: "liaochang (A)" In-Reply-To: <87sfgqr7d4.fsf@all.your.base.are.belong.to.us> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.108] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 在 2023/1/4 17:12, Björn Töpel 写道: > "liaochang (A)" writes: > >>>> +SYM_ENTRY(optprobe_template_insn, SYM_L_GLOBAL, SYM_A_NONE) >>>> + /* >>>> + * Step3: >>>> + * NOPS will be replaced by the probed instruction, at worst case 3 RVC >>>> + * and 1 RVI instructions is about to execute out of line. >>>> + */ >>>> + nop >>> >>> A nop here will be either a compressed nop or a non-compressed, >>> depending on the build (C-enabled or not), right? Maybe be explicit to >>> the assembler what you want? >>> >> >> You are right, if CONFIG_RISCV_ISA_C is disabled, two NOP is enough for 2 RVI execute out of line, >> if CONFIG_RISCV_ISA_C is enabled, it needs eight C.NOP here for the worst case (3 RVC + 1 RVI). >> >> I will use {C}.NOP explicitly for different configure in next revision, thanks. > > What I meant was that "nop" can expand to compressed instructions, and > you should be explicit. So you know how it's expanded by the > compiler/assembler. > > An example: > > $ cat bar.S > .text > bar: > nop > nop > $ riscv64-linux-gnu-gcc -O2 -o bar.o -c bar.S && riscv64-linux-gnu-objdump -M no-aliases -d bar.o > > bar.o: file format elf64-littleriscv > > > Disassembly of section .text: > > 0000000000000000 : > 0: 0001 c.addi zero,0 > 2: 0001 c.addi zero,0 > > > vs > > $ cat foo.S > .text > foo: > .option norvc > nop > nop > > $ riscv64-linux-gnu-gcc -O2 -o foo.o -c foo.S && riscv64-linux-gnu-objdump -M no-aliases -d foo.o > > foo.o: file format elf64-littleriscv > > > Disassembly of section .text: > > 0000000000000000 : > 0: 00000013 addi zero,zero,0 > 4: 00000013 addi zero,zero,0 Above examples are very clear, i will use these expaned instructions in next revision, thanks. > > > Björn -- BR, Liao, Chang