[PATCH 05/34] KVM: PPC: Drop dead code related to KVM_ARCH_WANT_MMU_NOTIFIER

2023-11-05 Thread Paolo Bonzini
&& 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_WANT_MMU_NOTIFIER. Signed-off-by: Sean Christopherson Reviewed-by: Paolo Bonzini Reviewed-by: Fuad Tabba Message-

[PATCH 06/34] KVM: PPC: Return '1' unconditionally for KVM_CAP_SYNC_MMU

2023-11-05 Thread Paolo Bonzini
S_HV_POSSIBLE=y. Suggested-by: Paolo Bonzini Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-7-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/powerpc/kvm/powerpc.c | 4 1 file changed, 4 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerp

[PATCH 07/34] KVM: Convert KVM_ARCH_WANT_MMU_NOTIFIER to CONFIG_KVM_GENERIC_MMU_NOTIFIER

2023-11-05 Thread Paolo Bonzini
there's no good reason not to define it in common KVM. Acked-by: Anup Patel Signed-off-by: Sean Christopherson Reviewed-by: Paolo Bonzini Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Message-Id: <20231027182217.3615211-8-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/ar

[PATCH 08/34] KVM: Introduce KVM_SET_USER_MEMORY_REGION2

2023-11-05 Thread Paolo Bonzini
ction of bad flags a bit more robust, e.g. if the new fd field is guarded only by a flag and not a new ioctl(), then a userspace bug (setting a "bad" flag) would generate out-of-bounds access instead of an -EINVAL error. Cc: Jarkko Sakkinen Reviewed-by: Paolo Bonzini Reviewed-by: X

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

2023-11-05 Thread Paolo Bonzini
Chao Peng 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 --- Documentation/virt/kvm/api.rst | 41 ++ arch/x86/kvm/x86.c

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

2023-11-05 Thread Paolo Bonzini
urned 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: Paolo Bonzini Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Message-Id: <20231027182217.3615211-11-sea...@google.com> Signed-off-by: Pa

[PATCH 11/34] KVM: Drop .on_unlock() mmu_notifier hook

2023-11-05 Thread Paolo Bonzini
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: Paolo Bonzini Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Message-Id: <20231027182217.3615211-12-sea...@google.com> Si

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

2023-11-05 Thread Paolo Bonzini
Id: <20231027182217.3615211-14-sea...@google.com> Signed-off-by: Paolo Bonzini --- Documentation/virt/kvm/api.rst | 36 ++ include/linux/kvm_host.h | 19 +++ include/uapi/linux/kvm.h | 13 ++ virt/kvm/Kconfig | 4 + virt/kvm/kvm_main.c| 216

[PATCH 13/34] mm: Add AS_UNMOVABLE to mark mapping as completely unmovable

2023-11-05 Thread Paolo Bonzini
NEVICTABLE. Cc: Matthew Wilcox Co-developed-by: Vlastimil Babka Signed-off-by: Vlastimil Babka Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-15-sea...@google.com> Signed-off-by: Paolo Bonzini --- include/linux/pagemap.h | 19 +- mm/compactio

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

2023-11-05 Thread Paolo Bonzini
(). There is no in-tree module that uses it, and the old name is gone anyway. If anybody actually needs the symbol, they can ask or they 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 --- fs

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

2023-11-05 Thread Paolo Bonzini
ick Cc: Isaku Yamahata Co-developed-by: Kirill A. Shutemov Signed-off-by: Kirill A. Shutemov Co-developed-by: Yu Zhang Signed-off-by: Yu Zhang Co-developed-by: Chao Peng Signed-off-by: Chao Peng Co-developed-by: Ackerley Tng Signed-off-by: Ackerley Tng Co-developed-by: Isaku Yamahata Signed-o

[PATCH 16/34] KVM: x86: "Reset" vcpu->run->exit_reason early in KVM_RUN

2023-11-05 Thread Paolo Bonzini
n is preserved across KVM_RUN when run->immediate_exit is true. Link: https://lore.kernel.org/all/20230908222905.1321305-1-amoor...@google.com Link: https://lore.kernel.org/all/zffbwoxz5ui%2fg...@google.com Signed-off-by: Sean Christopherson Reviewed-by: Paolo Bonzini Reviewed-by: Fuad Tabba Tested-by: Fuad

[PATCH 17/34] KVM: x86: Disallow hugepages when memory attributes are mixed

2023-11-05 Thread Paolo Bonzini
son Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-20-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 3 + arch/x86/kvm/mmu/mmu.c | 154 +++- arch/x86/kvm/x86.c | 4 +

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

2023-11-05 Thread Paolo Bonzini
e mappings always come from a guest_memfd instance. 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: <20231027182217.

