From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22287C433EF for ; Mon, 27 Jun 2022 16:13:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B97626B0071; Mon, 27 Jun 2022 12:13:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B47658E0002; Mon, 27 Jun 2022 12:13:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1A7E8E0001; Mon, 27 Jun 2022 12:13:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9464C6B0071 for ; Mon, 27 Jun 2022 12:13:46 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6E18F60D21 for ; Mon, 27 Jun 2022 16:13:46 +0000 (UTC) X-FDA: 79624511652.26.F5BA438 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf29.hostedemail.com (Postfix) with ESMTP id EA5C0120030 for ; Mon, 27 Jun 2022 16:13:45 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id mf9so20333191ejb.0 for ; Mon, 27 Jun 2022 09:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wowsignal-io.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5xu9pKdiT8Zuu1kC1mRY1/ZQNVs/rlHvU1SS4PVYjYo=; b=7t+3Pj43cvB53CV3y5qKOAc+LQITnAta8YmtyhAmSPlR1vCgQ0dMIOAnNRToE4dX7H eIYnumzX9Y+lA4imSk4i/K1sYH/2A56BaetwciwRwiilQXfPM3KowjPpLCBkvZQtprEa UbN79+2o4fRiQEntKpieJorK2PGHLl0FS/+6aeWsRHzcJhT5fQuNJMYyEGPAPf7mmoOV KHiEQa0ESwdlC6QRccFeBFwtdLTfMeyyz5GuDmuBAPxe0/QP4OQENyHB1U4Lva1lbirB qRBLr7bu4bnjjs6FzkLTsJFkSDvLHSYgkSheMn1+8rx8ucf7W/RilJJgsIFrrBAQ8EAT DwgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5xu9pKdiT8Zuu1kC1mRY1/ZQNVs/rlHvU1SS4PVYjYo=; b=ZElXCXrlJl4wu9neW464fb4JldKX88NqBSHlU55WeMC0enoqhySS9aSsuiTUVCp28W d8kNi7m332FGBNhZ3feF+F3oxFkyW7T09iDYuuSDfwP/jDRBxQKPy+B0dU6e29o6bufv 4CDLQWRNUSQjKeRnKBhTtuPPEFlkSTNTdz2o2akAeG5OsZJg9yYcrUxfwcr6pULs5/Po EPoX/d6p8nOPxv0HyZcjJqrYsrFgtef9uBCACA8OQ++NNRCjunDOlSC3QScRHXkQx/S5 P7lYCBDiB6u40ZoquN/rmW1EvCLIP7fnBPLyw4uUJKbZeubMzzcvUZA0CDQzQSctldVT 0TUQ== X-Gm-Message-State: AJIora+2+ioCr+pOMWtI8tacjgpr8tv3l0IdhZcR3xTaPEU5q/xShFgJ SZWUrW1m/A4/40WNFPXwHM7Jjg== X-Google-Smtp-Source: AGRyM1v3SeVLDBb1siUTu9NXpPoRlSKLIo7pIMgkx9nvlZMPXN5GVRsvgoX5zAo0sKT7JIVDvJYVSA== X-Received: by 2002:a17:906:dc8c:b0:722:f40e:e653 with SMTP id cs12-20020a170906dc8c00b00722f40ee653mr13610006ejc.83.1656346424630; Mon, 27 Jun 2022 09:13:44 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id g20-20020a170906521400b00722f48d1f19sm5188845ejm.67.2022.06.27.09.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 09:13:44 -0700 (PDT) From: Adam Sindelar To: Andrew Morton Cc: linux-mm@kvack.org, Adam Sindelar , Adam Sindelar , David Vernet , kernel-team@fb.com Subject: [PATCH v2] selftests/vm: Only run 128TBswitch with 5-level paging Date: Mon, 27 Jun 2022 18:13:32 +0200 Message-Id: <20220627161332.4536-1-adam@wowsignal.io> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=7t+3Pj43; dmarc=none; spf=none (imf29.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.218.46) smtp.mailfrom=adam@wowsignal.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656346426; a=rsa-sha256; cv=none; b=Wi6mgMLJ9C0xWcCv6W/1U0imEpaREQ9mCWx3vihzB0oRgIFojIJTh/YFJF9a5CePQS97PP tpcBKaEH6JmeM68vPtWsnw7OBQ7j/W/wO1g/JLg3T7aqZ2wqsUL16tF2Agm1yPRSVWAbrR jNZO1ClvcJdf/57GDRVWugmKhKMr7Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656346426; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=5xu9pKdiT8Zuu1kC1mRY1/ZQNVs/rlHvU1SS4PVYjYo=; b=pbg7NRaSyEL1sWecr4dGyVtSexLaFqrrIKYVVQwvz17vr1lBgiuuhB6RwzFV1O5VopsHYN 7VA8I/ovS3aZdR9Hk42LZku3+lfeQS7sbjecnJuRdbnLBxyF85gTxRoQqk9HsTDqWU3ryn UiHWLtqi1Rcm5DjksJrwL7mXJJiCt0c= X-Stat-Signature: i3nbc1s1tr17otgc7g8tqxskxcrhzugp X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: EA5C0120030 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=7t+3Pj43; dmarc=none; spf=none (imf29.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.218.46) smtp.mailfrom=adam@wowsignal.io X-HE-Tag: 1656346425-226126 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001347, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The test va_128TBswitch.c expects to be able to pass mmap an address hint and length that cross the address 1<<47. This is not possible without 5-level page tables, so the test fails. The test is already only run on 64-bit powerpc and x86 archs, but this patch adds an additional check that skips the test if PG_TABLE_LEVELS < 5. There is precedent for checking /proc/config.gz in selftests, e.g. in selftests/firmware. Running `sudo make -C tools/testing/selftests TARGETS=vm run_tests` produces the desired output: ``` --------------------------- running ./va_128TBswitch.sh --------------------------- ./va_128TBswitch.sh: PG_TABLE_LEVELS=4, must be >= 5 to run this test [SKIP] ------------------------------- ``` v2: - Function variables declared local - Fixed variable name typo in Makefile - Comment to explain gzip -dcfq Signed-off-by: Adam Sindelar --- tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/run_vmtests.sh | 2 +- tools/testing/selftests/vm/va_128TBswitch.sh | 39 ++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/vm/va_128TBswitch.sh diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index c45e535ff4b8..7860d0969888 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -91,6 +91,7 @@ endif TEST_PROGS := run_vmtests.sh TEST_FILES := test_vmalloc.sh +TEST_FILES += va_128TBswitch.sh KSFT_KHDR_INSTALL := 1 include ../lib.mk diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh index a2302b5faaf2..edda7350ccca 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -149,7 +149,7 @@ if [ $VADDR64 -ne 0 ]; then run_test ./virtual_address_range # virtual address 128TB switch test - run_test ./va_128TBswitch + run_test ./va_128TBswitch.sh fi # VADDR64 # vmalloc stability smoke test diff --git a/tools/testing/selftests/vm/va_128TBswitch.sh b/tools/testing/selftests/vm/va_128TBswitch.sh new file mode 100755 index 000000000000..767a6465b5d2 --- /dev/null +++ b/tools/testing/selftests/vm/va_128TBswitch.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2022 Adam Sindelar (Meta) +# +# This is a test for mmap behavior with 5-level paging. This script wraps the +# real test to check that the kernel is configured to support at least 5 +# pagetable levels. + +# 1 means the test failed +exitcode=1 + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +die() +{ + echo "$1" + exit $exitcode +} + +check_test_requirements() +{ + local config="/proc/config.gz" + [[ -f "${config}" ]] || config="/boot/config-$(uname -r)" + [[ -f "${config}" ]] || die "Cannot find kernel config in /proc or /boot" + + # gzip -dcfq automatically handles both compressed and plaintext input. + # See man 1 gzip under '-f'. + local pg_table_levels=$(gzip -dcfq "${config}" | grep PGTABLE_LEVELS | cut -d'=' -f 2) + + if [[ "${pg_table_levels}" -lt 5 ]]; then + echo "$0: PG_TABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test" + exit $ksft_skip + fi +} + +check_test_requirements +./va_128TBswitch -- 2.35.1