From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 5/7] x86/traps: Lift all non-entrypoint logic in entry_int82() up into C
Date: Tue, 2 May 2017 19:05:24 +0100 [thread overview]
Message-ID: <1493748326-9582-6-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1493748326-9582-1-git-send-email-andrew.cooper3@citrix.com>
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>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/pv/Makefile | 2 ++
xen/arch/x86/pv/traps.c | 44 +++++++++++++++++++++++++++++++++++++
xen/arch/x86/x86_64/compat/entry.S | 9 +-------
xen/drivers/passthrough/vtd/iommu.c | 4 ++--
xen/include/asm-x86/apic.h | 1 +
xen/include/asm-x86/hypercall.h | 4 ++++
xen/include/asm-x86/iommu.h | 2 ++
7 files changed, 56 insertions(+), 10 deletions(-)
create mode 100644 xen/arch/x86/pv/traps.c
diff --git a/xen/arch/x86/pv/Makefile b/xen/arch/x86/pv/Makefile
index ea94599..8a295d0 100644
--- a/xen/arch/x86/pv/Makefile
+++ b/xen/arch/x86/pv/Makefile
@@ -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
index 0000000..f3d8f70
--- /dev/null
+++ b/xen/arch/x86/pv/traps.c
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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>
+
+#ifdef CONFIG_COMPAT
+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);
+}
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index abf1094..90bda09 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -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)
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index a5c61c6..19328f6 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -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
diff --git a/xen/include/asm-x86/apic.h b/xen/include/asm-x86/apic.h
index 2f1398df..9952039 100644
--- a/xen/include/asm-x86/apic.h
+++ b/xen/include/asm-x86/apic.h
@@ -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);
diff --git a/xen/include/asm-x86/hypercall.h b/xen/include/asm-x86/hypercall.h
index c59aa69..95d48c0 100644
--- a/xen/include/asm-x86/hypercall.h
+++ b/xen/include/asm-x86/hypercall.h
@@ -25,6 +25,10 @@ typedef struct {
extern const hypercall_args_t hypercall_args_table[NR_hypercalls];
+#ifdef CONFIG_PV
+void pv_hypercall(struct cpu_user_regs *regs);
+#endif
+
/*
* Both do_mmuext_op() and do_mmu_update():
* We steal the m.s.b. of the @count parameter to indicate whether this
diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
index 0431233..14ad048 100644
--- a/xen/include/asm-x86/iommu.h
+++ b/xen/include/asm-x86/iommu.h
@@ -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);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-05-02 18:05 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-02 18:05 [PATCH 0/7] XSAs 213-315 followups Andrew Cooper
2017-05-02 18:05 ` [PATCH 1/7] x86/traps: Drop 32bit fields out of tss_struct Andrew Cooper
2017-05-03 8:10 ` Jan Beulich
2017-05-03 12:33 ` Andrew Cooper
2017-05-03 9:48 ` Wei Liu
2017-05-02 18:05 ` [PATCH 2/7] x86/traps: Poison unused stack pointers in the TSS Andrew Cooper
2017-05-03 8:14 ` Jan Beulich
2017-05-03 12:47 ` Andrew Cooper
2017-05-03 13:29 ` [PATCH v2 " Andrew Cooper
2017-05-03 13:45 ` Jan Beulich
2017-05-02 18:05 ` [PATCH 3/7] x86/mm: Further restrict permissions on some virtual mappings Andrew Cooper
2017-05-03 8:49 ` Jan Beulich
2017-05-03 13:38 ` Andrew Cooper
2017-05-03 13:48 ` Jan Beulich
2017-05-03 9:48 ` Wei Liu
2017-05-03 10:11 ` Tim Deegan
2017-05-03 11:13 ` George Dunlap
2017-05-02 18:05 ` [PATCH 4/7] x86/traps: Rename compat_hypercall() to entry_int82() Andrew Cooper
2017-05-03 8:55 ` Jan Beulich
2017-05-03 13:41 ` Andrew Cooper
2017-05-02 18:05 ` Andrew Cooper [this message]
2017-05-03 9:02 ` [PATCH 5/7] x86/traps: Lift all non-entrypoint logic in entry_int82() up into C Jan Beulich
2017-05-03 11:26 ` Wei Liu
2017-05-03 11:38 ` Andrew Cooper
2017-05-03 11:43 ` Wei Liu
2017-05-03 12:02 ` Jan Beulich
2017-05-03 12:18 ` Andrew Cooper
2017-05-03 12:37 ` Jan Beulich
2017-05-03 18:29 ` Andrew Cooper
2017-05-04 7:27 ` Jan Beulich
2017-05-04 9:27 ` Andrew Cooper
2017-05-04 9:36 ` Jan Beulich
2017-05-04 9:57 ` Andrew Cooper
2017-05-03 12:00 ` Jan Beulich
2017-05-04 10:01 ` [PATCH v2 " Andrew Cooper
2017-05-04 10:16 ` Andrew Cooper
2017-05-04 10:28 ` Jan Beulich
2017-05-04 11:09 ` Andrew Cooper
2017-05-04 10:22 ` Jan Beulich
2017-05-02 18:05 ` [PATCH 6/7] x86/asm: Fold LOAD_C_CLOBBERED into RESTORE_ALL Andrew Cooper
2017-05-03 9:08 ` Jan Beulich
2017-05-03 9:48 ` Wei Liu
2017-05-02 18:05 ` [PATCH 7/7] x86/asm: Clobber %r{8..15} on exit to 32bit PV guests Andrew Cooper
2017-05-03 9:13 ` Jan Beulich
2017-05-03 17:51 ` [PATCH v2 " Andrew Cooper
2017-05-04 8:50 ` Jan Beulich
2017-05-04 11:11 ` [RFC for 4.9] [PATCH 0/7] XSAs 213-315 followups Andrew Cooper
2017-05-04 12:52 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493748326-9582-6-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).