[PATCH 19/34] KVM: Drop superfluous __KVM_VCPU_MULTIPLE_ADDRESS_SPACE macro

2023-11-05 Thread Paolo Bonzini
From: Sean Christopherson 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 Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Message-Id

[PATCH 20/34] KVM: Allow arch code to track number of memslot address spaces per VM

2023-11-05 Thread Paolo Bonzini
eviewed-by: Paolo Bonzini Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Message-Id: <20231027182217.3615211-23-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/powerpc/kvm/book3s_hv.c| 2 +- arch/x86/include/asm/kvm_host.h | 8 +++- arch/x86/kvm/debugfs.c | 2 +-

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

2023-11-05 Thread Paolo Bonzini
emory isn't a realistic option. At the very least, KVM_X86_SW_PROTECTED_VM will enable a variety of selftests for guest_memfd and private memory support without requiring unique hardware. Signed-off-by: Sean Christopherson Reviewed-by: Paolo Bonzini Message-Id: <20231027182217.3615211

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

2023-11-05 Thread Paolo Bonzini
egion/slot information. Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-25-sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/include/kvm_util_base.h | 4 --- tools/testing/selftests/kvm/lib/kvm_util.c| 29 --- 2 files changed, 33 de

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

2023-11-05 Thread Paolo Bonzini
this point forward. Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-26-sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/include/kvm_util_base.h | 2 +- tools/testing/selftests/kvm/lib/kvm_util.c| 19 ++- 2 files

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

2023-11-05 Thread Paolo Bonzini
the fd without having to first destroy memslots. Co-developed-by: Ackerley Tng Signed-off-by: Ackerley Tng Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-27-sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/include/kvm_util_base.h | 23 ++

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

2023-11-05 Thread Paolo Bonzini
ge-Id: <20231027182217.3615211-28-sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/include/kvm_util_base.h | 48 +++ tools/testing/selftests/kvm/lib/kvm_util.c| 28 +++ 2 files changed, 76 insertions(+) diff --git a/tools/testing/selftests/

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

2023-11-05 Thread Paolo Bonzini
: 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 Bonzini --- .../selftests/kvm/include/x86_64/processor.h | 15 +++ 1 file changed, 15 insertions(+)

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

2023-11-05 Thread Paolo Bonzini
t's expected that x86 will double down and require unique VM types for TDX and SNP guests. Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-30-sea...@google.com> Signed-off-by: Paolo Bonzini --- tools/testing/selftests/kvm/dirty_log_test.c

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

2023-11-05 Thread Paolo Bonzini
From: Sean Christopherson Add GUEST_SYNC[1-6]() so that tests can pass the maximum amount of information supported via ucall(), without needing to resort to shared memory. Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-31-sea...@google.com> Signed-off-by: Paolo B

[PATCH 29/34] KVM: selftests: Add x86-only selftest for private memory conversions

2023-11-05 Thread Paolo Bonzini
Ackerley Tng Signed-off-by: Ackerley Tng Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-32-sea...@google.com> Signed-off-by: Paolo Bonzini --- tools/testing/selftests/kvm/Makefile | 1 + .../kvm/x86_64/private_me

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

2023-11-05 Thread Paolo Bonzini
ss version to reduce the amount of boilerplate code need for basic usage. Signed-off-by: Chao Peng Signed-off-by: Ackerley Tng Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-33-sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/includ

[PATCH 31/34] KVM: selftests: Expand set_memory_region_test to validate guest_memfd()

2023-11-05 Thread Paolo Bonzini
-by: Ackerley Tng Signed-off-by: Ackerley Tng [sean: trim the testcases to remove duplicate coverage] Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-34-sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/include/kvm_util_base.h

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

2023-11-05 Thread Paolo Bonzini
Signed-off-by: Ackerley Tng Co-developed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-35-sea...@google.com> Signed-off-by: Paolo Bonzini --- tools/testing/selftests/kvm/Ma

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

2023-11-05 Thread Paolo Bonzini
_X86_SW_PROTECTED_VM without its prerequisites. Signed-off-by: Ackerley Tng [sean: call out the similarities with set_memory_region_test] Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-36-sea...@google.com> Signed-off-by: Paolo Bonzini --- tools/testing/selftests/k

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

2023-11-05 Thread Paolo Bonzini
sea...@google.com> Signed-off-by: Paolo Bonzini --- .../selftests/kvm/set_memory_region_test.c| 49 +++ 1 file changed, 49 insertions(+) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index 189177

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

2023-11-05 Thread Paolo Bonzini
7182217.3615211-13-sea...@google.com> Signed-off-by: Paolo Bonzini --- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 17 + 2 files changed, 19 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3ebc6912c54a..4d5d139b0bde 10064

