From patchwork Tue Jun 25 12:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13711037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EDCA7C30653 for ; Tue, 25 Jun 2024 12:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=TzzHwXpjnbpEvGGxgHj7Ns2SWq9xcEyBCQfXvwRMCkM=; b=cNbkmO5gEzqBbDa2b9Qca3k0O9 puXTHPB4bHsC2dHCahBS1TSX+3QytaI5Zp+RI3YK3IDGBylzXbTk5ENz5hgwX4mn9Gc5lIFCs5kqS z+nNceTHCQIE9t8D1ku6NAGlk9kXsT8TPPkCnlODjynPYC3TbuF46ypo/DzJgK2kGv9gPWrQ9aILX mD7tlTDPy8y83mhVjXUaliyxfFXxVY68YyTNtv2CAaVKQZqruUUhouT6gxZV9zrbYCV+Gy6Y6GGtd mmzK50cRQWoGXO0qEfBYoYfhmHKbJyiXl9/vGvpH4dnbr/Q/61YnTmk6Jw8amL3I4EHfNmfkSXE3i E9SUbI9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM5EW-00000002jj9-45ld; Tue, 25 Jun 2024 12:25:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM5Du-00000002jOJ-2zBW for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 12:24:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE051339; Tue, 25 Jun 2024 05:24:56 -0700 (PDT) Received: from e116581.blr.arm.com (e116581.arm.com [10.162.41.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F04E83F766; Tue, 25 Jun 2024 05:24:26 -0700 (PDT) From: Dev Jain To: shuah@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Catalin.Marinas@arm.com, will@kernel.org Cc: broonie@kernel.org, ryan.roberts@arm.com, rob.herring@arm.com, mark.rutland@arm.com, linux@armlinux.org.uk, suzuki.poulose@arm.com, Anshuman.Khandual@arm.com, aneesh.kumar@kernel.org, linux-kernel@vger.kernel.org, Dev Jain Subject: [PATCH v3 0/9] A new selftests/ directory for arm compatibility testing Date: Tue, 25 Jun 2024 17:53:59 +0530 Message-Id: <20240625122408.1439097-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_052434_891315_29E32348 X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series introduces the selftests/arm directory, which tests 32 and 64-bit kernel compatibility with 32-bit ELFs running on the Aarch platform. The need for this bucket of tests is that 32 bit applications built on legacy ARM architecture must not break on the new Aarch64 platforms and the 64-bit kernel. The kernel must emulate the data structures, system calls and the registers according to Aarch32, when running a 32-bit process; this directory fills that testing requirement. One may find similarity between this directory and selftests/arm64; it is advisable to refer to that since a lot has been pulled from there itself. The mm directory includes a test for checking 4GB limit of the virtual address space of a process. The signal directory contains two tests, following a common theme: mangle with arm_cpsr, dumped by the kernel to user space while invoking the signal handler; kernel must spot this illegal attempt and terminate the program by SEGV. The elf directory includes a test for checking the 32-bit status of the ELF. The abi directory includes two ptrace tests, in the first, a 32-bit parent debugs a 32-bit child, and in the second, a 64-bit parent debugs a 32-bit child. The second test will be skipped when running on a 32-bit kernel. Credits to Mark Brown for suggesting this work. Testing: The series has been tested on the Aarch64 kernel. For the Aarch32 kernel, I used qemu-system-arm with machine 'vexpress-a15', along with a buildroot rootfs; the individual statically built tests pass on that, but building the entire test suite on that remains untested, due to my lack of experience with qemu and rootfses. Since I have done some changes in selftests/arm64, I have tested that those tests do not break. v2->v3: - mm, elf: Split into multiple testcases - Eliminate copying in signal/ using ifdeffery and pulling from selftests/arm64 - Delete config file, since it does not make sense for testing a 32-bit kernel - Split ptrace in selftests/arm64, and pull some stuff from there - Add abi tests containing ptrace and ptrace_64 - Fix build warnings in selftests/arm64 (can be applied independent of this series) v1->v2: - Formatting changes - Add .gitignore files and config file v1: - https://lore.kernel.org/all/20240405084410.256788-1-dev.jain@arm.com/ Dev Jain (9): selftests/arm: Add mm test selftests/arm: Add elf test selftests: arm, arm64: Use ifdeffery to pull signal infrastructure selftests/arm: Add signal tests selftests/arm64: Fix build warnings for ptrace selftests/arm64: Split ptrace, use ifdeffery selftests/arm: Add ptrace test selftests/arm: Add ptrace_64 test selftests: Add build infrastructure along with README tools/testing/selftests/Makefile | 1 + tools/testing/selftests/arm/Makefile | 56 ++++++++ tools/testing/selftests/arm/README | 32 +++++ tools/testing/selftests/arm/abi/.gitignore | 4 + tools/testing/selftests/arm/abi/Makefile | 26 ++++ tools/testing/selftests/arm/abi/ptrace.c | 82 +++++++++++ tools/testing/selftests/arm/abi/ptrace.h | 57 ++++++++ tools/testing/selftests/arm/abi/ptrace_64.c | 91 ++++++++++++ .../selftests/arm/abi/trivial_32bit_program.c | 14 ++ tools/testing/selftests/arm/elf/.gitignore | 2 + tools/testing/selftests/arm/elf/Makefile | 6 + tools/testing/selftests/arm/elf/parse_elf.c | 77 ++++++++++ tools/testing/selftests/arm/mm/.gitignore | 2 + tools/testing/selftests/arm/mm/Makefile | 6 + tools/testing/selftests/arm/mm/compat_va.c | 89 ++++++++++++ tools/testing/selftests/arm/signal/.gitignore | 3 + tools/testing/selftests/arm/signal/Makefile | 30 ++++ .../selftests/arm/signal/test_signals.c | 2 + .../selftests/arm/signal/test_signals.h | 2 + .../selftests/arm/signal/test_signals_utils.c | 2 + .../selftests/arm/signal/test_signals_utils.h | 2 + .../testcases/mangle_cpsr_invalid_aif_bits.c | 33 +++++ .../mangle_cpsr_invalid_compat_toggle.c | 29 ++++ tools/testing/selftests/arm64/abi/ptrace.c | 121 ++-------------- tools/testing/selftests/arm64/abi/ptrace.h | 135 ++++++++++++++++++ .../selftests/arm64/signal/test_signals.h | 12 ++ .../arm64/signal/test_signals_utils.c | 51 +++++-- .../arm64/signal/test_signals_utils.h | 3 + 28 files changed, 850 insertions(+), 120 deletions(-) create mode 100644 tools/testing/selftests/arm/Makefile create mode 100644 tools/testing/selftests/arm/README create mode 100644 tools/testing/selftests/arm/abi/.gitignore create mode 100644 tools/testing/selftests/arm/abi/Makefile create mode 100644 tools/testing/selftests/arm/abi/ptrace.c create mode 100644 tools/testing/selftests/arm/abi/ptrace.h create mode 100644 tools/testing/selftests/arm/abi/ptrace_64.c create mode 100644 tools/testing/selftests/arm/abi/trivial_32bit_program.c create mode 100644 tools/testing/selftests/arm/elf/.gitignore create mode 100644 tools/testing/selftests/arm/elf/Makefile create mode 100644 tools/testing/selftests/arm/elf/parse_elf.c create mode 100644 tools/testing/selftests/arm/mm/.gitignore create mode 100644 tools/testing/selftests/arm/mm/Makefile create mode 100644 tools/testing/selftests/arm/mm/compat_va.c create mode 100644 tools/testing/selftests/arm/signal/.gitignore create mode 100644 tools/testing/selftests/arm/signal/Makefile create mode 100644 tools/testing/selftests/arm/signal/test_signals.c create mode 100644 tools/testing/selftests/arm/signal/test_signals.h create mode 100644 tools/testing/selftests/arm/signal/test_signals_utils.c create mode 100644 tools/testing/selftests/arm/signal/test_signals_utils.h create mode 100644 tools/testing/selftests/arm/signal/testcases/mangle_cpsr_invalid_aif_bits.c create mode 100644 tools/testing/selftests/arm/signal/testcases/mangle_cpsr_invalid_compat_toggle.c create mode 100644 tools/testing/selftests/arm64/abi/ptrace.h