Re: [PATCH] KVM: selftests: fix irqfd_test on arm64

2025-09-30 Thread Sean Christopherson
+Naresh On Tue, Aug 26, 2025, Sean Christopherson wrote: > On Tue, Aug 26, 2025, Oliver Upton wrote: > > On Tue, Aug 26, 2025 at 11:51:18AM -0700, Sean Christopherson wrote: > > > On Mon, Aug 25, 2025, Oliver Upton wrote: > > > > The majority of selftests don

Re: selftests: kvm: irqfd_test: KVM_IRQFD failed, rc: -1 errno: 11 (Resource temporarily unavailable)

2025-09-30 Thread Sean Christopherson
On Tue, Sep 30, 2025, Naresh Kamboju wrote: > The selftests: kvm: irqfd_test consistently fails across all test platforms > since its introduction in Linux next-20250625. The failure occurs due to > a KVM_IRQFD ioctl returning errno 11 (Resource temporarily unavailable). > This has been observed fr

Re: [PATCH] vhost: Take a reference on the task that is reference in struct vhost_task.

2025-09-19 Thread Sean Christopherson
a valid task_struct. The wake is safe and will be skipped > in this case. > > Fixes: f9010dbdce911 ("fork, vhost: Use CLONE_THREAD to fix freezer/ps > regression") > Reported-by: Sean Christopherson > Closes: https://lore.kernel.org/all/akkletodxkxaa...@google.com/ &g