[PATCH 36/34] KVM: Add transparent hugepage support for dedicated guest memory

2023-11-05 Thread Paolo Bonzini
11-18-sea...@google.com> [Allow even with CONFIG_TRANSPARENT_HUGEPAGE; dropped momentarily due to uneasiness about the API. - Paolo] Signed-off-by: Paolo Bonzini --- Documentation/virt/kvm/api.rst| 7 ++ include/uapi/linux/kvm.h | 2 + .../testing/selfte

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

2023-11-06 Thread Paolo Bonzini
On 11/6/23 12:00, Fuad Tabba wrote: Hi, On Fri, Oct 27, 2023 at 7:23 PM Sean Christopherson wrote: Add a new x86 VM type, KVM_X86_SW_PROTECTED_VM, to serve as a development and testing vehicle for Confidential (CoCo) VMs, and potentially to even become a "real" product in the distant future,

Re: [PATCH 31/34] KVM: selftests: Expand set_memory_region_test to validate guest_memfd()

2023-11-06 Thread Paolo Bonzini
On 11/5/23 17:30, Paolo Bonzini wrote: From: Chao Peng Expand set_memory_region_test to exercise various positive and negative testcases for private memory. - Non-guest_memfd() file descriptor for private memory - guest_memfd() from different VM - Overlapping bindings - Unaligned

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

2023-11-09 Thread Paolo Bonzini
On 11/9/23 00:37, Anish Moorthy wrote: On Wed, Nov 8, 2023 at 9:00 AM Anish Moorthy wrote: This commit breaks the arm64 selftests build btw: looks like a simple oversight? Yup, fix is a one-liner. Posted below. diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/test

Re: [PATCH v14 00/34] KVM: guest_memfd() and per-page attributes

2023-11-13 Thread Paolo Bonzini
On 11/5/23 17:30, Paolo Bonzini wrote: The "development cycle" for this version is going to be very short; ideally, next week I will merge it as is in kvm/next, taking this through the KVM tree for 6.8 immediately after the end of the merge window. The series is still based on 6.6

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

2023-11-21 Thread Paolo Bonzini
6_64__, while the usages introduced here aren't. > > > > Should > > > > On Sun, Nov 5, 2023 at 8:35 AM Paolo Bonzini wrote: > > > > > > + test_invalid_memory_region_flags(); > > > > be #ifdef'd, perhaps? I'm not quite sure what th

Re: [RFC PATCH v11 01/29] KVM: Wrap kvm_gfn_range.pte in a per-action union

2023-07-19 Thread Paolo Bonzini
bility is to remove 'raw' and just assign the whole union. Apart from this, Reviewed-by: Paolo Bonzini Paolo + BUILD_BUG_ON(sizeof(gfn_range.arg) != sizeof(range->arg));

Re: [RFC PATCH v11 03/29] KVM: Use gfn instead of hva for mmu_notifier_retry

2023-07-19 Thread Paolo Bonzini
should be uncommon, so the impact is expected small. Reviewed-by: Paolo Bonzini Suggested-by: Sean Christopherson Signed-off-by: Chao Peng Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba [sean: convert vmx_set_apic_access_page_addr() to gfn-based API] Signed-off-by: Sean Christopherson --- arch

Re: [RFC PATCH v11 02/29] KVM: Tweak kvm_hva_range and hva_handler_t to allow reusing for gfn ranges

2023-07-19 Thread Paolo Bonzini
On 7/19/23 01:44, Sean Christopherson wrote: Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) Reviewed-by: Paolo Bonzini

Re: [RFC PATCH v11 04/29] KVM: PPC: Drop dead code related to KVM_ARCH_WANT_MMU_NOTIFIER

2023-07-19 Thread Paolo Bonzini
On 7/19/23 01:44, Sean Christopherson wrote: Signed-off-by: Sean Christopherson --- arch/powerpc/kvm/powerpc.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 7197c8256668..5cf9e5e3112a 100644 --- a/arch/p

Re: [RFC PATCH v11 06/29] KVM: Introduce KVM_SET_USER_MEMORY_REGION2

2023-07-21 Thread Paolo Bonzini
(kvm, &mem); break; } case KVM_GET_DIRTY_LOG: { Reviewed-by: Paolo Bonzini

Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes

2023-07-21 Thread Paolo Bonzini
erson Reviewed-by: Paolo Bonzini

Re: [RFC PATCH v11 09/29] KVM: x86: Disallow hugepages when memory attributes are mixed

2023-07-21 Thread Paolo Bonzini
On 7/19/23 01:44, Sean Christopherson wrote: +static bool range_has_attrs(struct kvm *kvm, gfn_t start, gfn_t end, + unsigned long attrs) +{ + XA_STATE(xas, &kvm->mem_attr_array, start); + unsigned long index; + bool has_attrs; + void *entry; + +

Re: [RFC PATCH v11 13/29] KVM: Add transparent hugepage support for dedicated guest memory

2023-07-21 Thread Paolo Bonzini
On 7/19/23 01:44, Sean Christopherson wrote: @@ -413,6 +454,9 @@ int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args) u64 flags = args->flags; u64 valid_flags = 0; + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) + valid_flags |= KVM_GUEST_M

