Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp168544ybt; Tue, 23 Jun 2020 18:28:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFDJPCsH+hvR1csy4uLZoyNhp2bHR90OwOFQ0kVV6LS9p0cYCn971KOvQxLVg6jiZHL8bk X-Received: by 2002:a05:6402:22b0:: with SMTP id cx16mr17356600edb.48.1592962084738; Tue, 23 Jun 2020 18:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592962084; cv=none; d=google.com; s=arc-20160816; b=bsvf9yyTOK7ase8isjLpYts/0kGxUD22FITHTw/Bo3m+zSe/oLo02+ubfLdzj2HAUA Ef7PKK9EI/hSy2GZ0hujI04ThEUhFtg4VJ5CdLev0gyKgHsecbjy9lEuML2Z9+5XHMS0 S4cce1xuhdZs4niiFaZAnA+NwWbpzF8UayRZUTXuA6/zKPfW7gzCngUerMopr8sagv0h m//fPHoKk58BHfiWFYv7LIOi41DThWqBgeK2kV0SPNY8QI0LKg+teFaC/33CHpdIGxW3 cZ+BqXLhjWTY3xORP1M/qX3ABG0G0lMEY1TL+XN4+RZBm9v9kqJR/CMlojZmnrAsysp+ 2wSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5WqxirMnj7b1Z9cfj2+T6ttey+7IO6/UmXnBcAnlL5o=; b=R5QTAdoXEuXDw/nLBR6M2Qk/uRdPloxtrex5acjVTqRuPhhOG9Pg1NGA87nYTXun8d g4PJdalkQ9CYuAdUTIJFFuboByjik+RzibAZ/B1sF0yyiFD7WjS87fQa1LONvdW+P/zv 1xo3UP7RxPvl3EyS2dusWXGUl/3Px/z2O0Uxh31/AuiYuhXLnHjyKkAI+bqi8IcN5c1O PfrVcFO1gLhCSYibeY6Ki7uCeri9P72uVJSvA1oKUoWqk8LnfFGn8/SquUa1JPAV7bfg SekuHMDm0NW+AOYos6cxCXPgb1d/g7WGSsoTuzsLFgO2682oOpkwC2CNVymxBFsATSU6 gC0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=WVLsE6GK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si12593972ejc.125.2020.06.23.18.27.41; Tue, 23 Jun 2020 18:28:04 -0700 (PDT) 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=@sifive.com header.s=google header.b=WVLsE6GK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388393AbgFXB1J (ORCPT + 99 others); Tue, 23 Jun 2020 21:27:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387842AbgFXB1J (ORCPT ); Tue, 23 Jun 2020 21:27:09 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF622C061573 for ; Tue, 23 Jun 2020 18:27:07 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id h22so351872pjf.1 for ; Tue, 23 Jun 2020 18:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5WqxirMnj7b1Z9cfj2+T6ttey+7IO6/UmXnBcAnlL5o=; b=WVLsE6GKyBKghjtlRRoqw+jK/TkSzt8Y8R9lLFgI6U17GJv2Jvt3eaK4wnyXiYkWGe 0Q6xvjT2TTBQmCmpzfKIdWZyrA44Rsvtn4AEzq9q2mBI/8/lZ67M1xVML+5ZTrZ1fmcY wH91F75UMO6Rzq9wkwYCenEUF3tWyu/dgat633p8XzrFPm8nuv14uQ8sIwOPg+YsdWjl 6fze+c9CqheqViv+bIGiXHVV/CKxC/q7Jd3UTEiVoXfCn1xkK6q+ULskWtoj0BzLLbD4 uhFIYPejKK1BB/uahHDwsSDmuEt2YYO9fDJkURJsuxbjWUCqR9T5TGfpO08bN5IbfThA bmrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5WqxirMnj7b1Z9cfj2+T6ttey+7IO6/UmXnBcAnlL5o=; b=AaEX8ojpvcG1TptukMMs9TTuZf1wFcO7n4A73upMo5Zsa7LQVyK6dq02ISdAfGoi2y 1++vo4gYKfit20rMpkHbgb1SIxK700QSEgpqVya6R2rQX9wIp8Tr4YNqng/V4OkRvdSS MSLydr3d2xsg9IhrBihntQAWPQfCHZi8Ts1H1OXo2hLkxgs0I6CvlVhtkHmIRjScAx2L iZxwwGsgZp6VgWDs3L3VVpeS/9CniSVw2jk/NSDBfCSk6AqBbHtnMcmJte9X60wZOru1 S6osYRABfIR2g+sIOjZCWQTrHZGz9atRujLNBUV0TEicb6V1d9t7xlEI9BKZ6XwuCmH0 DoDg== X-Gm-Message-State: AOAM5328Hvxirkww0dtHmpFrfAubvkYXxDtZ9M2IuZXmvR5oyKZeBRRg /fEp+z+zMppR0cJr3REA9koVpyEzMWjZrHDN+28B1u80GmBroQ== X-Received: by 2002:a17:90a:acf:: with SMTP id r15mr27081700pje.171.1592962027133; Tue, 23 Jun 2020 18:27:07 -0700 (PDT) MIME-Version: 1.0 References: <1592905854-60833-1-git-send-email-guoren@kernel.org> In-Reply-To: From: Vincent Chen Date: Wed, 24 Jun 2020 09:26:56 +0800 Message-ID: Subject: Re: [PATCH] riscv: Fixup __vdso_gettimeofday broke dynamic ftrace To: Greentime Hu Cc: Guo Ren , linux-riscv , Linux Kernel Mailing List , Paul Walmsley , Albert Ou , Guo Ren , Atish Patra , Palmer Dabbelt , Alan Kao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 23, 2020 at 9:27 PM Greentime Hu wrote: > > =E6=96=BC 2020=E5=B9=B46=E6=9C=8823=E6=97=A5 =E9=80= =B1=E4=BA=8C =E4=B8=8B=E5=8D=885:52=E5=AF=AB=E9=81=93=EF=BC=9A > > > > From: Guo Ren > > > > For linux-5.8-rc1, enable ftrace of riscv will cause boot panic: > > > > [ 2.388980] Run /sbin/init as init process > > [ 2.529938] init[39]: unhandled signal 4 code 0x1 at 0x0000003ff449e= 000 > > [ 2.531078] CPU: 0 PID: 39 Comm: init Not tainted 5.8.0-rc1-dirty #1= 3 > > [ 2.532719] epc: 0000003ff449e000 ra : 0000003ff449e954 sp : 0000003= fffedb900 > > [ 2.534005] gp : 00000000000e8528 tp : 0000003ff449d800 t0 : 000000= 000000001e > > [ 2.534965] t1 : 000000000000000a t2 : 0000003fffedb89e s0 : 000000= 3fffedb920 > > [ 2.536279] s1 : 0000003fffedb940 a0 : 0000003ff43d4b2c a1 : 000000= 0000000000 > > [ 2.537334] a2 : 0000000000000001 a3 : 0000000000000000 a4 : ffffff= fffbad8000 > > [ 2.538466] a5 : 0000003ff449e93a a6 : 0000000000000000 a7 : 000000= 0000000000 > > [ 2.539511] s2 : 0000000000000000 s3 : 0000003ff448412c s4 : 000000= 0000000010 > > [ 2.541260] s5 : 0000000000000016 s6 : 00000000000d0a30 s7 : 000000= 3fffedba70 > > [ 2.542152] s8 : 0000000000000000 s9 : 0000000000000000 s10: 000000= 3fffedb960 > > [ 2.543335] s11: 0000000000000000 t3 : 0000000000000000 t4 : 000000= 3fffedb8a0 > > [ 2.544471] t5 : 0000000000000000 t6 : 0000000000000000 > > [ 2.545730] status: 0000000000004020 badaddr: 00000000464c457f cause= : 0000000000000002 > > [ 2.549867] Kernel panic - not syncing: Attempted to kill init! exit= code=3D0x00000004 > > [ 2.551267] CPU: 0 PID: 1 Comm: init Not tainted 5.8.0-rc1-dirty #13 > > [ 2.552061] Call Trace: > > [ 2.552626] [] walk_stackframe+0x0/0xc4 > > [ 2.553486] [] show_stack+0x40/0x4c > > [ 2.553995] [] dump_stack+0x7a/0x98 > > [ 2.554615] [] panic+0x114/0x2f4 > > [ 2.555395] [] do_exit+0x89c/0x8c2 > > [ 2.555949] [] do_group_exit+0x3a/0x90 > > [ 2.556715] [] get_signal+0xe2/0x6e6 > > [ 2.557388] [] do_notify_resume+0x6a/0x37a > > [ 2.558089] [] ret_from_exception+0x0/0xc > > > > "ra:0x3ff449e954" is the return address of "call _mcount" in the > > prologue of __vdso_gettimeofday(). Without proper relocate, pc jmp > > to 0x0000003ff449e000 (vdso map base) with a illegal instruction > > trap. > > > > The solution comes from arch/arm64/kernel/vdso/Makefile: > > > > CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS= ) > > > > - CC_FLAGS_SCS is ShadowCallStack feature in Clang and only > > implemented for arm64, no use for riscv. > > > > The bug comes from the following commit: > > > > ad5d1122b82f ("riscv: use vDSO common flow to reduce the latency of the= time-related functions") > > > > Signed-off-by: Guo Ren > > Cc: Vincent Chen > > Cc: Atish Patra > > Cc: Palmer Dabbelt > > Cc: Alan Kao > > Cc: Greentime Hu > > --- > > arch/riscv/kernel/vdso/Makefile | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/M= akefile > > index 38ba55b..3079935 100644 > > --- a/arch/riscv/kernel/vdso/Makefile > > +++ b/arch/riscv/kernel/vdso/Makefile > > @@ -27,6 +27,9 @@ obj-vdso :=3D $(addprefix $(obj)/, $(obj-vdso)) > > obj-y +=3D vdso.o vdso-syms.o > > CPPFLAGS_vdso.lds +=3D -P -C -U$(ARCH) > > > > +# Disable -pg to prevent insert call site > > +CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_FTRACE) -Os > > + > > # Disable gcov profiling for VDSO code > > GCOV_PROFILE :=3D n > > > > Thank you, Guo. > I encounter the same bug in v5.8-rc2. > This patch works. > > Tested-by: Greentime Hu Sorry for any inconvenience caused by my mistake and thank you for resolving this bug. It looks good to me. Reviewed-by: Vincent Chen