Re: [patch V4 07/36] rseq, virt: Retrigger RSEQ after vcpu_run()

Sean Christopherson
2025-09-09T00:00:47Z

On Mon, Sep 08, 2025, Thomas Gleixner wrote:
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -49,6 +49,7 @@
> #include <linux/lockdep.h>
> #include <linux/kthread.h>
> #include <linux/suspend.h>
> +#include <linux/rseq.h>
>
> #include <asm/processor.h>
> #include <asm/ioctl.h>
> @@ -4466,6 +4467,8 @@ static long kvm_vcpu_ioctl(struct file *
> r = kvm_arch_vcpu_ioctl_run(vcpu);
> vcpu->wants_to_run = false;
>

Finally had a lightbulb moment as to how to eat this hack while not stonewalling
the entire series. Can you add something like:

/*
* FIXME: Remove this hack once all KVM architectures support
* the generic TIF bits, i.e. a dedicated TIF_RSEQ.
*/

to discourage further abuse, and to make it clear that such ugliness isn't anyone's
first choice. With that,

Acked-by: Sean Christopherson <seanjc@google.com>

> + rseq_virt_userspace_exit();
> +
> trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
> break;
> }
>