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 E3EFDC43334 for ; Fri, 1 Jul 2022 10:49:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 622B66B0071; Fri, 1 Jul 2022 06:49:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ABD56B0073; Fri, 1 Jul 2022 06:49:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44D946B0074; Fri, 1 Jul 2022 06:49:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 333FE6B0071 for ; Fri, 1 Jul 2022 06:49:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 0520460CED for ; Fri, 1 Jul 2022 10:49:41 +0000 (UTC) X-FDA: 79638210204.26.19A07B3 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by imf24.hostedemail.com (Postfix) with ESMTP id 7E4BF180007 for ; Fri, 1 Jul 2022 10:49:41 +0000 (UTC) Received: by mail-wm1-f48.google.com with SMTP id k129so1080810wme.0 for ; Fri, 01 Jul 2022 03:49:41 -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=Mj0Qvky9QHEcIUvIERs37vv+9RzxYW2GILvbnrn2C80=; b=DkiPDYcJKH9+67j7ePG5jMdxW6RkdFsuWa0HqgYn5kFnbmGFfjrGRebliRyz6QGKyG deVGU+zagjmBNe2DeOrFT34TB1eOyc1/82/tHAeReQLWK3IxEWo6jG1sibuxlCZAyr2I f1FHBkl7JAzalO/z97BReOfdbAxJ/PtliKOTmYhtFwoUVAByI0BEVT/IfZ/Yh/ykjRQJ YYDxl7eAehqT/U0n4KW3KydfRuC1b9yNiUaRABK4Od3P4LfOyi7V50P3QuhLCc02KjFZ qfHePIKx4S/UA/mVTpbik91i82cmbyw/wB0rSYewmrblcg+E1bx6m1q9Q9i2Az8011st KKEA== 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=Mj0Qvky9QHEcIUvIERs37vv+9RzxYW2GILvbnrn2C80=; b=YLScwWwPq343og/yBoK+cEol4801/r1JurgkNMvw+8dW3KbkXUFWSU9Supi3I9PAuI N5XkfP+85XbDJMldsqaJgfXqXBLriYmF3WY896gzNoDBXHhZfQgZNlXwZhpGR9R7ojB1 AzlDIKqdEejKuoqyFlEVHGJmMqz3SxhNUnYttcNCR7gvFVmiGP3Q5GK6QQLWszKlQZVg HPbj3JPftiWd07m2+dqP6/bNAelv00iuf6oILV7C5jTwqcIhLpJT10tvjComcFz5UgL1 zpMqaV6fhgZTTs6+9pf2mtrt/i+j6/pjMYh9XLRp68dchj/BSw3GV79lH43AStCZRKL1 /31Q== X-Gm-Message-State: AJIora+X0rd3QF3Xa7Ti+UVYbnWuAbBkZn6o6jhD9JQ0Jm1pl3dyL/7E Sdp0kudC0BDX7HyN+cXEyYGApw== X-Google-Smtp-Source: AGRyM1vmtRYfmP2Qw2ssg/79J8PFTOGtZ3uZa3GEQaEiqG+VWDs2Vgh7m1KRPte3vmqf5+3pKeR11A== X-Received: by 2002:a05:600c:4e04:b0:3a1:8f34:5633 with SMTP id b4-20020a05600c4e0400b003a18f345633mr1389536wmq.169.1656672579998; Fri, 01 Jul 2022 03:49:39 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id c8-20020a05600c0a4800b003a02f957245sm3143606wmq.26.2022.07.01.03.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 03:49:39 -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 v5] selftests/vm: Only run 128TBswitch with 5-level paging Date: Fri, 1 Jul 2022 12:49:34 +0200 Message-Id: <20220701104934.413146-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=1656672581; a=rsa-sha256; cv=none; b=dTYXnG3mFT+zrn8+bqoSmm6v58cSbuiVXYFR68c3E/n9tQLukjzr+SyDV6z2ZuFoTcPO5F 33oKvehOPZfcg8BGQGED+KSb7Pvm4xbWVtoqAGGnP5hLft5SsHmZB4FR+phNDCwYxT6ENd R+3sF6SMEQA+m30vs1PW9IS228ukcOs= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=DkiPDYcJ; dmarc=none; spf=none (imf24.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.128.48) smtp.mailfrom=adam@wowsignal.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656672581; 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=Mj0Qvky9QHEcIUvIERs37vv+9RzxYW2GILvbnrn2C80=; b=Y6Ygd5ojZ414vAh2OssxkdrhPocVx2tnEUab4+YVWwJkF6qD8c+ChIm00xOnnurnN5YP2q 8AEzbzb7E7nvID29WOacq/SaJUR2fNjZYSh/nnz+hVPQiWi4BjXHQBJmm9PhRTJQlVJbFW cYqKLmqtq26PVOGnSZjzXfIWOdGP8G8= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7E4BF180007 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=DkiPDYcJ; dmarc=none; spf=none (imf24.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.128.48) smtp.mailfrom=adam@wowsignal.io X-Rspam-User: X-Stat-Signature: uagcwwyouo4b5s3f1cjexm36154bx8m3 X-HE-Tag: 1656672581-888492 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000626, 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 --- 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..334d12715ac3 --- /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