Skip to content

Commit 173b534

Browse files
mgcaowenlingz
authored andcommitted
HV: modularization cleanup instr_emul header file
separate the private macro/structure/functions, which are just used in instr_emul.c; and move instr_emul.h to public include path. Tracked-On: #1842 Signed-off-by: Minggui Cao <minggui.cao@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 18dbdfd commit 173b534

File tree

7 files changed

+165
-205
lines changed

7 files changed

+165
-205
lines changed

hypervisor/arch/x86/ept.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <hypervisor.h>
88

9-
#include "guest/instr_emul.h"
9+
#include <instr_emul.h>
1010

1111
#define ACRN_DBG_EPT 6U
1212

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,35 @@
2929
*/
3030

3131
#include <hypervisor.h>
32+
#include <instr_emul.h>
33+
34+
#define CPU_REG_FIRST CPU_REG_RAX
35+
#define CPU_REG_LAST CPU_REG_GDTR
36+
#define CPU_REG_GENERAL_FIRST CPU_REG_RAX
37+
#define CPU_REG_GENERAL_LAST CPU_REG_R15
38+
#define CPU_REG_NONGENERAL_FIRST CPU_REG_CR0
39+
#define CPU_REG_NONGENERAL_LAST CPU_REG_GDTR
40+
#define CPU_REG_NATURAL_FIRST CPU_REG_CR0
41+
#define CPU_REG_NATURAL_LAST CPU_REG_RFLAGS
42+
#define CPU_REG_64BIT_FIRST CPU_REG_EFER
43+
#define CPU_REG_64BIT_LAST CPU_REG_PDPTE3
44+
#define CPU_REG_SEG_FIRST CPU_REG_ES
45+
#define CPU_REG_SEG_LAST CPU_REG_GS
46+
47+
#define PSL_C 0x00000001U /* carry bit */
48+
#define PSL_PF 0x00000004U /* parity bit */
49+
#define PSL_AF 0x00000010U /* bcd carry bit */
50+
#define PSL_Z 0x00000040U /* zero bit */
51+
#define PSL_N 0x00000080U /* negative bit */
52+
#define PSL_D 0x00000400U /* string instruction direction bit */
53+
#define PSL_V 0x00000800U /* overflow bit */
54+
#define PSL_AC 0x00040000U /* alignment checking */
3255

33-
#include "instr_emul.h"
56+
/*
57+
* Protections are chosen from these bits, or-ed together
58+
*/
59+
#define PROT_READ 0x01U /* pages can be read */
60+
#define PROT_WRITE 0x02U /* pages can be written */
3461

3562
/* struct vie_op.op_type */
3663
#define VIE_OP_TYPE_NONE 0U
@@ -192,6 +219,39 @@ struct vmcs_seg_field {
192219
uint32_t access_field;
193220
};
194221

222+
/*
223+
* The 'access' field has the format specified in Table 21-2 of the Intel
224+
* Architecture Manual vol 3b.
225+
*
226+
* XXX The contents of the 'access' field are architecturally defined except
227+
* bit 16 - Segment Unusable.
228+
*/
229+
struct seg_desc {
230+
uint64_t base;
231+
uint32_t limit;
232+
uint32_t access;
233+
};
234+
235+
static inline uint32_t seg_desc_type(uint32_t access)
236+
{
237+
return (access & 0x001fU);
238+
}
239+
240+
static inline bool seg_desc_present(uint32_t access)
241+
{
242+
return ((access & 0x0080U) != 0U);
243+
}
244+
245+
static inline bool seg_desc_def32(uint32_t access)
246+
{
247+
return ((access & 0x4000U) != 0U);
248+
}
249+
250+
static inline bool seg_desc_unusable(uint32_t access)
251+
{
252+
return ((access & 0x10000U) != 0U);
253+
}
254+
195255
static void encode_vmcs_seg_desc(enum cpu_reg_name seg,
196256
struct vmcs_seg_field *desc)
197257
{

hypervisor/arch/x86/guest/instr_emul.h

Lines changed: 0 additions & 200 deletions
This file was deleted.

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include <hypervisor.h>
3333

34-
#include "instr_emul.h"
34+
#include <instr_emul.h>
3535

3636
#include "vlapic_priv.h"
3737
#include "vlapic.h"

hypervisor/arch/x86/io_emul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <hypervisor.h>
88

9-
#include "guest/instr_emul.h"
9+
#include <instr_emul.h>
1010

1111
static void complete_ioreq(struct acrn_vcpu *vcpu, struct io_request *io_req)
1212
{

0 commit comments

Comments
 (0)