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 531BCC433EF for ; Fri, 1 Jul 2022 16:30:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7EDD6B0071; Fri, 1 Jul 2022 12:30:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2DFB6B0073; Fri, 1 Jul 2022 12:30:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF5BE6B0074; Fri, 1 Jul 2022 12:30:38 -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 AC9736B0071 for ; Fri, 1 Jul 2022 12:30:38 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83D27205AB for ; Fri, 1 Jul 2022 16:30:38 +0000 (UTC) X-FDA: 79639069356.04.66F0938 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by imf12.hostedemail.com (Postfix) with ESMTP id D04B740057 for ; Fri, 1 Jul 2022 16:30:35 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id s1so3961639wra.9 for ; Fri, 01 Jul 2022 09:30:35 -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=w3ZAsjWU4UXNXxbpKpbm6HGQ7uszRwstr++jz12BVRM=; b=BjOF3Rl+j3E+4RohLSQ4Unwfiv7mMB8DQ/VVVNLBSHgkGcU3fOgqgc3N4Ym6ACF6s+ /8fVpn0z7ZmnsxfseETWsduMnIOn1ZXfRWhsJdsz920qMoinwT3EgOfHXNy7PlwkdER4 iZQRXcEm6ZHSDmHa1lusivh6JbmkXE9IsJhZ5FmktHw9l9gP9e79yG1exflDMrhk3ogF 7i9kxXnM2R/R3YySTagWuO+Ts7GTNA94p//uni9inamd8EsYQ2NsCeVvRynKrctzjjE/ gGmSWeB3FtKqx16B92fuV52gV64hzLYSLoDBrlkxycw1T9QcKJcsHCiwHsdOUElw7BCS xykA== 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=w3ZAsjWU4UXNXxbpKpbm6HGQ7uszRwstr++jz12BVRM=; b=QrmDn94Ve8G121SPwavfJmRcYyJ8qbWZH55Rx70OlSPV9wMsAdzGFR/9lUopc9u6oy D5ao7qwXjYYaI+XqL/g5RIYotQuxfkMWN8hTN2fsmeiRRpnZiUMGaX4EGgrCFT2ocePk PJVHoVkBbrA87K38qrV7jzxLQAVPXQiaOXuT2L6D5skCAgg7yUVm4S7M2LmKULEaD3ij EPr+fI1qa5ahiJHpImRXPq91MCAUQS2sL3wA7lNM511CNnp2lsN4B4iOzOFlsQVbqSpx nicNphO5OTmsPz8N2iUSWG7XQXadpKPMz7/fVcmb9SolW7TwH5IPOYHaP3IaInCJjesP PB8w== X-Gm-Message-State: AJIora8uIrf/j0I3zS1Kb/vFpHucKVdCaJS3LGHPGVa24qMeL5Ct2TjN aPJZ9wW8a4hD7CCFTYMnExRyPw== X-Google-Smtp-Source: AGRyM1v/25Cw+Ffodz7ca6JPXY+ITzXvYxfhG4w3W6551a66ShoEPE3jmz+sWhlYQ6QmoEd3D1B1Ag== X-Received: by 2002:a5d:49c5:0:b0:21b:92d3:5585 with SMTP id t5-20020a5d49c5000000b0021b92d35585mr15126990wrs.318.1656693034300; Fri, 01 Jul 2022 09:30:34 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id s11-20020a5d4ecb000000b0020fe61acd09sm23297126wrv.12.2022.07.01.09.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 09:30:33 -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 v6] selftests/vm: Only run 128TBswitch with 5-level paging Date: Fri, 1 Jul 2022 18:30:30 +0200 Message-Id: <20220701163030.415735-1-adam@wowsignal.io> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656693036; a=rsa-sha256; cv=none; b=oDJCGBAdEXMmUpID05MdEE1bjrECF+Q3G/OtKUNI3+KAK4irhMYUWzjIntPG+bWY/9zLdL COFuSY+WyWrVAfNtEZI984St2H6ZAwmAv1OZFmhLQ+D9Ls0gstwkCupUgs6HAYKsBT2w1O ZYdWQLixtTmS9msEkA6Cl/g7FxqAfDk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=BjOF3Rl+; dmarc=none; spf=none (imf12.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.46) smtp.mailfrom=adam@wowsignal.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656693036; 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=w3ZAsjWU4UXNXxbpKpbm6HGQ7uszRwstr++jz12BVRM=; b=PMeooHCtm+bx21fafyEBr5rPIfpxaBAvIzfuiQCBfnBP5wyT5oREx7z8cILv0RdJkdUq47 xxzonp50nzwH0zm098MDI5B1U++qJfvXrpqjSPU/jESciPA1KuU2YPgLgCQtvVQk0GZEXs xIiUjTNiFENCStlXy6+hUJd6RSTDyXc= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D04B740057 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=BjOF3Rl+; dmarc=none; spf=none (imf12.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.46) smtp.mailfrom=adam@wowsignal.io X-Rspam-User: X-Stat-Signature: h48fujg8udjj4y144wzakfqt66az6d5p X-HE-Tag: 1656693035-207133 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000163, 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. On x86_64, 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_64 archs, but this patch adds an additional check on x86_64 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 the tests produces the desired output: sudo make -C tools/testing/selftests TARGETS=vm run_tests --------------------------- running ./va_128TBswitch.sh --------------------------- ./va_128TBswitch.sh: PG_TABLE_LEVELS=4, must be >= 5 to run this test [SKIP] ------------------------------- Signed-off-by: Adam Sindelar --- V5 -> V6: Fixed formatting issues V4 -> V5: Renamed "die" to "fail" (missed the review comment, sorry!) V3 -> V4: Restrict the check to x86_64 V2 -> V3: Clean up the commit message V1 -> V2: Variables local, fixed Makefile typo, comment on gzip usage tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/run_vmtests.sh | 2 +- tools/testing/selftests/vm/va_128TBswitch.sh | 54 ++++++++++++++++++++ 3 files changed, 56 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 44f25acfbeca..6a34209379a4 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -93,6 +93,7 @@ TEST_PROGS := run_vmtests.sh TEST_FILES := test_vmalloc.sh TEST_FILES += test_hmm.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 41fce8bea929..27c01c35c7a9 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -151,7 +151,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..41580751dc51 --- /dev/null +++ b/tools/testing/selftests/vm/va_128TBswitch.sh @@ -0,0 +1,54 @@ +#!/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 + +fail() +{ + echo "$1" + exit $exitcode +} + +check_supported_x86_64() +{ + local config="/proc/config.gz" + [[ -f "${config}" ]] || config="/boot/config-$(uname -r)" + [[ -f "${config}" ]] || fail "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: PGTABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test" + exit $ksft_skip + fi +} + +check_test_requirements() +{ + # The test supports x86_64 and powerpc64. We currently have no useful + # eligibility check for powerpc64, and the test itself will reject other + # architectures. + case `uname -m` in + "x86_64") + check_supported_x86_64 + ;; + *) + return 0 + ;; + esac +} + +check_test_requirements +./va_128TBswitch -- 2.35.1