From 5de6bf3d343cdacda375d74b49d7d7943efc3f88 Mon Sep 17 00:00:00 2001 From: Minggui Cao Date: Tue, 5 Jun 2018 15:10:12 +0800 Subject: [PATCH] fix a bug: UOS could hung after running some time. soft-lock or CPUs stalls can happen during UOS running; after debugging, find CPUs for UOS is in idle thread, and will not be scheduled back. root cause: PIO/MMIO from UOS will trigger SOS/DM to handle them. Usually, it should make sure UOS-vcpu pause first then resume, but for SOS/UOS in parallel,in former code, the UOS-vcpu resume could be called first by SOS before pause. Signed-off-by: Minggui Cao Acked-by: Eddie Dong --- hypervisor/common/io_request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hypervisor/common/io_request.c b/hypervisor/common/io_request.c index cdb6c0367..eeca9589e 100644 --- a/hypervisor/common/io_request.c +++ b/hypervisor/common/io_request.c @@ -74,6 +74,13 @@ int acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req) memcpy_s(&req_buf->req_queue[cur], sizeof(struct vhm_request), req, sizeof(struct vhm_request)); + /* pause vcpu, wait for VHM to handle the MMIO request. + * TODO: when pause_vcpu changed to switch vcpu out directlly, we + * should fix the race issue between req.valid = true and vcpu pause + */ + atomic_store(&vcpu->ioreq_pending, 1); + pause_vcpu(vcpu, VCPU_PAUSED); + /* Must clear the signal before we mark req valid * Once we mark to valid, VHM may process req and signal us * before we perform upcall. @@ -86,10 +93,6 @@ int acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req) /* signal VHM */ fire_vhm_interrupt(); - /* pause vcpu, wait for VHM to handle the MMIO request */ - atomic_store(&vcpu->ioreq_pending, 1); - pause_vcpu(vcpu, VCPU_PAUSED); - return 0; }