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 C430FC43334 for ; Tue, 28 Jun 2022 16:37:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09A226B0071; Tue, 28 Jun 2022 12:37:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 049606B0072; Tue, 28 Jun 2022 12:37:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E543C8E0001; Tue, 28 Jun 2022 12:37:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D30596B0071 for ; Tue, 28 Jun 2022 12:37:35 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id A2CF18111F for ; Tue, 28 Jun 2022 16:37:35 +0000 (UTC) X-FDA: 79628200470.04.640FA4B Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by imf29.hostedemail.com (Postfix) with ESMTP id 2B83C120032 for ; Tue, 28 Jun 2022 16:37:35 +0000 (UTC) Received: by mail-wr1-f44.google.com with SMTP id b26so6120224wrc.2 for ; Tue, 28 Jun 2022 09:37:34 -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=RVf4yl92oEsE1eFccDNhAE8/U0asRurT8KSr6vcQ/ik=; b=gqSXCg/PYz9m8xZqym4NJ06VPFYCE4gBb/gXm7GtDk8s/aT0P2bqfxKVaXEtCLW9Hs rH2SeTYILQvXhwDaztd4w2LiT16QDT0JqAO2s7yifc7OjsaeQfArp9D4d3UnOfPdRx36 6BV8urouYHRuEIJ/wuzi2MKK13zfeBMw2nAwiF9lNARzQtAh7qiQYxKc4EqDuu2JoPGi dnj79XUxmFfyTfDXBLSg800kEARPoph/zdV7JQ33UIVDozDeXtCcZXpyB6w4INqTiIWE Y9M5cJXDAmZK5WqXEuj/9SPRZzAGDxtMwmIbFNPdfoG6JLgvXH+JUA0CpYOP7/Hk6US3 AlUQ== 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=RVf4yl92oEsE1eFccDNhAE8/U0asRurT8KSr6vcQ/ik=; b=djpyGmu5mrywN0SWBTsJVsoQoe7vlqapfxZ82wb3wetgx07sqrmhQQgBu9ETKxIPM9 VrdlLWKRveffI62bH25wCnqw9SelJ8iwQwprWAAEF2TZxGcFbDRnXztvTrGPkQJRvAts 3y9Oz0C1SFgbuEdhHNpFaRQ2BE5cmXL7C5WLkQj6t1mzySsJmcQ+anI5SDU8HaCyiSYV sJCrHi9OivFdNRe6iAS1G9GucjDIFCpM1d6DkfisiBqFcZ272G4GQNCuDT6zzj7JbgAx xcm+ivHAUb+8sDlqRQ84UMhxHltmcdQAflfMkqS0JyIwYqCdbHbdgJNy0ptXz9bKOUnh pZtw== X-Gm-Message-State: AJIora/rrNO7xxe2WsmMBDZRnB+gNaYCleceBz5jaN3vb6h4ja5KPyJO 5pFuc7fCVpCEZ6dhMkDcLut/XA== X-Google-Smtp-Source: AGRyM1uZ4Cj3PiKKiHaFO0K/W/sn/0a6KrsPrJnQxYlBvLrAm1nf5hYgOdYkf89yic/v5EQJY/47xw== X-Received: by 2002:a05:6000:15c1:b0:21b:ad5d:64dd with SMTP id y1-20020a05600015c100b0021bad5d64ddmr18454588wry.642.1656434253617; Tue, 28 Jun 2022 09:37:33 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id h2-20020adff4c2000000b0021d221daccfsm1293517wrp.78.2022.06.28.09.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 09:37: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 v4] selftests/vm: Only run 128TBswitch with 5-level paging Date: Tue, 28 Jun 2022 18:36:54 +0200 Message-Id: <20220628163654.337600-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=1656434255; a=rsa-sha256; cv=none; b=sx8qP0EPZ9I1rroEKo0dHSo8LIzu1uXbTrRZiYxJDm13/nsRpRcqNwTHssaWGs/pcABoip 6WBeO44ONjYrlFfzeVBCR1g5kDH2HPBRP4642+Mmblpqyn18yjDqLQY0EoAdkgo/OvMbU5 Gx2hOtCBxCUetd4R4S+fGfpIW+1rIQg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b="gqSXCg/P"; dmarc=none; spf=none (imf29.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.44) smtp.mailfrom=adam@wowsignal.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656434255; 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=RVf4yl92oEsE1eFccDNhAE8/U0asRurT8KSr6vcQ/ik=; b=oXe2ONLZxfF1Q1R25G+L2+SCGQrUagKcS+FWgVZzhVt/rTSXjC83UMfew398FAIMOMxD06 oliau8B7SlANb8z/rx+eZwng6x0dimIDi6KivBrOxRF1ytEvnzeuHnkSP2Ur0au+PLNY9f HIiPhNqMQ563PcDAKbEm8ok2+uIo8Pw= X-Stat-Signature: 6c8fr9kbdkhq4fdptndqpm8g9jmkpi8t X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2B83C120032 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b="gqSXCg/P"; dmarc=none; spf=none (imf29.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.44) smtp.mailfrom=adam@wowsignal.io X-HE-Tag: 1656434255-135171 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000015, 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 --- 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..e6bbd36d4f55 --- /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 + +die() +{ + echo "$1" + exit $exitcode +} + +check_supported_x86_64() +{ + 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: 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