mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 17:27:53 +00:00
hv: mmio: refine mmio access handle lock granularity
Now only PCI MSI-X BAR access need dynamic register/unregister. Others don't need unregister once it's registered. So we don't need to lock the vm level emul_mmio_lock when we handle the MMIO access. Instead, we could use finer granularity lock in the handler to ptotest the shared resource. This patch fixed the dead lock issue when OVMF try to size the BAR size: Becasue OVMF use ECAM to access the PCI configuration space, it will first hold vm emul_mmio_lock, then calls vpci_handle_mmconfig_access. While this tries to size a BAR which is also a MSI-X Table BAR, it will call register_mmio_emulation_handler to register the MSI-X Table BAR MMIO access handler. This will causes the emul_mmio_lock dead lock. Tracked-On: #3475 Signed-off-by: Li Fei1 <fei1.li@intel.com>
This commit is contained in:
@@ -112,6 +112,13 @@ typedef int32_t (*hv_mem_io_handler_t)(struct io_request *io_req, void *handler_
|
||||
* @brief Structure for MMIO handler node
|
||||
*/
|
||||
struct mem_io_node {
|
||||
|
||||
/**
|
||||
* @brief Whether the lock needs to hold when handle the MMIO access
|
||||
*/
|
||||
bool hold_lock;
|
||||
|
||||
|
||||
/**
|
||||
* @brief A pointer to the handler
|
||||
*
|
||||
@@ -258,12 +265,13 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
|
||||
* @param start The base address of the range \p read_write can emulate
|
||||
* @param end The end of the range (exclusive) \p read_write can emulate
|
||||
* @param handler_private_data Handler-specific data which will be passed to \p read_write when called
|
||||
* @param hold_lock Whether hold the lock to handle the MMIO access
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void register_mmio_emulation_handler(struct acrn_vm *vm,
|
||||
hv_mem_io_handler_t read_write, uint64_t start,
|
||||
uint64_t end, void *handler_private_data);
|
||||
uint64_t end, void *handler_private_data, bool hold_lock);
|
||||
|
||||
/**
|
||||
* @brief Unregister a MMIO handler
|
||||
|
Reference in New Issue
Block a user