]> xenbits.xensource.com Git - xen.git/commitdiff
x86/traps: Lift all non-entrypoint logic in entry_int82() up into C
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 12 Apr 2017 16:40:32 +0000 (17:40 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 May 2017 08:54:28 +0000 (09:54 +0100)
This is more readable, maintainable, and livepatchable.

This involves declaring check_for_unexpected_msi(), untrusted_msi and
pv_hypercall() suitably for use by C.  While making these changes,
untrusted_msi is switched over to being a C99 bool.

No behavioural change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/x86/pv/Makefile
xen/arch/x86/pv/traps.c [new file with mode: 0644]
xen/arch/x86/x86_64/compat/entry.S
xen/drivers/passthrough/vtd/iommu.c
xen/include/asm-x86/apic.h
xen/include/asm-x86/hypercall.h
xen/include/asm-x86/iommu.h

index ea9459943814c065285cf820a187a3e1183ab78e..8a295d08892b02952d6c3741e146013002e68472 100644 (file)
@@ -1,2 +1,4 @@
 obj-y += hypercall.o
+obj-y += traps.o
+
 obj-bin-y += dom0_build.init.o
diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c
new file mode 100644 (file)
index 0000000..51125a8
--- /dev/null
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * arch/x86/pv/traps.c
+ *
+ * PV low level entry points.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2017 Citrix Systems Ltd.
+ */
+
+#include <xen/hypercall.h>
+
+#include <asm/apic.h>
+
+void do_entry_int82(struct cpu_user_regs *regs)
+{
+    if ( unlikely(untrusted_msi) )
+        check_for_unexpected_msi((uint8_t)regs->entry_vector);
+
+    pv_hypercall(regs);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index abf109447e3fa93c93ef054dd6d66b0f02f75ef9..90bda09614da18a328256af29e4bc80decb0251e 100644 (file)
@@ -17,17 +17,10 @@ ENTRY(entry_int82)
         SAVE_VOLATILE type=HYPERCALL_VECTOR compat=1
         CR4_PV32_RESTORE
 
-        cmpb  $0,untrusted_msi(%rip)
-UNLIKELY_START(ne, msi_check)
-        movl  $HYPERCALL_VECTOR,%edi
-        call  check_for_unexpected_msi
-        LOAD_C_CLOBBERED compat=1 ax=0
-UNLIKELY_END(msi_check)
-
         GET_CURRENT(bx)
 
         mov   %rsp, %rdi
-        call  pv_hypercall
+        call  do_entry_int82
 
 /* %rbx: struct vcpu */
 ENTRY(compat_test_all_events)
index a5c61c6e2169fc33c8f09f0be265d3d6f30d1cf7..19328f6def71f0dbc97cc0e6099cda0b0884f375 100644 (file)
@@ -48,7 +48,7 @@ struct mapped_rmrr {
 };
 
 /* Possible unfiltered LAPIC/MSI messages from untrusted sources? */
-bool_t __read_mostly untrusted_msi;
+bool __read_mostly untrusted_msi;
 
 int nr_iommus;
 
@@ -2334,7 +2334,7 @@ static int reassign_device_ownership(
      * by the root complex unless interrupt remapping is enabled.
      */
     if ( (target != hardware_domain) && !iommu_intremap )
-        untrusted_msi = 1;
+        untrusted_msi = true;
 
     /*
      * If the device belongs to the hardware domain, and it has RMRR, don't
index 2f1398df54c7df8d9370f79dd4b9be62485ecd1e..99520393be82b44df67473a104d9d24f4050791e 100644 (file)
@@ -213,6 +213,7 @@ extern int lapic_suspend(void);
 extern int lapic_resume(void);
 extern void record_boot_APIC_mode(void);
 extern enum apic_mode current_local_apic_mode(void);
+extern void check_for_unexpected_msi(unsigned int vector);
 
 extern int check_nmi_watchdog (void);
 
index c59aa69b14ec0e2cf0642f77506c965988709bdd..cfbcefe52f522543f7008dd32ae2f4cf67f7a85f 100644 (file)
@@ -25,6 +25,8 @@ typedef struct {
 
 extern const hypercall_args_t hypercall_args_table[NR_hypercalls];
 
+void pv_hypercall(struct cpu_user_regs *regs);
+
 /*
  * Both do_mmuext_op() and do_mmu_update():
  * We steal the m.s.b. of the @count parameter to indicate whether this
index 043123333ee6c59bcc22394fede29a135dc34722..14ad0489a6814db2b63014b5a9cf4313d623976c 100644 (file)
@@ -92,6 +92,8 @@ bool_t iommu_supports_eim(void);
 int iommu_enable_x2apic_IR(void);
 void iommu_disable_x2apic_IR(void);
 
+extern bool untrusted_msi;
+
 int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq,
                    const uint8_t gvec);