Re: [RFC PATCH v11 15/29] KVM: Drop superfluous __KVM_VCPU_MULTIPLE_ADDRESS_SPACE macro

2023-07-21 Thread Paolo Bonzini
ADDRESS_SPACE +#if KVM_ADDRESS_SPACE_NUM == 1 static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu) { return 0; Reviewed-by: Paolo Bonzini

Re: [RFC PATCH v11 14/29] KVM: x86/mmu: Handle page fault for private memory

2023-07-21 Thread Paolo Bonzini
RET_PF_FIXED, RET_PF_SPURIOUS, }; diff --git a/arch/x86/kvm/mmu/mmutrace.h b/arch/x86/kvm/mmu/mmutrace.h index ae86820cef69..2d7555381955 100644 --- a/arch/x86/kvm/mmu/mmutrace.h +++ b/arch/x86/kvm/mmu/mmutrace.h @@ -58,6 +58,7 @@ TRACE_DEFINE_ENUM(RET_PF_CONTINUE); TRACE_DEFINE

Re: [RFC PATCH v11 16/29] KVM: Allow arch code to track number of memslot address spaces per VM

2023-07-21 Thread Paolo Bonzini
On 7/19/23 01:44, Sean Christopherson wrote: @@ -4725,9 +4725,9 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) case KVM_CAP_IRQ_ROUTING: return KVM_MAX_IRQ_ROUTES; #endif -#if KVM_ADDRESS_SPACE_NUM > 1 +#if KVM_MAX_NR_ADDRESS_SPACES > 1

Re: [RFC PATCH v11 18/29] KVM: selftests: Drop unused kvm_userspace_memory_region_find() helper

2023-07-21 Thread Paolo Bonzini
On 7/19/23 01:45, Sean Christopherson wrote: Drop kvm_userspace_memory_region_find(), it's unused and a terrible API (probably why it's unused). If anything outside of kvm_util.c needs to get at the memslot, userspace_mem_region_find() can be exposed to give others full access to all memory regi

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

2023-07-21 Thread Paolo Bonzini
On 7/19/23 01:44, Sean Christopherson wrote: + inode = alloc_anon_inode(mnt->mnt_sb); + if (IS_ERR(inode)) + return PTR_ERR(inode); + + err = security_inode_init_security_anon(inode, &qname, NULL); + if (err) + goto err_inode; + I don't unders

Re: [RFC PATCH v11 10/29] mm: Add AS_UNMOVABLE to mark mapping as completely unmovable

2023-07-28 Thread Paolo Bonzini
On 7/28/23 18:02, Vlastimil Babka wrote: There's even a comment to that effect later on in the function: Hmm, well spotted. But it wouldn't be so great if we now had to lock every inspected page (and not just dirty pages), just to check the AS_ bit. But I wonder if this is leftover from previou

Re: [RFC PATCH v11 06/29] KVM: Introduce KVM_SET_USER_MEMORY_REGION2

2023-07-31 Thread Paolo Bonzini
On 7/29/23 02:03, Sean Christopherson wrote: KVM would need to do multiple uaccess reads, but that's not a big deal. Am I missing something, or did past us just get too clever and miss the obvious solution? You would have to introduce struct kvm_userspace_memory_region2 anyway, though not a n

Re: [RFC PATCH v11 13/29] KVM: Add transparent hugepage support for dedicated guest memory

2023-09-06 Thread Paolo Bonzini
On Fri, Jul 21, 2023 at 7:13 PM Sean Christopherson wrote: > On Fri, Jul 21, 2023, Paolo Bonzini wrote: > > On 7/19/23 01:44, Sean Christopherson wrote: > > > @@ -413,6 +454,9 @@ int kvm_gmem_create(struct kvm *kvm, struct > > > kvm_create_guest_memfd *args) > &

Re: [PATCH kernel] KVM: PPC: Make KVM_CAP_IRQFD_RESAMPLE platform dependent

2023-03-31 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH mm-unstable v2 01/10] mm/kvm: add mmu_notifier_ops->test_clear_young()

