[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 3/8] x86/hvm: Assert some expectations in hvm_inject_event()



Check that event->error_code is appropriate for the type/vector combination.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e0f936b..ac207e4 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1679,6 +1679,15 @@ void hvm_triple_fault(void)
 void hvm_inject_event(const struct x86_event *event)
 {
     struct vcpu *curr = current;
+    const uint8_t vector = event->vector;
+    const bool has_ec = ((event->type == X86_EVENTTYPE_HW_EXCEPTION) &&
+                         (vector < 32) && ((TRAP_HAVE_EC & 1u << vector)));
+
+    ASSERT(vector == event->vector); /* Confirm no truncation. */
+    if ( has_ec )
+        ASSERT(event->error_code != X86_EVENT_NO_EC);
+    else
+        ASSERT(event->error_code == X86_EVENT_NO_EC);
 
     if ( nestedhvm_enabled(curr->domain) &&
          !nestedhvm_vmswitch_in_progress(curr) &&
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.