diff mbox

[v4,07/27] x86: move do_set_trap_table to pv/traps.c

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

Commit Message

Wei Liu June 8, 2017, 5:11 p.m. UTC
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/pv/traps.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/traps.c    | 49 ----------------------------------------------
 2 files changed, 52 insertions(+), 49 deletions(-)

Comments

Andrew Cooper June 23, 2017, 11 a.m. UTC | #1
On 08/06/17 18:11, Wei Liu wrote:
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

I'd suggest folding this into the next patch, and putting the hypercall
in misc-hypercalls.c

Despite its name, this hypercall is just setting up state in the vcpu.

~Andrew
Wei Liu June 23, 2017, 1:59 p.m. UTC | #2
On Fri, Jun 23, 2017 at 12:00:35PM +0100, Andrew Cooper wrote:
> On 08/06/17 18:11, Wei Liu wrote:
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> 
> I'd suggest folding this into the next patch, and putting the hypercall
> in misc-hypercalls.c
> 
> Despite its name, this hypercall is just setting up state in the vcpu.
> 

This is trivial to do. But if I do it, does your Rb in the next patch
apply to the new version?

> ~Andrew
Andrew Cooper June 23, 2017, 1:59 p.m. UTC | #3
On 23/06/17 14:59, Wei Liu wrote:
> On Fri, Jun 23, 2017 at 12:00:35PM +0100, Andrew Cooper wrote:
>> On 08/06/17 18:11, Wei Liu wrote:
>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>> I'd suggest folding this into the next patch, and putting the hypercall
>> in misc-hypercalls.c
>>
>> Despite its name, this hypercall is just setting up state in the vcpu.
>>
> This is trivial to do. But if I do it, does your Rb in the next patch
> apply to the new version?

Yes.

~Andrew
diff mbox

Patch

diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c
index 51125a8d86..6e69f2ad58 100644
--- a/xen/arch/x86/pv/traps.c
+++ b/xen/arch/x86/pv/traps.c
@@ -19,7 +19,10 @@ 
  * Copyright (c) 2017 Citrix Systems Ltd.
  */
 
+#include <xen/event.h>
+#include <xen/guest_access.h>
 #include <xen/hypercall.h>
+#include <xen/sched.h>
 
 #include <asm/apic.h>
 
@@ -31,6 +34,55 @@  void do_entry_int82(struct cpu_user_regs *regs)
     pv_hypercall(regs);
 }
 
+long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
+{
+    struct trap_info cur;
+    struct vcpu *curr = current;
+    struct trap_info *dst = curr->arch.pv_vcpu.trap_ctxt;
+    long rc = 0;
+
+    /* If no table is presented then clear the entire virtual IDT. */
+    if ( guest_handle_is_null(traps) )
+    {
+        memset(dst, 0, NR_VECTORS * sizeof(*dst));
+        init_int80_direct_trap(curr);
+        return 0;
+    }
+
+    for ( ; ; )
+    {
+        if ( copy_from_guest(&cur, traps, 1) )
+        {
+            rc = -EFAULT;
+            break;
+        }
+
+        if ( cur.address == 0 )
+            break;
+
+        if ( !is_canonical_address(cur.address) )
+            return -EINVAL;
+
+        fixup_guest_code_selector(curr->domain, cur.cs);
+
+        memcpy(&dst[cur.vector], &cur, sizeof(cur));
+
+        if ( cur.vector == 0x80 )
+            init_int80_direct_trap(curr);
+
+        guest_handle_add_offset(traps, 1);
+
+        if ( hypercall_preempt_check() )
+        {
+            rc = hypercall_create_continuation(
+                __HYPERVISOR_set_trap_table, "h", traps);
+            break;
+        }
+    }
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index b5642b0f9a..440aad182b 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -2126,55 +2126,6 @@  int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr)
 }
 
 
-long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
-{
-    struct trap_info cur;
-    struct vcpu *curr = current;
-    struct trap_info *dst = curr->arch.pv_vcpu.trap_ctxt;
-    long rc = 0;
-
-    /* If no table is presented then clear the entire virtual IDT. */
-    if ( guest_handle_is_null(traps) )
-    {
-        memset(dst, 0, NR_VECTORS * sizeof(*dst));
-        init_int80_direct_trap(curr);
-        return 0;
-    }
-
-    for ( ; ; )
-    {
-        if ( copy_from_guest(&cur, traps, 1) )
-        {
-            rc = -EFAULT;
-            break;
-        }
-
-        if ( cur.address == 0 )
-            break;
-
-        if ( !is_canonical_address(cur.address) )
-            return -EINVAL;
-
-        fixup_guest_code_selector(curr->domain, cur.cs);
-
-        memcpy(&dst[cur.vector], &cur, sizeof(cur));
-
-        if ( cur.vector == 0x80 )
-            init_int80_direct_trap(curr);
-
-        guest_handle_add_offset(traps, 1);
-
-        if ( hypercall_preempt_check() )
-        {
-            rc = hypercall_create_continuation(
-                __HYPERVISOR_set_trap_table, "h", traps);
-            break;
-        }
-    }
-
-    return rc;
-}
-
 void activate_debugregs(const struct vcpu *curr)
 {
     ASSERT(curr == current);