summaryrefslogtreecommitdiff
path: root/xen
diff options
context:
space:
mode:
authorOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>2020-11-30 12:31:30 +0200
committerAlex Bennée <alex.bennee@linaro.org>2020-11-30 15:12:51 +0000
commit93110d2852752b7e1f912b614eabc307d7f2e673 (patch)
treefa052fde2d8aa533db61e51820b424632a2e815d /xen
parentee8b0c08a554f494789806c543264ffe2bccdbad (diff)
xen/arm: Stick around in leave_hypervisor_to_guest until I/O has completed
This patch adds proper handling of return value of vcpu_ioreq_handle_completion() which involves using a loop in leave_hypervisor_to_guest(). The reason to use an unbounded loop here is the fact that vCPU shouldn't continue until an I/O has completed. In Xen case, if an I/O never completes then it most likely means that something went horribly wrong with the Device Emulator. And it is most likely not safe to continue. So letting the vCPU to spin forever if I/O never completes is a safer action than letting it continue and leaving the guest in unclear state and is the best what we can do for now. This wouldn't be an issue for Xen as do_softirq() would be called at every loop. In case of failure, the guest will crash and the vCPU will be unscheduled. Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> CC: Julien Grall <julien.grall@arm.com> Message-Id: <1606732298-22107-16-git-send-email-olekstysh@gmail.com>
Diffstat (limited to 'xen')
-rw-r--r--xen/arch/arm/traps.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 036b13f08d..4cef43e897 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2257,18 +2257,23 @@ static void check_for_pcpu_work(void)
* Process pending work for the vCPU. Any call should be fast or
* implement preemption.
*/
-static void check_for_vcpu_work(void)
+static bool check_for_vcpu_work(void)
{
struct vcpu *v = current;
#ifdef CONFIG_IOREQ_SERVER
+ bool handled;
+
local_irq_enable();
- vcpu_ioreq_handle_completion(v);
+ handled = vcpu_ioreq_handle_completion(v);
local_irq_disable();
+
+ if ( !handled )
+ return true;
#endif
if ( likely(!v->arch.need_flush_to_ram) )
- return;
+ return false;
/*
* Give a chance for the pCPU to process work before handling the vCPU
@@ -2279,6 +2284,8 @@ static void check_for_vcpu_work(void)
local_irq_enable();
p2m_flush_vm(v);
local_irq_disable();
+
+ return false;
}
/*
@@ -2291,8 +2298,22 @@ void leave_hypervisor_to_guest(void)
{
local_irq_disable();
- check_for_vcpu_work();
- check_for_pcpu_work();
+ /*
+ * The reason to use an unbounded loop here is the fact that vCPU
+ * shouldn't continue until an I/O has completed. In Xen case, if an I/O
+ * never completes then it most likely means that something went horribly
+ * wrong with the Device Emulator. And it is most likely not safe to
+ * continue. So letting the vCPU to spin forever if I/O never completes
+ * is a safer action than letting it continue and leaving the guest in
+ * unclear state and is the best what we can do for now.
+ *
+ * This wouldn't be an issue for Xen as do_softirq() would be called at
+ * every loop. In case of failure, the guest will crash and the vCPU
+ * will be unscheduled.
+ */
+ do {
+ check_for_pcpu_work();
+ } while ( check_for_vcpu_work() );
vgic_sync_to_lrs();