Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp956744pxb; Thu, 5 Nov 2020 18:48:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyp36sE91PdPr1GTwmRHvkrrVPMvtPT750snFg13qjLOwRho0IIVu9qP7mvzoGC8U/AeYoK X-Received: by 2002:aa7:d717:: with SMTP id t23mr5735329edq.286.1604630904834; Thu, 05 Nov 2020 18:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604630904; cv=none; d=google.com; s=arc-20160816; b=QMIB5xSeNK2GcH8XlEv+i48r2X5Yr/uuu+CZ9GY48IpPclfagV+0pcsCET68nGFrp5 yTKMnBUVB0r1tyZNgF/qNbNrNz9oyFeWq8djE/4IgNJ/rRZWQ6k6e1p2RvRPSsE54b9Y 0ewbr1GJPny6dWhexAKIFxlFLB8IbmzhreVcQRhSI0e+qFgXMbQRd6WmkMcfATQ4nzHx EJvsK+NweR+BJVpd9ECNnumb7+vhDKEjRE2Ud5AGkPDGkhgCnJL52iR/qMZiYP/YAR1F 0c5ap977IEPlDhJ+Oo5Tx3uJmXehMYG+RQfVNMP9/KU/+3rZf+Yk+cCOBQD+fjhpnbpy V4rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tutAlePyK+Psaiz2GHMqJnxIRetZRhM+Rh3wtDsmeOI=; b=cXSA9PFj0Olokx6FEIz+NFSWC15F+VXxyuO5s+OXaVYb/5sBEQkYyVzV/vs8Pikwmz qLlOw0zLYVpHp28RklSWfa2W3MDcHpLZCAJPa2k+XGSq3glSAUp+5c9gzg2Vz1EFtfZp llzMPvSZ6GbZ8VfCyKsunILDVO8khll30jHNxCCx1SVtJ+w/CMtp5O0lI+HKZPY/Rc5M riabChn3M7DNNULqMbs51YjhzWxXYJgULFmD2XUgOgpRwwb+xTr+VWJqK848Lsn+lGrb 5BbA4G4rG58JBWp0yEUclbru9XBp84kJscnx6HR2w4jXzDZYprtmMxbudWeFpEX3Wkbv cH4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ei7E9EzW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hh16si2871198ejb.229.2020.11.05.18.47.58; Thu, 05 Nov 2020 18:48:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ei7E9EzW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1725893AbgKFCo3 (ORCPT + 99 others); Thu, 5 Nov 2020 21:44:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:42638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbgKFCo3 (ORCPT ); Thu, 5 Nov 2020 21:44:29 -0500 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C1962222A; Fri, 6 Nov 2020 02:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604630668; bh=u+MZqpvWInkjbiTiRhNhcfi5HyG0jDJfzIXf8mkzRTg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ei7E9EzWODWPV5ah0DiLrbW98dz4Cu/ApdiQXCoX3LOtv1wbjOROSXudjGF1vCpAs uaeVkcFwBVPYT7bkgoH41JFxsOpSF1ksEI4PRLHEyisritj0RpfeZRN2ubENGk5RHh ERomM+zEfTpynT4hYmTGzjaW6f7BmQoRI5mx6nJQ= Received: by mail-lj1-f170.google.com with SMTP id m16so3744946ljo.6; Thu, 05 Nov 2020 18:44:28 -0800 (PST) X-Gm-Message-State: AOAM533vm1MaQdFLRLrWbJc/CGei6r/Wynlm37tKKq6Rjl27ptY3Ilyn A6+m9mxywaZeMm/8UlBeGmlcjK8AlEF+xPhnMt4= X-Received: by 2002:a2e:b00d:: with SMTP id y13mr1855504ljk.346.1604630666154; Thu, 05 Nov 2020 18:44:26 -0800 (PST) MIME-Version: 1.0 References: <20201021073839.43935-1-zong.li@sifive.com> <20201030202818.72070cbd@oasis.local.home> In-Reply-To: From: Guo Ren Date: Fri, 6 Nov 2020 10:44:14 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] stop_machine: Mark functions as notrace To: Atish Patra Cc: Steven Rostedt , Zong Li , Paul McKenney , josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, joel@joelfernandes.org, vincent.whitchurch@axis.com, Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Masami Hiramatsu , Greentime Hu , Colin Ian King , rcu@vger.kernel.org, Linux Kernel Mailing List , linux-riscv Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 3, 2020 at 11:33 PM Atish Patra wrote: > > On Sat, Oct 31, 2020 at 12:42 AM Guo Ren wrote: > > > > On Sat, Oct 31, 2020 at 8:28 AM Steven Rostedt wrote: > > > > > > On Fri, 30 Oct 2020 14:47:56 -0700 > > > Atish Patra wrote: > > > > > > > > Look at arm64, they __kprobes flag and I guess it would also prevent > > > > > ftrace call site. > > > > > > > > > > > > > Are you sure about that ? __kprobes puts the code in .kprobes.text section > > > > which is under whitelist sections in recordmcount.pl & recordmcount.c. > > > > > > Correct, ftrace can trace functions marked with __kprobes. That said, > > I guess wrong, thx for correct me. > > > > > the instruction you are looking at here, is in a file that is > > > blacklisted from recordmcount. > > > > > > CFLAGS_REMOVE_insn.o = $(CC_FLAGS_FTRACE) > > > > > > All ftrace flags are removed from the compiling of insn.c, and every > > > function in that file will not be traced. > > Yes, arm64 prevents the whole file from ftrace. My patch just use > > notrace flag setting on some functions. > > > > @Atish How do think: > > CFLAGS_REMOVE_cacheflush.o = $(CC_FLAGS_FTRACE) > > CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE) > > > > Looks good to me. What should be done for copy_to_kernel_nofault ? > That is also in the calling path. There is no nops' entry in the prologue of copy_to_kernel_nofault. >>>> 000000000000007c <.LVL6>: } 7c: 6105 addi sp,sp,32 7e: 8082 ret 0000000000000080 : * * Safely write to address @dst from the buffer at @src. If a kernel fault * happens, handle that and return -EFAULT. */ long copy_to_user_nofault(void __user *dst, const void *src, size_t size) { 80: 1101 addi sp,sp,-32 82: e822 sd s0,16(sp) 84: ec06 sd ra,24(sp) 86: e426 sd s1,8(sp) 88: e04a sd s2,0(sp) 8a: 1000 addi s0,sp,32 <<<< >>>> cmd_mm/maccess.o := /root/source/riscv-tools/install_64gc/bin/riscv64-unknown-linux-gnu-gcc -Wp,-MMD,mm/.maccess.o.d -nostdinc -isystem /root/source/riscv-tools/install_64gc/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.4.0/include -I./arch/riscv/include -I./arch/riscv/include/generated -I./include -I./arch/riscv/include/uapi -I./arch/riscv/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ ***-DCC_USING_PATCHABLE_FUNCTION_ENTRY*** -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mabi=lp64 -march=rv64imac -mno-save-restore -DCONFIG_PAGE_OFFSET=0xffffffe000000000 -mcmodel=medany -fno-omit-frame-pointer -mstrict-align -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g ***-fpatchable-function-entry=8*** -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DKBUILD_MODFILE='"mm/maccess"' -DKBUILD_BASENAME='"maccess"' -DKBUILD_MODNAME='"maccess"' -c -o mm/maccess.o mm/maccess.c <<<< But copy_from_user_nofault has: 000000000000007c <.LVL6>: } 7c: 6105 addi sp,sp,32 7e: 8082 ret 0000000000000080 : * * Safely write to address @dst from the buffer at @src. If a kernel fault * happens, handle that and return -EFAULT. */ long copy_to_user_nofault(void __user *dst, const void *src, size_t size) { 80: 1101 addi sp,sp,-32 82: e822 sd s0,16(sp) 84: ec06 sd ra,24(sp) 86: e426 sd s1,8(sp) 88: e04a sd s2,0(sp) 8a: 1000 addi s0,sp,32 I think it's a gcc problem, but satisfy our ftrace requirement. -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/