2023-06-09 Thread Paolo Bonzini
On 5/31/23 21:17, Jason Gunthorpe wrote: + int (*test_clear_young)(struct mmu_notifier *mn, struct mm_struct *mm, + unsigned long start, unsigned long end, + bool clear, unsigned long *bitmap); + Why leave clear_young behind? Just

Re: [PATCH mm-unstable v2 09/10] kvm/x86: add kvm_arch_test_clear_young()

2023-06-09 Thread Paolo Bonzini
On 5/27/23 01:44, Yu Zhao wrote: +#define kvm_arch_has_test_clear_young kvm_arch_has_test_clear_young +static inline bool kvm_arch_has_test_clear_young(void) +{ + return IS_ENABLED(CONFIG_X86_64) && + (!IS_REACHABLE(CONFIG_KVM) || (tdp_mmu_enabled && shadow_accessed_mask)); +}

Re: [PATCH mm-unstable v2 00/10] mm/kvm: locklessly clear the accessed bit

2023-06-09 Thread Paolo Bonzini
On 5/27/23 01:44, Yu Zhao wrote: TLDR This patchset adds a fast path to clear the accessed bit without taking kvm->mmu_lock. It can significantly improve the performance of guests when the host is under heavy memory pressure. ChromeOS has been using a similar approach [1] since mid 2021 and

Re: [PATCH v2 2/4] eventfd: simplify eventfd_signal()

2024-02-07 Thread Paolo Bonzini
n > keeping that additional argument. > > Signed-off-by: Christian Brauner > --- > arch/x86/kvm/hyperv.c | 2 +- > arch/x86/kvm/xen.c| 2 +- > virt/kvm/eventfd.c| 4 ++-- > 30 files changed, 60 insert

Re: [PATCH] KVM: Get rid of return value from kvm_arch_create_vm_debugfs()

2024-02-23 Thread Paolo Bonzini
ail VM creation. > > Change to a void return to discourage architectures from making debugfs > failures fatal for the VM. Seems like everyone already had the right > idea, as all implementations already return 0 unconditionally. > > Signed-off-by: Oliver Upton Acked-by: Paolo Bonzini

Re: [PATCH] KVM: PPC: Fix refactoring goof in kvmppc_e500mc_init()

2023-01-24 Thread Paolo Bonzini
Queued, thanks. Paolo

[PATCH 0/4] KVM, mm: remove the .change_pte() MMU notifier and set_pte_at_notify()

2024-04-05 Thread Paolo Bonzini
onflicts. Thanks, Paolo Paolo Bonzini (4): KVM: delete .change_pte MMU notifier callback KVM: remove unused argument of kvm_handle_hva_range() mmu_notifier: remove the .change_pte() callback mm: replace set_pte_at_notify() with just set_pte_at() arch/arm64/kvm/mmu.c | 3

[PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-05 Thread Paolo Bonzini
y moot, because KVM unmaps the sPTEs during .invalidate_range_start() and therefore .change_pte() has no hope of finding a sPTE to change. Drop the generic KVM code that dispatches to kvm_set_spte_gfn(), as well as all the architecture specific implementations. Signed-off-by: Paolo Bonzini ---

[PATCH 3/4] mmu_notifier: remove the .change_pte() callback

2024-04-05 Thread Paolo Bonzini
set_pte_at_notify() even though it is just a synonym for set_pte_at(). Signed-off-by: Paolo Bonzini --- include/linux/mmu_notifier.h | 46 ++-- mm/mmu_notifier.c| 17 - 2 files changed, 2 insertions(+), 61 deletions(-) diff --git a/include/linux

[PATCH 2/4] KVM: remove unused argument of kvm_handle_hva_range()

2024-04-05 Thread Paolo Bonzini
The only user was kvm_mmu_notifier_change_pte(), which is now gone. Signed-off-by: Paolo Bonzini --- virt/kvm/kvm_main.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2fcd9979752a..970111ad 100644 --- a/virt/kvm

[PATCH 4/4] mm: replace set_pte_at_notify() with just set_pte_at()

2024-04-05 Thread Paolo Bonzini
With the demise of the .change_pte() MMU notifier callback, there is no notification happening in set_pte_at_notify(). It is a synonym of set_pte_at() and can be replaced with it. Signed-off-by: Paolo Bonzini --- include/linux/mmu_notifier.h | 2 -- kernel/events/uprobes.c | 5 ++--- mm

Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-11 Thread Paolo Bonzini
On Mon, Apr 8, 2024 at 3:56 PM Peter Xu wrote: > Paolo, > > I may miss a bunch of details here (as I still remember some change_pte > patches previously on the list..), however not sure whether we considered > enable it? Asked because I remember Andrea used to have a custom tree > maintaining tha

Re: [PATCH 0/4] KVM, mm: remove the .change_pte() MMU notifier and set_pte_at_notify()

2024-04-11 Thread Paolo Bonzini
On Wed, Apr 10, 2024 at 11:30 PM Andrew Morton wrote: > On Fri, 5 Apr 2024 07:58:11 -0400 Paolo Bonzini wrote: > > Please review! Also feel free to take the KVM patches through the mm > > tree, as I don't expect any conflicts. > > It's mainly a KVM thing and the

Re: [PATCH 1/4] KVM: PPC: Book3S HV: Make struct kernel_param_ops definition const

2020-10-19 Thread Paolo Bonzini
On 04/10/20 02:18, Joe Perches wrote: > This should be const, so make it so. > > Signed-off-by: Joe Perches > --- > arch/powerpc/kvm/book3s_hv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 4ba06a2a3

Re: [PATCH 10/44] KVM: VMX: Clean up eVMCS enabling if KVM initialization fails

2022-11-03 Thread Paolo Bonzini
On 11/3/22 00:18, Sean Christopherson wrote: +static void hv_cleanup_evmcs(void) This needs to be __init. Paolo

Re: [PATCH 10/44] KVM: VMX: Clean up eVMCS enabling if KVM initialization fails

2022-11-03 Thread Paolo Bonzini
On Thu, Nov 3, 2022 at 3:01 PM Paolo Bonzini wrote: > > On 11/3/22 00:18, Sean Christopherson wrote: > > +static void hv_cleanup_evmcs(void) > > This needs to be __init. Error: brain temporarily disconnected. Paolo

Re: [PATCH 33/44] KVM: x86: Do VMX/SVM support checks directly in vendor code

2022-11-03 Thread Paolo Bonzini
On 11/3/22 00:19, Sean Christopherson wrote: + if (!boot_cpu_has(X86_FEATURE_MSR_IA32_FEAT_CTL) || + !boot_cpu_has(X86_FEATURE_VMX)) { + pr_err("VMX not enabled in MSR_IA32_FEAT_CTL\n"); + return false; I think the reference to the BIOS should remain

Re: [PATCH 36/44] KVM: x86: Do compatibility checks when onlining CPU

2022-11-03 Thread Paolo Bonzini
On 11/3/22 00:19, Sean Christopherson wrote: From: Chao Gao Do compatibility checks when enabling hardware to effectively add compatibility checks when onlining a CPU. Abort enabling, i.e. the online process, if the (hotplugged) CPU is incompatible with the known good setup. This paragraph is

Re: [PATCH 39/44] KVM: Drop kvm_count_lock and instead protect kvm_usage_count with kvm_lock

2022-11-03 Thread Paolo Bonzini
On 11/3/22 00:19, Sean Christopherson wrote: +- kvm_lock is taken outside kvm->mmu_lock Not surprising since one is a mutex and one is an rwlock. :) You can drop this hunk as well as the "Opportunistically update KVM's locking documentation" sentence in the commit message. - vcpu->mutex

Re: [PATCH 00/44] KVM: Rework kvm_init() and hardware enabling

2022-11-03 Thread Paolo Bonzini
On 11/3/22 13:08, Christian Borntraeger wrote: There are bug fixes throughout this series.  They are more scattered than I would usually prefer, but getting the sequencing correct was a gigantic pain for many of the x86 fixes due to needing to fix common code in order for the x86 fix to have any

Re: [PATCH 36/44] KVM: x86: Do compatibility checks when onlining CPU

2022-11-03 Thread Paolo Bonzini
On 11/3/22 18:44, Sean Christopherson wrote: Do compatibility checks when enabling hardware to effectively add compatibility checks when onlining a CPU. Abort enabling, i.e. the online process, if the (hotplugged) CPU is incompatible with the known good setup. This paragraph is not true with t

Re: [PATCH 33/44] KVM: x86: Do VMX/SVM support checks directly in vendor code

2022-11-03 Thread Paolo Bonzini
On 11/3/22 19:35, Sean Christopherson wrote: It's technically required. IA32_FEAT_CTL and thus KVM_INTEL depends on any of CPU_SUP_{INTEL,CENATUR,ZHAOXIN}, but init_ia32_feat_ctl() is invoked if and only if the actual CPU type matches one of the aforementioned CPU_SUP_*. E.g. running a kernel b

Re: [PATCH 00/44] KVM: Rework kvm_init() and hardware enabling

2022-11-04 Thread Paolo Bonzini
On 11/4/22 08:17, Isaku Yamahata wrote: On Wed, Nov 02, 2022 at 11:18:27PM +, Sean Christopherson wrote: Non-x86 folks, please test on hardware when possible. I made a _lot_ of mistakes when moving code around. Thankfully, x86 was the trickiest code to deal with, and I'm fairly confident

Re: [PATCH 33/44] KVM: x86: Do VMX/SVM support checks directly in vendor code

2022-11-04 Thread Paolo Bonzini
On 11/3/22 19:58, Sean Christopherson wrote: diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 3e508f239098..ebe617ab0b37 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -191,6 +191,8 @@ static void default_init(struct cpuinfo_x86 *c)

Re: [PATCH v2 00/50] KVM: Rework kvm_init() and hardware enabling

2022-12-27 Thread Paolo Bonzini
Queued, thanks. I will leave this in kvm/queue after testing everything else and moving it to kvm/next; this way, we can wait for test results on other architectures. Paolo

Re: [PATCH v2 00/50] KVM: Rework kvm_init() and hardware enabling

2022-12-28 Thread Paolo Bonzini
On 12/28/22 12:22, Marc Zyngier wrote: Queued, thanks.  I will leave this in kvm/queue after testing everything else and moving it to kvm/next; this way, we can wait for test results on other architectures. Can you please make this a topic branch, and if possible based on a released -rc? It w

Re: [PATCH v2 00/50] KVM: Rework kvm_init() and hardware enabling

2022-12-29 Thread Paolo Bonzini
On 12/28/22 12:22, Marc Zyngier wrote: Queued, thanks.  I will leave this in kvm/queue after testing everything else and moving it to kvm/next; this way, we can wait for test results on other architectures. Can you please make this a topic branch, and if possible based on a released -rc? It w

Re: [PATCH 0/3] KVM: x86 SRCU bug fix and SRCU hardening

2022-04-20 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH RESEND] KVM: powerpc: remove extraneous asterisk from rm_host_ipi_action comment

