diff mbox

[for-next,v3,13/22] x86/traps: move toggle_guest_mode

Message ID 20170518171004.27204-14-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu May 18, 2017, 5:09 p.m. UTC
Move from x86_64/traps.c to pv/traps.c.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/pv/traps.c     | 30 ++++++++++++++++++++++++++++++
 xen/arch/x86/x86_64/traps.c | 30 ------------------------------
 2 files changed, 30 insertions(+), 30 deletions(-)

Comments

Jan Beulich May 29, 2017, 4:05 p.m. UTC | #1
>>> On 18.05.17 at 19:09, <wei.liu2@citrix.com> wrote:
> Move from x86_64/traps.c to pv/traps.c.

This again doesn't necessarily fit into traps.c (but it's an option).
Perhaps we want some misc.c or util.c?

Jan
Andrew Cooper May 30, 2017, 5:47 p.m. UTC | #2
On 29/05/17 17:05, Jan Beulich wrote:
>>>> On 18.05.17 at 19:09, <wei.liu2@citrix.com> wrote:
>> Move from x86_64/traps.c to pv/traps.c.
> This again doesn't necessarily fit into traps.c (but it's an option).
> Perhaps we want some misc.c or util.c?

Or pv/domain.c, as this does logically fit with the context switching theme?

~Andrew
Jan Beulich May 31, 2017, 6 a.m. UTC | #3
>>> On 30.05.17 at 19:47, <andrew.cooper3@citrix.com> wrote:
> On 29/05/17 17:05, Jan Beulich wrote:
>>>>> On 18.05.17 at 19:09, <wei.liu2@citrix.com> wrote:
>>> Move from x86_64/traps.c to pv/traps.c.
>> This again doesn't necessarily fit into traps.c (but it's an option).
>> Perhaps we want some misc.c or util.c?
> 
> Or pv/domain.c, as this does logically fit with the context switching theme?

Good point.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c
index 7c841e04cc..5b84a617e6 100644
--- a/xen/arch/x86/pv/traps.c
+++ b/xen/arch/x86/pv/traps.c
@@ -332,6 +332,36 @@  int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr)
     return -EIO;
 }
 
+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
diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c
index 78f410517c..36b694c605 100644
--- a/xen/arch/x86/x86_64/traps.c
+++ b/xen/arch/x86/x86_64/traps.c
@@ -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();