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 959F6C4345F for ; Mon, 15 Apr 2024 18:32:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C2776B009A; Mon, 15 Apr 2024 14:32:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24A926B009B; Mon, 15 Apr 2024 14:32:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C50B6B009C; Mon, 15 Apr 2024 14:32:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DF4FE6B009A for ; Mon, 15 Apr 2024 14:32:19 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A7C9A1A0736 for ; Mon, 15 Apr 2024 18:32:19 +0000 (UTC) X-FDA: 82012611198.14.75F3F20 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf09.hostedemail.com (Postfix) with ESMTP id 713C914001C for ; Mon, 15 Apr 2024 18:32:16 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=XJAvGcDq; spf=pass (imf09.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713205936; a=rsa-sha256; cv=none; b=tZt8r1jm+XUC0sYvP3/rq/3bODspK+g+GNtiVpV+3HYxz1aK//W77egxIub7JdTj873Esr E0OBuU6eIkmM01LlEZE0mfzOQvfuCYmwxmCCttqqhwV7qxQEXcyxHwgORGitgW2uIzagic ve01AQcDjcJL+lRVJOiSG6/O1MU4C4o= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=XJAvGcDq; spf=pass (imf09.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713205936; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/fn16ORoqa+E+PXLbTdrI62OA21/9pS9m8VfggXMkxw=; b=XN8vDGAoNqRN97KjqGarLBsfe8Yi8a8MtVhGRssl0JmxuNuzUTmJF+K6WODB9cvL5cPsoU n5cDcHJWM4oW6VSZDB4Jxqs+EvQNcazsFfUHSTPVJp1I6YDXroITOG80QgwJceuMrGz1wP 7JYHhmfJa9DXuRm1oKEIRPpJJ2+W7co= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713205934; bh=p8eY082JkC3KPLbfUGfr481x8SEdz/YLHgqGEpwKKdg=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=XJAvGcDqP0Vt+/a6ZRFb0h5+g8hgOaGIveEs1cMbQRBl/HGMq09mRCyIdSRVXp2t+ ENn77R12rxPJQ/Lb1mz+StEHb9MNSEq/dKH8XjzyPhuTDEGURTxML/th7/UrMJpv5N jX4BXGtF7O9UOaonMufXeo96KpZwpGcA3tOBMX12eh98k/mNS1T+0kPZJX6BZlwUSm xNqyrnvQBvgej7aS79D0qvlyIUIA0umXkTxHgOdPVb0Ml2RJwPYZhQnWt0ubIwFPw4 olR+R5Fozy0rTDurjH2xfpAJCea2xY20ILGEmSZJekpk/oLkal5DidGr4FkWHItcMZ R0Mq7SKaJherw== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 73D9937810F1; Mon, 15 Apr 2024 18:32:09 +0000 (UTC) Message-ID: Date: Mon, 15 Apr 2024 23:32:41 +0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , jeffxu@google.com, jorgelo@chromium.org, groeck@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, pedro.falcato@gmail.com, dave.hansen@intel.com, linux-hardening@vger.kernel.org, deraadt@openbsd.org Subject: Re: [PATCH v10 3/5] selftest mm/mseal memory sealing To: jeffxu@chromium.org, akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, sroettger@google.com, willy@infradead.org, gregkh@linuxfoundation.org, torvalds@linux-foundation.org, corbet@lwn.net, Liam.Howlett@oracle.com, surenb@google.com, merimus@google.com, rdunlap@infradead.org References: <20240415163527.626541-1-jeffxu@chromium.org> <20240415163527.626541-4-jeffxu@chromium.org> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240415163527.626541-4-jeffxu@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 713C914001C X-Stat-Signature: 5i1eyfr4j3mjnityj8mp85at6zes999z X-Rspam-User: X-HE-Tag: 1713205936-464603 X-HE-Meta: U2FsdGVkX19/wAffCgpu7a77bQU2MTL/rJTTc1QEh/U+mABIhroEN7nVoIeTLg4dYc9H6xHo8aKh7iA5wFRsJjnt3RKEKcDuc7U3vzL0Z7OY/RtVciCk/C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U6q3LU9LzHpWq/9ahHbsNg9R5Tjx0uWLhKTSZ4Jz3/80SJBxLGYCQ5DqrDRmb4w0b6YjW5POeZNtEfgSpfsBODdH6ReA451jQV3XSQbyaVSLIHtfhavEcX6QfTfLb1C3XtZ19LYGg9JEMzndgiwtSZe4bFF8bM0A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Please fix following for this and fifth patch as well: --> checkpatch.pl --codespell tools/testing/selftests/mm/mseal_test.c WARNING: Macros with flow control statements should be avoided #42: FILE: tools/testing/selftests/mm/mseal_test.c:42: +#define FAIL_TEST_IF_FALSE(c) do {\ + if (!(c)) {\ + ksft_test_result_fail("%s, line:%d\n", __func__, __LINE__);\ + goto test_end;\ + } \ + } \ + while (0) WARNING: Macros with flow control statements should be avoided #50: FILE: tools/testing/selftests/mm/mseal_test.c:50: +#define SKIP_TEST_IF_FALSE(c) do {\ + if (!(c)) {\ + ksft_test_result_skip("%s, line:%d\n", __func__, __LINE__);\ + goto test_end;\ + } \ + } \ + while (0) WARNING: Macros with flow control statements should be avoided #59: FILE: tools/testing/selftests/mm/mseal_test.c:59: +#define TEST_END_CHECK() {\ + ksft_test_result_pass("%s\n", __func__);\ + return;\ +test_end:\ + return;\ +} On 4/15/24 9:35 PM, jeffxu@chromium.org wrote: > From: Jeff Xu > > selftest for memory sealing change in mmap() and mseal(). > > Signed-off-by: Jeff Xu > --- > tools/testing/selftests/mm/.gitignore | 1 + > tools/testing/selftests/mm/Makefile | 1 + > tools/testing/selftests/mm/mseal_test.c | 1836 +++++++++++++++++++++++ > 3 files changed, 1838 insertions(+) > create mode 100644 tools/testing/selftests/mm/mseal_test.c > > diff --git a/tools/testing/selftests/mm/.gitignore b/tools/testing/selftests/mm/.gitignore > index d26e962f2ac4..98eaa4590f11 100644 > --- a/tools/testing/selftests/mm/.gitignore > +++ b/tools/testing/selftests/mm/.gitignore > @@ -47,3 +47,4 @@ mkdirty > va_high_addr_switch > hugetlb_fault_after_madv > hugetlb_madv_vs_map > +mseal_test > diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile > index eb5f39a2668b..95d10fe1b3c1 100644 > --- a/tools/testing/selftests/mm/Makefile > +++ b/tools/testing/selftests/mm/Makefile > @@ -59,6 +59,7 @@ TEST_GEN_FILES += mlock2-tests > TEST_GEN_FILES += mrelease_test > TEST_GEN_FILES += mremap_dontunmap > TEST_GEN_FILES += mremap_test > +TEST_GEN_FILES += mseal_test > TEST_GEN_FILES += on-fault-limit > TEST_GEN_FILES += pagemap_ioctl > TEST_GEN_FILES += thuge-gen > diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c > new file mode 100644 > index 000000000000..06c780d1d8e5 > --- /dev/null > +++ b/tools/testing/selftests/mm/mseal_test. > +static void __write_pkey_reg(u64 pkey_reg) > +{ > +#if defined(__i386__) || defined(__x86_64__) /* arch */ > + unsigned int eax = pkey_reg; > + unsigned int ecx = 0; > + unsigned int edx = 0; > + > + asm volatile(".byte 0x0f,0x01,0xef\n\t" > + : : "a" (eax), "c" (ecx), "d" (edx)); > + assert(pkey_reg == __read_pkey_reg()); Use ksft_exit_fail_msg instead of assert to stay inside TAP format if condition is false and error is generated. > +int main(int argc, char **argv) > +{ > + bool test_seal = seal_support(); > + > + ksft_print_header(); > + > + if (!test_seal) > + ksft_exit_skip("sealing not supported, check CONFIG_64BIT\n"); > + > + if (!pkey_supported()) > + ksft_print_msg("PKEY not supported\n"); > + > + ksft_set_plan(80); > + > + test_seal_addseal(); > + test_seal_unmapped_start(); > + test_seal_unmapped_middle(); > + test_seal_unmapped_end(); > + test_seal_multiple_vmas(); > + test_seal_split_start(); > + test_seal_split_end(); > + test_seal_invalid_input(); > + test_seal_zero_length(); > + test_seal_twice(); > + > + test_seal_mprotect(false); > + test_seal_mprotect(true); > + > + test_seal_start_mprotect(false); > + test_seal_start_mprotect(true); > + > + test_seal_end_mprotect(false); > + test_seal_end_mprotect(true); > + > + test_seal_mprotect_unalign_len(false); > + test_seal_mprotect_unalign_len(true); > + > + test_seal_mprotect_unalign_len_variant_2(false); > + test_seal_mprotect_unalign_len_variant_2(true); > + > + test_seal_mprotect_two_vma(false); > + test_seal_mprotect_two_vma(true); > + > + test_seal_mprotect_two_vma_with_split(false); > + test_seal_mprotect_two_vma_with_split(true); > + > + test_seal_mprotect_partial_mprotect(false); > + test_seal_mprotect_partial_mprotect(true); > + > + test_seal_mprotect_two_vma_with_gap(false); > + test_seal_mprotect_two_vma_with_gap(true); > + > + test_seal_mprotect_merge(false); > + test_seal_mprotect_merge(true); > + > + test_seal_mprotect_split(false); > + test_seal_mprotect_split(true); > + > + test_seal_munmap(false); > + test_seal_munmap(true); > + test_seal_munmap_two_vma(false); > + test_seal_munmap_two_vma(true); > + test_seal_munmap_vma_with_gap(false); > + test_seal_munmap_vma_with_gap(true); > + > + test_munmap_start_freed(false); > + test_munmap_start_freed(true); > + test_munmap_middle_freed(false); > + test_munmap_middle_freed(true); > + test_munmap_end_freed(false); > + test_munmap_end_freed(true); > + > + test_seal_mremap_shrink(false); > + test_seal_mremap_shrink(true); > + test_seal_mremap_expand(false); > + test_seal_mremap_expand(true); > + test_seal_mremap_move(false); > + test_seal_mremap_move(true); > + > + test_seal_mremap_shrink_fixed(false); > + test_seal_mremap_shrink_fixed(true); > + test_seal_mremap_expand_fixed(false); > + test_seal_mremap_expand_fixed(true); > + test_seal_mremap_move_fixed(false); > + test_seal_mremap_move_fixed(true); > + test_seal_mremap_move_dontunmap(false); > + test_seal_mremap_move_dontunmap(true); > + test_seal_mremap_move_fixed_zero(false); > + test_seal_mremap_move_fixed_zero(true); > + test_seal_mremap_move_dontunmap_anyaddr(false); > + test_seal_mremap_move_dontunmap_anyaddr(true); > + test_seal_discard_ro_anon(false); > + test_seal_discard_ro_anon(true); > + test_seal_discard_ro_anon_on_rw(false); > + test_seal_discard_ro_anon_on_rw(true); > + test_seal_discard_ro_anon_on_shared(false); > + test_seal_discard_ro_anon_on_shared(true); > + test_seal_discard_ro_anon_on_filebacked(false); > + test_seal_discard_ro_anon_on_filebacked(true); > + test_seal_mmap_overwrite_prot(false); > + test_seal_mmap_overwrite_prot(true); > + test_seal_mmap_expand(false); > + test_seal_mmap_expand(true); > + test_seal_mmap_shrink(false); > + test_seal_mmap_shrink(true); > + > + test_seal_merge_and_split(); > + test_seal_zero_address(); > + > + test_seal_discard_ro_anon_on_pkey(false); > + test_seal_discard_ro_anon_on_pkey(true); > + > + ksft_finished(); > + return 0; The return isn't needed as ksft_finished() calls exit() with right exit code. > +} -- BR, Muhammad Usama Anjum