Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
xcap
xcap-capability-linux
Commits
89d31ccd
Commit
89d31ccd
authored
Jul 08, 2014
by
Charles Jacobsen
Committed by
Vikram Narayanan
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debugging build errors. Some of them taken care of.
parent
364254ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
50 deletions
+49
-50
arch/x86/include/asm/lcd-domains-arch.h
arch/x86/include/asm/lcd-domains-arch.h
+18
-19
arch/x86/lcd-domains/lcd-domains-arch.c
arch/x86/lcd-domains/lcd-domains-arch.c
+31
-31
No files found.
arch/x86/include/asm/lcd-domains-arch.h
View file @
89d31ccd
...
...
@@ -7,10 +7,10 @@
/* ADDRESS SPACE TYPES ---------------------------------------- */
typedef
struct
{
unsigned
long
gva
}
gva_t
;
typedef
struct
{
unsigned
long
hva
}
hva_t
;
typedef
struct
{
unsigned
long
gpa
}
gpa_t
;
typedef
struct
{
unsigned
long
hpa
}
hpa_t
;
typedef
struct
{
unsigned
long
gva
;
}
gva_t
;
typedef
struct
{
unsigned
long
hva
;
}
hva_t
;
typedef
struct
{
unsigned
long
gpa
;
}
gpa_t
;
typedef
struct
{
unsigned
long
hpa
;
}
hpa_t
;
static
inline
gva_t
__gva
(
unsigned
long
gva
)
{
...
...
@@ -92,15 +92,14 @@ static inline hva_t hpa2hva(hpa_t hpa)
{
return
(
hva_t
){
(
unsigned
long
)
__va
(
hpa
.
hpa
)
};
}
static
inline
hpa_t
hva2hpa
(
hva_t
hva
)
{
return
(
hpa_t
){
(
unsigned
long
)
__pa
(
hva2va
(
hva
))
};
}
static
inline
void
*
hva2va
(
hva_t
hva
)
{
return
(
void
*
)
hva_val
(
hva
);
}
static
inline
hpa_t
hva2hpa
(
hva_t
hva
)
{
return
(
hpa_t
){
(
unsigned
long
)
__pa
(
hva2va
(
hva
))
};
}
/* LCD ARCH DATA STRUCTURES ---------------------------------------- */
...
...
@@ -137,15 +136,15 @@ enum lcd_arch_reg {
#define LCD_ARCH_EPTP_WALK_SHIFT 3
#define LCD_ARCH_PTRS_PER_EPTE (1 << 9)
typedef
unsigned
long
lcd_arch_epte_t
;
struct
lcd_arch_ept
{
spinlock_t
lock
;
hpa
_t
root
;
lcd_arch_epte
_t
*
root
;
unsigned
long
vmcs_ptr
;
bool
access_dirty_enabled
;
};
typedef
unsigned
long
lcd_arch_epte_t
;
struct
lcd_arch_tss
{
/*
* Intel SDM V3 7.7
...
...
@@ -342,16 +341,16 @@ int lcd_arch_set_gva_root(struct lcd_arch *vcpu, gpa_t a);
* See Intel SDM V3 3.4.2, 3.4.3 for segment register layout
* See Intel SDM V3 2.4.1 - 2.4.4 for gdtr, ldtr, idtr, tr
*/
#define LCD_ARCH_FS_BASE __gpa(0UL)
;
#define LCD_ARCH_FS_BASE __gpa(0UL)
#define LCD_ARCH_FS_LIMIT 0xFFFFFFFF
#define LCD_ARCH_GS_BASE __gpa(0UL)
;
#define LCD_ARCH_GS_BASE __gpa(0UL)
#define LCD_ARCH_GS_LIMIT 0xFFFFFFFF
#define LCD_ARCH_GDTR_BASE __gpa(1UL << PAGE_SHIFT)
;
#define LCD_ARCH_GDTR_BASE __gpa(1UL << PAGE_SHIFT)
#define LCD_ARCH_GDTR_LIMIT ((u32)~(PAGE_SIZE - 1))
#define LCD_ARCH_TSS_BASE __gpa(2UL << PAGE_SHIFT)
;
#define LCD_ARCH_TSS_BASE __gpa(2UL << PAGE_SHIFT)
/* tss base + limit = address of last byte in tss, hence -1 */
#define LCD_ARCH_TSS_LIMIT (sizeof(struct lcd_arch_tss) - 1)
#define LCD_ARCH_IDTR_BASE __gpa(0UL)
;
#define LCD_ARCH_IDTR_BASE __gpa(0UL)
#define LCD_ARCH_IDTR_LIMIT 0x0
/* no idt right now */
#define LCD_ARCH_CS_SELECTOR (1 << 3)
...
...
@@ -388,8 +387,8 @@ int lcd_arch_set_gva_root(struct lcd_arch *vcpu, gpa_t a);
* | (not mapped) | (4 KBs)
* +---------------------------+ 0x0000 0000 0000 0000
*/
#define LCD_ARCH_UTCB __gpa(3UL << PAGE_SHIFT)
;
#define LCD_ARCH_STACK_TOP __gpa(4UL << PAGE_SHIFT)
;
#define LCD_ARCH_UTCB __gpa(3UL << PAGE_SHIFT)
#define LCD_ARCH_STACK_TOP __gpa(4UL << PAGE_SHIFT)
#define LCD_ARCH_FREE LCD_ARCH_STACK_TOP
/*
...
...
arch/x86/lcd-domains/lcd-domains-arch.c
View file @
89d31ccd
...
...
@@ -138,11 +138,11 @@ static inline bool cpu_has_vmx_ept_ad_bits(void)
return
vmx_capability
.
ept
&
VMX_EPT_AD_BIT
;
}
static
inline
void
__invept
(
int
ext
,
u64
eptp
,
gpa_t
a
)
static
inline
void
__invept
(
int
ext
,
u64
eptp
)
{
struct
{
u64
eptp
,
gpa
;
}
operand
=
{
eptp
,
gpa_val
(
a
)
};
}
operand
=
{
eptp
,
0
};
asm
volatile
(
ASM_VMX_INVEPT
/* CF==1 or ZF==1 --> rc = -1 */
...
...
@@ -156,7 +156,7 @@ static inline void __invept(int ext, u64 eptp, gpa_t a)
static
inline
void
invept_global_context
(
void
)
{
if
(
cpu_has_vmx_invept_global
())
__invept
(
VMX_EPT_EXTENT_GLOBAL
,
0
,
0
);
__invept
(
VMX_EPT_EXTENT_GLOBAL
,
0
);
}
/**
...
...
@@ -166,7 +166,7 @@ static inline void invept_global_context(void)
static
inline
void
invept_single_context
(
u64
eptp
)
{
if
(
cpu_has_vmx_invept_context
())
__invept
(
VMX_EPT_EXTENT_CONTEXT
,
eptp
,
0
);
__invept
(
VMX_EPT_EXTENT_CONTEXT
,
eptp
);
else
invept_global_context
();
}
...
...
@@ -226,7 +226,7 @@ static void vmcs_clear(struct lcd_arch_vmcs *vmcs)
:
"=qm"
(
error
)
:
"a"
(
hpa_ptr
(
&
a
)),
"m"
(
hpa_val
(
a
))
:
"cc"
,
"memory"
);
if
(
error
)
printk
(
KERN_ERR
"lcd vmx: vmclear fail: %p/%
l
lx
\n
"
,
printk
(
KERN_ERR
"lcd vmx: vmclear fail: %p/%lx
\n
"
,
vmcs
,
hpa_val
(
a
));
}
...
...
@@ -243,7 +243,7 @@ static void vmcs_load(struct lcd_arch_vmcs *vmcs)
:
"=qm"
(
error
)
:
"a"
(
hpa_ptr
(
&
a
)),
"m"
(
hpa_val
(
a
))
:
"cc"
,
"memory"
);
if
(
error
)
printk
(
KERN_ERR
"lcd vmx: vmptrld %p/%
l
lx failed
\n
"
,
printk
(
KERN_ERR
"lcd vmx: vmptrld %p/%lx failed
\n
"
,
vmcs
,
hpa_val
(
a
));
}
...
...
@@ -965,7 +965,7 @@ int lcd_arch_ept_walk(struct lcd_arch *vcpu, gpa_t a, int create,
u64
idx
;
hva_t
page
;
dir
=
(
lcd_arch_epte_t
*
)
hpa2va
(
vcpu
->
ept
.
root
)
;
dir
=
vcpu
->
ept
.
root
;
/*
* Walk plm4 -> pdpt -> pd. Each step uses 9 bits
...
...
@@ -987,7 +987,7 @@ int lcd_arch_ept_walk(struct lcd_arch *vcpu, gpa_t a, int create,
* set the epte's addr to the host physical addr
*/
page
=
__hva
(
__get_free_page
(
GFP_KERNEL
));
if
(
!
page
)
{
if
(
!
hva_val
(
page
)
)
{
printk
(
KERN_ERR
"lcd_arch_ept_walk: alloc failed
\n
"
);
return
-
ENOMEM
;
}
...
...
@@ -1007,7 +1007,7 @@ int lcd_arch_ept_walk(struct lcd_arch *vcpu, gpa_t a, int create,
void
lcd_arch_ept_set
(
lcd_arch_epte_t
*
epte
,
hpa_t
a
)
{
vmx_epte_set
(
epte
,
hp
a
,
3
);
vmx_epte_set
(
epte
,
a
,
3
);
}
int
lcd_arch_ept_unset
(
lcd_arch_epte_t
*
epte
)
...
...
@@ -1060,18 +1060,18 @@ int lcd_arch_ept_map_range(struct lcd_arch *lcd, gpa_t ga_start, hpa_t ha_start,
len
=
npages
*
PAGE_SIZE
;
for
(
off
=
0
;
off
<
len
;
off
+=
PAGE_SIZE
)
{
if
(
lcd_arch_ept_map
_gpa_to_hpa
(
lcd
,
/* gpa */
gpa_
val
(
ga_start
)
+
off
,
/* hpa */
hpa_
val
(
ha_start
)
+
off
,
/* create */
1
,
/* no overwrite */
0
))
{
if
(
lcd_arch_ept_map
(
lcd
,
/* gpa */
gpa_
add
(
ga_start
,
off
)
,
/* hpa */
hpa_
add
(
ha_start
,
off
)
,
/* create */
1
,
/* no overwrite */
0
))
{
printk
(
KERN_ERR
"lcd_arch_ept_map_range: error mapping gpa %lx to hpa %lx
\n
"
,
gpa_val
(
gpa_start
)
+
off
,
hpa_val
(
hpa_start
)
+
off
));
gpa_val
(
gpa_
add
(
ga_
start
,
off
))
,
hpa_val
(
hpa_
add
(
ha_
start
,
off
));
return
-
EIO
;
}
}
...
...
@@ -1144,7 +1144,7 @@ int lcd_arch_ept_gpa_to_hpa(struct lcd_arch *vcpu, gpa_t ga, hpa_t *ha_out)
*/
hpa
=
lcd_arch_ept_hpa
(
ept_entry
);
hpa
=
hpa_add
(
hpa
,
vmx_ept_offset
(
ga
));
*
h
p
a_out
=
hpa
;
*
ha_out
=
hpa
;
return
0
;
}
...
...
@@ -1216,7 +1216,7 @@ static void vmx_free_ept(struct lcd_arch *vcpu)
*/
int
vmx_init_ept
(
struct
lcd_arch
*
vcpu
)
{
void
*
page
;
hva_t
page
;
u64
eptp
;
/*
...
...
@@ -1230,7 +1230,7 @@ int vmx_init_ept(struct lcd_arch *vcpu)
}
memset
(
hva2va
(
page
),
0
,
PAGE_SIZE
);
vcpu
->
ept
.
root
=
hva2
hp
a
(
page
);
vcpu
->
ept
.
root
=
(
lcd_arch_epte_t
*
)
hva2
v
a
(
page
);
/*
* Init the VMCS EPT pointer
...
...
@@ -1249,7 +1249,7 @@ int vmx_init_ept(struct lcd_arch *vcpu)
vcpu
->
ept
.
access_dirty_enabled
=
true
;
eptp
|=
VMX_EPT_AD_ENABLE_BIT
;
}
eptp
|=
(
hpa_val
(
vcpu
->
ept
.
root
)
&
PAGE_MASK
);
eptp
|=
(
((
unsigned
long
)
vcpu
->
ept
.
root
)
&
PAGE_MASK
);
vcpu
->
ept
.
vmcs_ptr
=
eptp
;
/*
...
...
@@ -1932,9 +1932,9 @@ static int vmx_init_gdt(struct lcd_arch *vcpu)
*/
tssd
=
(
struct
tss_desc
*
)(
vcpu
->
gdt
+
(
LCD_ARCH_TR_SELECTOR
>>
3
));
set_tssldt_descriptor
(
tssd
,
LCD_ARCH_TSS_BASE
,
/* base */
0xB
,
/* type = 64-bit busy tss */
LCD_ARCH_TSS_LIMIT
);
/* limit */
gpa_val
(
LCD_ARCH_TSS_BASE
)
,
/* base */
0xB
,
/* type = 64-bit busy tss */
LCD_ARCH_TSS_LIMIT
);
/* limit */
/*
*===--- Map GDT in guest physical address space ---===
...
...
@@ -2393,7 +2393,7 @@ static int vmx_handle_hard_exception(struct lcd_arch *vcpu)
*
* Set page fault address, and return status code.
*/
vcpu
->
run_info
.
gva
=
__gva
(
vcpu
->
exit_qualification
);
vcpu
->
run_info
.
fault_
gva
=
__gva
(
vcpu
->
exit_qualification
);
return
LCD_ARCH_STATUS_PAGE_FAULT
;
default:
printk
(
KERN_ERR
"lcd vmx: unhandled hw exception:
\n
"
);
...
...
@@ -2437,8 +2437,8 @@ static int vmx_handle_ept(struct lcd_arch *vcpu)
/*
* Intel SDM V3 27.2.1
*/
vcpu
->
run_info
.
gva
=
__gva
(
vmcs_readl
(
GUEST_LINEAR_ADDRESS
));
vcpu
->
run_info
.
gpa
=
__gpa
(
vmcs_readl
(
GUEST_PHYSICAL_ADDRESS
));
vcpu
->
run_info
.
fault_
gva
=
__gva
(
vmcs_readl
(
GUEST_LINEAR_ADDRESS
));
vcpu
->
run_info
.
fault_
gpa
=
__gpa
(
vmcs_readl
(
GUEST_PHYSICAL_ADDRESS
));
return
LCD_ARCH_STATUS_EPT_FAULT
;
}
...
...
@@ -2745,7 +2745,7 @@ EXPORT_SYMBOL(lcd_arch_ept_unset);
EXPORT_SYMBOL
(
lcd_arch_ept_unmap_gpa
);
EXPORT_SYMBOL
(
lcd_arch_ept_unmap_range
);
EXPORT_SYMBOL
(
lcd_arch_ept_hpa
);
EXPORT_SYMBOL
(
lcd_arch_ept_map
_gpa_to_hpa
);
EXPORT_SYMBOL
(
lcd_arch_ept_map
);
EXPORT_SYMBOL
(
lcd_arch_ept_map_range
);
EXPORT_SYMBOL
(
lcd_arch_ept_gpa_to_hpa
);
EXPORT_SYMBOL
(
lcd_arch_set_pc
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment