Re: [RFC PATCH v12 11/33] KVM: Introduce per-page memory attributes

2023-10-03 Thread Fuad Tabba
Hi, > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > index d2d913acf0df..f8642ff2eb9d 100644 > --- a/include/uapi/linux/kvm.h > +++ b/include/uapi/linux/kvm.h > @@ -1227,6 +1227,7 @@ struct kvm_ppc_resize_hpt { > #define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228 > #define KVM_CA

Re: [RFC PATCH v12 11/33] KVM: Introduce per-page memory attributes

2023-10-03 Thread Fuad Tabba
Hi Sean, On Tue, Oct 3, 2023 at 4:59 PM Sean Christopherson wrote: > > On Tue, Oct 03, 2023, Fuad Tabba wrote: > > Hi, > > > > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > > > index d2d913acf0df..f8642ff2eb9d 100644 > > &g

Re: [RFC PATCH v12 11/33] KVM: Introduce per-page memory attributes

2023-10-05 Thread Fuad Tabba
Hi Sean, On Tue, Oct 3, 2023 at 9:51 PM Sean Christopherson wrote: > > On Tue, Oct 03, 2023, Fuad Tabba wrote: > > On Tue, Oct 3, 2023 at 4:59 PM Sean Christopherson > > wrote: > > > On Tue, Oct 03, 2023, Fuad Tabba wrote: > > > > > +#define KVM_MEM

Re: [RFC PATCH v12 11/33] KVM: Introduce per-page memory attributes

2023-10-06 Thread Fuad Tabba
Hi Sean, On Fri, Oct 6, 2023 at 4:21 AM Sean Christopherson wrote: > > On Thu, Oct 05, 2023, Fuad Tabba wrote: > > Hi Sean, > > > > On Tue, Oct 3, 2023 at 9:51 PM Sean Christopherson > > wrote: > > > > Like I said, pKVM doesn't need a use

Re: [PATCH v13 16/35] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-10-31 Thread Fuad Tabba
Hi, On Fri, Oct 27, 2023 at 7:23 PM Sean Christopherson wrote: ... > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index e2252c748fd6..e82c69d5e755 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -6079,6 +6079,15 @@ appl

Re: [PATCH v13 16/35] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-11-01 Thread Fuad Tabba
Hi Sean, On Tue, Oct 31, 2023 at 10:13 PM Sean Christopherson wrote: > > On Tue, Oct 31, 2023, Fuad Tabba wrote: > > Hi, > > > > On Fri, Oct 27, 2023 at 7:23 PM Sean Christopherson > > wrote: > > > > ... > > > > > diff --git a/Docum

Re: [PATCH v13 01/35] KVM: Tweak kvm_hva_range and hva_handler_t to allow reusing for gfn ranges

2023-11-01 Thread Fuad Tabba
nzini > Reviewed-by: Xiaoyao Li > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > virt/kvm/kvm_main.c | 34 +++--- > 1 file changed, 19 insertions(+), 15 deletions(-) > > diff --git a/virt/kv

Re: [PATCH v13 02/35] KVM: Assert that mmu_invalidate_in_progress *never* goes negative

2023-11-01 Thread Fuad Tabba
t; invalidation, i.e. a potential use-after-free, would manifest as no > notification whatsoever, not an end() without a start(). > > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > virt/kvm/kvm_main.c | 3 +-- > 1 file ch

Re: [PATCH v13 04/35] KVM: WARN if there are dangling MMU invalidations at VM destruction

2023-11-01 Thread Fuad Tabba
https://lore.kernel.org/all/e397d30c-c6af-e68f-d18e-b4e3739c5...@linux.intel.com > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > virt/kvm/kvm_main.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > dif

Re: [PATCH v13 05/35] KVM: PPC: Drop dead code related to KVM_ARCH_WANT_MMU_NOTIFIER

2023-11-01 Thread Fuad Tabba
ill allow combining all of the > > #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER) > > checks into a single > > #ifdef CONFIG_KVM_GENERIC_MMU_NOTIFIER > > without having to worry about PPC's "bare" usage of > KVM_ARCH

Re: [PATCH v13 07/35] KVM: Convert KVM_ARCH_WANT_MMU_NOTIFIER to CONFIG_KVM_GENERIC_MMU_NOTIFIER

2023-11-01 Thread Fuad Tabba
m *kvm, struct kvm_gfn_range *range); > > Alternatively, PPC could forward declare kvm_gfn_range, but there's no > good reason not to define it in common KVM. > > Acked-by: Anup Patel > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad Tabba Tested-by

