Message ID | 20231018-module_relocations-v5-0-dfee32d4dfc3@rivosinc.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3A88CDB47E for <linux-mm@archiver.kernel.org>; Wed, 18 Oct 2023 22:51:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CD0F80055; Wed, 18 Oct 2023 18:51:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 455298004A; Wed, 18 Oct 2023 18:51:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F50A80055; Wed, 18 Oct 2023 18:51:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1D6388004A for <linux-mm@kvack.org>; Wed, 18 Oct 2023 18:51:07 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 80EF61604A2 for <linux-mm@kvack.org>; Wed, 18 Oct 2023 22:51:06 +0000 (UTC) X-FDA: 81360079332.13.56DE12C Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by imf17.hostedemail.com (Postfix) with ESMTP id AAA1740006 for <linux-mm@kvack.org>; Wed, 18 Oct 2023 22:51:04 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="utqUzw/g"; spf=pass (imf17.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.46 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697669464; a=rsa-sha256; cv=none; b=CgpmgCNcs1XZL0dVMUCHOFjHRMTSjeP3Th09h9splVp50eTjicofyz6rrtO67hG31rPL/B TBXM1AtX1GACKPBCaC5pORSWsieP2/0Fw0XuvOOqgIrlRo1rkymyGjjE/FLRIjxqjd/Spt 6Fx4iqFz19dljyw3pyhgXxdP9P6uP4U= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="utqUzw/g"; spf=pass (imf17.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.46 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697669464; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=9/6gRB6PKN0zKg0UrM+QY05Z/ZteQMJLVCSifjerBXY=; b=XPDaHCexLWgMKaVc30Hksdys/W6Gd3b3ZXwwQH082jnJb0hWEuzj2wWNdyhLDwSAaQgJQL TV3ISx/FDjr5b/hWQNNVSYESYRTyIGTzCJDkZ4nnoOVrBSww+xtfB8AlYxx6WTBs49nwtb wEASnEi5x/M8DeHUnPqYl5LqPg0DesQ= Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6ce291b5df9so47586a34.2 for <linux-mm@kvack.org>; Wed, 18 Oct 2023 15:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697669464; x=1698274264; darn=kvack.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=9/6gRB6PKN0zKg0UrM+QY05Z/ZteQMJLVCSifjerBXY=; b=utqUzw/gl9fZQOWVQGCAfsilVv0WW2nSiP4ItSNdAfFxK4AJb7cEtWfmm4Qs+NifT3 rNyzCplef24eXVzpfrPLCdwRNDoH3vIRt96rkQZ9cAkBw2b6kJWTKLCOgahMMKGOQKFD m1fhXIz/FjTdITFJpAdNBjCOGxjILfl4wYaH5hh2hvaR461D9i0XG5EF3D/4IUMEpTPO 6wAxXCkjdaMbu7sJNDEBKal0aBzIvGJwvgXrjCofItIsTxowyVgY7ngt/s5uHDl0dXbd f+usqN8ZEcPo3pnX35IoDR7ESgBg+JTwF4OSD/KDv3Wm7Q3aUSI5C7Q7Io2yDxBC6JXO dWoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697669464; x=1698274264; 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=9/6gRB6PKN0zKg0UrM+QY05Z/ZteQMJLVCSifjerBXY=; b=Gl6xGEPCqswFK4YZaT7nAPV/D+nUejo1pbffYOzRPMXLdbamZ5V5f1aTcVhfnLh4Af 21XHxQ8HSgfMOutQ7DwkzG9/WbItdRqVLEtmIqNa60KIlzX4+7lPpKLvZTqBAlO2mIFE fOHSdxMfRS8TIxsYC4MRTWRWY5YnmLJtTH5LHw1bwK62JdL/kkoWYTngE8oSFO+wKxh0 ws/LL1KqJgJZMkQA4/tFd4qHm/OuVqBEG4C7oZXp8o2hCssFZyDfrxlQOXploJXVFj1J UVsMvWdEL46u2jCKS/gzASP/dB+Vl85n4FtzK+wxyuKcmhOQ4Yk0LZtE6VHHVndIqMJ6 Q0Tw== X-Gm-Message-State: AOJu0YzvAMsbG8lkjW5WQVwr72HSnAWwxvACLrlSRAgODlt/9l+eCIHP 4H41E5I6ihMfixi58o87S8aD6w== X-Google-Smtp-Source: AGHT+IHPM5SEb3p3yXI6+cmxTQEe9iGrXUotAOK1ZPi+82laCIzaDi0NMhLemTRTVTsPi8QNYprGKw== X-Received: by 2002:a9d:7398:0:b0:6ce:21c:28a9 with SMTP id j24-20020a9d7398000000b006ce021c28a9mr634585otk.34.1697669463891; Wed, 18 Oct 2023 15:51:03 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id r195-20020a4a37cc000000b00581e7506f2fsm641134oor.9.2023.10.18.15.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 15:51:03 -0700 (PDT) From: Charlie Jenkins <charlie@rivosinc.com> Subject: [PATCH v5 0/3] riscv: Add remaining module relocations and tests Date: Wed, 18 Oct 2023 15:51:00 -0700 Message-Id: <20231018-module_relocations-v5-0-dfee32d4dfc3@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAFRhMGUC/23NwWoDIRCA4VcJnmvQHR2zPeU9Qii7OjZCshZNJ CHsu9ddQgnF4z/MfPNkmVKgzD43T5aohBziVEN/bJg9DdM38eBqs050IHqx45fobmf6SnSOdrj W7cw9giWHWo7OsHr4k8iH+4oejrVPIV9jeqw/ilymL05CiyuSCz6O4HYKDZke9imUmMNktzZe2 CKW7k+RQmBT6aqijEZUGjw521DgTZFtBaoyIBrvUBhJfUNR74ppKqoqPRivyYNEL/4p8zz/Ai9 cJJSJAQAA 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>, Andreas Schwab <schwab@linux-m68k.org>, Emil Renner Berthing <emil.renner.berthing@canonical.com>, Samuel Holland <samuel.holland@sifive.com>, Charlie Jenkins <charlie@rivosinc.com>, Emil Renner Berthing <kernel@esmil.dk> X-Mailer: b4 0.12.3 X-Rspamd-Server: rspam08 X-Rspamd-Que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HAyWf86DX43N1gkBwzH9sCYBPc3i0vPJahZAInZWtVN05pqw+tHBEUtUdeNIeRuNGMdKfZVvghoAi5qwtd417aoCnzHqJ0uJV1evPXDhrjBZg8hGsKsxFSq1x+oiM+MJNV8lcmvsDBLQNIwPYP2z1J8+ovClvJB3ccO6ygvMo4Rs3JSAvoQeJZpLppcyNL76R7Bo328RcPwulodttTiHLk68XS3Pyw24g8TKyzNX4ttKGSOOeagji12/KkidD2CaOLY4DBE+dPSsWxw8JmlWAvzHeX4gYR9IIwpYKSGTGRYOfZwHp/odSFaRuxuRg+vJnufm0wrjj0otXvMvC3CD1jOm0xy97G6ZwM/dDL7m2hsAQ68Tf1KkaVTFVDncCGOl7vDLVuLy0mlGgvXxAN1JydSZqcclR4A2YVtluHoADdmWbRnidQsRsPTwTrlqzFJft2NrkAMSYStdBmrOm4yFdXfnAayHFQzFYQpixmOZw0G7ydmukDOhe3iXliJF7L7foOABDA8tbW0/CzzA6UsjOJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.103596, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
riscv: Add remaining module relocations and tests
|
expand
|
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 <charlie@rivosinc.com> --- Changes in v5: - Brought in patch by Emil and fixed it up to force little endian - Fixed up issues with apply_r_riscv_32_pcrel_rela and apply_r_riscv_plt32_rela (Samuel) - Added u8 cast in apply_r_riscv_sub6_rela (Andreas) - Link to v4: https://lore.kernel.org/r/20231017-module_relocations-v4-0-937f5ef316f0@rivosinc.com 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 Emil Renner Berthing (1): riscv: Avoid unaligned access when relocating modules arch/riscv/Kconfig.debug | 1 + arch/riscv/include/uapi/asm/elf.h | 5 +- arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/module.c | 371 +++++++++++++++------ 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, 637 insertions(+), 101 deletions(-) --- base-commit: 4d320c2d9a2b22f53523a1b012cda17a50220965 change-id: 20230908-module_relocations-f63ced651bd7