hv: move pi_desc related code from vlapic.h/vlapic.c to vmx.h/vmx.c/vcpu.h

The posted interrupt descriptor is more of a vmx/vmcs concept than a vlapic
concept. struct acrn_vcpu_arch stores the vmx/vmcs info, so put struct pi_desc
in struct acrn_vcpu_arch.

Remove the function apicv_get_pir_desc_paddr()

A few coding style/typo fixes

Tracked-On: #4506
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@Intel.com>
This commit is contained in:
dongshen
2020-03-18 11:47:35 -07:00
committed by wenlingz
parent b384d04ad1
commit 8f732f2809
5 changed files with 36 additions and 54 deletions

View File

@@ -27,6 +27,7 @@
#include <msr.h>
#include <cpu.h>
#include <instr_emul.h>
#include <vmx.h>
/**
* @brief vcpu
@@ -200,6 +201,9 @@ struct acrn_vcpu_arch {
/* per vcpu lapic */
struct acrn_vlapic vlapic;
/* pid MUST be 64 bytes aligned */
struct pi_desc pid __aligned(64);
struct acrn_vmtrr vmtrr;
int32_t cur_context;
@@ -297,12 +301,25 @@ static inline void vcpu_retain_rip(struct acrn_vcpu *vcpu)
(vcpu)->arch.inst_len = 0U;
}
static inline struct acrn_vlapic *
vcpu_vlapic(struct acrn_vcpu *vcpu)
static inline struct acrn_vlapic *vcpu_vlapic(struct acrn_vcpu *vcpu)
{
return &(vcpu->arch.vlapic);
}
/**
* @brief Get pointer to PI description.
*
* @param[in] vcpu Target vCPU
*
* @return pointer to PI description
*
* @pre vcpu != NULL
*/
static inline struct pi_desc *get_pi_desc(struct acrn_vcpu *vcpu)
{
return &(vcpu->arch.pid);
}
uint16_t pcpuid_from_vcpu(const struct acrn_vcpu *vcpu);
void default_idle(__unused struct thread_object *obj);
void vcpu_thread(struct thread_object *obj);
@@ -557,7 +574,7 @@ static inline bool is_pae(struct acrn_vcpu *vcpu)
}
struct acrn_vcpu *get_running_vcpu(uint16_t pcpu_id);
struct acrn_vcpu* get_ever_run_vcpu(uint16_t pcpu_id);
struct acrn_vcpu *get_ever_run_vcpu(uint16_t pcpu_id);
void save_xsave_area(struct ext_context *ectx);
void rstore_xsave_area(const struct ext_context *ectx);

View File

@@ -43,14 +43,6 @@
#define VLAPIC_MAXLVT_INDEX APIC_LVT_CMCI
/* Posted Interrupt Descriptor (PID) in VT-d spec */
struct pi_desc {
/* Posted Interrupt Requests, one bit per requested vector */
uint64_t pir[4];
uint64_t pending;
uint64_t unused[3];
} __aligned(64);
struct vlapic_timer {
struct hv_timer timer;
uint32_t mode;
@@ -60,16 +52,14 @@ struct vlapic_timer {
struct acrn_vlapic {
/*
* Please keep 'apic_page' and 'pid' be the first two fields in
* Please keep 'apic_page' as the first field in
* current structure, as below alignment restrictions are mandatory
* to support APICv features:
* - 'apic_page' MUST be 4KB aligned.
* - 'pid' MUST be 64 bytes aligned.
* IRR, TMR and PIR could be accessed by other vCPUs when deliver
* an interrupt to vLAPIC.
*/
struct lapic_regs apic_page;
struct pi_desc pid;
struct acrn_vm *vm;
struct acrn_vcpu *vcpu;
@@ -124,20 +114,6 @@ bool vlapic_inject_intr(struct acrn_vlapic *vlapic, bool guest_irq_enabled, bool
bool vlapic_has_pending_delivery_intr(struct acrn_vcpu *vcpu);
bool vlapic_has_pending_intr(struct acrn_vcpu *vcpu);
/**
* @brief Get physical address to PIR description.
*
* If APICv Posted-interrupt is supported, this address will be configured
* to VMCS "Posted-interrupt descriptor address" field.
*
* @param[in] vcpu Target vCPU
*
* @return physicall address to PIR
*
* @pre vcpu != NULL
*/
uint64_t apicv_get_pir_desc_paddr(struct acrn_vcpu *vcpu);
uint64_t vlapic_get_tsc_deadline_msr(const struct acrn_vlapic *vlapic);
void vlapic_set_tsc_deadline_msr(struct acrn_vlapic *vlapic, uint64_t val_arg);
uint64_t vlapic_get_apicbase(const struct acrn_vlapic *vlapic);

View File

@@ -374,6 +374,14 @@
#define VMX_INT_TYPE_HW_EXP 3U
#define VMX_INT_TYPE_SW_EXP 6U
/* Posted Interrupt Descriptor (PID) in VT-d spec */
struct pi_desc {
/* Posted Interrupt Requests, one bit per requested vector */
uint64_t pir[4];
uint64_t pending;
uint32_t unused[3];
} __aligned(64);
/* External Interfaces */
void vmx_on(void);
void vmx_off(void);