Re: [patch v11 10/13] KVM: x86: process isolation work from VM-entry code path

From: Frederic Weisbecker
Date: Mon Feb 07 2022 - 10:53:38 EST


On Fri, Feb 04, 2022 at 02:35:47PM -0300, Marcelo Tosatti wrote:
> VM-entry code path is an entry point similar to userspace return
> when task isolation is concerned.
>
> Call isolation_exit_to_user_mode before VM-enter.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
>
> ---
> v11
> - Add TIF_TASK_ISOL bit to thread info flags and use it
> to decide whether to perform task isolation work on
> return to userspace (Frederic W. Weisbecker)
>
> include/linux/entry-kvm.h | 4 +++-
> kernel/entry/kvm.c | 18 ++++++++++++++----
> 2 files changed, 17 insertions(+), 5 deletions(-)
>
> Index: linux-2.6/kernel/entry/kvm.c
> ===================================================================
> --- linux-2.6.orig/kernel/entry/kvm.c
> +++ linux-2.6/kernel/entry/kvm.c
> @@ -2,6 +2,7 @@
>
> #include <linux/entry-kvm.h>
> #include <linux/kvm_host.h>
> +#include <linux/task_isolation.h>
>
> static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
> {
> @@ -22,6 +23,9 @@ static int xfer_to_guest_mode_work(struc
> if (ti_work & _TIF_NOTIFY_RESUME)
> tracehook_notify_resume(NULL);
>
> + if (ti_work & _TIF_TASK_ISOL)
> + task_isol_exit_to_user_mode();
> +
> ret = arch_xfer_to_guest_mode_handle_work(vcpu, ti_work);
> if (ret)
> return ret;
>
>

Do you need this?

diff --git a/include/linux/entry-kvm.h b/include/linux/entry-kvm.h
index 07c878d6e323..3588d6071caf 100644
--- a/include/linux/entry-kvm.h
+++ b/include/linux/entry-kvm.h
@@ -18,7 +18,7 @@

#define XFER_TO_GUEST_MODE_WORK \
(_TIF_NEED_RESCHED | _TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL | \
- _TIF_NOTIFY_RESUME | ARCH_XFER_TO_GUEST_MODE_WORK)
+ _TIF_NOTIFY_RESUME | _TIF_TASK_ISOL | ARCH_XFER_TO_GUEST_MODE_WORK)

struct kvm_vcpu;