diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 2a256e0f1..e7c664e6a 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -255,6 +255,7 @@ int reset_vm(struct acrn_vm *vm) (void )vm_sw_loader(vm); } + reset_vm_ioreqs(vm); vioapic_reset(vm_ioapic(vm)); destroy_secure_world(vm, false); vm->sworld_control.flag.active = 0UL; diff --git a/hypervisor/common/io_request.c b/hypervisor/common/io_request.c index 59dfd3a4c..a6c50142d 100644 --- a/hypervisor/common/io_request.c +++ b/hypervisor/common/io_request.c @@ -55,6 +55,25 @@ static void acrn_print_request(uint16_t vcpu_id, const struct vhm_request *req) } } +/** + * @brief Reset all IO requests status of the VM + * + * @param vm The VM whose IO requests to be reset + * + * @return N/A + */ +void reset_vm_ioreqs(struct acrn_vm *vm) +{ + uint16_t i; + union vhm_request_buffer *req_buf; + + req_buf = vm->sw.io_shared_page; + for (i = 0U; i < VHM_REQUEST_MAX; i++) { + req_buf->req_queue[i].valid = 0U; + atomic_store32(&req_buf->req_queue[i].processed, REQ_STATE_FREE); + } +} + /** * @brief Deliver \p io_req to SOS and suspend \p vcpu till its completion * diff --git a/hypervisor/include/arch/x86/ioreq.h b/hypervisor/include/arch/x86/ioreq.h index 89d1c9903..ce151a817 100644 --- a/hypervisor/include/arch/x86/ioreq.h +++ b/hypervisor/include/arch/x86/ioreq.h @@ -287,6 +287,15 @@ void emulate_io_post(struct acrn_vcpu *vcpu); */ int32_t acrn_insert_request_wait(struct acrn_vcpu *vcpu, const struct io_request *io_req); +/** + * @brief Reset all IO requests status of the VM + * + * @param vm The VM whose IO requests to be reset + * + * @return N/A + */ +void reset_vm_ioreqs(struct acrn_vm *vm); + /** * @} */