public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Timer Signals vs KVM
@ 2024-03-27 13:46 Julian Stecklina
  2024-04-01 22:22 ` Sean Christopherson
  0 siblings, 1 reply; 4+ messages in thread
From: Julian Stecklina @ 2024-03-27 13:46 UTC (permalink / raw)
  To: kvm@vger.kernel.org; +Cc: Thomas Prescher

Hey everyone,

we are developing the KVM backend for VirtualBox [0] and wanted to reach out
regarding some weird behavior.

We are using `timer_create` to deliver timer events to vCPU threads as signals.
We mask the signal using pthread_sigmask in the host vCPU thread and unmask them
for guest execution using KVM_SET_SIGNAL_MASK.

This method of handling timers works well and gives us very low latency as
opposed to using a separate thread that handles timers. As far as we can tell,
neither Qemu nor other VMMs use such a setup. We see two issues:

When we enable nested virtualization, we see what looks like corruption in the
nested guest. The guest trips over exceptions that shouldn't be there. We are
currently debugging this to find out details, but the setup is pretty painful
and it will take a bit. If we disable the timer signals, this issue goes away
(at the cost of broken VBox timers obviously...).  This is weird and has left us
wondering, whether there might be something broken with signals in this
scenario, especially since none of the other VMMs uses this method.

The other issue is that we have a somewhat sad interaction with split-lock
detection, which I've blogged about some time ago [1]. Long story short: When
you program timers <10ms into the future, you run the risk of making no progress
anymore when the guest triggers the split-lock punishment [2]. See the blog post
for details. I was wondering whether there is a better solution here than
disabling the split-lock detection or whether our approach here is fundamentally
broken.

Looking forward to your thoughts. :)

Thanks!
Julian

[0] https://github.com/cyberus-technology/virtualbox-kvm
[1] https://x86.lol/generic/2023/11/07/split-lock.html
[2]
https://elixir.bootlin.com/linux/v6.9-rc1/source/arch/x86/kernel/cpu/intel.c#L1137

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-16 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-27 13:46 Timer Signals vs KVM Julian Stecklina
2024-04-01 22:22 ` Sean Christopherson
2024-04-16 12:44   ` Julian Stecklina
2024-04-16 12:53     ` Julian Stecklina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox