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 62C62C25B47 for ; Fri, 27 Oct 2023 18:22:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF8E2900003; Fri, 27 Oct 2023 14:22:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8050900002; Fri, 27 Oct 2023 14:22:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFB6A900003; Fri, 27 Oct 2023 14:22:28 -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 B95D6900002 for ; Fri, 27 Oct 2023 14:22:28 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 96C39B60FA for ; Fri, 27 Oct 2023 18:22:28 +0000 (UTC) X-FDA: 81392061576.07.26FE3A7 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf04.hostedemail.com (Postfix) with ESMTP id B2BA640002 for ; Fri, 27 Oct 2023 18:22:26 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=EzcqqhfI; spf=pass (imf04.hostedemail.com: domain of 34f87ZQYKCAIugcpleiqqing.eqonkpwz-oomxcem.qti@flex--seanjc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=34f87ZQYKCAIugcpleiqqing.eqonkpwz-oomxcem.qti@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698430946; h=from:from:sender:reply-to: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=fUZ5ENGgmRmdtlmB4O/zxFZAY6wVMss4e0CPBbiQKYo=; b=ejNVz1qd2HjXAWKaxR+l5afPAkanD21Rm0By/vjZHLDBF3qURDG0ew1pUt8B8Yjaai+Omp PlKaqeXRKHS6TA8YwAivTmyKsYgt037KfyHpSxaNFBdkz8702U+RcEDJghxMrKpfraxc8J LmeZuoh9DWLhw+bcEnXA43k0cyi9QW8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=EzcqqhfI; spf=pass (imf04.hostedemail.com: domain of 34f87ZQYKCAIugcpleiqqing.eqonkpwz-oomxcem.qti@flex--seanjc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=34f87ZQYKCAIugcpleiqqing.eqonkpwz-oomxcem.qti@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698430946; a=rsa-sha256; cv=none; b=0MoJTMxqMN/U/wTWAFbp7PrDwZl0OF2uzoxqcK0mgUq5lTllYeQ3VDhH+UTyoUgOXC1BsE 5N2DpDuPHC9e9IPkvKTg6ml9FjbEBBcmQLscQq4Cg77DYOYGXZhc2aQcDdDThR5AXjmshG y3Gq5441i4n4vAobaNrUcc2udXjP7og= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-da033914f7cso1721451276.0 for ; Fri, 27 Oct 2023 11:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698430945; x=1699035745; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:reply-to:from:to:cc:subject:date:message-id :reply-to; bh=fUZ5ENGgmRmdtlmB4O/zxFZAY6wVMss4e0CPBbiQKYo=; b=EzcqqhfIm99RHFMuoK6HN4UvgFI3raWGBu65VcgJeBlyA63TygyUDyMg3G5eDc8fnM HXBIlE0AFFGS0qy5ft2cfG4u0Zjqo96FiWCzwIK95dVqVFHZQ7QS9wnegUk70P3JYe/M Eu6tITj1akV8FFzheSww7VxdTYnKTrubQCWI4iOMm1ErX2JfFKDnavJZ/rLnvFXftEmW jyOMf7DFpkg+/TCbQaoD+gjVUPwYkL1FPcUUz9SQYQ+pGzvuXRrYWjjsL80t+hW+DJk5 Vxs54gpyniw08ra4bds97Z7Jnj2YTOo8k2re+DD7MsXmonDUhwGxZ9axTVa7Zxe/azl+ wcfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698430945; x=1699035745; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=fUZ5ENGgmRmdtlmB4O/zxFZAY6wVMss4e0CPBbiQKYo=; b=evfmwULVzlZf5t8yhqozVZxSvab6gXzEG0uj/ii2L8XLAzIlp1Yq87CBL508sfNmj7 3gOhufOYhObUeRY/eAW18DCA9rDMKRqi73B5TANSMaYgJOBPOV/mkZ/zyT4W7sIrybAP MRH8GAA5LjiaEP5bZqGtH9TnA48ZhLwr1T3wi1tePY9BKLc+RRAQFq7NdynsC1tKMzEo Q8b5mU8lHMx7V6Jkc9rgis7BdFBVg7b4gGkmme6Qv2+Bz/2W7lexpg5b+mALKBmZKSmc OkvGppCzx/LOe0CRRRc/Yq++O/SMm5y2iYluAOG1CTvhO6YdUoxWyudtugiuNc7OVU/q 5z0g== X-Gm-Message-State: AOJu0Yy8Fk8490Yz8IIJmsRqKkTTYZBCeRUr5U8P8CkEBisQgno9ehtI +Yqw0Ae79SL44XmRyImyqh7SX0cv6TM= X-Google-Smtp-Source: AGHT+IGTik1l5+MoAT0aZ1l3D7LvoGlEGGN/NmlkhnDMNOMyyxG0/NfMrOpUoSzppBt5u8UnrWOecHFs6SQ= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:d601:0:b0:d9a:6b49:433d with SMTP id n1-20020a25d601000000b00d9a6b49433dmr66158ybg.6.1698430945618; Fri, 27 Oct 2023 11:22:25 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 27 Oct 2023 11:21:42 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231027182217.3615211-1-seanjc@google.com> Subject: [PATCH v13 00/35] KVM: guest_memfd() and per-page attributes From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Sean Christopherson , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , "=?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?=" , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: B2BA640002 X-Rspam-User: X-Stat-Signature: cfadajbqmca5zifkubwe9wwtasz8tucb X-Rspamd-Server: rspam01 X-HE-Tag: 1698430946-388990 X-HE-Meta: U2FsdGVkX18Wb5V6C/1pq992kVD553PKcsZ+xONecwBTI7dwANKqVIuQvq594KHXFGvMF+Za+a38mXoWJBraXzhg1waRfMCp5Ua9g1cjsOZQUvY6gvtduV3SQWSsbdG3RQfPu72NNY/8jyZ0RLFctOG/kZqvU4nrA+614dJpBG1gNqVwRKScIFvGkSO3RVuhk+8MOr3rq/RJFH8ews547JcTwyVfLC0Kok0mG7Ote6UvV0SMwiV+crjo+VJ0lqS7qn5nJ1Y0oXmp7yU/DRde+h/hvwwKkehEu36cPcehvfbLVbhFgSro2EVjLqqcRUZQ+XA29YL4HZ6cY2ABmaWSMNbfiMmniMn+WP/iYqvAMPkAKi+pQ4aQlATUQK1oyBf/BK+YWM8YQ1rnxsLmSxqLFswbUWwu1OCm/rKaRIhxFkLUkamQdmjQEMHkS2Zu/CmPB88L7Bj+chcgiG8OJj9ddP09l5Nzrfvctxb0A4ed0sf/GGoikmn4V2cIHeljuIpO1I/trdrgg0ml8w8z73AKAq0xGBGTwOoekfAw3x6Q9N1C+7/FBN9GmWQofjgwYRQri9TGfBvm3hkWwSkGvM5RZdgk0x2U4yh9t0FRqCaPKaxlQeYaQBsphFKo3faTT6FMZswHeOds1fLTKA29Natq0Cv2gNk+Miw0OD3rgYRtVGEbispoceppYaHVpOPCrok119a++3vGAG+14gCR01X7Yxc71aEeoDy1inYgZqkO+SKlELhg8GLpcqwQU+hce7iRzJT6w1UVoB4G8s8rIsO8CLq1dtU/EcstleEovyRdtBjy6U+N8h9wiER8vsXbFngJlidu8zRf933iBNV4ikt8W/uQYPu5wB7QJzIO7ZQNnNk8V+i0qM6h2C5qWFp/+EcuPvOwV2FWPBMa/KxEw7VcHXYhf+/msr3barbUiafJmyKmJYCJMF27OfBex8W8B6oneSdbboVrnn83Ws+Gn2r aHAbGmn2 cDWmcyTVeRgjLhA9P47q5PeNir9rXkSS7TzOKloZyrM/gnFZ2NfL7lqBx6B+ryIyfnUouxu+GXREDMm+XK6ZcccZlH+lsNaB3tV+9lLpThbiMAZE/6E0LTgGkzXE+m9Ao2UKBneI+U/nUkR0+PVV/BdHkJRI5TmTrn/Iv3l5TWpOozzo91g0mZlNcAAvSRUP9hiV+cioOvAQCqbKn+f/Vv5eSSkPcN71H5h0ZKK3/ABAaQgO9CnmijTR0oESdrS1YLu1y4yBe5j5YOwpTGWzF13qcD42TrO/gEMV8fUan8EDQGbR8lPA0nblb01blcO1DWlxTfHRYhSK/2jSxLkADj9U1X29WGAnszkRo/5Gisnx/hxFdvYW8tffsperbIJi23W5kFDeJxbmeue4DmbccYlNA4McLmxm3YMce1YCHvmu/KNuAogGgstHued4o1oVJhRb65TKlJs4waR+ZW3JQeUCYqTk7hrE3SqdlqcEqJpNnNXXzvOFKS3tl/2a6XQuf1kUC4wDcimo6YHAPtfDKQbu80h1eaeLVYVwQ19Xc9tJ17FVp9kWKPQ/3y/eMbCdXrEshhKCFD9lL2e+Ax/m85AN4OUsnKsqzajEjYNz34waT3zqmk7CkboeFbfOVSHEY6zSAmeqOpVTjQpj8+wcPYz2tBXDpg+dF+Ih1K3M/M7Paaz5CSqe12vbPxtr4aHiHPPySyA68YFucq15WuQSo+EmkUSAZjl0DgiXICh8Awlij/F5ecBt1zzh5jk8630p2uPNsiJAZjWXRlXV6sV2+LKgpGXpF3JiXEHgwiaoX22vARZyTgu5MnOZbL+ofomuSkoDvETWpbs8/6QhodaYlPo19JnTZj9p2XWqo+tiRadF5wDyyVERestRxRcKAm2AtPkVcpT7mWvmcxeg= 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: Non-KVM people, please take a gander at two small-ish patches buried in the middle of this series: fs: Export anon_inode_getfile_secure() for use by KVM mm: Add AS_UNMOVABLE to mark mapping as completely unmovable Our plan/hope is to take this through the KVM tree for 6.8, reviews (and ac= ks!) would be much appreciated. Note, adding AS_UNMOVABLE isn't strictly requir= ed as it's "just" an optimization, but we'd prefer to have it in place straightaw= ay. Reviews on all the KVM changes, especially the guest_memfd.c implementation= , are also most definitely welcome. The "what and why" at the very bottom is hopefully old news for most reader= s. My plan is to copy the blurb into a tag when this is merged (today's word of t= he day is: optimism), e.g. so that the big picture and why we're doing this is cap= tured in the git history. Note, the v13 changelog below captures only changes that were not posted an= d applied to the v12+ development branch. Those changes can be found in comm= its 46c10adeda81..74a4d3b6a284 at =20 https://github.com/kvm-x86/linux.git tags/kvm-x86-guest_memfd-v12 This series can be found at https://github.com/kvm-x86/linux.git guest_memfd kvm-x86/guest_memfd is also now being fed into kvm-x86/next, i.e. will be g= etting coverage in linux-next as of the next build. Similar to the v12 "development cycle", any changes needed will be applied = on top of v13, and squashed prior to sending v14 (if needed) or merging (optim= ism!). KVM folks, ***LOOK HERE***. v13 has several breaking userspace changes rel= ative to v12. Some were "necessary" (removal of a pointless ioctl), others were opportunistic and opinionated (renaming kvm_userspace_memory_region2 fields= to use guest_memfd instead of gmem). I didn't post changes as I found the "is= sues" very late (when writing documentation) and didn't want to delay v13. Here's a diff of the linux/include/uapi/linux/kvm.h changes that will break userspace developed for v12. @@ -102,8 +102,8 @@ struct kvm_userspace_memory_region2 { __u64 guest_phys_addr; __u64 memory_size; __u64 userspace_addr; - __u64 gmem_offset; - __u32 gmem_fd; + __u64 guest_memfd_offset; + __u32 guest_memfd; __u32 pad1; __u64 pad2[14]; }; @@ -1231,9 +1215,10 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228 #define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229 #define KVM_CAP_USER_MEMORY2 230 -#define KVM_CAP_MEMORY_ATTRIBUTES 231 -#define KVM_CAP_GUEST_MEMFD 232 -#define KVM_CAP_VM_TYPES 233 +#define KVM_CAP_MEMORY_FAULT_INFO 231 +#define KVM_CAP_MEMORY_ATTRIBUTES 232 +#define KVM_CAP_GUEST_MEMFD 233 +#define KVM_CAP_VM_TYPES 234 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -2301,8 +2286,7 @@ struct kvm_s390_zpci_op { #define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0) =20 /* Available with KVM_CAP_MEMORY_ATTRIBUTES */ -#define KVM_GET_SUPPORTED_MEMORY_ATTRIBUTES _IOR(KVMIO, 0xd2, __u64) -#define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd3, struct k= vm_memory_attributes) +#define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd2, struct k= vm_memory_attributes) =20 v13: - Drop KVM_GET_SUPPORTED_MEMORY_ATTRIBUTES, have KVM_CAP_MEMORY_ATTRIBUTES return the supported attributes. - Add KVM_CAP_MEMORY_FAULT_INFO to report support for KVM_EXIT_MEMORY_FAUL= T, and shift capability numbers accordingly. - Do s/gmem/guest_memfd (roughly) in userspace-facing APIs, i.e. use guest= _memfd as the formal name. Going off of various internal conversations, "gmem"= isn't at all intuitive, whereas "guest_memfd" gives readers/listeners a rough = idea of what's going on. If you don't like the rename, then next time volunt= eer to write the documentation. :-) - Rename a leftover "out_restricted" label to "out_unbind". - Write and clean up changelogs. - Write and clean up documentation. - Move "memory_fault" to the standard exit reasons union (requires userspa= ce to rebuild, but shouldn't require code changes). - Fix intermediate build issues (hidden behind unselectable Kconfigs) - KVM_CAP_GUEST_MEMFD and KVM_CREATE_GUEST_MEMFD under the same #ifdefs. - Fix a bug in kvm_mmu_invalidate_range_add() where adding multiple ranges= in a single invalidation would captured only the last range. [Xu Yilun] v12: https://lore.kernel.org/all/20230914015531.1419405-1-seanjc@google.com v11: https://lore.kernel.org/all/20230718234512.1690985-1-seanjc@google.com v10: https://lore.kernel.org/all/20221202061347.1070246-1-chao.p.peng@linux= .intel.coms Fodder for a merge tag: --- Introduce several new KVM uAPIs to ultimately create a guest-first memory subsystem within KVM, a.k.a. guest_memfd. Guest-first memory allows KVM to provide features, enhancements, and optimizations that are kludgly or outri= ght impossible to implement in a generic memory subsystem. The core KVM ioctl() for guest_memfd is KVM_CREATE_GUEST_MEMFD, which simil= ar to the generic memfd_create(), creates an anonymous file and returns a file descriptor that refers to it. Again like "regular" memfd files, guest_memf= d files live in RAM, have volatile storage, and are automatically released wh= en the last reference is dropped. The key differences between memfd files (an= d every other memory subystem) is that guest_memfd files are bound to their o= wning virtual machine, cannot be mapped, read, or written by userspace, and canno= t be resized (guest_memfd files do however support PUNCH_HOLE). A second KVM ioctl(), KVM_SET_MEMORY_ATTRIBUTES, allows userspace to specif= y attributes for a given page of guest memory, e.g. in the long term, it will likely be extended to allow userspace to specify per-gfn RWX protections. The immediate and driving use case for guest_memfd are Confidential (CoCo) = VMs, specifically AMD's SEV-SNP, Intel's TDX, and KVM's own pKVM. For KVM CoCo = use cases, being able to map memory into KVM guests without requireming said me= mory to be mapped into the host is a hard requirement. While SEV+ and TDX preve= nt untrusted software from reading guest private data by encrypting guest memo= ry, pKVM provides confidentiality and integrity *without* relying on memory encryption. And with SEV-SNP and TDX, accessing guest private memory can b= e fatal to the host, i.e. KVM must be prevent host userspace from accessing g= uest memory irrespective of hardware behavior. Long term, guest_memfd provides KVM line-of-sight to use cases beyond CoCo = VMs, e.g. KVM currently doesn't support mapping memory as writable in the guest without it also being writable in host userspace, as KVM's ABI uses userspa= ce VMA protections to define the allow guest protection (with an exception gra= nted to mapping guest memory executable). Similarly, KVM currently requires the guest mapping size to be a strict sub= set of the host userspace mapping size, e.g. KVM doesn=E2=80=99t support creati= ng a 1GiB guest mapping unless userspace also has a 1GiB guest mapping. Decoupling t= he mappings sizes would allow userspace to precisely map only what is needed without impacting guest performance, e.g. to again harden against unintenti= onal accesses to guest memory. A guest-first memory subsystem also provides clearer line of sight to thing= s like a dedicated memory pool (for slice-of-hardware VMs) and elimination of "struct page" (for offload setups where userspace _never_ needs to mmap() g= uest memory). guest_memfd is the result of 3+ years of development and exploration; takin= g on memory management responsibilities in KVM was not the first, second, or eve= n third choice for supporting CoCo VMs. But after many failed attempts to av= oid KVM-specific backing memory, and looking at where things ended up, it is qu= ite clear that of all approaches tried, guest_memfd is the simplest, most robus= t, and most extensible, and the right thing to do for KVM and the kernel at-la= rge. --- Ackerley Tng (1): KVM: selftests: Test KVM exit behavior for private memory/access Chao Peng (8): KVM: Use gfn instead of hva for mmu_notifier_retry KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace KVM: Introduce per-page memory attributes KVM: x86: Disallow hugepages when memory attributes are mixed KVM: x86/mmu: Handle page fault for private memory KVM: selftests: Add KVM_SET_USER_MEMORY_REGION2 helper KVM: selftests: Expand set_memory_region_test to validate guest_memfd() KVM: selftests: Add basic selftest for guest_memfd() Sean Christopherson (23): KVM: Tweak kvm_hva_range and hva_handler_t to allow reusing for gfn ranges KVM: Assert that mmu_invalidate_in_progress *never* goes negative KVM: WARN if there are dangling MMU invalidations at VM destruction KVM: PPC: Drop dead code related to KVM_ARCH_WANT_MMU_NOTIFIER KVM: PPC: Return '1' unconditionally for KVM_CAP_SYNC_MMU KVM: Convert KVM_ARCH_WANT_MMU_NOTIFIER to CONFIG_KVM_GENERIC_MMU_NOTIFIER KVM: Introduce KVM_SET_USER_MEMORY_REGION2 KVM: Add a dedicated mmu_notifier flag for reclaiming freed memory KVM: Drop .on_unlock() mmu_notifier hook KVM: Prepare for handling only shared mappings in mmu_notifier events mm: Add AS_UNMOVABLE to mark mapping as completely unmovable fs: Export anon_inode_getfile_secure() for use by KVM KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory KVM: Add transparent hugepage support for dedicated guest memory KVM: x86: "Reset" vcpu->run->exit_reason early in KVM_RUN KVM: Drop superfluous __KVM_VCPU_MULTIPLE_ADDRESS_SPACE macro KVM: Allow arch code to track number of memslot address spaces per VM KVM: x86: Add support for "protected VMs" that can utilize private memory KVM: selftests: Drop unused kvm_userspace_memory_region_find() helper KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2 KVM: selftests: Add support for creating private memslots KVM: selftests: Introduce VM "shape" to allow tests to specify the VM type KVM: selftests: Add GUEST_SYNC[1-6] macros for synchronizing more data Vishal Annapurve (3): KVM: selftests: Add helpers to convert guest memory b/w private and shared KVM: selftests: Add helpers to do KVM_HC_MAP_GPA_RANGE hypercalls (x86) KVM: selftests: Add x86-only selftest for private memory conversions Documentation/virt/kvm/api.rst | 208 ++++++ arch/arm64/include/asm/kvm_host.h | 2 - arch/arm64/kvm/Kconfig | 2 +- arch/mips/include/asm/kvm_host.h | 2 - arch/mips/kvm/Kconfig | 2 +- arch/powerpc/include/asm/kvm_host.h | 2 - arch/powerpc/kvm/Kconfig | 8 +- arch/powerpc/kvm/book3s_hv.c | 2 +- arch/powerpc/kvm/powerpc.c | 7 +- arch/riscv/include/asm/kvm_host.h | 2 - arch/riscv/kvm/Kconfig | 2 +- arch/x86/include/asm/kvm_host.h | 17 +- arch/x86/include/uapi/asm/kvm.h | 3 + arch/x86/kvm/Kconfig | 14 +- arch/x86/kvm/debugfs.c | 2 +- arch/x86/kvm/mmu/mmu.c | 271 +++++++- arch/x86/kvm/mmu/mmu_internal.h | 2 + arch/x86/kvm/vmx/vmx.c | 11 +- arch/x86/kvm/x86.c | 26 +- fs/anon_inodes.c | 1 + include/linux/kvm_host.h | 143 ++++- include/linux/kvm_types.h | 1 + include/linux/pagemap.h | 19 +- include/uapi/linux/kvm.h | 51 ++ mm/compaction.c | 43 +- mm/migrate.c | 2 + tools/testing/selftests/kvm/Makefile | 3 + tools/testing/selftests/kvm/dirty_log_test.c | 2 +- .../testing/selftests/kvm/guest_memfd_test.c | 221 +++++++ .../selftests/kvm/include/kvm_util_base.h | 148 ++++- .../testing/selftests/kvm/include/test_util.h | 5 + .../selftests/kvm/include/ucall_common.h | 11 + .../selftests/kvm/include/x86_64/processor.h | 15 + .../selftests/kvm/kvm_page_table_test.c | 2 +- tools/testing/selftests/kvm/lib/kvm_util.c | 233 ++++--- tools/testing/selftests/kvm/lib/memstress.c | 3 +- .../selftests/kvm/set_memory_region_test.c | 100 +++ .../kvm/x86_64/private_mem_conversions_test.c | 487 ++++++++++++++ .../kvm/x86_64/private_mem_kvm_exits_test.c | 120 ++++ .../kvm/x86_64/ucna_injection_test.c | 2 +- virt/kvm/Kconfig | 17 + virt/kvm/Makefile.kvm | 1 + virt/kvm/dirty_ring.c | 2 +- virt/kvm/guest_memfd.c | 607 ++++++++++++++++++ virt/kvm/kvm_main.c | 505 ++++++++++++--- virt/kvm/kvm_mm.h | 26 + 46 files changed, 3083 insertions(+), 272 deletions(-) create mode 100644 tools/testing/selftests/kvm/guest_memfd_test.c create mode 100644 tools/testing/selftests/kvm/x86_64/private_mem_conversi= ons_test.c create mode 100644 tools/testing/selftests/kvm/x86_64/private_mem_kvm_exit= s_test.c create mode 100644 virt/kvm/guest_memfd.c base-commit: 2b3f2325e71f09098723727d665e2e8003d455dc --=20 2.42.0.820.g83a721a137-goog