From patchwork Thu Mar 16 00:30:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13176851 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 9EBDDC61DA4 for ; Thu, 16 Mar 2023 00:31:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC0276B0078; Wed, 15 Mar 2023 20:31:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E70C26B007B; Wed, 15 Mar 2023 20:31:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D38676B007D; Wed, 15 Mar 2023 20:31:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C7ABE6B0078 for ; Wed, 15 Mar 2023 20:31:15 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 877011611D7 for ; Thu, 16 Mar 2023 00:31:15 +0000 (UTC) X-FDA: 80572882110.21.0E868D3 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf03.hostedemail.com (Postfix) with ESMTP id C8D4020018 for ; Thu, 16 Mar 2023 00:31:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Nz5kUB5U; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3UGMSZAsKCIclnvp2wp94yrrzzrwp.nzxwty58-xxv6lnv.z2r@flex--ackerleytng.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3UGMSZAsKCIclnvp2wp94yrrzzrwp.nzxwty58-xxv6lnv.z2r@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678926673; 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: references:dkim-signature; bh=hT7y2XaFexWW4GTLeQpLaRg79NNFfwA0Go2glRLgBd0=; b=K5NLzN/D1R0uz8Z/9NgBITx8gGz6XDFTM9IZfp3SIJOGAcr/GUFQUViKHcCt8b90Tyndb2 Kd8N82Uu48gE5rUEkr+I8OMDwFNMTdfibbrXQSoqIWrgfhn59SslcWNoL5p2ibLFPmMenX OuoEL3pAIm4wtvaGJQqcsbplpaNw3XU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Nz5kUB5U; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3UGMSZAsKCIclnvp2wp94yrrzzrwp.nzxwty58-xxv6lnv.z2r@flex--ackerleytng.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3UGMSZAsKCIclnvp2wp94yrrzzrwp.nzxwty58-xxv6lnv.z2r@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678926673; a=rsa-sha256; cv=none; b=wzZrh0DacYgL/V0tClXRgbFD1VJF6Rl8uIM9Arw9DYMjmkd6sbsFiexaE645bm3Axq0kMk OgCX3ATJ0Wybaw0kq/2+mu/HrqXnJUfDVuVdcoG4njKDu8uDG3zJi7YzdYsdGctR3WyEFt x4OJHUZIO821u8B1o8KGnOkZs8Bdtc8= Received: by mail-pf1-f201.google.com with SMTP id a17-20020a056a001d1100b00625760338c5so169823pfx.14 for ; Wed, 15 Mar 2023 17:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678926672; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=hT7y2XaFexWW4GTLeQpLaRg79NNFfwA0Go2glRLgBd0=; b=Nz5kUB5UsktVLM+1ioYn0/f+EE3tG8bYDmBZ7k4J/Gt/p5gTfQtvXXnoIclpQPuDya iUSZv4Ya8c29iPtlOA7O8kWfsasypPc8z6XfRhbOcsmBwYKUvOolqz9fQyk7NgQiLh/7 c/HaSbFKMHr9gsoqPFgvukhunTri9uzxM+/T1bb2dlQR9ihIBftzfIgbbB2EA9ig0QfN QH/Qst7Frnk64y0MYkI8/9p+OMNZJnbfWHBkKL+LoqwoHnfU22JRu1wnbHr5/KauoW4g wseQ2RJb2qNMKAO2J1HN6p/Ws+7+zkBAtzloNtEG5key9qZ2BL1aJc7RLJD21ClZZS8U CQZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678926672; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hT7y2XaFexWW4GTLeQpLaRg79NNFfwA0Go2glRLgBd0=; b=5EsjYiqfubBeA1eOTJahlQJF8qv89bAZ/pAbRgvGjVupj59b/Ez6pH2fmHUScPD8vw HZMhj4VLMpy9kccJoC3nFKGRspBQPL9L/qWlCJoLsHJAXTH72jtbpujjLTFr9YweVde0 N2jSc2ujPKoFv7jnB9VQsnZlD1XFk1XcQI8pesQuYE6+066mNSouerNlKQ45jJ3DEjwx d3DeOqSKP/BrcdN8wmo+Tc9vpn+HMvo4A0BcSsNfAl9AoCYafbAtACAuSFmxJfr76utS OyBgWexJBm5rgHIVuH5Gz9yiKz5r1W5K/4fTyDE199+emTRDbnCynx2yfXwd38ZjEHcb zRGQ== X-Gm-Message-State: AO0yUKU7wLkLU2j0HBekwHLOWhp3GyGegZArtj1c1/hht2Evvut9XLPB nC7QP2v/wNRxUBqS6AjFzsk4deKOJyIM+x6Zow== X-Google-Smtp-Source: AK7set8RzBYOsHbOBr2r5L/IBVJur+dXP5lqulE2m7qrJjHyB4MEFVa/vv90/0ZD7J2Luh92QLgQMrMQJM0g7dhFsw== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a17:90a:ea89:b0:237:2516:f76a with SMTP id h9-20020a17090aea8900b002372516f76amr548955pjz.2.1678926672510; Wed, 15 Mar 2023 17:31:12 -0700 (PDT) Date: Thu, 16 Mar 2023 00:30:53 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog Message-ID: Subject: [RFC PATCH 00/10] Additional selftests for restrictedmem From: Ackerley Tng To: kvm@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, qemu-devel@nongnu.org Cc: aarcange@redhat.com, ak@linux.intel.com, akpm@linux-foundation.org, arnd@arndb.de, bfields@fieldses.org, bp@alien8.de, chao.p.peng@linux.intel.com, corbet@lwn.net, dave.hansen@intel.com, david@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, hpa@zytor.com, hughd@google.com, jlayton@kernel.org, jmattson@google.com, joro@8bytes.org, jun.nakajima@intel.com, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, luto@kernel.org, mail@maciej.szmigiero.name, mhocko@suse.com, michael.roth@amd.com, mingo@redhat.com, naoya.horiguchi@nec.com, pbonzini@redhat.com, qperret@google.com, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, tabba@google.com, tglx@linutronix.de, vannapurve@google.com, vbabka@suse.cz, vkuznets@redhat.com, wanpengli@tencent.com, wei.w.wang@intel.com, x86@kernel.org, yu.c.zhang@linux.intel.com, Ackerley Tng X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C8D4020018 X-Stat-Signature: weqkxaexpou6my8m366o6hj8i4ui576x X-HE-Tag: 1678926673-968801 X-HE-Meta: U2FsdGVkX1/5jI0EboIdPv7AVfP5bI7JH3whiwUtpD3bAVUyISFkAWS69+4qrNe9LCtPL4VS2kgInNzTgo4OcKtJKxeYwMknrl2TYbH8LRrSY60O82O+GdommImrE3LnTglUTNrJHaw/3VuGEpuXfGmWhCoeAdiZgS/H/JSMUTuxxT6doNlf3oNuUp/0TRy034r6poG8FdT3T9PzIlMOD1V5ClivoGGZszDSNm7DSoauK5Udsu37DGS/8IIGx2vNvJMQ+zN5Ya9aLzHo/WxFwQxpF4ZyZzSVS0i7cKFdp8pikd437FCECHIkJX49AlOELVwYbldKkWjWlNU0mrYjJI98UiejW0upTXqpYol1miATumGTMcKJTI/XijA54KOBB7z1Ck/jORbx2RTpuXHZrhzCu4JqY5rjanPdeIgEHP1F59jiJpIH0LLW8tKAvn12GR0UkJE79CrPVeF0OGbOzsbA2yqlTgifEjOzCkO1gp0AUEEvMrJGHWOC7QbWm1Ax399x7CRPcepBO4vO8h/kKXBvEmdRDlo2UrKCsmVn1WcvFX0dzWT2swpU2B4iXJDMsOEExKXM0UYBmAMpRqNca2DpMyLyEgNPDymFy2vakVte0M3u0EhZcPD8ViV3syNg7eV/jZUBsY3OtMovk00nFT2O3/Z26cc92zSiZykuDtwj/zR2gqiIDwA63U5PJ8nunds3XZmTueJ0LWr+JJDWk5x8PCE/djVV9CaSqHgo3PP2sjdDhqHN9xKUSkfKEpgdGTCt6phqA2MUbKuYMqANf6XpzrcFLqXHIjCSmvQEjYJu8/1N2de/xZ8MxDwIFic+kDtElgTUa8YlrhLG88lncPqXkCtxgQK9380m8UamutMGwhhSAb5jwNF26Iuc+rSTh9P0GTLSWv4BYo0iLyzcTkrulnTR6I6QhdgQFfQVkr4sOB3hzWVeduBq2qy2TzgbKmTFogjRLVVngS9IzKE K0JWIp60 CJrlEhWVnxT9x70qm83jFqzFAXpbyg2Typova8d/rYVcRzDhZtmlHaHs88Djx8ltSfnjj3Z5qikM+eVhLxcaG1Y/jETuet9JnuU1QUGA2Ayt7AIhrBCzP91ZtGTxC1FxlgWaFodGj9wHxVmcXHAvcAaH3MMhv6Qh3/JHh/uhS6600cvRarqW5IXMdYx33sHbOOpigkThaAaWozyc7/xqZITTiQ2i5HuQgqn9zabyNFfNgDSORbIHbf72kNMUpmGvNikr8vDThaXItgp5bmoOsFe1qFP3fiYHzFxrHqE8KXiQaxuBifo7UxDrD9V1WJigR7KHe0Y2OviAGGsiSRHYU08N96rTOrKFbE0VF/8B5GoHOkbMuMT/fojF8C5p5eygtbcF34Fn3o9swR566cIWp7D0Tz3qaX6qcyEJXxEweQzIAqAdUoYvoARxoEozjbqSxhBvSD+4BW1D2SW5CgtxMKBajYuruBRNXuttpnhjJGajhuQXKfjvq5TOjT8mh7OPXkyFmM/i04FnaDeqyh2mWmEKQkfv2aqYjbHtsI1E/0NBybqZJKGdvIxeFYXys+IjpAmahiXfGWfHiL29h6cARxnbNGWZnEN0kNXldmq822YJx+1pq7Okn4lrbmR8YeG5H4QoVTXrrOCOwlfMMy8xIFmwFcIRPblLmDXtKOBnSTWxdZqi2XqPcucEutt0l54398FhAAKDkE2VVVWezqCxSB9bKHVE4IxD2oADXcwd4z3ud9puYVX6gz69QqDZQUM6TYKa5AT+r8yrgcMK2soDnVLkYdBUkqavp6ZAJ6113FPLHUDhL/V3xQSlbNoqquXBQgdiU 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: Hello, This is a series containing additional selftests for restrictedmem, prepared to be used with the next iteration of the restrictedmem series after v10. restrictedmem v10 is available at https://lore.kernel.org/lkml/20221202061347.1070246-1-chao.p.peng@linux.intel.com/T/. The tree can be found at https://github.com/googleprodkernel/linux-cc/tree/restrictedmem-additional-selftests-rfc-v1/. Dependencies + The next iteration of the restrictedmem series + branch: https://github.com/chao-p/linux/commits/privmem-v11.4 + commit: https://github.com/chao-p/linux/tree/ddd2c92b268a2fdc6158f82a6169ad1a57f2a01d + Proposed fix to adjust VM's initial stack address to align with SysV ABI spec: https://lore.kernel.org/lkml/20230227180601.104318-1-ackerleytng@google.com/ Ackerley Tng (10): KVM: selftests: Test error message fixes for memfd_restricted selftests KVM: selftests: Test that ftruncate to non-page-aligned size on a restrictedmem fd should fail KVM: selftests: Test that VM private memory should not be readable from host KVM: selftests: Exercise restrictedmem allocation and truncation code after KVM invalidation code has been unbound KVM: selftests: Generalize private_mem_conversions_test for parallel execution KVM: selftests: Default private_mem_conversions_test to use 1 memslot for test data KVM: selftests: Add vm_userspace_mem_region_add_with_restrictedmem KVM: selftests: Default private_mem_conversions_test to use 1 restrictedmem file for test data KVM: selftests: Add tests around sharing a restrictedmem fd KVM: selftests: Test KVM exit behavior for private memory/access tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/kvm_util_base.h | 4 + tools/testing/selftests/kvm/lib/kvm_util.c | 46 ++- .../selftests/kvm/set_memory_region_test.c | 29 +- .../kvm/x86_64/private_mem_conversions_test.c | 295 +++++++++++++++--- .../kvm/x86_64/private_mem_kvm_exits_test.c | 124 ++++++++ tools/testing/selftests/vm/memfd_restricted.c | 9 +- 7 files changed, 455 insertions(+), 53 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/private_mem_kvm_exits_test.c --- 2.40.0.rc2.332.ga46443480c-goog