Re: [PATCH v13 08/35] KVM: Introduce KVM_SET_USER_MEMORY_REGION2

2023-11-01 Thread Fuad Tabba
instead of an > -EINVAL error. > > Cc: Jarkko Sakkinen > Reviewed-by: Paolo Bonzini > Reviewed-by: Xiaoyao Li > Signed-off-by: Sean Christopherson > --- With the missing pad in api.rst fixed: Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > D

Re: [PATCH v13 16/35] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-11-02 Thread Fuad Tabba
On Wed, Nov 1, 2023 at 9:55 PM Sean Christopherson wrote: > > On Wed, Nov 01, 2023, Fuad Tabba wrote: > > > > > @@ -1034,6 +1034,9 @@ static void kvm_destroy_dirty_bitmap(struct > > > > > kvm_memory_slot *memslot) > > > > > /* This doe

Re: [PATCH v13 10/35] KVM: Add a dedicated mmu_notifier flag for reclaiming freed memory

2023-11-02 Thread Fuad Tabba
> __always_inlined, practically speaking, the struct will never actually be > returned from a function call (not to mention the size of the struct will > be two bytes in practice). > > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad Tabba Tested-by: Fuad T

Re: [PATCH v13 11/35] KVM: Drop .on_unlock() mmu_notifier hook

2023-11-02 Thread Fuad Tabba
stically add a lockdep assertion in kvm_mmu_invalidate_end() to > guard against future bugs of this nature. > > Reported-by: Isaku Yamahata > Link: > https://lore.kernel.org/all/20230802203119.gb2021...@ls.amr.corp.intel.com > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad T

Re: [PATCH v13 12/35] KVM: Prepare for handling only shared mappings in mmu_notifier events

2023-11-02 Thread Fuad Tabba
Hi, On Fri, Oct 27, 2023 at 7:22 PM Sean Christopherson wrote: > > Add flags to "struct kvm_gfn_range" to let notifier events target only > shared and only private mappings, and write up the existing mmu_notifier > events to be shared-only (private memory is never associated with a > userspace vi

Re: [PATCH v13 18/35] KVM: x86: "Reset" vcpu->run->exit_reason early in KVM_RUN

2023-11-02 Thread Fuad Tabba
ote, KVM must wait until after run->immediate_exit is serviced to > sanitize run->exit_reason as KVM's ABI is that run->exit_reason is > preserved across KVM_RUN when run->immediate_exit is true. > > Link: https://lore.kernel.org/all/20230908222905.1321305-1-amoor...@googl

Re: [PATCH v13 20/35] KVM: x86/mmu: Handle page fault for private memory

2023-11-02 Thread Fuad Tabba
d-off-by: Yu Zhang > Signed-off-by: Chao Peng > Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > --- With my limited understanding of kvm-x86 mmu code: Reviewed-by: Fuad Tabba Tested the x86 code (as part of this patch series) on qemu. The x86 fault handlin

Re: [PATCH v13 21/35] KVM: Drop superfluous __KVM_VCPU_MULTIPLE_ADDRESS_SPACE macro

2023-11-02 Thread Fuad Tabba
On Fri, Oct 27, 2023 at 7:23 PM Sean Christopherson wrote: > > Drop __KVM_VCPU_MULTIPLE_ADDRESS_SPACE and instead check the value of > KVM_ADDRESS_SPACE_NUM. > > No functional change intended. > > Reviewed-by: Paolo Bonzini > Signed-off-by: Sean Christopherson > -

Re: [PATCH v13 12/35] KVM: Prepare for handling only shared mappings in mmu_notifier events

2023-11-02 Thread Fuad Tabba
On Thu, Nov 2, 2023 at 2:41 PM Sean Christopherson wrote: > > On Thu, Nov 02, 2023, Fuad Tabba wrote: > > Hi, > > > > On Fri, Oct 27, 2023 at 7:22 PM Sean Christopherson > > wrote: > > > > > > Add flags to "struct kvm_gfn_range" to let

Re: [PATCH v13 22/35] KVM: Allow arch code to track number of memslot address spaces per VM

2023-11-02 Thread Fuad Tabba
ress space across all > architectures). > > Signed-off-by: Sean Christopherson > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > arch/powerpc/kvm/book3s_hv.c| 2 +- > arch/x86/include/asm/kvm_host.h | 8 +++- > arch/x86/kvm/debugfs.c | 2

Re: [PATCH v13 16/35] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-11-03 Thread Fuad Tabba
Hi, ... > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index e2252c748fd6..e82c69d5e755 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst ... > +4.141 KVM_CREATE_GUEST_MEMFD > + > + > +:Capability:

Re: [PATCH 09/34] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace

2023-11-06 Thread Fuad Tabba
; Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > Reviewed-by: Paolo Bonzini > Message-Id: <20231027182217.3615211-10-sea...@google.com> > Signed-off-by: Paolo Bonzini > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad

Re: [PATCH 12/34] KVM: Introduce per-page memory attributes

2023-11-06 Thread Fuad Tabba
notifier_block pm_notifier; > +#endif > +#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES > + /* Protected by slots_locks (for writes) and RCU (for reads) */ slots_locks -> slots_lock Otherwise, Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > + struct xarray mem_attr_array; > #endi

