diff --git a/devicemodel/core/sw_load_bzimage.c b/devicemodel/core/sw_load_bzimage.c index a505b2d80..2f1455ad1 100644 --- a/devicemodel/core/sw_load_bzimage.c +++ b/devicemodel/core/sw_load_bzimage.c @@ -310,7 +310,7 @@ acrn_sw_load_bzimage(struct vmctx *ctx) { int ret, setup_size; - memset(&ctx->bsp_regs, 0, sizeof(struct acrn_set_vcpu_regs)); + memset(&ctx->bsp_regs, 0, sizeof(struct acrn_vcpu_regs)); ctx->bsp_regs.vcpu_id = 0; if (with_bootargs) { diff --git a/devicemodel/core/sw_load_elf.c b/devicemodel/core/sw_load_elf.c index 0a88cc18f..c321bc578 100644 --- a/devicemodel/core/sw_load_elf.c +++ b/devicemodel/core/sw_load_elf.c @@ -272,7 +272,7 @@ acrn_sw_load_elf(struct vmctx *ctx) /* set guest bsp state. Will call hypercall set bsp state * after bsp is created. */ - memset(&ctx->bsp_regs, 0, sizeof( struct acrn_set_vcpu_regs)); + memset(&ctx->bsp_regs, 0, sizeof( struct acrn_vcpu_regs)); ctx->bsp_regs.vcpu_id = 0; memcpy(ctx->baseaddr + GDT_LOAD_OFF(ctx), &acrn_init_gdt, diff --git a/devicemodel/core/sw_load_ovmf.c b/devicemodel/core/sw_load_ovmf.c index c7d6fd0b2..74f4ccc6e 100644 --- a/devicemodel/core/sw_load_ovmf.c +++ b/devicemodel/core/sw_load_ovmf.c @@ -299,7 +299,7 @@ acrn_sw_load_ovmf(struct vmctx *ctx) /* set guest bsp state. Will call hypercall set bsp state * after bsp is created. */ - memset(&ctx->bsp_regs, 0, sizeof(struct acrn_set_vcpu_regs)); + memset(&ctx->bsp_regs, 0, sizeof(struct acrn_vcpu_regs)); ctx->bsp_regs.vcpu_id = 0; /* CR0_ET | CR0_NE */ diff --git a/devicemodel/core/sw_load_vsbl.c b/devicemodel/core/sw_load_vsbl.c index 68a01769e..49bcbd31e 100644 --- a/devicemodel/core/sw_load_vsbl.c +++ b/devicemodel/core/sw_load_vsbl.c @@ -297,7 +297,7 @@ acrn_sw_load_vsbl(struct vmctx *ctx) /* set guest bsp state. Will call hypercall set bsp state * after bsp is created. */ - memset(&ctx->bsp_regs, 0, sizeof( struct acrn_set_vcpu_regs)); + memset(&ctx->bsp_regs, 0, sizeof( struct acrn_vcpu_regs)); ctx->bsp_regs.vcpu_id = 0; /* CR0_ET | CR0_NE */ diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index 5bcb14243..1ae0ce3bc 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -642,9 +642,9 @@ vm_reset_ptdev_intx_info(struct vmctx *ctx, uint16_t virt_bdf, uint16_t phys_bdf } int -vm_set_vcpu_regs(struct vmctx *ctx, struct acrn_set_vcpu_regs *vcpu_regs) +vm_set_vcpu_regs(struct vmctx *ctx, struct acrn_vcpu_regs *vcpu_regs) { - return ioctl(ctx->fd, IC_SET_VCPU_REGS, vcpu_regs); + return ioctl(ctx->fd, ACRN_IOCTL_SET_VCPU_REGS, vcpu_regs); } int diff --git a/devicemodel/include/public/hsm_ioctl_defs.h b/devicemodel/include/public/hsm_ioctl_defs.h index 57b78f6aa..184cda7d2 100644 --- a/devicemodel/include/public/hsm_ioctl_defs.h +++ b/devicemodel/include/public/hsm_ioctl_defs.h @@ -72,7 +72,6 @@ #define ACRN_IOCTL_GET_PLATFORM_INFO \ _IOR(ACRN_IOCTL_TYPE, 0x03, struct acrn_platform_info) -#define IC_ID_VM_BASE 0x10UL #define ACRN_IOCTL_CREATE_VM \ _IOWR(ACRN_IOCTL_TYPE, 0x10, struct acrn_vm_creation) #define ACRN_IOCTL_DESTROY_VM \ @@ -83,8 +82,8 @@ _IO(ACRN_IOCTL_TYPE, 0x13) #define ACRN_IOCTL_RESET_VM \ _IO(ACRN_IOCTL_TYPE, 0x15) - -#define IC_SET_VCPU_REGS _IC_ID(IC_ID, IC_ID_VM_BASE + 0x06) +#define ACRN_IOCTL_SET_VCPU_REGS \ + _IOW(ACRN_IOCTL_TYPE, 0x16, struct acrn_vcpu_regs) /* IRQ and Interrupts */ #define IC_ID_IRQ_BASE 0x20UL diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index 2a4b543e6..efd5d3f25 100644 --- a/devicemodel/include/vmmapi.h +++ b/devicemodel/include/vmmapi.h @@ -67,7 +67,7 @@ struct vmctx { void *tpm_dev; /* BSP state. guest loader needs to fill it */ - struct acrn_set_vcpu_regs bsp_regs; + struct acrn_vcpu_regs bsp_regs; /* if gvt-g is enabled for current VM */ bool gvt_enabled; @@ -142,7 +142,7 @@ int vm_remove_hv_vdev(struct vmctx *ctx, struct acrn_emul_dev *dev); int acrn_parse_cpu_affinity(char *arg); uint64_t vm_get_cpu_affinity_dm(void); -int vm_set_vcpu_regs(struct vmctx *ctx, struct acrn_set_vcpu_regs *cpu_regs); +int vm_set_vcpu_regs(struct vmctx *ctx, struct acrn_vcpu_regs *cpu_regs); int vm_get_cpu_state(struct vmctx *ctx, void *state_buf); int vm_intr_monitor(struct vmctx *ctx, void *intr_buf); diff --git a/doc/developer-guides/hld/hv-cpu-virt.rst b/doc/developer-guides/hld/hv-cpu-virt.rst index 0ad6a0195..2f304b1ae 100644 --- a/doc/developer-guides/hld/hv-cpu-virt.rst +++ b/doc/developer-guides/hld/hv-cpu-virt.rst @@ -568,7 +568,7 @@ For a guest vCPU's state initialization: - If it's AP, then it will always start from real mode, and the start vector will always come from vlapic INIT-SIPI emulation. -.. doxygenstruct:: acrn_vcpu_regs +.. doxygenstruct:: acrn_regs :project: Project ACRN .. list-table:: diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index 9c8ef256b..066891965 100644 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -323,7 +323,7 @@ static void init_xsave(struct acrn_vcpu *vcpu) ectx->xs_area.xsave_hdr.hdr.xcomp_bv |= XSAVE_COMPACTED_FORMAT; } -void set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs) +void set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_regs *vcpu_regs) { struct ext_context *ectx; struct run_context *ctx; @@ -406,7 +406,7 @@ void set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs) vcpu_regs->cr0); } -static struct acrn_vcpu_regs realmode_init_vregs = { +static struct acrn_regs realmode_init_vregs = { .gdt = { .limit = 0xFFFFU, .base = 0UL, @@ -432,7 +432,7 @@ static uint64_t init_vgdt[] = { 0x00CF93000000FFFFUL, /* Linear Data */ }; -static struct acrn_vcpu_regs protect_mode_init_vregs = { +static struct acrn_regs protect_mode_init_vregs = { .cs_ar = PROTECTED_MODE_CODE_SEG_AR, .cs_limit = PROTECTED_MODE_SEG_LIMIT, .cs_sel = 0x10U, @@ -463,10 +463,10 @@ void reset_vcpu_regs(struct acrn_vcpu *vcpu) void init_vcpu_protect_mode_regs(struct acrn_vcpu *vcpu, uint64_t vgdt_base_gpa) { - struct acrn_vcpu_regs vcpu_regs; + struct acrn_regs vcpu_regs; - (void)memcpy_s((void *)&vcpu_regs, sizeof(struct acrn_vcpu_regs), - (void *)&protect_mode_init_vregs, sizeof(struct acrn_vcpu_regs)); + (void)memcpy_s((void *)&vcpu_regs, sizeof(struct acrn_regs), + (void *)&protect_mode_init_vregs, sizeof(struct acrn_regs)); vcpu_regs.gdt.base = vgdt_base_gpa; vcpu_regs.gdt.limit = sizeof(init_vgdt) - 1U; diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 400828828..db445c51d 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -419,7 +419,7 @@ int32_t hcall_set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, __unused uint64_t param1, uint64_t param2) { struct acrn_vm *vm = vcpu->vm; - struct acrn_set_vcpu_regs vcpu_regs; + struct acrn_vcpu_regs vcpu_regs; struct acrn_vcpu *target_vcpu; int32_t ret = -1; diff --git a/hypervisor/include/arch/x86/asm/guest/vcpu.h b/hypervisor/include/arch/x86/asm/guest/vcpu.h index 0f29dd9e6..406145803 100644 --- a/hypervisor/include/arch/x86/asm/guest/vcpu.h +++ b/hypervisor/include/arch/x86/asm/guest/vcpu.h @@ -557,7 +557,7 @@ void vcpu_clear_eoi_exit_bitmap(struct acrn_vcpu *vcpu, uint32_t vector); * * @return None */ -void set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs); +void set_vcpu_regs(struct acrn_vcpu *vcpu, struct acrn_regs *vcpu_regs); /** * @brief reset all the vcpu registers diff --git a/hypervisor/include/public/acrn_common.h b/hypervisor/include/public/acrn_common.h index 23f6b5788..c6e918b5d 100644 --- a/hypervisor/include/public/acrn_common.h +++ b/hypervisor/include/public/acrn_common.h @@ -418,7 +418,7 @@ struct acrn_descriptor_ptr { /** * @brief registers info for vcpu. */ -struct acrn_vcpu_regs { +struct acrn_regs { struct acrn_gp_regs gprs; struct acrn_descriptor_ptr gdt; struct acrn_descriptor_ptr idt; @@ -445,8 +445,6 @@ struct acrn_vcpu_regs { uint16_t gs_sel; uint16_t ldt_sel; uint16_t tr_sel; - - uint16_t reserved_16[4]; }; /** @@ -454,15 +452,15 @@ struct acrn_vcpu_regs { * * the pamameter for HC_SET_VCPU_STATE */ -struct acrn_set_vcpu_regs { +struct acrn_vcpu_regs { /** the virtual CPU ID for the VCPU to set state */ uint16_t vcpu_id; /** reserved space to make cpu_state aligned to 8 bytes */ - uint16_t reserved0[3]; + uint16_t reserved[3]; /** the structure to hold vcpu state */ - struct acrn_vcpu_regs vcpu_regs; + struct acrn_regs vcpu_regs; } __aligned(8); /**