Re: [PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-09-18 Thread Sean Christopherson
On Thu, Sep 18, 2025, Michael S. Tsirkin wrote: > On Thu, Sep 18, 2025 at 09:52:19AM -0700, Sean Christopherson wrote: > > On Thu, Sep 18, 2025, Michael S. Tsirkin wrote: > > > On Thu, Sep 18, 2025 at 09:04:07AM -0700, Sean Christopherson wrote: > > > > On Thu, S

Re: [PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-09-18 Thread Sean Christopherson
On Thu, Sep 18, 2025, Michael S. Tsirkin wrote: > On Thu, Sep 18, 2025 at 09:04:07AM -0700, Sean Christopherson wrote: > > On Thu, Sep 18, 2025, Sebastian Andrzej Siewior wrote: > > > On 2025-09-18 11:09:05 [-0400], Michael S. Tsirkin wrote: > > > > So how about s

Re: [PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-09-18 Thread Sean Christopherson
Longer term, I'd still like to land everything though. > > Sean? > > Since I am in To: here. You want me to resent my diff as a proper patch? Ya, I think it makes sense to harden against UAF even if we fix the KVM bug more directly.

Re: [GIT PULL] virtio,vhost: last minute fixes

2025-09-18 Thread Sean Christopherson
iwari (1): > vhost-scsi: fix argument order in tport allocation error message > > Alyssa Ross (1): > virtio_config: clarify output parameters > > Ashwini Sahu (1): > uapi: vduse: fix typo in comment > > Michael S. Tsirkin (1): > Revert "vi

Re: [PATCH] KVM: selftests: Fix typo in hyperv cpuid test message

2025-09-15 Thread Sean Christopherson
On Sun, 24 Aug 2025 11:16:40 -0700, Alok Tiwari wrote: > Fix a typo in hyperv_cpuid.c test assertion log: > replace "our of supported range" -> "out of supported range". Applied to kvm-x86 selftests, thanks! [1/1] KVM: selftests: Fix typo in hyperv cpuid test message https://github.com/kvm-

Re: [PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-09-15 Thread Sean Christopherson
On Mon, Sep 15, 2025, Michael S. Tsirkin wrote: > On Mon, Sep 15, 2025 at 02:03:00PM -0700, Sean Christopherson wrote: > > On Wed, Aug 27, 2025, Sean Christopherson wrote: > > > Michael, > > > > > > Do you want to take this through the vhost tree? It technical

Re: [PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-09-15 Thread Sean Christopherson
On Wed, Aug 27, 2025, Sean Christopherson wrote: > Michael, > > Do you want to take this through the vhost tree? It technically fixes a KVM > bug, but this obviously touches far more vhost code than KVM code, and the > patch that needs to go into 6.17 doesn't touch KVM

Re: [PATCH 5/9] KVM: selftests: Prevent PAGE_SIZE redefinition on x86

2025-09-08 Thread Sean Christopherson
On Fri, Sep 05, 2025, Aqib Faruqui wrote: > Thanks for the suggestion. I don't see your previous redefinition of > PAGE_SIZE > upstream, just 3 lines above the warning redefinition: Oh, I manually added a conflicting definition to demonstrate the warning gcc will provide. > > In file included f

Re: [PATCH] selftests/kvm: Use vcpus count instead of hardcoded 0xff in test_icr

2025-09-08 Thread Sean Christopherson
On Sat, Sep 06, 2025, Sukrut Heroorkar wrote: > Replace the hardcoded 0xff in test_icr() with the actual number of vcpus > created for the vm. This address the existing TODO and keeps the test > correct if it is ever run with multiple vcpus. The TODO is stale, it was resolved by commit 376bc1b458c

Re: [PATCH v9 18/19] KVM: selftests: Add ucall support for TDX

2025-09-02 Thread Sean Christopherson
On Wed, Aug 27, 2025, Binbin Wu wrote: > On 8/21/2025 12:29 PM, Sagi Shahar wrote: > > @@ -46,11 +69,23 @@ void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu) > > { > > struct kvm_run *run = vcpu->run; > > - if (run->exit_reason == KVM_EXIT_IO && run->io.port == UCALL_PIO_PORT) { > > -

Re: [PATCH 1/9] KVM: selftests: Add pidfd_open syscall number fallback

2025-08-29 Thread Sean Christopherson
Subject says KVM, but I don't see anything KVM related in here. I don't think any of the KVM selftests even use pidfd_open() directly. On Fri, Aug 29, 2025, Aqib Faruqui wrote: > The kselftest-harness uses pidfd_open() for test timeout handling, but > non-glibc C library headers may not define th

Re: [PATCH 2/9] KVM: selftests: Add __packed attribute fallback

2025-08-29 Thread Sean Christopherson
On Fri, Aug 29, 2025, Aqib Faruqui wrote: > Kernel UAPI headers use __packed but don't provide the definition in > userspace builds. > > Add a fallback definition matching the kernel's implementation. This > follows the same pattern used by BPF and SGX selftests. Ugh. No, this needs to be fixed

Re: [PATCH 3/9] KVM: selftests: Add pthread_attr_setaffinity_np fallback

2025-08-29 Thread Sean Christopherson
ally something that provides roughly equivalent functionality. This particular test will still pass because forced preemption isn't strictly necessary, but this is still gross. Luckily, KVM selftests already provides APIs to pin tasks, just use those and the problem naturally goes away. --

Re: [PATCH 5/9] KVM: selftests: Prevent PAGE_SIZE redefinition on x86

2025-08-29 Thread Sean Christopherson
On Fri, Aug 29, 2025, Aqib Faruqui wrote: > Prevent PAGE_SIZE redefinition warnings that can occur due to namespace > pollution from included headers. > > Add an #ifndef directive before defining PAGE_SIZE to avoid redefinition > conflicts. Please provide more details on what is causing the confl

Re: [PATCH 1/1] KVM: selftests: Fix force_emulation_prefix parameter type mismatch

2025-08-29 Thread Sean Christopherson
pts Y/N > values, but the function was incorrectly trying to parse it as an > integer using strtol(). Nope, it's been an int since commit: commit d500e1ed3dc873818277e109ccf6407118669236 Author: Sean Christopherson AuthorDate: Tue Aug 30 23:15:51 2022 + Commit: Paolo Bonzini

Re: [PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-08-27 Thread Sean Christopherson
On Wed, Aug 27, 2025, Sebastian Andrzej Siewior wrote: > On 2025-08-27 12:41:04 [-0700], Sean Christopherson wrote: > > Michael, > > Sean, > > would the bellow work by chance? It is a quick shot but it looks > symmetrical… Gah, sorry, I flagged your earlier mail and th

[PATCH v2 3/3] KVM: x86/mmu: Don't register a sigkill callback for NX hugepage recovery tasks

2025-08-27 Thread Sean Christopherson
Don't register a sigkill callback with vhost_task when creating NX hugepage recovery threads now that said callback is optional. In addition to removing what is effectively dead code, not registering a sigkill "handler" also guards against improper use of __vhost_task_wake(). Sign

[PATCH v2 2/3] vhost_task: Allow caller to omit handle_sigkill() callback

2025-08-27 Thread Sean Christopherson
it didn't help KVM do the right thing with respect to signals, and adding a sanity check in __vhost_task_wake() gives developers a hint as to what needs to be done in response to sigkill. Signed-off-by: Sean Christopherson --- kernel/vhost_task.c | 10 +- 1 file changed, 9 insertions

[PATCH v2 1/3] vhost_task: Don't wake KVM x86's recovery thread if vhost task was killed

2025-08-27 Thread Sean Christopherson
kernel.org/all/akkletodxkxaa...@google.com Link: https://lore.kernel.org/all/aj_vep2ehj6l0...@google.com Suggested-by: Sebastian Andrzej Siewior Fixes: d96c77bd4eeb ("KVM: x86: switch hugepage recovery thread to vhost_task") Cc: sta...@vger.kernel.org Signed-off-by: Sean Christopherson --

[PATCH v2 0/3] vhost_task: Fix a bug where KVM wakes an exited task

2025-08-27 Thread Sean Christopherson
task_wake() and __vhost_task_wake() for the public APIs, and vhost_task_wake_up_process() for the local helper. [Michael] - Drag the signalas back from their Spanish holiday. [Sebastian] v1: https://lore.kernel.org/all/20250826004012.3835150-1-sea...@google.com Sean Christopherson (3): vhost_t

Re: [PATCH v9 15/19] KVM: selftests: Hook TDX support to vm and vcpu creation

2025-08-26 Thread Sean Christopherson
On Tue, Aug 26, 2025, Sagi Shahar wrote: > On Tue, Aug 26, 2025 at 3:29 PM Sagi Shahar wrote: > > > > On Tue, Aug 26, 2025 at 3:14 PM Ira Weiny wrote: > > > > > > Sean Christopherson wrote: > > > > Ugh. IMO, this is a KVM bug. Allowing KVM_C

Re: [PATCH] KVM: selftests: fix irqfd_test on arm64

2025-08-26 Thread Sean Christopherson
On Tue, Aug 26, 2025, Oliver Upton wrote: > On Tue, Aug 26, 2025 at 11:51:18AM -0700, Sean Christopherson wrote: > > On Mon, Aug 25, 2025, Oliver Upton wrote: > > > The majority of selftests don't even need an irqchip anyway. > > > > But it's really, reall

Re: [PATCH v9 04/19] KVM: selftests: Expose function to allocate guest vCPU stack

2025-08-26 Thread Sean Christopherson
On Tue, Aug 26, 2025, Binbin Wu wrote: > > > On 8/21/2025 12:28 PM, Sagi Shahar wrote: > > TDX guests' registers cannot be initialized directly using > > vcpu_regs_set(), hence the stack pointer needs to be initialized by > > the guest itself, running boot code beginning at the reset vector. > >

Re: [PATCH] KVM: selftests: fix irqfd_test on arm64

2025-08-26 Thread Sean Christopherson
On Mon, Aug 25, 2025, Oliver Upton wrote: > On Mon, Aug 25, 2025 at 02:11:30PM -0700, Sean Christopherson wrote: > > On Mon, Aug 25, 2025, Marc Zyngier wrote: > > > On Mon, 25 Aug 2025 20:52:21 +0100, > > > Sean Christopherson wrote: > > > > Is ther

Re: [PATCH v9 15/19] KVM: selftests: Hook TDX support to vm and vcpu creation

2025-08-26 Thread Sean Christopherson
On Wed, Aug 20, 2025, Sagi Shahar wrote: > TDX require special handling for VM and VCPU initialization for various > reasons: > - Special ioctlss for creating VM and VCPU. > - TDX registers are inaccessible to KVM. > - TDX require special boot code trampoline for loading parameters. > - TDX only su

Re: [PATCH v9 10/19] KVM: selftests: Set up TDX boot code region

2025-08-26 Thread Sean Christopherson
On Mon, Aug 25, 2025, Yan Zhao wrote: > > + /* > > +* Handcode "JMP rel8" at the RESET vector to jump back to the TD boot > > +* code, as there are only 16 bytes at the RESET vector before RIP will > > +* wrap back to zero. Insert a trailing int3 so that the vCPU crashes > > +* i

Re: [PATCH 1/3] vhost_task: KVM: Don't wake KVM x86's recovery thread if vhost task was killed

2025-08-26 Thread Sean Christopherson
On Tue, Aug 26, 2025, Michael S. Tsirkin wrote: > On Mon, Aug 25, 2025 at 05:40:09PM -0700, Sean Christopherson wrote: > > Provide an API in vhost task instead of forcing KVM to solve the problem, > > as KVM would literally just add an equivalent to VHOST_TASK_FLAGS_KILLED, >

Re: [PATCH v9 03/19] KVM: selftests: Expose functions to get default sregs values

2025-08-26 Thread Sean Christopherson
On Tue, Aug 26, 2025, Binbin Wu wrote: > On 8/21/2025 12:28 PM, Sagi Shahar wrote: > > TDX can't set sregs values directly using KVM_SET_SREGS. Expose the > > default values of certain sregs used by TDX VMs so they can be set > > manually. > > > > Signed-off-by: Sagi Shahar > > --- > > .../self

[PATCH 3/3] KVM: x86/mmu: Don't register a sigkill callback for NX hugepage recovery tasks

2025-08-25 Thread Sean Christopherson
Don't register a sigkill callback with vhost_task when creating NX hugepage recovery threads now that said callback is optional. In addition to removing what is effectively dead code, not registering a sigkill "handler" also guards against improper use of vhost_task_wake(). Sign

[PATCH 2/3] vhost_task: Allow caller to omit handle_sigkill() callback

2025-08-25 Thread Sean Christopherson
it didn't help KVM do anything useful, and adding a sanity check in vhost_task_wake() gives developers a hint as to what needs to be done in response to sigkill. Signed-off-by: Sean Christopherson --- kernel/vhost_task.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff

[PATCH 1/3] vhost_task: KVM: Don't wake KVM x86's recovery thread if vhost task was killed

2025-08-25 Thread Sean Christopherson
//lore.kernel.org/all/aj_vep2ehj6l0...@google.com Suggested-by: Sebastian Andrzej Siewior Fixes: d96c77bd4eeb ("KVM: x86: switch hugepage recovery thread to vhost_task") Cc: sta...@vger.kernel.org Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 2 +- includ

[PATCH 0/3] vhost_task: KVM: Fix a race where KVM wakes an exited task

2025-08-25 Thread Sean Christopherson
r-CPU reference counting instead of rcuref_t") landed. I have no idea why the futex changes exposed the bug, and I don't care all that much, as this is firmly a KVM bug. Sean Christopherson (3): vhost_task: KVM: Don't wake KVM x86's recovery thread if vhost task was killed vh

Re: [PATCH] KVM: selftests: fix irqfd_test on arm64

2025-08-25 Thread Sean Christopherson
On Mon, Aug 25, 2025, Marc Zyngier wrote: > On Mon, 25 Aug 2025 20:52:21 +0100, > Sean Christopherson wrote: > > Is there a sane way to handle vGIC creation in kvm_arch_vm_post_create()? > > E.g. > > could we create a v3 GIC when possible, and fall back to v2? And the

Re: [PATCH] KVM: selftests: fix irqfd_test on arm64

2025-08-25 Thread Sean Christopherson
On Mon, Aug 25, 2025, Sebastian Ott wrote: > irqfd_test on arm triggers the following assertion: > Test Assertion Failure > include/kvm_util.h:527: !ret > pid=3643 tid=3643 errno=11 - Resource temporarily unavailable > 1 0x004026d7: kvm_irqfd at kvm_util.h:527 > 2

Re: [PATCH v9 01/19] KVM: selftests: Include overflow.h instead of redefining is_signed_type()

2025-08-21 Thread Sean Christopherson
On Thu, Aug 21, 2025, Ira Weiny wrote: > Need to add the selftest folks. > > + linux-kselft...@vger.kernel.org > + Kees Cook > + Shuah Khan > > Sagi Shahar wrote: > > Redefinition of is_signed_type() causes compilation warning for tests > > which use kselftest_harness. Replace the definition wi

Re: [PATCH v9 01/19] KVM: selftests: Include overflow.h instead of redefining is_signed_type()

2025-08-21 Thread Sean Christopherson
On Wed, Aug 20, 2025, Sagi Shahar wrote: > Redefinition of is_signed_type() causes compilation warning for tests > which use kselftest_harness. Replace the definition with linux/overflow.h Heh, tried that: https://lore.kernel.org/all/18f2ea68-0f7c-465e-917e-e07933599...@sirena.org.uk There's now

Re: [PATCH] selftests: harness: Rework is_signed_type() to avoid collision with overflow.h

2025-08-20 Thread Sean Christopherson
On Wed, Aug 20, 2025, Sean Christopherson wrote: > On Wed, Aug 20, 2025, Mark Brown wrote: > > On Tue, Jun 24, 2025 at 04:19:30PM -0700, Sean Christopherson wrote: > > > Rename is_signed_type() to is_signed_var() to avoid colliding with a macro > > > of the same name

Re: [PATCH] selftests: harness: Rework is_signed_type() to avoid collision with overflow.h

2025-08-20 Thread Sean Christopherson
On Wed, Aug 20, 2025, Mark Brown wrote: > On Tue, Jun 24, 2025 at 04:19:30PM -0700, Sean Christopherson wrote: > > Rename is_signed_type() to is_signed_var() to avoid colliding with a macro > > of the same name defined by linux/overflow.h. Note, overflow.h's version > >

Re: [PATCH v2] arch/x86/kvm/ioapic: Remove license boilerplate with bad FSF address

2025-08-19 Thread Sean Christopherson
On Mon, 28 Jul 2025 17:28:43 +0200, Thomas Huth wrote: > The Free Software Foundation does not reside in "59 Temple Place" > anymore, so we should not mention that address in the source code here. > But instead of updating the address to their current location, let's > rather drop the license boile

Re: [PATCH] selftests: harness: Rework is_signed_type() to avoid collision with overflow.h

2025-08-19 Thread Sean Christopherson
On Tue, 24 Jun 2025 16:19:30 -0700, Sean Christopherson wrote: > Rename is_signed_type() to is_signed_var() to avoid colliding with a macro > of the same name defined by linux/overflow.h. Note, overflow.h's version > takes a type as the input, whereas the harness's versi

[PATCH] rseq/selftests: Use weak symbol reference, not definition, to link with glibc

2025-08-19 Thread Sean Christopherson
cally linked against a libc that doesn't support rseq in any capacity. Fixes: 3bcbc20942db ("selftests/rseq: Play nice with binaries statically linked against glibc 2.35+") Cc: sta...@vger.kernel.org Suggested-by: Florian Weimer Reported-by: Thomas Gleixner Closes: https://lore

Re: [PATCH v8 06/30] KVM: selftests: Add helper functions to create TDX VMs

2025-08-15 Thread Sean Christopherson
On Fri, Aug 15, 2025, Sagi Shahar wrote: > On Tue, Aug 12, 2025 at 11:22 PM Binbin Wu wrote: > > > > > > > > On 8/12/2025 4:13 AM, Sean Christopherson wrote: > > > On Thu, Aug 07, 2025, Sagi Shahar wrote: > > [...] > > >&

Re: [PATCH v8 00/30] TDX KVM selftests

2025-08-15 Thread Sean Christopherson
On Thu, Aug 14, 2025, Sagi Shahar wrote: > On Mon, Aug 11, 2025 at 3:53 PM Sean Christopherson wrote: > > > > On Mon, Aug 11, 2025, Rick P Edgecombe wrote: > > > But Sean, if you want to save some time I think we can just accelerate > > > this > > &

Re: [PATCH v8 25/30] KVM: selftests: KVM: selftests: Expose new vm_vaddr_alloc_private()

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Ackerley Tng > > vm_vaddr_alloc_private allow specifying both the virtual and physical > addresses for the allocation. Why?

Re: [PATCH v8 24/30] KVM: selftests: TDX: Add shared memory test

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > @@ -189,3 +199,19 @@ uint64_t tdg_vp_info(uint64_t *rcx, uint64_t *rdx, > > return ret; > } > + > +uint64_t tdg_vp_vmcall_map_gpa(uint64_t address, uint64_t size, uint64_t > *data_out) > +{ > + struct tdx_hypercall_args args = { > +

Re: [PATCH v8 00/30] TDX KVM selftests

2025-08-11 Thread Sean Christopherson
On Mon, Aug 11, 2025, Rick P Edgecombe wrote: > But Sean, if you want to save some time I think we can just accelerate this > other reviewing. As far as new-fangled features, having this upstream is > important even for that, because we are currently having to keep these tests > pl

Re: [PATCH v8 21/30] KVM: selftests: TDX: Verify the behavior when host consumes a TD private memory

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > +void verify_host_reading_private_mem(void) > +{ > + uint64_t second_host_read; > + uint64_t first_host_read; > + struct kvm_vcpu *vcpu; > + vm_vaddr_t test_page; > + uint64_t *host_virt; > + struct kvm_vm *vm; > + > + vm = td_c

Re: [PATCH v8 08/30] KVM: selftests: TDX: Update load_td_memory_region() for VM memory backed by guest memfd

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Ackerley Tng > > If guest memory is backed by restricted memfd > > + UPM is being used, hence encrypted memory region has to be > registered > + Can avoid making a copy of guest memory before getting TDX to > initialize the memory region > >

Re: [PATCH v8 06/30] KVM: selftests: Add helper functions to create TDX VMs

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Erdem Aktas > > TDX requires additional IOCTLs to initialize VM and vCPUs to add > private memory and to finalize the VM memory. Also additional utility > functions are provided to manipulate a TD, similar to those that > manipulate a VM in the cur

Re: [PATCH v8 05/30] KVM: selftests: Update kvm_init_vm_address_properties() for TDX

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Isaku Yamahata > > Let kvm_init_vm_address_properties() initialize vm->arch.{s_bit, tag_mask} > similar to SEV. > > Set shared bit position based on guest maximum physical address width > instead of maximum physical address width, because that is

Re: [PATCH v8 04/30] KVM: selftests: Add vCPU descriptor table initialization utility

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Ackerley Tng > > Turn vCPU descriptor table initialization into a utility for use by tests > needing finer control, for example for TDX TD creation. NAK. "needing finer control" is not a sufficient explanation for why _this_ patch is necessary.

Re: [PATCH v8 03/30] KVM: selftests: Store initial stack address in struct kvm_vcpu

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Ackerley Tng > > TDX guests' registers cannot be initialized directly using > vcpu_regs_set(), hence the stack pointer needs to be initialized by > the guest itself, running boot code beginning at the reset vector. > > Store the stack address as p

Re: [PATCH v8 02/30] KVM: selftests: Expose function that sets up sregs based on VM's mode

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Ackerley Tng > Make changelogs standalone, i.e. don't rely on the subject/shortlog for context. > This allows initializing sregs without setting vCPU registers in > KVM. > > No functional change intended. > > Signed-off-by: Ackerley Tng > Sign

Re: [PATCH v8 01/30] KVM: selftests: Add function to allow one-to-one GVA to GPA mappings

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > From: Ackerley Tng > > One-to-one GVA to GPA mappings can be used in the guest to set up boot > sequences during which paging is enabled, hence requiring a transition > from using physical to virtual addresses in consecutive instructions. NAK, this is a

Re: [PATCH v8 00/30] TDX KVM selftests

2025-08-11 Thread Sean Christopherson
On Thu, Aug 07, 2025, Sagi Shahar wrote: > This is v8 of the TDX selftests. > > This series is based on v6.16 > > Aside from a rebase, this version includes a minor bug fix for > "KVM: selftests: Update kvm_init_vm_address_properties() for TDX" which > was called out in v6 by Ira Weiny. Folks, t

Re: [PATCH RFC V10 0/7] Add NUMA mempolicy support for KVM guest-memfd

2025-08-11 Thread Sean Christopherson
On Mon, Aug 11, 2025, Shivank Garg wrote: > This series introduces NUMA-aware memory placement support for KVM guests > with guest_memfd memory backends. It builds upon Fuad Tabba's work (V17) > that enabled host-mapping for guest_memfd memory [1]. Is this still actually an RFC? If so, why? If n

Re: [PATCH v4 20/38] KVM: x86/pmu: Check if mediated vPMU can intercept rdpmc

2025-08-04 Thread Sean Christopherson
On Fri, Aug 01, 2025, Sean Christopherson wrote: > On Wed, Jul 30, 2025, Dapeng Mi wrote: > > > > On 7/30/2025 8:38 AM, Sean Christopherson wrote: > > > On Tue, Jul 29, 2025, Dapeng Mi wrote: > > >> BTW, Sean, may I know your plan about the mediated vPMU v5 p

Re: [PATCH v4 20/38] KVM: x86/pmu: Check if mediated vPMU can intercept rdpmc

2025-08-01 Thread Sean Christopherson
On Wed, Jul 30, 2025, Dapeng Mi wrote: > > On 7/30/2025 8:38 AM, Sean Christopherson wrote: > > On Tue, Jul 29, 2025, Dapeng Mi wrote: > >> BTW, Sean, may I know your plan about the mediated vPMU v5 patch set? > >> Thanks. > > I'll get it out this

Re: [PATCH v4 20/38] KVM: x86/pmu: Check if mediated vPMU can intercept rdpmc

2025-07-29 Thread Sean Christopherson
On Tue, Jul 29, 2025, Dapeng Mi wrote: > BTW, Sean, may I know your plan about the mediated vPMU v5 patch set? Thanks. I'll get it out this week (hopefully tomorrow).

Re: [PATCH v4 10/38] perf/x86: Support switch_guest_ctx interface

2025-07-29 Thread Sean Christopherson
On Fri, Apr 25, 2025, Kan Liang wrote: > On 2025-04-25 9:43 a.m., Peter Zijlstra wrote: > > On Fri, Apr 25, 2025 at 09:06:26AM -0400, Liang, Kan wrote: > >> > >> > >> On 2025-04-25 7:15 a.m., Peter Zijlstra wrote: > >>> On Mon, Mar 24, 2025 at 05:30:50PM +, Mingwei Zhang wrote: > From: Kan

[PATCH 6/6] x86: Restrict KVM-induced symbol exports to KVM modules where obvious/possible

2025-07-29 Thread Sean Christopherson
built (because no vendor modules are selected), let arch code #define EXPORT_SYMBOL_GPL_FOR_KVM to suppress/override the exports. Note, the set of symbols to restrict to KVM was generated by manual search and audit; any "misses" are due to human error, not some grand plan. Sign

[PATCH 5/6] KVM: x86: Export KVM-internal symbols for sub-modules only

2025-07-29 Thread Sean Christopherson
Rework almost all of KVM x86's exports to expose symbols only to KVM's vendor modules, i.e. to kvm-{amd,intel}.ko. Keep the generic exports that are guarded by CONFIG_KVM_EXTERNAL_WRITE_TRACKING=y, as they're explicitly designed/intended for external usage. Signed-off-by: Sean

[PATCH 4/6] KVM: x86: Drop pointless exports of kvm_arch_xxx() hooks

2025-07-29 Thread Sean Christopherson
Drop the exporting of several kvm_arch_xxx() hooks that are only called from arch-neutral code, i.e. that are only called from kvm.ko. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index

[PATCH 3/6] KVM: x86: Move kvm_intr_is_single_vcpu() to lapic.c

2025-07-29 Thread Sean Christopherson
("KVM: x86: Dedup AVIC vs. PI code for identifying target vCPU") Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 3 --- arch/x86/kvm/irq.c | 28 arch/x86/kvm/lapic.c| 32 ++--

[PATCH 2/6] KVM: Export KVM-internal symbols for sub-modules only

2025-07-29 Thread Sean Christopherson
providing a macro to restrict KVM-specific kernel exports, i.e. to provide symbol exports for KVM if and only if KVM is built as one or more modules. Signed-off-by: Sean Christopherson --- arch/powerpc/include/asm/kvm_types.h | 15 arch/x86/include/asm/kvm_types.h | 10 +++ inclu

[PATCH 1/6] KVM: s390/vfio-ap: Use kvm_is_gpa_in_memslot() instead of open coded equivalent

2025-07-29 Thread Sean Christopherson
o x86's kvm-{amd,intel}.ko vendor mdoules). No functional change intended. Signed-off-by: Sean Christopherson --- arch/s390/include/asm/kvm_host.h | 2 ++ arch/s390/kvm/priv.c | 8 drivers/s390/crypto/vfio_ap_ops.c | 2 +- 3 files changed, 11 insertions(+), 1 dele

[PATCH 0/6] KVM: Export KVM-internal symbols for sub-modules only

2025-07-29 Thread Sean Christopherson
KVM. Based on kvm/queue. Sean Christopherson (6): KVM: s390/vfio-ap: Use kvm_is_gpa_in_memslot() instead of open coded equivalent KVM: Export KVM-internal symbols for sub-modules only KVM: x86: Move kvm_intr_is_single_vcpu() to lapic.c KVM: x86: Drop pointless exports of kvm_arch_xxx()

Re: [PATCH v2 5/5] KVM: selftests: x86: Add a test for KVM_CAP_X86_VMWARE_HYPERCALL

2025-07-23 Thread Sean Christopherson
On Tue, Apr 22, 2025, Zack Rusin wrote: > Add a testcase to exercise KVM_CAP_X86_VMWARE_HYPERCALL and validate > that KVM exits to userspace on hypercalls and registers are correctly > preserved. > > Signed-off-by: Zack Rusin > Cc: Doug Covelli > Cc: Paolo Bonzini > Cc

Re: [PATCH V9 0/7] Add NUMA mempolicy support for KVM guest-memfd

2025-07-22 Thread Sean Christopherson
On Tue, Jul 22, 2025, David Hildenbrand wrote: > On 22.07.25 16:45, Sean Christopherson wrote: > > On Tue, Jul 22, 2025, David Hildenbrand wrote: > > > Just to clarify: this is based on Fuad's stage 1 and should probably > > > still be > > > tagge

Re: [PATCH V9 0/7] Add NUMA mempolicy support for KVM guest-memfd

2025-07-22 Thread Sean Christopherson
On Tue, Jul 22, 2025, David Hildenbrand wrote: > Just to clarify: this is based on Fuad's stage 1 and should probably still be > tagged "RFC" until stage-1 is finally upstream. > > (I was hoping stage-1 would go upstream in 6.17, but I am not sure yet if > that is > still feasible looking at the

Re: [PATCH] KVM: selftests: Add CONFIG_EVENTFD for irqfd selftest

2025-07-10 Thread Sean Christopherson
On Thu, 10 Jul 2025 12:12:20 +0100, Mark Brown wrote: > In 7e9b231c402a ("KVM: selftests: Add a KVM_IRQFD test to verify > uniqueness requirements") we added a test for the newly added irqfd > support but since this feature works with eventfds it won't work unless > the kernel has been built wth ev

Re: [PATCH v4 20/38] KVM: x86/pmu: Check if mediated vPMU can intercept rdpmc

2025-07-09 Thread Sean Christopherson
On Mon, May 26, 2025, Sandipan Das wrote: > > @@ -212,6 +212,18 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu) > > bitmap_set(pmu->all_valid_pmc_idx, 0, pmu->nr_arch_gp_counters); > > } > > > > +static void amd_pmu_refresh(struct kvm_vcpu *vcpu) > > +{ > > + struct vcpu_svm *svm = t

Re: [PATCH] selftests: harness: Rework is_signed_type() to avoid collision with overflow.h

2025-07-07 Thread Sean Christopherson
On Fri, Jun 27, 2025, Kees Cook wrote: > On Tue, Jun 24, 2025 at 04:19:30PM -0700, Sean Christopherson wrote: > > Rename is_signed_type() to is_signed_var() to avoid colliding with a macro > > of the same name defined by linux/overflow.h. Note, overflow.h's version > >

Re: [PATCH v2 0/8] irqbypass: Cleanups and a perf improvement

2025-06-25 Thread Sean Christopherson
On Fri, 16 May 2025 16:07:26 -0700, Sean Christopherson wrote: > The two primary goals of this series are to make the irqbypass concept > easier to understand, and to address the terrible performance that can > result from using a list to track connections. > > For the first

Re: [PATCH] selftests: kvm: Fix spelling of 'occurrences' in sparsebit.c comments

2025-06-24 Thread Sean Christopherson
On Fri, 23 May 2025 23:43:52 +0530, Rahul Kumar wrote: > Corrected two instances of the misspelled word 'occurences' to > 'occurrences' in comments explaining node invariants in sparsebit.c. > These comments describe core behavior of the data structure and > should be clear. Applied to kvm-x86 s

[PATCH] selftests: harness: Rework is_signed_type() to avoid collision with overflow.h

2025-06-24 Thread Sean Christopherson
~~~ Opportunistically use is_signed_type() to implement is_signed_var() so that the relationship and differences are obvious. Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources") Cc: Vincent Mailhol Cc: Arnaldo Carvalho de Melo Signed-off-by: Sean C

Re: [PATCH v2 0/8] irqbypass: Cleanups and a perf improvement

2025-06-02 Thread Sean Christopherson
On Mon, Jun 02, 2025, Alex Williamson wrote: > On Fri, 16 May 2025 16:07:26 -0700 > Sean Christopherson wrote: > > > The two primary goals of this series are to make the irqbypass concept > > easier to understand, and to address the terrible performance that can > >

Re: [PATCH v4 14/38] KVM: x86/pmu: Introduce enable_mediated_pmu global parameter

2025-05-21 Thread Sean Christopherson
On Thu, May 15, 2025, Dapeng Mi wrote: > On 5/15/2025 8:09 AM, Sean Christopherson wrote: > > On Mon, Mar 24, 2025, Mingwei Zhang wrote: > >> + return vcpu->kvm->arch.enable_pmu && > > This is superfluous, pmu->version should never be non-zero without

[PATCH v2 6/8] irqbypass: Use guard(mutex) in lieu of manual lock+unlock

2025-05-16 Thread Sean Christopherson
Use guard(mutex) to clean up irqbypass's error handling. Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean Christopherson --- virt/lib/irqbypass.c | 38 ++ 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/vir

[PATCH v2 5/8] irqbypass: Use paired consumer/producer to disconnect during unregister

2025-05-16 Thread Sean Christopherson
Use the paired consumer/producer information to disconnect IRQ bypass producers/consumers in O(1) time (ignoring the cost of __disconnect()). Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean Christopherson --- virt/lib/irqbypass.c | 48

[PATCH v2 8/8] irqbypass: Require producers to pass in Linux IRQ number during registration

2025-05-16 Thread Sean Christopherson
soon as a connection is possible. Signed-off-by: Sean Christopherson --- drivers/vfio/pci/vfio_pci_intrs.c | 3 +-- drivers/vhost/vdpa.c | 4 ++-- include/linux/irqbypass.h | 2 +- virt/lib/irqbypass.c | 5 - 4 files changed, 8 insertions(+), 6 deletions(

[PATCH v2 7/8] irqbypass: Use xarray to track producers and consumers

2025-05-16 Thread Sean Christopherson
-by: Yong He Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217379 Link: https://lore.kernel.org/all/20230801115646.33990-1-lik...@tencent.com Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean Christopherson --- include/linux/irqbypass.h | 4 --- virt/lib/irqbypass.c

[PATCH v2 3/8] irqbypass: Take ownership of producer/consumer token tracking

2025-05-16 Thread Sean Christopherson
eventfd_ctx pointer (for all intents and purposes) unnecessarily obfuscates the code and makes it more brittle. Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c| 4 +-- drivers/vfio/pci/vfio_pci_intrs.c | 9

[PATCH v2 4/8] irqbypass: Explicitly track producer and consumer bindings

2025-05-16 Thread Sean Christopherson
Explicitly track IRQ bypass producer:consumer bindings. This will allow making removal an O(1) operation; searching through the list to find information that is trivially tracked (and useful for debug) is wasteful. Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean

[PATCH v2 2/8] irqbypass: Drop superfluous might_sleep() annotations

2025-05-16 Thread Sean Christopherson
Drop superfluous might_sleep() annotations from irqbypass, mutex_lock() provides all of the necessary tracking. Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean Christopherson --- virt/lib/irqbypass.c | 8 1 file changed, 8 deletions(-) diff --git a/virt/lib

[PATCH v2 1/8] irqbypass: Drop pointless and misleading THIS_MODULE get/put

2025-05-16 Thread Sean Christopherson
. E.g. if try_module_get() fails because irqbypass.ko is being unloaded, then the kernel has already hit a use-after-free by virtue of executing code whose lifecycle is tied to irqbypass.ko. Reviewed-by: Kevin Tian Acked-by: Michael S. Tsirkin Signed-off-by: Sean Christopherson --- virt/lib/irqbyp

[PATCH v2 0/8] irqbypass: Cleanups and a perf improvement

2025-05-16 Thread Sean Christopherson
tmp == consumer" check from patch 3. [Kevin] - Require producers to pass in the line IRQ number. v1: https://lore.kernel.org/all/20250404211449.1443336-1-sea...@google.com [1] https://lore.kernel.org/all/20230801115646.33990-1-lik...@tencent.com [2] https://lore.kernel.org/all/202504011

Re: [PATCH v4 27/38] KVM: x86/pmu: Handle PMU MSRs interception and event filtering

2025-05-16 Thread Sean Christopherson
gt;eventsel_hw &= > > ~ARCH_PERFMON_EVENTSEL_ENABLE; > > + } else { > > + int idx = pmc->idx - KVM_FIXED_PMC_BASE_IDX; > > + > > + if (allowed) > > + pmu->fixed_ctr_ctrl_hw = pmu->fixed_

Re: [PATCH v4 24/38] KVM: x86/pmu: Exclude PMU MSRs in vmx_get_passthrough_msr_slot()

2025-05-16 Thread Sean Christopherson
On Fri, May 16, 2025, Sean Christopherson wrote: > On Mon, Mar 24, 2025, Mingwei Zhang wrote: > > Reject PMU MSRs interception explicitly in > > vmx_get_passthrough_msr_slot() since interception of PMU MSRs are > > specially handled in intel_passthrough_pmu_msrs(). > >

Re: [PATCH v4 25/38] KVM: x86/pmu: Add AMD PMU registers to direct access list

2025-05-16 Thread Sean Christopherson
On Mon, Mar 24, 2025, Mingwei Zhang wrote: > From: Sandipan Das > > Add all PMU-related MSRs (including legacy K7 MSRs) to the list of > possible direct access MSRs. Most of them will not be intercepted when > using passthrough PMU. > > Signed-off-by: Sandipan Das > Signed-off-by: Mingwei Zhan

Re: [PATCH v4 24/38] KVM: x86/pmu: Exclude PMU MSRs in vmx_get_passthrough_msr_slot()

2025-05-16 Thread Sean Christopherson
On Mon, Mar 24, 2025, Mingwei Zhang wrote: > Reject PMU MSRs interception explicitly in > vmx_get_passthrough_msr_slot() since interception of PMU MSRs are > specially handled in intel_passthrough_pmu_msrs(). > > Signed-off-by: Mingwei Zhang > Co-developed-by: Dapeng Mi > Signed-off-by: Dapeng M

Re: [PATCH v4 23/38] KVM: x86/pmu: Configure the interception of PMU MSRs

2025-05-16 Thread Sean Christopherson
On Mon, Mar 24, 2025, Mingwei Zhang wrote: > +static void amd_pmu_update_msr_intercepts(struct kvm_vcpu *vcpu) > +{ > + struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); > + struct vcpu_svm *svm = to_svm(vcpu); > + int msr_clear = !!(kvm_mediated_pmu_enabled(vcpu)); > + int i; > + > + fo

Re: [PATCH v4 32/38] KVM: nVMX: Add nested virtualization support for mediated PMU

2025-05-16 Thread Sean Christopherson
This shortlog is unnecessarily confusing. It reads as if supported for running L2 in a vCPU with a mediated PMU is somehow lacking. On Mon, Mar 24, 2025, Mingwei Zhang wrote: > Add nested virtualization support for mediated PMU by combining the MSR > interception bitmaps of vmcs01 and vmcs12. Do

Re: [PATCH v4 29/38] KVM: x86/pmu: Switch host/guest PMU context at vm-exit/vm-entry

2025-05-16 Thread Sean Christopherson
On Mon, Mar 24, 2025, Mingwei Zhang wrote: > + /* > + * Clear hardware selector MSR content and its counter to avoid > + * leakage and also avoid this guest GP counter get accidentally > + * enabled during host running when host enable global ctrl. > + */ > + for (i = 0;

Re: [PATCH v4 30/38] KVM: x86/pmu: Handle emulated instruction for mediated vPMU

2025-05-15 Thread Sean Christopherson
On Mon, Mar 24, 2025, Mingwei Zhang wrote: > static void kvm_pmu_incr_counter(struct kvm_pmc *pmc) > { > - pmc->emulated_counter++; > - kvm_pmu_request_counter_reprogram(pmc); > + struct kvm_vcpu *vcpu = pmc->vcpu; > + > + /* > + * For perf-based PMUs, accumulate software-emu

Re: [PATCH v4 05/38] perf: Add generic exclude_guest support

2025-05-15 Thread Sean Christopherson
On Thu, May 15, 2025, Kan Liang wrote: > On 2025-05-14 7:19 p.m., Sean Christopherson wrote: > >> This naming is confusing on purpose? Pick either guest/host and stick > >> with it. > > > > +1. I also think the inner perf_host_{enter,exit}() helpers are superflou

Re: [PATCH v4 22/38] KVM: x86/pmu: Optimize intel/amd_pmu_refresh() helpers

2025-05-15 Thread Sean Christopherson
On Thu, May 15, 2025, Dapeng Mi wrote: > On 5/15/2025 8:37 AM, Sean Christopherson wrote: > >> diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c > >> index 153972e944eb..eba086ef5eca 100644 > >> --- a/arch/x86/kvm/svm/pmu.c > >> +++ b/arch/x8

  1   2   3   4   5   6   7   8   9   10   >