Skip to content

Commit 0e0dbba

Browse files
fyin1lijinxia
authored andcommitted
hv: Move the strcut acrn_vcpu_regs to public header file
Move struct acrn_vcpu_regs, acrn_descriptor_ptr and acrn_gp_regs to acrn_common.h. The struct acrn_vcpu_regs will be used as parameter of hypercall Tracked-On: #1231 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 572b59f commit 0e0dbba

File tree

5 files changed

+64
-61
lines changed

5 files changed

+64
-61
lines changed

hypervisor/bsp/uefi/efi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ LDSCRIPT := $(GNUEFI_DIR)/elf_$(ARCH)_efi.lds
6161
INCDIR := $(SYSROOT)/usr/include
6262

6363
CFLAGS=-I. -I.. -I../../../include/arch/x86/guest -I$(INCDIR)/efi -I$(INCDIR)/efi/$(ARCH) \
64+
-I../../../include/public -I../../../include/lib \
6465
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
6566
-Wall -I../fs/ -D$(ARCH) -O2 \
6667
-include config.h

hypervisor/bsp/uefi/efi/boot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "efilinux.h"
3737
#include "stdlib.h"
3838
#include "boot.h"
39+
#include "acrn_common.h"
3940
#include "vm0_boot.h"
4041

4142
EFI_SYSTEM_TABLE *sys_table;

hypervisor/include/arch/x86/guest/gpr.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,4 @@
77
#ifndef _VGPR_H_
88
#define _VGPR_H_
99

10-
/* General-purpose register layout aligned with the general-purpose register idx
11-
* when vmexit, such as vmexit due to CR access, refer to SMD Vol.3C 27-6.
12-
*/
13-
struct acrn_gp_regs {
14-
uint64_t rax;
15-
uint64_t rcx;
16-
uint64_t rdx;
17-
uint64_t rbx;
18-
uint64_t rsp;
19-
uint64_t rbp;
20-
uint64_t rsi;
21-
uint64_t rdi;
22-
uint64_t r8;
23-
uint64_t r9;
24-
uint64_t r10;
25-
uint64_t r11;
26-
uint64_t r12;
27-
uint64_t r13;
28-
uint64_t r14;
29-
uint64_t r15;
30-
};
3110
#endif

hypervisor/include/arch/x86/guest/vm0_boot.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,6 @@
4545
#define BOOT_CTX_EFER_HIGH_OFFSET 204U
4646
#define SIZE_OF_BOOT_CTX 296U
4747

48-
/* struct to define how the descriptor stored in memory.
49-
* Refer SDM Vol3 3.5.1 "Segment Descriptor Tables"
50-
* Figure 3-11
51-
*/
52-
struct acrn_descriptor_ptr {
53-
uint16_t limit;
54-
uint64_t base;
55-
uint16_t reserved[3]; /* align struct size to 64bit */
56-
} __attribute__((packed));
57-
58-
struct acrn_vcpu_regs {
59-
struct acrn_gp_regs gprs;
60-
struct acrn_descriptor_ptr gdt;
61-
struct acrn_descriptor_ptr idt;
62-
63-
uint64_t rip;
64-
uint64_t cs_base;
65-
uint64_t cr0;
66-
uint64_t cr4;
67-
uint64_t cr3;
68-
uint64_t ia32_efer;
69-
uint64_t rflags;
70-
uint64_t reserved_64[4];
71-
72-
uint32_t cs_ar;
73-
uint32_t reserved_32[4];
74-
75-
/* don't change the order of following sel */
76-
uint16_t cs_sel;
77-
uint16_t ss_sel;
78-
uint16_t ds_sel;
79-
uint16_t es_sel;
80-
uint16_t fs_sel;
81-
uint16_t gs_sel;
82-
uint16_t ldt_sel;
83-
uint16_t tr_sel;
84-
85-
uint16_t reserved_16[4];
86-
};
87-
8848
#ifdef CONFIG_EFI_STUB
8949
struct efi_context {
9050
struct acrn_vcpu_regs vcpu_regs;

hypervisor/include/public/acrn_common.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,68 @@ struct acrn_create_vcpu {
248248
uint16_t pcpu_id;
249249
} __aligned(8);
250250

251+
/* General-purpose register layout aligned with the general-purpose register idx
252+
* when vmexit, such as vmexit due to CR access, refer to SMD Vol.3C 27-6.
253+
*/
254+
struct acrn_gp_regs {
255+
uint64_t rax;
256+
uint64_t rcx;
257+
uint64_t rdx;
258+
uint64_t rbx;
259+
uint64_t rsp;
260+
uint64_t rbp;
261+
uint64_t rsi;
262+
uint64_t rdi;
263+
uint64_t r8;
264+
uint64_t r9;
265+
uint64_t r10;
266+
uint64_t r11;
267+
uint64_t r12;
268+
uint64_t r13;
269+
uint64_t r14;
270+
uint64_t r15;
271+
};
272+
273+
/* struct to define how the descriptor stored in memory.
274+
* Refer SDM Vol3 3.5.1 "Segment Descriptor Tables"
275+
* Figure 3-11
276+
*/
277+
struct acrn_descriptor_ptr {
278+
uint16_t limit;
279+
uint64_t base;
280+
uint16_t reserved[3]; /* align struct size to 64bit */
281+
} __attribute__((packed));
282+
283+
struct acrn_vcpu_regs {
284+
struct acrn_gp_regs gprs;
285+
struct acrn_descriptor_ptr gdt;
286+
struct acrn_descriptor_ptr idt;
287+
288+
uint64_t rip;
289+
uint64_t cs_base;
290+
uint64_t cr0;
291+
uint64_t cr4;
292+
uint64_t cr3;
293+
uint64_t ia32_efer;
294+
uint64_t rflags;
295+
uint64_t reserved_64[4];
296+
297+
uint32_t cs_ar;
298+
uint32_t reserved_32[4];
299+
300+
/* don't change the order of following sel */
301+
uint16_t cs_sel;
302+
uint16_t ss_sel;
303+
uint16_t ds_sel;
304+
uint16_t es_sel;
305+
uint16_t fs_sel;
306+
uint16_t gs_sel;
307+
uint16_t ldt_sel;
308+
uint16_t tr_sel;
309+
310+
uint16_t reserved_16[4];
311+
};
312+
251313
/**
252314
* @brief Info to set ioreq buffer for a created VM
253315
*

0 commit comments

Comments
 (0)