Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984AbeAOHY5 (ORCPT + 1 other); Mon, 15 Jan 2018 02:24:57 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:37047 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751329AbeAOHYz (ORCPT ); Mon, 15 Jan 2018 02:24:55 -0500 X-Google-Smtp-Source: ACJfBovT/mnjTXJ3FsZROJTM2XgnCJ2NkYZhf+Vsog0/Qx/N1kkS7025B3L1Ve8rz0cCZZVWw/2dr1ffMCWyHBU1Wkc= MIME-Version: 1.0 In-Reply-To: <20180115064742.25324-3-alankao@andestech.com> References: <20180115064742.25324-1-alankao@andestech.com> <20180115064742.25324-3-alankao@andestech.com> From: "Stefan O'Rear" Date: Sun, 14 Jan 2018 23:24:53 -0800 Message-ID: Subject: Re: [patches] [PATCH v2 2/6] riscv/ftrace: Add dynamic function tracer support To: patches@groups.riscv.org Cc: Palmer Dabbelt , Albert Ou , Christoph Hellwig , Steven Rostedt , Ingo Molnar , Masahiro Yamada , Kamil Rytarowski , Andrew Morton , linux-kernel@vger.kernel.org, Alan Kao , Greentime Hu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Sun, Jan 14, 2018 at 10:47 PM, Alan Kao wrote: > + /* > + * For the dynamic ftrace to work, here we should reserve at least > + * 8 bytes for a functional auipc-jalr pair. Pseudo inst nop may be > + * interpreted as different length in different models, so we manually > + * *expand* two 4-byte nops here. > + * > + * Calling ftrace_update_ftrace_func would overwrite the nops below. > + * Check ftrace_modify_all_code for details. > + */ > + addi x0, x0, 0 > + addi x0, x0, 0 This relies on behavior of the assembler which is undocumented and, if my reading of the specification is correct, a bug. The documented way to assemble an sequence of 2 4-byte NOPs regardless of subtarget is as follows: .option push .option norvc nop nop .option pop I have filed https://github.com/riscv/riscv-binutils-gdb/issues/135 to get clarity on the assembler behavior; the explicit approach may be preferable even if the assembler behavior turns out to be correct. -s