x86: move toggle_guest_mode to pv/domain.c

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Wei Liu committed 2017-06-23 16:06:19 +01:00
1 parent 0142064421
commit ffd13cd2b6
2 files changed
+31 -30

No files matched your search

+31
View File
@@ -213,6 +213,37 @@ int pv_domain_initialise(struct domain *d, unsigned int domcr_flags,
return rc;
}
void toggle_guest_mode(struct vcpu *v)
{
if ( is_pv_32bit_vcpu(v) )
return;
if ( cpu_has_fsgsbase )
{
if ( v->arch.flags & TF_kernel_mode )
v->arch.pv_vcpu.gs_base_kernel = __rdgsbase();
else
v->arch.pv_vcpu.gs_base_user = __rdgsbase();
}
v->arch.flags ^= TF_kernel_mode;
asm volatile ( "swapgs" );
update_cr3(v);
/* Don't flush user global mappings from the TLB. Don't tick TLB clock. */
asm volatile ( "mov %0, %%cr3" : : "r" (v->arch.cr3) : "memory" );
if ( !(v->arch.flags & TF_kernel_mode) )
return;
if ( v->arch.pv_vcpu.need_update_runstate_area &&
update_runstate_area(v) )
v->arch.pv_vcpu.need_update_runstate_area = 0;
if ( v->arch.pv_vcpu.pending_system_time.version &&
update_secondary_system_time(v,
&v->arch.pv_vcpu.pending_system_time) )
v->arch.pv_vcpu.pending_system_time.version = 0;
}
/*
* Local variables:
* mode: C
-30
View File
@@ -254,36 +254,6 @@ void do_double_fault(struct cpu_user_regs *regs)
panic("DOUBLE FAULT -- system shutdown");
}
void toggle_guest_mode(struct vcpu *v)
{
if ( is_pv_32bit_vcpu(v) )
return;
if ( cpu_has_fsgsbase )
{
if ( v->arch.flags & TF_kernel_mode )
v->arch.pv_vcpu.gs_base_kernel = __rdgsbase();
else
v->arch.pv_vcpu.gs_base_user = __rdgsbase();
}
v->arch.flags ^= TF_kernel_mode;
asm volatile ( "swapgs" );
update_cr3(v);
/* Don't flush user global mappings from the TLB. Don't tick TLB clock. */
asm volatile ( "mov %0, %%cr3" : : "r" (v->arch.cr3) : "memory" );
if ( !(v->arch.flags & TF_kernel_mode) )
return;
if ( v->arch.pv_vcpu.need_update_runstate_area &&
update_runstate_area(v) )
v->arch.pv_vcpu.need_update_runstate_area = 0;
if ( v->arch.pv_vcpu.pending_system_time.version &&
update_secondary_system_time(v,
&v->arch.pv_vcpu.pending_system_time) )
v->arch.pv_vcpu.pending_system_time.version = 0;
}
unsigned long do_iret(void)
{
struct cpu_user_regs *regs = guest_cpu_user_regs();
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.