Message ID | 20231127-module_linking_freeing-v4-0-a2ca1d7027d0@rivosinc.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3495553vqx; Mon, 27 Nov 2023 14:05:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhWcD9pJt34M/qos1qQv2SsdDcblfakosD5DVyOBnMa8lhtG60yfB0SP/CF9EI7NWXWrwN X-Received: by 2002:a17:902:e88b:b0:1cf:d404:5e7c with SMTP id w11-20020a170902e88b00b001cfd4045e7cmr5174462plg.42.1701122741553; Mon, 27 Nov 2023 14:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701122741; cv=none; d=google.com; s=arc-20160816; b=kGE2rRqeuwzDQYoQrRk/ku6qdMC8ZpJkYMGIV6JSkfx9jjn6f5JyE/uOR+4NoUpaud 3uEyFWBRjDeGC7crEtYmxAQesv0j4Qw000xpR+hdXrEZ1gldNoekbvcC+SWdS3mVdm3j wifG06At8z1xphOyX6VKXs7m82cBeDXdWGvHORZFdu22gSRYKQSCADgwdMWhvOnZ30g3 m/IFc1pYNTfW7Iq2hTixrDMRub1ExXu5baYl/9cgxUw5qfTid6cU+mJL4WXuJJ0RWZxC O48pUjNtxL9WG+rxkfnWT9pM5x4lJEDlCNy0o74/1rs6eUxxfTBMyJqTWDmpbhBLbNt/ FwbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=ddP9Seydg6uEHR4Cvl6RvAssgCZN9rnWQDGKZ5eImoI=; fh=JJWLC8JDTrLhOtDGzmNVOTlcKjXUUCXUAyo0QdPUBPI=; b=VYMKXN8Dl+os1nsQGbxBhdKn57bUrmtHbqlUMP5hkytBwsPE8grOE2nGgd/Y3BcR5T gDSZroZmo6kytgPiOUI/+4G4iWPGE9Y4ytaDdGkrkST3VNjo10hUHI+cWhYDD+3FntnL aU4QVEW129XSm4fYGUzp70ozCjixnx5fiopbsJM0rdaeDxU1+s8sKdwFnYxYb+O+RG1S p7BSHMYCxdhJWW5nkHk2DK3+xypElNKB7bABC32HMjRyPLmmWnmuOFEGrfonRUlgKGED XinfmGS2B2ZAIxq52TQeujyCO+YmTfbxMi/oMcBvB2ztSD35qI3iK81A6gP1LCctVT0L wUgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ncEyNEJb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x5-20020a1709029a4500b001bdd0d0530dsi9783038plv.129.2023.11.27.14.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:05:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ncEyNEJb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9BF09807C550; Mon, 27 Nov 2023 14:05:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233435AbjK0WFL (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 17:05:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbjK0WFK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 17:05:10 -0500 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B3781A1 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:05:16 -0800 (PST) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-1f5da5df68eso2860033fac.2 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701122715; x=1701727515; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=ddP9Seydg6uEHR4Cvl6RvAssgCZN9rnWQDGKZ5eImoI=; b=ncEyNEJbvWhsaBY29eJFOGggCC34Ka0RjJ4NQBqiLZ7viuMrEYpcP/Wt99+lI9MqOC XTj4dGFtdGnxSU0Q4CgqvE1GJEswqrYqGrfnkBuHCl/hUkvT+2jUCsV2RgDaBHpmGPEM O93paTRA018yacQrvlyrR7clJLmCY3H9gzeRMqgSHAcJLfNAbqHaRtQaiaihP6n91HiJ /4m+kG7ikeLeUtuej0X6etHW20NZMfeBVlkhUzt+QvKDUqSewD4VGAr7s/FRZ6NKCCBq o7PUy2/oeb+ubNt28RKdndhH5GCGsu2lZ6PYgsDHPLTZE3kVFM/8ANy/rhm9A5K9VUUr Gd2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701122715; x=1701727515; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ddP9Seydg6uEHR4Cvl6RvAssgCZN9rnWQDGKZ5eImoI=; b=Iyh9/wk8E1c/kjI0ygqdV9l8qOQLYkxP+3pA6pb53Pqra8QrZ5oKjZvWQCee/ZFoKo 4qZdxwpEFXZhENHRzxeVILP1w6oL7o9LlrLQnngHWVjCLKdX9ZFkHweqnkmUESuBz66T KpX3Fk92cMNDuhhxRWNksxOiXGsED5ofw+3yUXLy2GpnuZHprC3BWRfu+amBToQhDA4i GLuPdOtY9GmaoVcsvkhlzFTiVSKmn8aHJkSxbzZHDHbno1xbrj7EKr58xAemhR9WmXGQ iuGIRuLkz3BYjwyhm/AFqRrZAFPjqHaySrvQJpvB5Rz7tx6yCYXxpKIet3eZVFORtFeB GrKg== X-Gm-Message-State: AOJu0Ywg14eNDNrQoOO1jZlr1Io5FrqU4imkZ94WrfyhTLngysnTAqGs WXvjiDNYbNbj+J8BkeSlI2doYA== X-Received: by 2002:a05:6870:b88:b0:1fa:1c63:738d with SMTP id lg8-20020a0568700b8800b001fa1c63738dmr14171941oab.7.1701122715440; Mon, 27 Nov 2023 14:05:15 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id x23-20020a056830115700b006d679b53e8asm1458890otq.24.2023.11.27.14.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:05:15 -0800 (PST) From: Charlie Jenkins <charlie@rivosinc.com> Subject: [PATCH v4 0/2] riscv: Fix issues with module loading Date: Mon, 27 Nov 2023 14:04:58 -0800 Message-Id: <20231127-module_linking_freeing-v4-0-a2ca1d7027d0@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAIoSZWUC/4XNwQrCMAyA4VcZPVtZ01U3T76HiGxtqsGtlVaLM vbudp5EFE/hD+TLyCIGwsg2xcgCJorkXY5qUTB9at0ROZncDEqQQkDJB29uPR56cmdyx4MNiHl y6FQrO1CqU8jy8SWgpfsL3u1znyhefXi8/iQxb/+SSXDBrbW1MGuoG6u3gZKP5PRS+4HNaoJ3S fyUIEvNuuqsNnK1qvCLJN8l+ClJXvIaG6wEtFKW6kOapukJKCp0/lMBAAA= To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Ron Economos <re@w6rz.net>, Samuel Holland <samuel.holland@sifive.com>, Andreas Schwab <schwab@linux-m68k.org> Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Charlie Jenkins <charlie@rivosinc.com> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1701122714; l=1275; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=ktmhIbS4nLRNl0CJgpmhOEvy8Ne38cd75WPfhvHt4w8=; b=LvG3ouNrZDAB8lSTyo77I0DXPO2z8KvBEY0edkFxLi/zJhf9q/nZbwvTknADYULxy6qmtlgoV Wb0g/PZstEtAy3ZNIDk8PWwi5awR4QNle4aGVl8+hSrIs5vPyWmNvGc X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:05:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783756479541355613 X-GMAIL-MSGID: 1783756479541355613 |
Series |
riscv: Fix issues with module loading
|
|
Message
Charlie Jenkins
Nov. 27, 2023, 10:04 p.m. UTC
Module loading did not account for multiple threads concurrently loading
modules. This patch fixes that issue. There is also a small patch to fix
the type of a __le16 variable.
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
---
Changes in v4:
- Make functions only used internally static
- Free data structures on kmalloc failure (Andreas)
- Link to v3: https://lore.kernel.org/r/20231122-module_linking_freeing-v3-0-8e9e412a3305@rivosinc.com
Changes in v3:
- Cleanup pointer passing (Samuel)
- Correct indentation (Samuel)
- Check for kmalloc failures (Samuel)
- Link to v2: https://lore.kernel.org/r/20231121-module_linking_freeing-v2-1-974bfcd3664e@rivosinc.com
Changes in v2:
- Support linking modules concurrently across threads.
- Link to v1: https://lore.kernel.org/r/20231120-module_linking_freeing-v1-1-fff81d7289fc@rivosinc.com
---
Charlie Jenkins (2):
riscv: Safely remove entries from relocation list
riscv: Correct type casting in module loading
arch/riscv/kernel/module.c | 114 +++++++++++++++++++++++++++++++++------------
1 file changed, 84 insertions(+), 30 deletions(-)
---
base-commit: 98b1cc82c4affc16f5598d4fa14b1858671b2263
change-id: 20231120-module_linking_freeing-2b5a3b255b5e
Comments
Charlie Jenkins <charlie@rivosinc.com> writes: > Module loading did not account for multiple threads concurrently loading > modules. This patch fixes that issue. There is also a small patch to fix > the type of a __le16 variable. > > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> > --- > Changes in v4: > - Make functions only used internally static > - Free data structures on kmalloc failure (Andreas) > - Link to v3: https://lore.kernel.org/r/20231122-module_linking_freeing-v3-0-8e9e412a3305@rivosinc.com > > Changes in v3: > - Cleanup pointer passing (Samuel) > - Correct indentation (Samuel) > - Check for kmalloc failures (Samuel) > - Link to v2: https://lore.kernel.org/r/20231121-module_linking_freeing-v2-1-974bfcd3664e@rivosinc.com > > Changes in v2: > - Support linking modules concurrently across threads. > - Link to v1: https://lore.kernel.org/r/20231120-module_linking_freeing-v1-1-fff81d7289fc@rivosinc.com > > --- > Charlie Jenkins (2): > riscv: Safely remove entries from relocation list > riscv: Correct type casting in module loading I got hit by this on QEMU for 6.7-rc3: | Unable to handle kernel paging request at virtual address 6b6b6b6b6b6b6b83 | Oops [#1] | Modules linked in: | CPU: 3 PID: 1 Comm: systemd Not tainted 6.7.0-rc3 #1 | Hardware name: riscv-virtio,qemu (DT) | epc : process_accumulated_relocations+0x70/0x162 | ra : process_accumulated_relocations+0x96/0x162 | epc : ffffffff8000c528 ra : ffffffff8000c54e sp : ff20000000023ab0 | gp : ffffffff8257fea0 tp : ff60000080860040 t0 : ff60000083934d68 | t1 : 0000000000000006 t2 : 0000000000000002 s0 : ff20000000023b30 | s1 : 6b6b6b6b6b6b6b6b a0 : ffffffff80ed48d8 a1 : 0000000000000000 | a2 : ff1c0000040a9610 a3 : 0000000000000000 a4 : 0000000000000000 | a5 : ff600000832d6990 a6 : ff1c0000040e4d10 a7 : 000000000bbb1d6d | s2 : 0000000000000023 s3 : 0000000000000230 s4 : ffffffff0264dd40 | s5 : 000000000000003e s6 : ffffffff81401898 s7 : ffffffff0264d040 | s8 : ff60000083934e80 s9 : ffffffff825b7240 s10: ff60000083934de0 | s11: ff200000007a25b0 t3 : ffffffff0264d000 t4 : ffffffff0264d040 | t5 : 0000000000000017 t6 : ff60000083367eb8 | status: 0000000200000120 badaddr: 6b6b6b6b6b6b6b83 cause: 000000000000000d | [<ffffffff8000c528>] process_accumulated_relocations+0x70/0x162 | [<ffffffff8000ca9a>] apply_relocate_add+0x142/0x37a | [<ffffffff800e79f0>] load_module+0x1720/0x227c | [<ffffffff800e8790>] init_module_from_file+0x82/0xba | [<ffffffff800e8940>] __riscv_sys_finit_module+0x178/0x300 | [<ffffffff80ec9160>] do_trap_ecall_u+0xc6/0x142 | [<ffffffff80ed5cac>] ret_from_exception+0x0/0x64 | Code: 060d 3783 010d 3823 f804 3b83 018d 6384 8363 0a97 (a903) 0184 | ---[ end trace 0000000000000000 ]--- This series resolved the issue for me. Tested-by: Björn Töpel <bjorn@rivosinc.com>
Hello: This series was applied to riscv/linux.git (fixes) by Palmer Dabbelt <palmer@rivosinc.com>: On Mon, 27 Nov 2023 14:04:58 -0800 you wrote: > Module loading did not account for multiple threads concurrently loading > modules. This patch fixes that issue. There is also a small patch to fix > the type of a __le16 variable. > > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> > --- > Changes in v4: > - Make functions only used internally static > - Free data structures on kmalloc failure (Andreas) > - Link to v3: https://lore.kernel.org/r/20231122-module_linking_freeing-v3-0-8e9e412a3305@rivosinc.com > > [...] Here is the summary with links: - [v4,1/2] riscv: Safely remove entries from relocation list https://git.kernel.org/riscv/c/d8792a5734b0 - [v4,2/2] riscv: Correct type casting in module loading https://git.kernel.org/riscv/c/4a92a87950c4 You are awesome, thank you!