Re: [PATCH 15/34] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-11-06 Thread Fuad Tabba
- > + > +:Capability: KVM_CAP_GUEST_MEMFD > +:Architectures: none > +:Type: vm ioctl > +:Parameters: struct kvm_create_guest_memfd(in) nit: space before (in) Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > +:Returns: 0 on success, <0 on error > + > +K

Re: [PATCH 18/34] KVM: x86/mmu: Handle page fault for private memory

2023-11-06 Thread Fuad Tabba
stance. > > Co-developed-by: Yu Zhang > Signed-off-by: Yu Zhang > Signed-off-by: Chao Peng > Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > Reviewed-by: Fuad Tabba > Tested-by: Fuad Tabba > Message-Id:

Re: [PATCH v13 23/35] KVM: x86: Add support for "protected VMs" that can utilize private memory

2023-11-06 Thread Fuad Tabba
iversally accessible. I.e. relying SEV-SNP or TDX nit: "that isn't" Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > for maintaining guest private memory isn't a realistic option. > > At the very least, KVM_X86_SW_PROTECTED_VM will enable a variety of

Re: [PATCH 21/34] KVM: x86: Add support for "protected VMs" that can utilize private memory

2023-11-06 Thread Fuad Tabba
are that's isn't universally accessible. I.e. relying SEV-SNP or TDX (replied to v13 earlier, sorry) nit: "that isn't" Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > for maintaining guest private memory isn't a realistic option. > > At

Re: [PATCH 22/34] KVM: selftests: Drop unused kvm_userspace_memory_region_find() helper

2023-11-06 Thread Fuad Tabba
region_find() can be exposed to give > others full access to all memory region/slot information. > > Signed-off-by: Sean Christopherson > Message-Id: <20231027182217.3615211-25-sea...@google.com> > Signed-off-by: Paolo Bonzini > --- Reviewed-by: Fuad Tabba Tested-by: Fuad

Re: [PATCH 23/34] KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2

