mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 17:58:30 +00:00
HV: io: unify vhm_request req and mem_io in vcpu
The current struct vcpu has two members, namely 'struct vhm_request req' and 'struct mem_io mmio', that hold similar info, including the address, direction, size, value and status of mmio reqeusts. As a step towards a unified framework for both MMIO/PIO, this patch unifies these two members by a tailored version of vhm_reqeust, mostly with the reserved fields dropped. The definitions to request types, directions and process status are reused. Handling errors during emulations will be revisited after the I/O emulation paths are unified. Thus for this patch the mmio.mmio_status in inherited by io_req.processed which is not yet properly processed. Signed-off-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -250,8 +250,7 @@ struct vcpu {
|
||||
uint32_t running; /* vcpu is picked up and run? */
|
||||
uint32_t ioreq_pending; /* ioreq is ongoing or not? */
|
||||
|
||||
struct vhm_request req; /* used by io/ept emulation */
|
||||
struct mem_io mmio; /* used by io/ept emulation */
|
||||
struct io_request req; /* used by io/ept emulation */
|
||||
|
||||
/* save guest msr tsc aux register.
|
||||
* Before VMENTRY, save guest MSR_TSC_AUX to this fields.
|
||||
|
@@ -52,7 +52,7 @@ void vioapic_mmio_read(struct vm *vm, uint64_t gpa, uint32_t *rval);
|
||||
uint8_t vioapic_pincount(struct vm *vm);
|
||||
void vioapic_process_eoi(struct vm *vm, uint32_t vector);
|
||||
bool vioapic_get_rte(struct vm *vm, uint8_t pin, union ioapic_rte *rte);
|
||||
int vioapic_mmio_access_handler(struct vcpu *vcpu, struct mem_io *mmio,
|
||||
int vioapic_mmio_access_handler(struct vcpu *vcpu, struct io_request *io_req,
|
||||
void *handler_private_data);
|
||||
|
||||
#ifdef HV_DEBUG
|
||||
|
@@ -111,7 +111,7 @@ void vlapic_set_tmr_one_vec(struct vlapic *vlapic, uint32_t delmode,
|
||||
void
|
||||
vlapic_apicv_batch_set_tmr(struct vlapic *vlapic);
|
||||
|
||||
int vlapic_mmio_access_handler(struct vcpu *vcpu, struct mem_io *mmio,
|
||||
int vlapic_mmio_access_handler(struct vcpu *vcpu, struct io_request *io_req,
|
||||
void *handler_private_data);
|
||||
|
||||
uint32_t vlapic_get_id(struct vlapic *vlapic);
|
||||
|
@@ -8,6 +8,20 @@
|
||||
#define IOREQ_H
|
||||
|
||||
#include <types.h>
|
||||
#include <acrn_common.h>
|
||||
|
||||
/* Internal representation of a I/O request. */
|
||||
struct io_request {
|
||||
/** Type of the request (PIO, MMIO, etc). Refer to vhm_request. */
|
||||
uint32_t type;
|
||||
|
||||
/** Status of request handling. Written by request handlers and read by
|
||||
* the I/O emulation framework. Refer to vhm_request. */
|
||||
int32_t processed;
|
||||
|
||||
/** Details of this request in the same format as vhm_request. */
|
||||
union vhm_io_request reqs;
|
||||
};
|
||||
|
||||
/* Definition of a IO port range */
|
||||
struct vm_io_range {
|
||||
@@ -80,29 +94,9 @@ struct vm_io_handler {
|
||||
#define IO_ATTR_RW 1U
|
||||
#define IO_ATTR_NO_ACCESS 2U
|
||||
|
||||
/* MMIO memory access types */
|
||||
enum mem_io_type {
|
||||
HV_MEM_IO_READ = 0,
|
||||
HV_MEM_IO_WRITE,
|
||||
};
|
||||
|
||||
/* MMIO emulation related structures */
|
||||
#define MMIO_TRANS_VALID 1U
|
||||
#define MMIO_TRANS_INVALID 0U
|
||||
struct mem_io {
|
||||
uint64_t paddr; /* Physical address being accessed */
|
||||
enum mem_io_type read_write; /* 0 = read / 1 = write operation */
|
||||
uint8_t access_size; /* Access size being emulated */
|
||||
uint8_t sign_extend_read; /* 1 if sign extension required for read */
|
||||
uint64_t value; /* Value read or value to write */
|
||||
uint8_t mmio_status; /* Indicates if this MMIO transaction is valid */
|
||||
/* Used to store emulation context for this mmio transaction */
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/* Typedef for MMIO handler and range check routine */
|
||||
struct mmio_request;
|
||||
typedef int (*hv_mem_io_handler_t)(struct vcpu *, struct mem_io *, void *);
|
||||
typedef int (*hv_mem_io_handler_t)(struct vcpu *, struct io_request *, void *);
|
||||
|
||||
/* Structure for MMIO handler node */
|
||||
struct mem_io_node {
|
||||
@@ -130,6 +124,6 @@ void unregister_mmio_emulation_handler(struct vm *vm, uint64_t start,
|
||||
uint64_t end);
|
||||
int dm_emulate_mmio_post(struct vcpu *vcpu);
|
||||
|
||||
int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req);
|
||||
int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct io_request *req);
|
||||
|
||||
#endif /* IOREQ_H */
|
||||
|
Reference in New Issue
Block a user