2022-05-20 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include

2021-04-15 Thread Paolo Bonzini
On 15/04/21 09:27, Masahiro Yamada wrote: Since commit d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler"), some kselftests fail to build. The tools/ directory opted out Kbuild, and went in a different direction. They copy any kind of files to the tools/ directory i

Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include

2021-04-15 Thread Paolo Bonzini
On 15/04/21 10:04, Masahiro Yamada wrote: On Thu, Apr 15, 2021 at 4:40 PM Paolo Bonzini wrote: I think it would make sense to add try-run, cc-option and .DELETE_ON_ERROR to tools/build/Build.include? To be safe, I just copy-pasted what the makefiles need. If someone wants to refactor the

Re: [PATCH v2] tools: do not include scripts/Kbuild.include

2021-04-16 Thread Paolo Bonzini
On 16/04/21 15:26, Christian Borntraeger wrote: On 16.04.21 15:00, Masahiro Yamada wrote: Since commit d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler"), some kselftests fail to build. The tools/ directory opted out Kbuild, and went in a different direction. Th

Re: [PATCH] KVM: PPC: Book3S HV: Fix conversion to gfn-based MMU notifier callbacks

2021-05-05 Thread Paolo Bonzini
On 05/05/21 14:15, Nicholas Piggin wrote: Commit b1c5356e873c ("KVM: PPC: Convert to the gfn-based MMU notifier callbacks") causes unmap_gfn_range and age_gfn callbacks to only work on the first gfn in the range. It also makes the aging callbacks call into both radix and hash aging functions for

Re: [PATCH v6 1/5] KVM: s390: clean up redundant 'kvm_run' parameters

2020-07-10 Thread Paolo Bonzini
On 23/06/20 17:31, Christian Borntraeger wrote: > > I have trouble seeing value in this particular patch. We add LOCs > without providing any noticable benefit. All other patches in this series at > least reduce the amount of code. So I would defer this to Paolo if he prefers > to have this way ac

Re: [PATCH v6 3/5] KVM: PPC: clean up redundant kvm_run parameters in assembly

2020-07-10 Thread Paolo Bonzini
On 23/06/20 15:14, Tianjia Zhang wrote: > > /* Load non-volatile guest state from the vcpu */ > - VCPU_LOAD_NVGPRS(r4) > + VCPU_LOAD_NVGPRS(r3) > > kvm_start_lightweight: > /* Copy registers into shadow vcpu so we can access them in real mode */ > - mr r3, r4 >

Re: [PATCH v6 0/5] clean up redundant 'kvm_run' parameters

2020-07-10 Thread Paolo Bonzini
On 10/07/20 09:32, Tianjia Zhang wrote: > Hi Paolo, > > Any opinion on this series patches? Can I help with this patchset ? I was hoping to have some Tested-by, for now I'm queuing patches 1 and 2. Thanks, Paolo > Thanks and best, > Tianjia > > On 2020/6/23 21:14, Tianjia Zhang wrote: >> In t

Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest

