Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3585024rdg; Tue, 17 Oct 2023 22:34:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsVCXQdxj7lCmXPuG4XaThbv7zqEXfoJ/jPh+WlFoqkV4b27rZhrgSYoV/8iPJrMoWBcqj X-Received: by 2002:a05:6808:2811:b0:3b2:ee79:c0fd with SMTP id et17-20020a056808281100b003b2ee79c0fdmr11394oib.1.1697607279937; Tue, 17 Oct 2023 22:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697607279; cv=none; d=google.com; s=arc-20160816; b=e3RYBhzTHDwa1uc3eXwxv+KxvG6t8tCBJqNxeseJbFyFM5AxRfom+FOwFzZ4Y2YhXj xnrnPVDyqV3bsGn37djDKvPeKndT0riEbgS0LDJfoqVojGGKjRtc18lm6HPzBIL6MCZ6 ymHqUocRsTR5dpSeOiPP56odP2A7AKwuoZhM5wzBWRp/0R8oy4U6/ElrlD+ldHIQJ9gv O0Y5iqtl49x03w40DRBaW/xW7ZAxEWPPwG1u9UmE0OgOup4+hnHbUSIGoryRLgQqPdyw Xk072UViG8YpUUpiyB2LK8tFB9T0spTlqh2awI4YNixJ1M0uaiZXA5Q02cCMDaSIgr8C IQWQ== 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=zcA19DI8JxNOsatUyRCutdloslAvaeKjMvE3flJ53dg=; fh=KZqRT9ufKlz9AAx/9RG99hMgOts4DBuJCtI1Ondw5wc=; b=JpbCAzOMi3mxGAatgbpfQu6INLoUHMx+Hi6OV/GnyNhGJo8hPad3veFkRr2X3qUEt0 SnevWHyNvFLBy+q1OOrvBvJMHGkaXmJREN5P9pnQxCJ4UrICRJjkKzXB3MmwE2qxdb9l j6fjZHXdIjJH+UJgPg8QcEJG786sZ2acHi5C6FshP5RMtKwoAI1y3svwgVeOjt+JlBOn FD5ZxCRmfU9CXV3EVWqE7DgY2nM9TeiKebbgPjnnFUCEDj4NLArQuc88o8Ma2iiXadBY M10N6SLuSoafjOyNwrfAkUNN68InqvUYowl6Z8JaFHnlwqj0j2HjdzsVfJ8c7/9bBC/p w4Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gv8a2RWa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k36-20020a634b64000000b0056f8fdb4430si1384728pgl.893.2023.10.17.22.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 22:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gv8a2RWa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 4AAE081489EC; Tue, 17 Oct 2023 22:34:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229575AbjJRFeW (ORCPT + 99 others); Wed, 18 Oct 2023 01:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbjJRFeV (ORCPT ); Wed, 18 Oct 2023 01:34:21 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0B9B0 for ; Tue, 17 Oct 2023 22:34:19 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3b0dcbf3672so3932738b6e.1 for ; Tue, 17 Oct 2023 22:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697607259; x=1698212059; 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=zcA19DI8JxNOsatUyRCutdloslAvaeKjMvE3flJ53dg=; b=gv8a2RWaPf8xdy/oifB3e9wYwO+0rbd2JLjNPe8N1lrJ3e5N1xtECXOyvlNTZurmG3 NM1pzoEfiPOXWM/vmnAj1uiHAI1XZlPnNHzan0izJL1fj8Kw43ueCaqhHY+6bnPMDGnU rGsry14y+5hljMBSEgdFlkk99pLYEED0XiKkX7RhbtP5Nq/+YXeUIvV2st2cHftpwc1R Jnr6IvZlF8PjBzHWYGMVAgdSKAexeqVSPkWvNto1GQIf+TwIS0v5PoTsGi2XloGSBNye 4au60wVYQiMxI3x17EzPwp4+xsyWDLF6xz0tqxudAQFpgb8p6n6+2CHsFlFMyGDMw9Bz ps7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697607259; x=1698212059; 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=zcA19DI8JxNOsatUyRCutdloslAvaeKjMvE3flJ53dg=; b=Sp3dedCJUDPSAH5rcXXRAaO1T9a10g4cdqmIw5aFihmCPaUmGGavvZATiQn1nTTcX3 aU6Du256zJg1aaRKByxkuy6Hp1A7K48rssa6Xq5mzUKLU+i21BWQ4NmRC6UCH8FS9H5+ wVZpx1KhH/Kc5TGgSLIBJm++JFk4Rl34OeEDwj5CAFh17292fed2SW/lU/ub/Ji280zO wAjlP/MGm9hId02zihYOcS+aOJXHifNy8PB2EP9kADSSFYOdvm4CPa8wXvqOuUeAfQZD ZnniS6mVVnfhxUindqlmm6XCPjXxmIgG+/u7duQS6rxRLIllixGoJaVaXUPxr394n9qu Hx4g== X-Gm-Message-State: AOJu0YxxYYZJ8gkBHvfYU1C1g2BO+R2WYmO9ixmujuMk2yjOuajq/g7P EkBATYZXAtVlMPGAsX4mkYNVQA== X-Received: by 2002:a05:6808:8b:b0:3ae:156f:d325 with SMTP id s11-20020a056808008b00b003ae156fd325mr4197727oic.58.1697607258872; Tue, 17 Oct 2023 22:34:18 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id z26-20020a54459a000000b003af60f06629sm527977oib.6.2023.10.17.22.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 22:34:18 -0700 (PDT) From: Charlie Jenkins Subject: [PATCH v4 0/2] riscv: Add remaining module relocations and tests Date: Tue, 17 Oct 2023 22:34:15 -0700 Message-Id: <20231017-module_relocations-v4-0-937f5ef316f0@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAFduL2UC/23N3QqCMBTA8VeRXbfYh55pV71HROh2zIG52GwU4 rs3JSLCy//hnN+ZSEBvMZBDNhGP0QbrhhT5LiO6q4crUmtSE8GEZBUr6c2ZR48Xj73T9Zi2A21 BajRQ8MYokg7vHlv7XNHTOXVnw+j8a/0R+TL9cFxucZFTRptGmjIHhaqSR2+jC3bQe+1uZBGj+ CqcMdhURFJyVQDkhWzR6A1F/ih8W5FJqQFUa4ApjtWfMs/zGxPwXQpDAQAA 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=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 22:34:33 -0700 (PDT) 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. A psABI proposal [1] mandates that the first SET_ULEB128 that appears before a SUB_ULEB128 is the associated SET_ULEB128. This can be tested by enabling KUNIT, RUNTIME_KERNEL_TESTING_MENU, and RISCV_MODULE_LINKING_KUNIT. [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/403 Signed-off-by: Charlie Jenkins --- Changes in v4: - Complete removal of R_RISCV_RVC_LUI - Fix bug in R_RISCV_SUB6 linking - Only build ULEB128 tests if supported by toolchain - Link to v3: https://lore.kernel.org/r/20231016-module_relocations-v3-0-a667fd6071e9@rivosinc.com Changes in v3: - Add prototypes to test_module_linking_main as recommended by intel zero day bot - Improve efficiency of ULEB128 pair matching - Link to v2: https://lore.kernel.org/r/20231006-module_relocations-v2-0-47566453fedc@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 | 5 +- arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/module.c | 207 ++++++++++++++++++--- arch/riscv/kernel/tests/Kconfig.debug | 35 ++++ arch/riscv/kernel/tests/Makefile | 1 + arch/riscv/kernel/tests/module_test/Makefile | 15 ++ .../tests/module_test/test_module_linking_main.c | 85 +++++++++ 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, 548 insertions(+), 26 deletions(-) --- base-commit: 4d320c2d9a2b22f53523a1b012cda17a50220965 change-id: 20230908-module_relocations-f63ced651bd7 -- - Charlie