Message ID | 20231006-module_relocations-v2-0-47566453fedc@rivosinc.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp678084vqo; Fri, 6 Oct 2023 17:42:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOdRiIXn06nBPq/ZO6GJcueoLPZtVAuD5m2iEJ/CABArgvJQOrRgRJ9ZE1jC4tZwYTBjlP X-Received: by 2002:a05:6870:d7a7:b0:1bf:b863:b6d with SMTP id bd39-20020a056870d7a700b001bfb8630b6dmr10714668oab.1.1696639374548; Fri, 06 Oct 2023 17:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696639374; cv=none; d=google.com; s=arc-20160816; b=WmNA6gstv+WT5C5CH62wkDEX2+KmI6i2EDl90/8WoTQw1dzkYCSlsCi9MvV4JB3+n/ X4SnoGfH4CeLLAdLry3mk6lInR04iwdi9eyRCt+aieWr5rdoLV81xeP0udHP6LQq2McZ NbiudwfFTfTvmHybeSt4bLqJ+H97JrlQCFeHpHiesX58i5s5651aQuLz+kOnaKiNj+MS p1qXTTcPdy5I6dOJx0kZ9sSUqG97pPZIv7jfS6EXXp6B1Pou8lovbrdCo4Uyn+zvEV8F r0ZtPb7Dc4f+ZNYUiu0s2nSw4NIS1GYVHqDsyjy7ndYN7AG1b+8kdNHOUPNJejZEtJ/t p41g== 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=0Hp0ECJm0gFf8INn0HiZKpVqg/IUsayxsh+1diajkmI=; fh=KZqRT9ufKlz9AAx/9RG99hMgOts4DBuJCtI1Ondw5wc=; b=jTBTAfOeZ1ToUb/VVr05MhV6GHst1XZNafJ08NF/PhiDN7d/lXSFzMpOhRcg3qYuiM ePK2TabJDrbNvQHWOo647CZ6JoELCwwyEXfhmcKHMpF1cDYh7scytPwP6cbY4tWsb0t/ NB/hUm5qtfDUAxMxEDrakGIYHYYz06wC/TYcV9l/Bt/ecOazB4bN7QvsQup3OWUul/27 xM6k/L8+jCQn3yUchKIwDdZQgkO03tecIZwHRtoC0+xZFHVqwp8pPNa4BkmcT2eHjxDV IQFU32Insdw/t81aqfrDo3quM5ekqJBpOGBAc+YGoDaZQ09l2xEQi20yZBGuB9b2Bhot lXiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=0snFmb3P; 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 bx18-20020a056a02051200b00565e424cbc7si5422251pgb.109.2023.10.06.17.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 17:42:54 -0700 (PDT) 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=0snFmb3P; 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 B9E4C8077A69; Fri, 6 Oct 2023 17:41:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233954AbjJGAlZ (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Fri, 6 Oct 2023 20:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233894AbjJGAlY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Oct 2023 20:41:24 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03ABBE for <linux-kernel@vger.kernel.org>; Fri, 6 Oct 2023 17:41:18 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c87e55a6baso20686675ad.3 for <linux-kernel@vger.kernel.org>; Fri, 06 Oct 2023 17:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696639278; x=1697244078; 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=0Hp0ECJm0gFf8INn0HiZKpVqg/IUsayxsh+1diajkmI=; b=0snFmb3PiemW40ppTS6XhdS+2Q2BYx3bB5yjqUtuthVDYihbbHjT4n/ZhmtNuDQ3Ot wv1n5sY4TbZHk0RL0/NtPlmSZZF/Gb/HxGPwmOHplmP3eWImzxG1lP9AvVUFBQR132Dt SERJgx2ksaS6ZVM/MhxsjwymIu2RactGqsKWdN06g6p+9hNXH4CyyVjRzw6mnCa0rsaq kHBPS8EYWktLwkSUqLX5MmPPTZEsdfs5eFQHbZEiObnPavb7jMsFGNzkGllRtT8h/GrB tLbcO166lHTlsUurqH76vXIqYVNNCVDMc7V+59BCDTEKvzKgMuhXJ7Kj4oPYwju1enNh S8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696639278; x=1697244078; 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=0Hp0ECJm0gFf8INn0HiZKpVqg/IUsayxsh+1diajkmI=; b=udW/LGgm9locIHcVC/PtGLMV7+eqMflF/h/K6LTOQd2CMA3rwGx6I6K+5jnjkxcJUt nBAgpn25YLmtL1yZXp3xePbfAXV0/HGmmHa/1gRa/SUGCdbLDOh0gveg5I4rJXFi1x9/ 0whpq1Ih6jRCE0SGp2DGM1W1JLtoPL22xqBBNR62RSzs31cM9DzCd4Cc6x5rmcwPVl0D yC8wym7mI0P411tjhZeSUDAQWCPPjKL9LjME0r2mSEZdjpO7aIu3WWzYxxs7pJJnjk4P /nMx+gWIxqbVBGXkkdDe8kVjsJIVP/0vexf6U8aY273850fgohxnyJ/+yvSO3HhSu+8d pUVw== X-Gm-Message-State: AOJu0Yxb/o1ibziJCWvj6b01uRuxwt2hngQoigaH7ITwz8WrrnkCFkTp hV7x+C0+gyfHN+gi7nZurTucjw== X-Received: by 2002:a17:902:c112:b0:1c0:93b6:2e4b with SMTP id 18-20020a170902c11200b001c093b62e4bmr9338829pli.33.1696639278389; Fri, 06 Oct 2023 17:41:18 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id x16-20020a170902ec9000b001c582de968dsm4534540plg.72.2023.10.06.17.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 17:41:17 -0700 (PDT) From: Charlie Jenkins <charlie@rivosinc.com> Subject: [PATCH v2 0/2] riscv: Add remaining module relocations and tests Date: Fri, 06 Oct 2023 17:41:05 -0700 Message-Id: <20231006-module_relocations-v2-0-47566453fedc@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIACGpIGUC/22Nyw7CIBREf6W5azFQlD5W/odpTAu39iYtGKhE0 /DvYuPS5ZnMnNkgoCcM0BYbeIwUyNkM5aEAPfX2joxMZih5KXnDa7Y485zx5nF2ul9zO7BRSY1 GncVgKsjDh8eRXrv02mWeKKzOv/ePKL7pTyfkP10UjLNhkKY+qQqrRl48RRfI6qN2C3QppQ8nx buxtwAAAA== To: linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Eric Biederman <ebiederm@xmission.com>, Kees Cook <keescook@chromium.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Charlie Jenkins <charlie@rivosinc.com> X-Mailer: b4 0.12.3 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Fri, 06 Oct 2023 17:41:42 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779055328747459155 X-GMAIL-MSGID: 1779055328747459155 |
Series |
riscv: Add remaining module relocations and tests
|
|
Message
Charlie Jenkins
Oct. 7, 2023, 12:41 a.m. UTC
A handful of module relocations were missing, this patch includes the
remaining ones. I also wrote some test cases to ensure that module
loading works properly. Some relocations cannot be supported in the
kernel, these include the ones that rely on thread local storage and
dynamic linking.
ULEB128 handling is a bit special because SET and SUB relocations must
happen together, and SET must happen before SUB. The module linking
ignores a SET unless it is followed by a SUB. In order to find the
corresponding SET, module linking starts at the relocation above the SUB
and iterates up until it hits the SET. If a SET is not found, module
linking fails.
This can be tested by enabling KUNIT, RUNTIME_KERNEL_TESTING_MENU, and
RISCV_MODULE_LINKING_KUNIT.
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
---
Changes in v2:
- Added ULEB128 relocations
- Link to v1: https://lore.kernel.org/r/20230913-module_relocations-v1-0-bb3d8467e793@rivosinc.com
---
Charlie Jenkins (2):
riscv: Add remaining module relocations
riscv: Add tests for riscv module loading
arch/riscv/Kconfig.debug | 1 +
arch/riscv/include/uapi/asm/elf.h | 6 +-
arch/riscv/kernel/Makefile | 1 +
arch/riscv/kernel/module.c | 247 ++++++++++++++++++---
arch/riscv/kernel/tests/Kconfig.debug | 32 +++
arch/riscv/kernel/tests/Makefile | 1 +
arch/riscv/kernel/tests/module_test/Makefile | 15 ++
.../tests/module_test/test_module_linking_main.c | 73 ++++++
arch/riscv/kernel/tests/module_test/test_set16.S | 23 ++
arch/riscv/kernel/tests/module_test/test_set32.S | 20 ++
arch/riscv/kernel/tests/module_test/test_set6.S | 23 ++
arch/riscv/kernel/tests/module_test/test_set8.S | 23 ++
arch/riscv/kernel/tests/module_test/test_sub16.S | 22 ++
arch/riscv/kernel/tests/module_test/test_sub32.S | 22 ++
arch/riscv/kernel/tests/module_test/test_sub6.S | 22 ++
arch/riscv/kernel/tests/module_test/test_sub64.S | 27 +++
arch/riscv/kernel/tests/module_test/test_sub8.S | 22 ++
arch/riscv/kernel/tests/module_test/test_uleb128.S | 20 ++
18 files changed, 574 insertions(+), 26 deletions(-)
---
base-commit: 82714078aee4ccbd6ee7579d5a21f8a72155d0fb
change-id: 20230908-module_relocations-f63ced651bd7