2021-09-06 Thread Paolo Bonzini
On 20/08/21 20:51, Mathieu Desnoyers wrote: Ah, or is it the case that rseq_cs is non-NULL if and only if userspace is in an rseq critical section, and because syscalls in critical sections are illegal, by definition clearing rseq_cs is a nop unless userspace is misbehaving. Not quite, as I desc

Re: [PATCH 0/5] KVM: rseq: Fix and a test for a KVM+rseq bug

2021-09-22 Thread Paolo Bonzini
On 18/08/21 02:12, Sean Christopherson wrote: Patch 1 fixes a KVM+rseq bug where KVM's handling of TIF_NOTIFY_RESUME, e.g. for task migration, clears the flag without informing rseq and leads to stale data in userspace's rseq struct. Patch 2 is a cleanup to try and make future bugs less likely.

Re: [PATCH 0/2] kvm: fix KVM_MAX_VCPU_ID handling

2021-09-23 Thread Paolo Bonzini
On 13/09/21 15:57, Juergen Gross wrote: Revert commit 76b4f357d0e7d8f6f00 which was based on wrong reasoning and rename KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS in order to avoid the same issue in future. Juergen Gross (2): x86/kvm: revert commit 76b4f357d0e7d8f6f00 kvm: rename KVM_MAX_VCPU_ID

Re: [PATCH] MAINTAINERS: Update powerpc KVM entry

2021-10-27 Thread Paolo Bonzini
abs.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git topic/ppc-kvm F:arch/powerpc/include/asm/kvm* F:arch/powerpc/include/uapi/asm/kvm* F:arch/powerpc/kernel/kvm* Acked-by: Paolo Bonzini Thanks Michael and Paul! Paolo

Re: [PATCH 1/5] KVM: Move wiping of the kvm->vcpus array to common code

2021-11-16 Thread Paolo Bonzini
On 11/6/21 12:17, Marc Zyngier wrote: If you too believe that this is just wrong, I'm happy to drop the locking altogether. If that breaks someone's flow, they'll shout soon enough. Yes, it's not necessary. It was added in 2009 (commit 988a2cae6a3c, "KVM: Use macro to iterate over vcpus.") a

Re: [PATCH 4/5] KVM: x86: Use kvm_get_vcpu() instead of open-coded access

2021-11-16 Thread Paolo Bonzini
On 11/5/21 21:03, Sean Christopherson wrote: But I think even that is flawed, as APICv can be dynamically deactivated and re-activated while the VM is running, and I don't see a path that re-updates the IRTE when APICv is re-activated. So I think a more conservative check is needed, e.g. diff -

Re: [PATCH 0/5] KVM: Turn the vcpu array into an xarray

2021-11-16 Thread Paolo Bonzini
On 11/16/21 15:13, Juergen Gross wrote: On 05.11.21 20:20, Marc Zyngier wrote: The kvm structure is pretty large. A large portion of it is the vcpu array, which is 4kB on x86_64 and arm64 as they deal with 512 vcpu VMs. Of course, hardly anyone runs VMs this big, so this is often a net waste of

Re: [PATCH 0/5] KVM: Turn the vcpu array into an xarray

2021-11-16 Thread Paolo Bonzini
On 11/5/21 20:20, Marc Zyngier wrote: The kvm structure is pretty large. A large portion of it is the vcpu array, which is 4kB on x86_64 and arm64 as they deal with 512 vcpu VMs. Of course, hardly anyone runs VMs this big, so this is often a net waste of memory and cache locality. A possible app

Re: [PATCH 4/5] KVM: x86: Use kvm_get_vcpu() instead of open-coded access

2021-11-16 Thread Paolo Bonzini
On 11/16/21 17:07, Sean Christopherson wrote: if (!kvm_arch_has_assigned_device(kvm) || !irq_remapping_cap(IRQ_POSTING_CAP) || - !kvm_vcpu_apicv_active(kvm->vcpus[0])) + !irqchip_in_kernel(kvm) || !enable_apicv) return 0; id

Re: [PATCH v3 08/12] KVM: Propagate vcpu explicitly to mark_page_dirty_in_slot()

2021-11-18 Thread Paolo Bonzini
On 11/17/21 22:09, David Woodhouse wrote: { - struct kvm_vcpu *vcpu = kvm_get_running_vcpu(); + struct kvm_vcpu *running_vcpu = kvm_get_running_vcpu(); + WARN_ON_ONCE(vcpu && vcpu != running_vcpu); WARN_ON_ONCE(vcpu->kvm != kvm); Ah, that one needs to be changed to c

<    1   2   3   4   >