2023-11-06 Thread Fuad Tabba
t; Note, this obviously makes selftests backwards-incompatible with older KVM > versions from this point forward. > > Signed-off-by: Sean Christopherson > Message-Id: <20231027182217.3615211-26-sea...@google.com> > Signed-off-by: Paolo Bonzini > --- Reviewed-

Re: [PATCH 24/34] KVM: selftests: Add support for creating private memslots

2023-11-06 Thread Fuad Tabba
ory region flags (e.g. KVM_MEM_LOG_DIRTY_PAGES) > - * > - * Output Args: None > - * > - * Return: None > - * > - * Allocates a memory area of the number of pages specified by npages > - * and maps it to the VM specified by vm, at a starting physical address > - * given by guest_paddr. Th

Re: [PATCH 25/34] KVM: selftests: Add helpers to convert guest memory b/w private and shared

2023-11-06 Thread Fuad Tabba
+ > + ret = fallocate(region->region.guest_memfd, mode, fd_offset, > len); > + TEST_ASSERT(!ret, "fallocate() failed to %s at %lx (len = > %lu), fd = %d, mode = %x, offset = %lx\n", > + punch_hole ? "punch hole" : "allocate", gpa, len, > + region->region.guest_memfd, mode, fd_offset); > + } > +} > + > /* Returns the size of a vCPU's kvm_run structure. */ > static int vcpu_mmap_sz(void) > { Nits aside: Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > -- > 2.39.1 > >

Re: [PATCH v13 27/35] KVM: selftests: Add helpers to convert guest memory b/w private and shared

2023-11-06 Thread Fuad Tabba
arentheses? > + fd_offset = region->region.guest_memfd_offset + offset; > + len = min_t(uint64_t, end - gpa, region->region.memory_size - > offset); > + > + ret = fallocate(region->region.guest_memfd, mode, fd_offset, > len); > +

Re: [PATCH 14/34] fs: Rename anon_inode_getfile_secure() and anon_inode_getfd_secure()

2023-11-06 Thread Fuad Tabba
ey can just use > anon_inode_create_getfile(), which will be exported very soon for use > in KVM. > > Suggested-by: Christian Brauner > Signed-off-by: Paolo Bonzini > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > fs/anon_inodes.c|

Re: [PATCH 26/34] KVM: selftests: Add helpers to do KVM_HC_MAP_GPA_RANGE hypercalls (x86)

2023-11-06 Thread Fuad Tabba
ween host userspace code and > guest code. > > Signed-off-by: Vishal Annapurve > [sean: drop shared/private helpers (let tests specify flags)] > Signed-off-by: Sean Christopherson > Message-Id: <20231027182217.3615211-29-sea...@google.com> > Signed-off-by: Paolo Bonzi

Re: [PATCH 28/34] KVM: selftests: Add GUEST_SYNC[1-6] macros for synchronizing more data

2023-11-06 Thread Fuad Tabba
stopherson > Message-Id: <20231027182217.3615211-31-sea...@google.com> > Signed-off-by: Paolo Bonzini > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > tools/testing/selftests/kvm/include/ucall_common.h | 11 +++ > 1 file changed, 11 insertions(+)

Re: [PATCH 27/34] KVM: selftests: Introduce VM "shape" to allow tests to specify the VM type

2023-11-06 Thread Fuad Tabba
1-30-sea...@google.com> > Signed-off-by: Paolo Bonzini > --- nit: as in a prior selftest commit messages, references in the commit message to guest _private_ memory. Should these be changed to just guest memory? Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /f

Re: [PATCH 27/34] KVM: selftests: Introduce VM "shape" to allow tests to specify the VM type

2023-11-06 Thread Fuad Tabba
On Mon, Nov 6, 2023 at 4:04 PM Sean Christopherson wrote: > > On Mon, Nov 06, 2023, Fuad Tabba wrote: > > On Sun, Nov 5, 2023 at 4:34 PM Paolo Bonzini wrote: > > > > > > From: Sean Christopherson > > > > > > Add a "vm_shape" structur

Re: [PATCH 25/34] KVM: selftests: Add helpers to convert guest memory b/w private and shared

2023-11-06 Thread Fuad Tabba
On Mon, Nov 6, 2023 at 4:13 PM Sean Christopherson wrote: > > On Mon, Nov 06, 2023, Fuad Tabba wrote: > > On Sun, Nov 5, 2023 at 4:34 PM Paolo Bonzini wrote: > > > +void vm_guest_mem_fallocate(struct kvm_vm *vm, uint64_t base, uint64_t > > > size, > >

Re: [PATCH 30/34] KVM: selftests: Add KVM_SET_USER_MEMORY_REGION2 helper

2023-11-07 Thread Fuad Tabba
<20231027182217.3615211-33-sea...@google.com> > Signed-off-by: Paolo Bonzini > --- Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > .../selftests/kvm/include/kvm_util_base.h | 7 + > tools/testing/selftests/kvm/lib/kvm_util.c| 29 +++ &

Re: [PATCH 32/34] KVM: selftests: Add basic selftest for guest_memfd()

2023-11-07 Thread Fuad Tabba
+ > +#define _GNU_SOURCE > +#include "test_util.h" > +#include "kvm_util_base.h" > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include The inclu

Re: [PATCH 33/34] KVM: selftests: Test KVM exit behavior for private memory/access

2023-11-07 Thread Fuad Tabba
482 > --- /dev/null > +++ b/tools/testing/selftests/kvm/x86_64/private_mem_kvm_exits_test.c > @@ -0,0 +1,120 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2022, Google LLC. nit: 2023 Nits aside: Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Cheers, /fuad > +

Re: [PATCH 34/34] KVM: selftests: Add a memory region subtest to validate invalid flags

2023-11-09 Thread Fuad Tabba
Hi Anish, On Thu, Nov 9, 2023 at 1:08 AM Anish Moorthy wrote: > > Applying [1] and [2] reveals that this also breaks non-x86 builds- the > MEM_REGION_GPA/SLOT definitions are guarded behind an #ifdef > __x86_64__, while the usages introduced here aren't. > > Should > > On Sun, Nov 5, 2023 at 8:35

Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-07-27 Thread Fuad Tabba
Hi Sean, ... > @@ -5134,6 +5167,16 @@ static long kvm_vm_ioctl(struct file *filp, > case KVM_GET_STATS_FD: > r = kvm_vm_ioctl_get_stats_fd(kvm); > break; > + case KVM_CREATE_GUEST_MEMFD: { > + struct kvm_create_guest_memfd guest_memfd;

Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-07-31 Thread Fuad Tabba
Hi Sean, On Thu, Jul 27, 2023 at 6:13 PM Sean Christopherson wrote: > > On Thu, Jul 27, 2023, Fuad Tabba wrote: > > Hi Sean, > > > > > > ... > > > > > @@ -5134,6 +5167,16 @@ static long kvm_vm_ioctl(struct file *filp, > > >

Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-07-31 Thread Fuad Tabba
Hi Sean, On Tue, Jul 25, 2023 at 5:04 PM Sean Christopherson wrote: > > On Tue, Jul 25, 2023, Wei W Wang wrote: > > On Wednesday, July 19, 2023 7:45 AM, Sean Christopherson wrote: > > > +int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot, > > > +gfn_t gfn, kvm_pfn_

Re: [PATCH v12 54/84] KVM: arm64: Mark "struct page" pfns accessed/dirty before dropping mmu_lock

2024-08-06 Thread Fuad Tabba
Hi Oliver, On Tue, 6 Aug 2024 at 00:26, Oliver Upton wrote: > > [+cc Fuad] > > Fuad, you mentioned in commit 9c30fc615daa ("KVM: arm64: Move setting > the page as dirty out of the critical section") that restructuring > around the MMU lock was helpful for reuse (presumably for pKVM), but I > lack