From patchwork Wed Jan 3 08:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 18668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4910288dyb; Wed, 3 Jan 2024 01:13:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjwNov6YnvyK66Op18EwIfxKCEyPmBczGXAVwpK++a3lK5lLKg7wu1nNh/oyZMlkY1HAWF X-Received: by 2002:a05:6a20:da86:b0:198:5739:22b9 with SMTP id iy6-20020a056a20da8600b00198573922b9mr61114pzb.56.1704273220593; Wed, 03 Jan 2024 01:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704273220; cv=none; d=google.com; s=arc-20160816; b=lpb3zV88iX2QqKM024jQ6HGk57e+0Vf3w4nOH7rx3Rv7Z7Rh2whgaOzv+wtdAF6Jpe g1pV1tUPfKzxjqfPqf+QrQep6s7BnpmrlPs0R55owv1UebYEWtlr5pnIg/hk7608rhRe HofD1TbI7Ygu2wwFrnVH7MQ//SIyd8oDbv9YUTIaXB+RBKOjcAxM8vS4x+anXVC3Xjrg oPeekHYLe9t1Hjerd4wbGdaN6IEB+5QHLmauZeEW/RnET5+B7g8NVmb9dSoJsiuXNFv7 rG47YTpxZVTM2L88MCO/5cixLFrdmB8lQoOnJM4+il60sQbHfBXp85/IRSt5eG5ex+xC Bhlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=PQ03vxn9DsVx+3hwFil7+V2M/O+QIG13nnHLdj3jUIU=; fh=Vx93WHraSNwAtImeuZXYuwSlSJ9uZLtDICdtmXdGBhg=; b=XcKMpF30B7DIxB7dEWExD/56zfvMDfvZ1VM7xJXoqfGvl44So6Y7mwl5PMMcRJjIai GP4bhK3+dmp0Q3n2Euz7b9TYdnl0stnrsmxn9pfk/AyLQc4iT5V/uLNck/Pz0j7Pc9jb RNEyGdyTq/VEsls2dBEJKERQB69nZ055ECNkuAmgN6Bjc52kaU1XSFPUGciIPDy+KEJX ZrX2yrr7voQww9n5zYJvZcBuKC8V5jZl5rv0LyYTIw5tOBStk08eOGH0QD5OdraPGNih tzlGCjC6bZZX6Xbb4lK5F3MfgMezhNxSD+dHmlZdhxTXfQ7VJxd2iCELcw1QCRX6IhNo o1Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RgmJcQaY; spf=pass (google.com: domain of linux-kernel+bounces-15308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x26-20020aa7919a000000b006d09859390bsi21298451pfa.16.2024.01.03.01.13.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 01:13:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RgmJcQaY; spf=pass (google.com: domain of linux-kernel+bounces-15308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A65CDB22AAC for ; Wed, 3 Jan 2024 09:13:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A49F318656; Wed, 3 Jan 2024 09:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RgmJcQaY" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCB0F182AF; Wed, 3 Jan 2024 09:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704273168; x=1735809168; h=from:to:cc:subject:date:message-id; bh=gPf7rfKmzwzlXV8d5iHJVEkj1nA/mwcPl3PJ7L7K2SY=; b=RgmJcQaYTdhtkAMWmVasSkGa3nwp9fdwGMzftKwiXfqQFi4oCdQotMp/ 990xE/ePj+O2oY0hST05KlA+j6sRrzXS+hUNloz9YrdRFxCF2y/fbj3kr cCvfBGRv79raVpmfNNcvo0u3EJ67tCJ5E8MD+42iU11/yEDhrTEw6fE7B 35zjStJQgtwxjY00MRPDVVzyx8sEy5rc4wQ13aln8YDhUl/4/yaVKw1Nj NW6uafhp/pmwjK51rDMpMzayaSnGdfjNxRcpjf/yp/UCruEQth7BseTJX OkZuIQf5cwhV42Hlx0TIANcBG2vD3/GY1KHocJF/cd4HqCbvb7rKK7K11 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="463386609" X-IronPort-AV: E=Sophos;i="6.04,327,1695711600"; d="scan'208";a="463386609" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2024 01:12:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="783445220" X-IronPort-AV: E=Sophos;i="6.04,327,1695711600"; d="scan'208";a="783445220" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2024 01:12:45 -0800 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, shuah@kernel.org, stevensd@chromium.org, Yan Zhao Subject: [RFC PATCH v2 0/3] KVM: allow mapping of compound tail pages for IO or PFNMAP mapping Date: Wed, 3 Jan 2024 16:43:27 +0800 Message-Id: <20240103084327.19955-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787059996438594106 X-GMAIL-MSGID: 1787059996438594106 This is a v2 for previous series [1] to allow mapping for compound tail pages for IO or PFNMAP mapping. Compared to v1, this version provides selftest to check functionality in KVM to map memslots for MMIO BARs (VMAs with flag VM_IO | VM_PFNMAP), as requested by Sean in [1]. The selftest can also be used to test series "allow mapping non-refcounted pages" [2]. Tag RFC is added because a test driver is introduced in patch 2, which is new to KVM selftest, and test "set_memory_region_io" in patch 3 depends on that the test driver is compiled and loaded in kernel. Besides, patch 3 calls vm_set_user_memory_region() directly without modifying vm_mem_add(). So, this series is sent to ensure the main direction is right. Thanks Yan [1] https://lore.kernel.org/all/20230719083332.4584-1-yan.y.zhao@intel.com/ [2] https://lore.kernel.org/all/20230911021637.1941096-1-stevensd@google.com/ v2: added patch 2 and 3 to do selftest for patch 1 (Sean). Yan Zhao (3): KVM: allow mapping of compound tail pages for IO or PFNMAP mapping KVM: selftests: add selftest driver for KVM to test memory slots for MMIO BARs KVM: selftests: Add set_memory_region_io to test memslots for MMIO BARs lib/Kconfig.debug | 14 + lib/Makefile | 1 + lib/test_kvm_mock_device.c | 281 ++++++++++++++++++ lib/test_kvm_mock_device_uapi.h | 16 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/set_memory_region_io.c | 188 ++++++++++++ virt/kvm/kvm_main.c | 2 +- 7 files changed, 502 insertions(+), 1 deletion(-) create mode 100644 lib/test_kvm_mock_device.c create mode 100644 lib/test_kvm_mock_device_uapi.h create mode 100644 tools/testing/selftests/kvm/set_memory_region_io.c base-commit: 8ed26ab8d59111c2f7b86d200d1eb97d2a458fd1