From: Sean Christopherson <seanjc@google.com>
To: Naman Jain <namjain@linux.microsoft.com>
Cc: "K . Y . Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, Mukesh Rathor <mrathor@linux.microsoft.com>,
Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
Nuno Das Neves <nunodasneves@linux.microsoft.com>,
Peter Zijlstra <peterz@infradead.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Michael Kelley <mhklinux@outlook.com>,
Christoph Hellwig <hch@infradead.org>,
Saurabh Sengar <ssengar@linux.microsoft.com>,
ALOK TIWARI <alok.a.tiwari@oracle.com>
Subject: Re: [PATCH v8 2/2] Drivers: hv: Introduce mshv_vtl driver
Date: Mon, 13 Oct 2025 07:12:42 -0700 [thread overview]
Message-ID: <aO0I2va2HQ6mA-u0@google.com> (raw)
In-Reply-To: <20251013060353.67326-3-namjain@linux.microsoft.com>
On Mon, Oct 13, 2025, Naman Jain wrote:
> +static int mshv_vtl_ioctl_return_to_lower_vtl(void)
> +{
> + preempt_disable();
> + for (;;) {
> + u32 cancel;
> + unsigned long irq_flags;
> + struct hv_vp_assist_page *hvp;
> + int ret;
> +
> + local_irq_save(irq_flags);
> + cancel = READ_ONCE(mshv_vtl_this_run()->cancel);
> + if (cancel)
> + current_thread_info()->flags |= _TIF_SIGPENDING;
There's no need to force SIGPENDING, this code can return directly if cancel is
set[1]. And then you can wait to disable IRQs until after handling pending work,
and thus avoid having to immediately re-enable IRQs[2].
[1] https://lore.kernel.org/all/20250828000156.23389-3-seanjc@google.com
[2] https://lore.kernel.org/all/20250828000156.23389-4-seanjc@google.com
> +
> + if (unlikely(cancel) || __xfer_to_guest_mode_work_pending()) {
> + local_irq_restore(irq_flags);
> + preempt_enable();
> + ret = xfer_to_guest_mode_handle_work();
> + if (ret)
> + return ret;
> + preempt_disable();
> + continue;
> + }
> +
> + mshv_vtl_return(&mshv_vtl_this_run()->cpu_context);
> + local_irq_restore(irq_flags);
> +
> + hvp = hv_vp_assist_page[smp_processor_id()];
> + this_cpu_inc(num_vtl0_transitions);
> + switch (hvp->vtl_entry_reason) {
> + case MSHV_ENTRY_REASON_INTERRUPT:
> + if (!mshv_vsm_capabilities.intercept_page_available &&
> + likely(!mshv_vtl_process_intercept()))
> + goto done;
> + break;
> +
> + case MSHV_ENTRY_REASON_INTERCEPT:
> + WARN_ON(!mshv_vsm_capabilities.intercept_page_available);
> + memcpy(mshv_vtl_this_run()->exit_message, hvp->intercept_message,
> + sizeof(hvp->intercept_message));
> + goto done;
> +
> + default:
> + panic("unknown entry reason: %d", hvp->vtl_entry_reason);
> + }
> + }
> +
> +done:
> + preempt_enable();
> +
> + return 0;
> +}
next prev parent reply other threads:[~2025-10-13 14:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 6:03 [PATCH v8 0/2] Drivers: hv: Introduce new driver - mshv_vtl Naman Jain
2025-10-13 6:03 ` [PATCH v8 1/2] Drivers: hv: Export some symbols for mshv_vtl Naman Jain
2025-10-13 6:03 ` [PATCH v8 2/2] Drivers: hv: Introduce mshv_vtl driver Naman Jain
2025-10-13 14:12 ` Sean Christopherson [this message]
2025-10-14 5:34 ` Naman Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aO0I2va2HQ6mA-u0@google.com \
--to=seanjc@google.com \
--cc=alok.a.tiwari@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hch@infradead.org \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=mrathor@linux.microsoft.com \
--cc=namjain@linux.microsoft.com \
--cc=nunodasneves@linux.microsoft.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=skinsburskii@linux.microsoft.com \
--cc=ssengar@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox