Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp717580rdb; Fri, 6 Oct 2023 17:42:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEIkB1zcrYO+BQReRNAC4BMwKA2kbebJxxMYF09lQ5YRBSUVXTQHw+Xok3FRNxV9rlpUMO X-Received: by 2002:a05:6a00:22c2:b0:68f:bd37:13df with SMTP id f2-20020a056a0022c200b0068fbd3713dfmr11470477pfj.16.1696639378317; Fri, 06 Oct 2023 17:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696639378; cv=none; d=google.com; s=arc-20160816; b=yJ2DtiqaXy9r5wCVO0ZLJfmvPdR2rSdDqKu2eixe+KODLF4JR5CG4m5QJi+E19nPUO GqVjd4+ilXCkE4A1FQlpV8ae2rgYgZ1gE+cJ8DmQvBNRf4FQuc+Q2K7i6v51IjFZPJ7y JNCeHyxZe8BZvm8wcRIRUCJvp/L4n4wMzHOLnvg4gXh1Cm387OUTXYGS7bmlzPNNWrQo J1lGTRRuUcoWuEg0a7EMArIyJeQ/KgeDvyl1zsb73oQ/NLRS7YNQinOqEo1s7mwoA6qb q5NLwd9YuGJyfcoAUJayYyLsflYZsjlOLO9ara/ZNhJpJDwTG+ZgVi4vox6JAsMNKF6r 9GDA== 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 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id be11-20020a056a001f0b00b0068beea8071esi2472417pfb.221.2023.10.06.17.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 17:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 1061B8077507; Fri, 6 Oct 2023 17:41:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233950AbjJGAlZ (ORCPT + 99 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 ); 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 ; Fri, 6 Oct 2023 17:41:18 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c87e55a6baso20686675ad.3 for ; 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 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 , Kees Cook , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins 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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 17:41:52 -0700 (PDT) X-Spam-Level: ** 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 --- 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 -- - Charlie