Skip to content

Commit 4acce93

Browse files
binbinwu1lijinxia
authored andcommitted
hv: move save_segment/load_segment to a header file
save_segment/load_segment is common code and can be used outside of trusty, move to a header file. Signed-off-by: Binbin Wu <binbin.wu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 43db87c commit 4acce93

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

hypervisor/arch/x86/trusty.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ static struct trusty_key_info g_key_info = {
3535
.platform = 3U,
3636
.num_seeds = 1U
3737
};
38-
#define save_segment(seg, SEG_NAME) \
39-
{ \
40-
seg.selector = exec_vmread16(SEG_NAME##_SEL); \
41-
seg.base = exec_vmread(SEG_NAME##_BASE); \
42-
seg.limit = exec_vmread32(SEG_NAME##_LIMIT); \
43-
seg.attr = exec_vmread32(SEG_NAME##_ATTR); \
44-
}
45-
46-
#define load_segment(seg, SEG_NAME) \
47-
{ \
48-
exec_vmwrite16(SEG_NAME##_SEL, seg.selector); \
49-
exec_vmwrite(SEG_NAME##_BASE, seg.base); \
50-
exec_vmwrite32(SEG_NAME##_LIMIT, seg.limit); \
51-
exec_vmwrite32(SEG_NAME##_ATTR, seg.attr); \
52-
}
5338

5439
/**
5540
* @defgroup trusty_apis Trusty APIs

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@
4646

4747
#define E820_MAX_ENTRIES 32U
4848

49+
#define save_segment(seg, SEG_NAME) \
50+
{ \
51+
seg.selector = exec_vmread16(SEG_NAME##_SEL); \
52+
seg.base = exec_vmread(SEG_NAME##_BASE); \
53+
seg.limit = exec_vmread32(SEG_NAME##_LIMIT); \
54+
seg.attr = exec_vmread32(SEG_NAME##_ATTR); \
55+
}
56+
57+
#define load_segment(seg, SEG_NAME) \
58+
{ \
59+
exec_vmwrite16(SEG_NAME##_SEL, seg.selector); \
60+
exec_vmwrite(SEG_NAME##_BASE, seg.base); \
61+
exec_vmwrite32(SEG_NAME##_LIMIT, seg.limit); \
62+
exec_vmwrite32(SEG_NAME##_ATTR, seg.attr); \
63+
}
64+
4965
struct e820_mem_params {
5066
uint64_t mem_bottom;
5167
uint64_t mem_top;

0 commit comments

Comments
 (0)