Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp327855ybh; Mon, 20 Jul 2020 18:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4ahprcpNhE+Vx+WGqFtaxFpe//mZDUJkzHpUcM4hsCghmNBXVmykTeoZM/1ntyp/GzRvy X-Received: by 2002:a17:906:ce43:: with SMTP id se3mr22754707ejb.543.1595293929993; Mon, 20 Jul 2020 18:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595293929; cv=none; d=google.com; s=arc-20160816; b=KWanbow1/MjuvNo3bnLAhMRXWvLA9y8PH/7AZYYnr7Et0BsbcymFKMGba04fM6nta1 TMXe3KKFPpXmAOlP7P00n8cbCRrUFsSH0o24GLHpXColM72zTRaniqpQth5tdvt91lIg Cpm2iS+xxgJomNeTIRczbvDp9oHJhj9IjyBP0p/7wnxz2eRs+iam/iFATADb3hMezPhx cnxPKwIS9gMn7Yt3FNVIYmdjSRK1ZC9/TnEM74urhIqSzBrvjtg2+53Pq9q1Ym1s9Zn4 sDcSub097HWkaWDqt3iDTl+aTTPmyLzwHMOXhDrBSgGy9giWpNDA+MPmLQjLoEgnXW43 iV2w== 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:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=gkVwrlwYmgNFDT5XRE1O5q8mSuD5zpRetSCBX/aZTqM=; b=SCOGnuO1ZPgvuOs4vDmo98kxLPCg8NMZjfiFtnb3J2und2yB4pHQej2wZC+ioBEPwy nbDy0S3oZSJM86nj8MXTVHebTp6t2wXS04gXTDM9t2YNv8b7N7WRvqfBXWRm7W9PjtS2 Xj0rqT2JpfSf9d4uqOIykITmM4sVJFjPb/c3Ob2IhXU0AZq+ggmoztN4eiCJkbcxeaGO Fq2+ChwyT+Wssh5y4lXD+s6bu9ZObzu4jQihLN5ywjPDxJZIidkO1aE36JS7MHa4vcTb hRaNgV7UnQUZLVsF2YCZyMaOO4fPFhV0rb7aR8Axrkx7a6zLqjpYPBrW2PxH6ze8O0F8 Cj7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GnJa1tYY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt3si11376672ejc.325.2020.07.20.18.11.46; Mon, 20 Jul 2020 18:12:09 -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=@google.com header.s=20161025 header.b=GnJa1tYY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728092AbgGUBK6 (ORCPT + 99 others); Mon, 20 Jul 2020 21:10:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgGUBK5 (ORCPT ); Mon, 20 Jul 2020 21:10:57 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8421BC0619D5 for ; Mon, 20 Jul 2020 18:10:57 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id a24so9922617pfc.10 for ; Mon, 20 Jul 2020 18:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=gkVwrlwYmgNFDT5XRE1O5q8mSuD5zpRetSCBX/aZTqM=; b=GnJa1tYYo+Em6pZ/CY6/bvN2rPpSCTHkGcqeuRF+deo/vPfmwsn61aZMAwz3AU8PjC VLBUodyc+p0ogqlYwmbiN7KIW0Aj5/0iebDBzr5RueHUTLAIl9FXN5eXgrCsKkJefnYk IlEDVw3mkrB5Oxf/UwJ6JplYT+/y84ysa8SoW+6nfI/iBpu3swXbptcyVvi6qdaUbCJZ p2iNqKoO/2saBE2zRtDPVUjqrvXDxszThY2s7oYhLOsYhxoL9AwJHbTlJ4H6ACGJM/ho f2cpNUdU666IyDxHGP9VOxj5bpDs8WLoCQpvlaonrFqRpLIlEEPQHGbYKq8O++1KqveF iluA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=gkVwrlwYmgNFDT5XRE1O5q8mSuD5zpRetSCBX/aZTqM=; b=S1GJE4yGXhwb8rGiKxoZWkIo+d6qzE+JUo7LGcO9Lo6juq4XdGpbqZmT/W29omrzCP lVGhVWZlget+DqxQ8dMJdWJb8dGzat9pODP3dG/blDj6Mk2GjQVI6O8v5iSJzp52wJaG sYCmZfLVzRN/1xQysrSN79MmiaufmRPHa6Z9JL4ihq4CXyTwwYwoYpJDiPDDDomSMpqo c2zJff5faBSAVoRpFsS/jC/3urTKd43gZr+0/n+YuK7ImTW+5irk5SBa43DYoQNAq4tY c9P1icn4lD++23PrHk4jOKWarP2L3W/x44uRDRz9kxPvdDXbjZ/s+MOecMywe0ptoq+f p0YA== X-Gm-Message-State: AOAM530GioN1NPSx7kLfIpDyEl0brv5uMpUJjUdEeWGMEoRjiZ26hcYm Gk+auPu6hbiYjfyTDVEff/IMRg== X-Received: by 2002:a63:7a56:: with SMTP id j22mr19904601pgn.194.1595293856800; Mon, 20 Jul 2020 18:10:56 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id c30sm18043111pfj.213.2020.07.20.18.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 18:10:56 -0700 (PDT) Date: Mon, 20 Jul 2020 18:10:56 -0700 (PDT) X-Google-Original-Date: Mon, 20 Jul 2020 18:10:53 PDT (-0700) Subject: Re: [PATCH v2 1/6] riscv: Fixup __vdso_gettimeofday broke dynamic ftrace In-Reply-To: <1594261154-69745-2-git-send-email-guoren@kernel.org> CC: Paul Walmsley , anup@brainfault.org, greentime.hu@sifive.com, zong.li@sifive.com, me@packi.ch, Bjorn Topel , Atish Patra , penberg@kernel.org, mhiramat@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, guoren@kernel.org, guoren@linux.alibaba.com, vincent.chen@sifive.com, alankao@andestech.com, green.hu@gmail.com From: Palmer Dabbelt To: guoren@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 08 Jul 2020 19:19:09 PDT (-0700), guoren@kernel.org wrote: > 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 0x0000003ff449e000 > [ 2.531078] CPU: 0 PID: 39 Comm: init Not tainted 5.8.0-rc1-dirty #13 > [ 2.532719] epc: 0000003ff449e000 ra : 0000003ff449e954 sp : 0000003fffedb900 > [ 2.534005] gp : 00000000000e8528 tp : 0000003ff449d800 t0 : 000000000000001e > [ 2.534965] t1 : 000000000000000a t2 : 0000003fffedb89e s0 : 0000003fffedb920 > [ 2.536279] s1 : 0000003fffedb940 a0 : 0000003ff43d4b2c a1 : 0000000000000000 > [ 2.537334] a2 : 0000000000000001 a3 : 0000000000000000 a4 : fffffffffbad8000 > [ 2.538466] a5 : 0000003ff449e93a a6 : 0000000000000000 a7 : 0000000000000000 > [ 2.539511] s2 : 0000000000000000 s3 : 0000003ff448412c s4 : 0000000000000010 > [ 2.541260] s5 : 0000000000000016 s6 : 00000000000d0a30 s7 : 0000003fffedba70 > [ 2.542152] s8 : 0000000000000000 s9 : 0000000000000000 s10: 0000003fffedb960 > [ 2.543335] s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000003fffedb8a0 > [ 2.544471] t5 : 0000000000000000 t6 : 0000000000000000 > [ 2.545730] status: 0000000000004020 badaddr: 00000000464c457f cause: 0000000000000002 > [ 2.549867] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 > [ 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 = $(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 > Reviewed-by: Pekka Enberg > 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/Makefile > index 38ba55b..3079935 100644 > --- a/arch/riscv/kernel/vdso/Makefile > +++ b/arch/riscv/kernel/vdso/Makefile > @@ -27,6 +27,9 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) > obj-y += vdso.o vdso-syms.o > CPPFLAGS_vdso.lds += -P -C -U$(ARCH) > > +# Disable -pg to prevent insert call site > +CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os > + > # Disable gcov profiling for VDSO code > GCOV_PROFILE := n As far as I can tell this is already in Linus' tree. LMK if I'm missing something.