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

[PATCH v5 6/5] x86/hvm: Add a non-FEP path to the #UD handler


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Thu, 12 Mar 2026 14:45:32 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mWAqciHDj/rPLHpzZWTBXdYeHhPDbCPzvP3OS9/0ZqE=; b=a1L+ek6pCCxpBX9MAQvNOFFmLiMYC+dXs7YX1Roz+nziCXPkOlCDSb3yg5JvFsQfGnU8VLG/Ee5U9YIxna5oiTWvp9ce81yYQunoZxloPVPwJxMNpN04KlidkTmR0FMfa/U+QBda0l4CWCrBhzQ2QT/N2tBRn5qZtvulEt+vR63cZxjndci6i30t2fHV2u09C5S51yTnzKT9yrEI5y3aCf/fgW77iR16zN+UxCJfrM9EycJSITaxEj15LjR6bJrAPqW6EfZhk/VrW8dd5P9pt5Qsr7ZAlHyis/brTxbqJXiZnHwsP/TJm9mYmt5RGswTvXR0SpkQSawTCALOGHfqXg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Lts2hOeEooK5cdjHD5svNT5XN/8Pbt37zKVH4hER71TCka+QbpuCYJDyBlXgMHo+KyREXlkXAU+nO4rx+WHi+55sMv2xBdKs6gEZ6vbmOzoEZzzEjlX88U9E74R5j9f6cnD77d9VZqpwU3rPvtnta+2dOJcXOYa5Ob/mMrdLonZPIEptpKLFekx4QF9V9eFDpJOR6Yw5RHIl7YqLcHoaJ92hLWCGlqPA1WutVAsKwmND8SrJiVBUamhzIyeHShryymCZ7QfdddZS40BWXX4BzLuzzZa7G4rfEDYg1faPJMdAhMKrpICqA5nLI+SOelCiVLDTb9irz/a7QjRNcXkCWw==
  • Cc: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 12 Mar 2026 13:50:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

While the #UD handler is dead code when CONFIG_HVM_FEP is disabled it's
helpful to keep the function around. Reinject #UD in the non-FEP case so
DCE can remove the rest.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
 xen/arch/x86/hvm/hvm.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 4c00cf4c4fe..0eaeb728382 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3835,13 +3835,18 @@ int hvm_descriptor_access_intercept(uint64_t exit_info,
 void hvm_ud_intercept(struct cpu_user_regs *regs)
 {
     struct vcpu *cur = current;
-    bool should_emulate = false;
     struct hvm_emulate_ctxt ctxt;
     const struct segment_register *cs;
     uint32_t walk;
     unsigned long addr;
     char sig[5]; /* ud2; .ascii "xen" */
 
+    if ( !opt_hvm_fep )
+    {
+        ASSERT_UNREACHABLE();
+        goto reinject;
+    }
+
     hvm_emulate_init_once(&ctxt, NULL, regs);
 
     cs = &ctxt.seg_reg[x86_seg_cs];
@@ -3863,20 +3868,15 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
             regs->rip = (uint32_t)regs->rip;
 
         add_taint(TAINT_HVM_FEP);
-
-        should_emulate = true;
-    }
-
-    if ( !should_emulate )
-    {
-        hvm_inject_hw_exception(X86_EXC_UD, X86_EVENT_NO_EC);
-        return;
     }
+    else
+        goto reinject;
 
     switch ( hvm_emulate_one(&ctxt, VIO_no_completion) )
     {
     case X86EMUL_UNHANDLEABLE:
     case X86EMUL_UNIMPLEMENTED:
+    reinject:
         hvm_inject_hw_exception(X86_EXC_UD, X86_EVENT_NO_EC);
         break;
     case X86EMUL_EXCEPTION:
-- 
2.43.0




 


Rackspace

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