From 4acce9338a2e9d6d59111b13b481444dded55800 Mon Sep 17 00:00:00 2001 From: Binbin Wu Date: Tue, 7 Aug 2018 18:56:07 +0800 Subject: [PATCH] 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 Acked-by: Eddie Dong --- hypervisor/arch/x86/trusty.c | 15 --------------- hypervisor/include/arch/x86/guest/guest.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hypervisor/arch/x86/trusty.c b/hypervisor/arch/x86/trusty.c index af7ea7112..9ed5c5f2e 100644 --- a/hypervisor/arch/x86/trusty.c +++ b/hypervisor/arch/x86/trusty.c @@ -35,21 +35,6 @@ static struct trusty_key_info g_key_info = { .platform = 3U, .num_seeds = 1U }; -#define save_segment(seg, SEG_NAME) \ -{ \ - seg.selector = exec_vmread16(SEG_NAME##_SEL); \ - seg.base = exec_vmread(SEG_NAME##_BASE); \ - seg.limit = exec_vmread32(SEG_NAME##_LIMIT); \ - seg.attr = exec_vmread32(SEG_NAME##_ATTR); \ -} - -#define load_segment(seg, SEG_NAME) \ -{ \ - exec_vmwrite16(SEG_NAME##_SEL, seg.selector); \ - exec_vmwrite(SEG_NAME##_BASE, seg.base); \ - exec_vmwrite32(SEG_NAME##_LIMIT, seg.limit); \ - exec_vmwrite32(SEG_NAME##_ATTR, seg.attr); \ -} /** * @defgroup trusty_apis Trusty APIs diff --git a/hypervisor/include/arch/x86/guest/guest.h b/hypervisor/include/arch/x86/guest/guest.h index 583ac302c..c0dc96649 100644 --- a/hypervisor/include/arch/x86/guest/guest.h +++ b/hypervisor/include/arch/x86/guest/guest.h @@ -46,6 +46,22 @@ #define E820_MAX_ENTRIES 32U +#define save_segment(seg, SEG_NAME) \ +{ \ + seg.selector = exec_vmread16(SEG_NAME##_SEL); \ + seg.base = exec_vmread(SEG_NAME##_BASE); \ + seg.limit = exec_vmread32(SEG_NAME##_LIMIT); \ + seg.attr = exec_vmread32(SEG_NAME##_ATTR); \ +} + +#define load_segment(seg, SEG_NAME) \ +{ \ + exec_vmwrite16(SEG_NAME##_SEL, seg.selector); \ + exec_vmwrite(SEG_NAME##_BASE, seg.base); \ + exec_vmwrite32(SEG_NAME##_LIMIT, seg.limit); \ + exec_vmwrite32(SEG_NAME##_ATTR, seg.attr); \ +} + struct e820_mem_params { uint64_t mem_bottom; uint64_t mem_top;