From patchwork Wed May 25 16:04:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 12861419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1825C433F5 for ; Wed, 25 May 2022 16:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CbttlHJbaPMuUxEyc8ncsc4J1Y1eKVF6mSHgEdMak04=; b=uAtcVfYCfv5mnN E72kez3aI6JbgCyhZVsm4fMvSa6FMl/Q4YXSjPFJON9EBZNiGd8Mozgppj3zkSpNUoe3J3xgNmHs/ swkBsBAmNrPGYQdzchR/TDxJLsLNNCIVs/zFvwyNmRxbeU5rEKqczFISs33TKA25J19Dw2IbX+fG4 W3Sa3INTLxRjby4xyg2RQJYUCy3tXTDVNmZlYkYveawovdxUWgOhTpuFDqJixWMHNEV9FkrVYP1xs PKaZn7GZsOCpZhejdqTCVoeMChmDV1P3uF0v826nO1WmlmSiZ9KG+Uj64BPdXb/j5mMltn5P/en/u AsPbjLiBvsM5JrwUPLWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nttUq-00BlC7-7Q; Wed, 25 May 2022 16:04:28 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nttUm-00BlAy-U8 for linux-riscv@lists.infradead.org; Wed, 25 May 2022 16:04:26 +0000 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 sin.source.kernel.org (Postfix) with ESMTPS id A76A5CE1F7B; Wed, 25 May 2022 16:04:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF2EEC385B8; Wed, 25 May 2022 16:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653494652; bh=9SsmUxRspR26RN2LNvw0etslFl1c4fkjQCM9Ey0idec=; h=From:To:Cc:Subject:Date:From; b=SugjF9n+aZoxi+E3o/AOBu3PmbEXcq2JYOU+7DP2xhuvWJD5WCyvChXVA/9SSctCV +fwRuJ58O4VXbgZ+iX4yCVi4zm0TE7XLQVo973sWHAf6Vooj1gGl+zaQ6ymWvH291b JsCcAwuS/6ofu5SHzgRXom/y1HoBsXAfQwSxhoxV2XUL4RYrKZtWwZ6ufyT86scMwn hM2TojGU0hi/W8/QZKuCGqSko965sfkMaAo1enGMVkHkU2kduNtwhZWIQoPJP0VerJ Iem0GPGqoBIRxkQlpVkLOntzZlZkvTeELsziD1DErGw/cU9cUQPd6hFRW1CbneX+uJ wLj7qxzTCmJgg== From: guoren@kernel.org To: palmer@rivosinc.com, arnd@arndb.de, linux@roeck-us.net, palmer@dabbelt.com, heiko@sntech.de Cc: linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Guo Ren , Guo Ren Subject: [PATCH] riscv: compat: Using seperated vdso_maps for compat_vdso_info Date: Wed, 25 May 2022 12:04:04 -0400 Message-Id: <20220525160404.2930984-1-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220525_090425_368644_41478375 X-CRM114-Status: GOOD ( 12.28 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Guo Ren This is a fixup for vdso implementation which caused musl to fail. [ 11.600082] Run /sbin/init as init process [ 11.628561] init[1]: unhandled signal 11 code 0x1 at 0x0000000000000000 in libc.so[ffffff8ad39000+a4000] [ 11.629398] CPU: 0 PID: 1 Comm: init Not tainted 5.18.0-rc7-next-20220520 #1 [ 11.629462] Hardware name: riscv-virtio,qemu (DT) [ 11.629546] epc : 00ffffff8ada1100 ra : 00ffffff8ada13c8 sp : 00ffffffc58199f0 [ 11.629586] gp : 00ffffff8ad39000 tp : 00ffffff8ade0998 t0 : ffffffffffffffff [ 11.629598] t1 : 00ffffffc5819fd0 t2 : 0000000000000000 s0 : 00ffffff8ade0cc0 [ 11.629610] s1 : 00ffffff8ade0cc0 a0 : 0000000000000000 a1 : 00ffffffc5819a00 [ 11.629622] a2 : 0000000000000001 a3 : 000000000000001e a4 : 00ffffffc5819b00 [ 11.629634] a5 : 00ffffffc5819b00 a6 : 0000000000000000 a7 : 0000000000000000 [ 11.629645] s2 : 00ffffff8ade0ac8 s3 : 00ffffff8ade0ec8 s4 : 00ffffff8ade0728 [ 11.629656] s5 : 00ffffff8ade0a90 s6 : 0000000000000000 s7 : 00ffffffc5819e40 [ 11.629667] s8 : 00ffffff8ade0ca0 s9 : 00ffffff8addba50 s10: 0000000000000000 [ 11.629678] s11: 0000000000000000 t3 : 0000000000000002 t4 : 0000000000000001 [ 11.629688] t5 : 0000000000020000 t6 : ffffffffffffffff [ 11.629699] status: 0000000000004020 badaddr: 0000000000000000 cause: 000000000000000d The last __vdso_init(&compat_vdso_info) replaces the data in normal vdso_info. This is an obvious bug. Reported-by: Guenter Roeck Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Palmer Dabbelt Cc: Heiko Stübner Tested-by: Heiko Stuebner Tested-by: Guenter Roeck --- arch/riscv/kernel/vdso.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index 50fe4c877603..69b05b6c181b 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -206,12 +206,23 @@ static struct __vdso_info vdso_info __ro_after_init = { }; #ifdef CONFIG_COMPAT +static struct vm_special_mapping rv_compat_vdso_maps[] __ro_after_init = { + [RV_VDSO_MAP_VVAR] = { + .name = "[vvar]", + .fault = vvar_fault, + }, + [RV_VDSO_MAP_VDSO] = { + .name = "[vdso]", + .mremap = vdso_mremap, + }, +}; + static struct __vdso_info compat_vdso_info __ro_after_init = { .name = "compat_vdso", .vdso_code_start = compat_vdso_start, .vdso_code_end = compat_vdso_end, - .dm = &rv_vdso_maps[RV_VDSO_MAP_VVAR], - .cm = &rv_vdso_maps[RV_VDSO_MAP_VDSO], + .dm = &rv_compat_vdso_maps[RV_VDSO_MAP_VVAR], + .cm = &rv_compat_vdso_maps[RV_VDSO_MAP_VDSO], }; #endif