Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12971023rwl; Wed, 4 Jan 2023 01:23:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXtGlIv/Ob9S2ASX12TYdSS8DjkF+Bcs4e+Mo56//PrQnePYj8PmVukrkFJfQlw4qJrj7D2v X-Received: by 2002:a17:90a:a597:b0:226:587:7911 with SMTP id b23-20020a17090aa59700b0022605877911mr30667205pjq.20.1672824198762; Wed, 04 Jan 2023 01:23:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672824198; cv=none; d=google.com; s=arc-20160816; b=IuoETOcKbfmeMKo4SO1U9mpBnPPD2Nc08sHN/Yc+Fe4zE++VW6KN+u3xYahh+rhtYC 4VbEWeQoq4ddo56OKcMF8B2OIgLYJmA30xMMxJIAVu0loZOeNba4s6rdytWOIyETVbAa 8ZtHUUgUs1+NdBOy+aNy62pWiwAGVm/KScDpNzZz7M27lHxpCC1QWpjkCLAwzYbW2kXd Zlib4TctKxVFACS5LtFnvHngOiTWugfu19jUi50cKZDySS2rTU6kdxbN7130m7im49q6 uXAx3o7tsMnij+axx2ybuqM0OIZcTCJYAUd+263l+cy/7K2WjE7ZVc+u68Ro84l37PWX ewgw== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=KUCFtsTTcc5bgJS5OZ7Bk96u22KW/8B7VG703nK4IiI=; b=0E+3WfZfZ44TJBcvp1UU5+fMsJIowmhK5bDyKq4k7aegJguuqqpj67+5WmPEDeTtrJ ldA9Z5mLi5gkEq718+cjrA9M8ca/teykKL0E5wJ8wNjO0cIzkgsVK2OfRX2tbb7ZXa3e /hfrzlMbw0AHrxTgH9toKVjc80WvUFwR41g/lWelQXdlE3g0vS17eEHFOixWKPYWmTru QYHuKz0qAj+fAzsmwL37iMlG+UIJChqOozwPYzBhoIbxvkR5/BdeIjSMhMNRW0uzQkaD E+KEtyTs1LEMhkSaupGxFiUQNLNO6Qj/TvMg1O1C0/kaFLhy1l2a3jM4GikfFMYmc6z0 pCVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u3+CsheN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l123-20020a633e81000000b00477ae8def63si36879187pga.495.2023.01.04.01.23.11; Wed, 04 Jan 2023 01:23:18 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u3+CsheN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233651AbjADJMq (ORCPT + 57 others); Wed, 4 Jan 2023 04:12:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239117AbjADJMa (ORCPT ); Wed, 4 Jan 2023 04:12:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BBFB1C408 for ; Wed, 4 Jan 2023 01:12:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CBC72B810FA for ; Wed, 4 Jan 2023 09:12:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41330C433D2; Wed, 4 Jan 2023 09:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672823545; bh=Hr95qdIHJ3vIdDscritgygh7Q2O7d4i8wglmOqf/p48=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=u3+CsheNf9bobT93mNgsGA68gR+9bS/z0GyylZIoWcbeiwOQ2OnLHh0Kiqmb95dIl bzF1L0nlgALs1KD1uxDcn7s73yNMp/Wbu2st8NdkwUoH87ZtVrfH7ku+e+oXOcNiq+ HmT5wHRWfJ3dKgCSirXyVW4K/huMlbt90n/CV7t4sa+V5SDLOLS1UerflfR2XkWrNW XkuTQdntlgyqoKso1QIJnF0zhsuxCLgNMqDtKQALzpJDikb9W2ohSkkUogq5tCZcM9 T55cKec4lKKrQXMoVtdKJpJ2JR0tRYCyXPsHWzOc5bUAmLKedYU6X3YO1l9GN3eNiK rTQGD2DeNNMxQ== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: "liaochang (A)" , Chen Guokai , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, rostedt@goodmis.org, mingo@redhat.com, sfr@canb.auug.org.au Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 7/9] riscv/kprobe: Prepare detour buffer for optimized kprobe In-Reply-To: <088ed826-59a8-37a3-401e-2ed022a4a097@huawei.com> 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> Date: Wed, 04 Jan 2023 10:12:23 +0100 Message-ID: <87sfgqr7d4.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 "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 R= VC >>> + * and 1 RVI instructions is about to execute out of line. >>> + */ >>> + nop >>=20 >> 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? >>=20 > > 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, t= hanks. 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 Bj=C3=B6rn