From patchwork Wed Oct 30 13:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Roy X-Patchwork-Id: 13856553 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 2F26ED5CCAF for ; Wed, 30 Oct 2024 13:50:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B284D6B00C3; Wed, 30 Oct 2024 09:50:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB0C26B00C4; Wed, 30 Oct 2024 09:50:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 901846B00C5; Wed, 30 Oct 2024 09:50:58 -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 70E056B00C3 for ; Wed, 30 Oct 2024 09:50:58 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BCE69ACB55 for ; Wed, 30 Oct 2024 13:50:57 +0000 (UTC) X-FDA: 82730404050.16.35C6A04 Received: from smtp-fw-9102.amazon.com (smtp-fw-9102.amazon.com [207.171.184.29]) by imf03.hostedemail.com (Postfix) with ESMTP id 79E2420022 for ; Wed, 30 Oct 2024 13:50:43 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=amazon.co.uk header.s=amazon201209 header.b=SgkMt6J9; spf=pass (imf03.hostedemail.com: domain of "prvs=02621381b=roypat@amazon.co.uk" designates 207.171.184.29 as permitted sender) smtp.mailfrom="prvs=02621381b=roypat@amazon.co.uk"; dmarc=pass (policy=quarantine) header.from=amazon.co.uk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730296042; 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=7/qXvSh0Hjany10m5XTRwJaHsD/IFz61ERHpnmidOYs=; b=vgECuLV2EG62n+d0y1nTknenVO56VGiCNkW4CbXjj4Q01P2DY8vzXjwj40ks32osOJK5P7 EF6rTvyk2+FP+hFjAR8Kb6f5ulbEWGnNYT7N9ch/lYhypKOsgDbGN+ZKQheXZxvzBXhPA/ b6Jb8llBz81DVg0TKg1o9mKWTF7zF8I= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=amazon.co.uk header.s=amazon201209 header.b=SgkMt6J9; spf=pass (imf03.hostedemail.com: domain of "prvs=02621381b=roypat@amazon.co.uk" designates 207.171.184.29 as permitted sender) smtp.mailfrom="prvs=02621381b=roypat@amazon.co.uk"; dmarc=pass (policy=quarantine) header.from=amazon.co.uk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730296042; a=rsa-sha256; cv=none; b=Ip+1/ONyRnpcHA2lWnQ78PDlVsvJDohh6dE9SjXMVsPUm0ES0sXwL61LdBBoK9pYtfaOK+ GBqY2vsKOfMdy6l87uhNB2dazBBZJzbcDH6t6cUKG3NjjWPTbEmy5/7ichn+4RyAtjp8Lu 9zHgYtqNHrhkR8KWXqjAw9gljqiuRKM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.uk; i=@amazon.co.uk; q=dns/txt; s=amazon201209; t=1730296256; x=1761832256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7/qXvSh0Hjany10m5XTRwJaHsD/IFz61ERHpnmidOYs=; b=SgkMt6J9HN8iWG2LiVkJbpRYGXJj2T5vudnopPfPxO6nQwuibQIZnVaE BePjy8WnN6Bxq8cIgZ1Lnyw66abb5pWrBHZ3+PBSxn5tsZH+6wtfUbBIj vckF7LDmKOx0NlQY3LDtN7/QphgzD9dVJZfmoI4qyuoTwWgXKCQ8tz5cd A=; X-IronPort-AV: E=Sophos;i="6.11,245,1725321600"; d="scan'208";a="465820264" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.214]) by smtp-border-fw-9102.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 13:50:54 +0000 Received: from EX19MTAUWB002.ant.amazon.com [10.0.21.151:12628] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.35.102:2525] with esmtp (Farcaster) id 00b2c9f1-27f5-4a01-ae54-6fda17405dbb; Wed, 30 Oct 2024 13:50:53 +0000 (UTC) X-Farcaster-Flow-ID: 00b2c9f1-27f5-4a01-ae54-6fda17405dbb Received: from EX19D020UWC002.ant.amazon.com (10.13.138.147) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Wed, 30 Oct 2024 13:50:46 +0000 Received: from EX19MTAUEB002.ant.amazon.com (10.252.135.47) by EX19D020UWC002.ant.amazon.com (10.13.138.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Wed, 30 Oct 2024 13:50:45 +0000 Received: from email-imr-corp-prod-pdx-all-2c-8a67eb17.us-west-2.amazon.com (10.43.8.2) by mail-relay.amazon.com (10.252.135.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34 via Frontend Transport; Wed, 30 Oct 2024 13:50:45 +0000 Received: from ua2d7e1a6107c5b.home (dev-dsk-roypat-1c-dbe2a224.eu-west-1.amazon.com [172.19.88.180]) by email-imr-corp-prod-pdx-all-2c-8a67eb17.us-west-2.amazon.com (Postfix) with ESMTPS id B5B724032D; Wed, 30 Oct 2024 13:50:35 +0000 (UTC) From: Patrick Roy To: , , , , , , , , CC: Patrick Roy , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v3 6/6] kvm: selftests: run gmem tests with KVM_GMEM_NO_DIRECT_MAP set Date: Wed, 30 Oct 2024 13:49:10 +0000 Message-ID: <20241030134912.515725-7-roypat@amazon.co.uk> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030134912.515725-1-roypat@amazon.co.uk> References: <20241030134912.515725-1-roypat@amazon.co.uk> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 79E2420022 X-Stat-Signature: 1ccd8mhedk8i3wmfkmeg45qikex8mq3e X-Rspam-User: X-HE-Tag: 1730296243-273635 X-HE-Meta: U2FsdGVkX1/14vU12xIgzcPL9dUNcLRmiGONApETNc1ZQgu7Xcx868yVmOC74osOUKH3LSVZDmqs8HjIRtE+UsJ+7qz+qWLa1iTRFSKLEfBfpVVP629cwERZj+HfeELPD7JVIGyIefCW3pqnQRk9+Vxe+6B72LJpGr7qYXoqTAgv3EmxPWZyEWLYIDJ2eMiJQQlIvkqVGVn+8xUPzKiZp1UyLZeYUDQjBXKooLDTLgQNQb3yKPU2j4qhOy6KHPFAk1tvOSetbE2vfPczkJ1E3RRdGVjliVpJMSfAFApG6cjBj7sdACh6wy98A0wLpR4kbj7ebi6cwy7MhlNZEKVnRAqP1gkE9kr4ZDyagcpDiJomwXpREM9lxQv81upW6mfNDPAz3h3zk4JTwA3M1+b4W7urCEoIyam5UlfAgmAsU5FujLfas/n4r4CYi/b4gvvgeb9VkfPDVe+ayeRKSqpdN8IipMD/MccMkvERCWj54GmxOzN2ls77mHgOO36lxMUCHSZiz1BJE7Bzjj8fxlRYc/7ufvRWIftBP6/4sxcZEKGyf2r0Lxf5rL4Zyhp5taRLflIX/WK9BIK1x8UqIL/uWFI+EODTgdQOluybJ7ShIbCT2qTwISL+PjcbBB1+61YbW8L32hbbKhPVKBbYlbRQ6hujDSByfRfiArhjt9UUH/bgheODRQP0PgMWN0ICxLx4iUJfPArag/dNp4GR1443VydwPhGsQdURq84vXJC2SZFhbVV/8e7FdOIbJBiATfaivzRKnlN0g3aw2yg02NkpPGXqv88iZ8IdZJFNsSx3DyeH/QS2i6hpWlEsqQmAsRJaCC3dbKRC1N9vudtpzUsJDU7Ed/XJoYN1zV6nS5FgiAqBnuGkHK5aKSbXXiz371i23B98lHqts7Mrx6FhqPgBfX62+qIJxIn+WFnwZFM+Ev1AQg/+7BZzWSauAkDcBuuvF0uWyxhViEGIZk01GH4 3jTZbeo8 ryRsU9ZZj5O/rzimyIkS8a81HehVViZiWpZ9Zg745rKEkP9CgMfW46tPoblAYpP63GaaVtV+/5pXoyFESl+NQ4HfHOFsvXRQLXnxCM0dWvqUwXNY1/m5VCf2dLQzVDdxS1bazKZ2n0PGKfv26E953NaJ1TKv39vpSVgWJrzX6t7ukb8ahWRKRRJDtExaM7AuWwv5etEC3LsO5DBNltBPWHacEIvo0GKjmIrJ0V+bXimBzAiOzzRo48a1Vk3mfbWu0jefnwTsYiPd4yYwcd5SryLCh5DMflKm3SyShjzA6Hf28kOybJk6dXeFK6SSQOkOWt51J93vbKPbVNNye+AmCHupQrF4GxghsD8pI6aTQELOMKPSYhElkLT8nZdjomS6O0H57XUOVpVI0oBR8Get67u8/9cQx7mjLvgjF8lnmbGd/eBG8PIQzglP5c8RXPKG5Vc8UDADOBzvQ6nI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Also adjust test_create_guest_memfd_invalid, as now BIT(0) is a valid value for flags (note that this also fixes an issue where the loop in test_create_guest_memfd_invalid is a noop. I've posted that fix as a separate patch last week [1]). [1]: https://lore.kernel.org/kvm/20241024095956.3668818-1-roypat@amazon.co.uk/ Signed-off-by: Patrick Roy --- tools/testing/selftests/kvm/guest_memfd_test.c | 2 +- .../selftests/kvm/x86_64/private_mem_conversions_test.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c index ba0c8e9960358..d04f7ff3dfb15 100644 --- a/tools/testing/selftests/kvm/guest_memfd_test.c +++ b/tools/testing/selftests/kvm/guest_memfd_test.c @@ -134,7 +134,7 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm) size); } - for (flag = 0; flag; flag <<= 1) { + for (flag = BIT(1); flag; flag <<= 1) { fd = __vm_create_guest_memfd(vm, page_size, flag); TEST_ASSERT(fd == -1 && errno == EINVAL, "guest_memfd() with flag '0x%lx' should fail with EINVAL", diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c index 82a8d88b5338e..dfc78781e93b8 100644 --- a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c +++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c @@ -367,7 +367,7 @@ static void *__test_mem_conversions(void *__vcpu) } static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t nr_vcpus, - uint32_t nr_memslots) + uint32_t nr_memslots, uint64_t gmem_flags) { /* * Allocate enough memory so that each vCPU's chunk of memory can be @@ -394,7 +394,7 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t vm_enable_cap(vm, KVM_CAP_EXIT_HYPERCALL, (1 << KVM_HC_MAP_GPA_RANGE)); - memfd = vm_create_guest_memfd(vm, memfd_size, 0); + memfd = vm_create_guest_memfd(vm, memfd_size, gmem_flags); for (i = 0; i < nr_memslots; i++) vm_mem_add(vm, src_type, BASE_DATA_GPA + slot_size * i, @@ -477,7 +477,8 @@ int main(int argc, char *argv[]) } } - test_mem_conversions(src_type, nr_vcpus, nr_memslots); + test_mem_conversions(src_type, nr_vcpus, nr_memslots, 0); + test_mem_conversions(src_type, nr_vcpus, nr_memslots, KVM_GMEM_NO_DIRECT_MAP); return 0; }