Skip to contentSkip to conversation

x86/nestedsvm: Inject #UD for not-intercepted VMMCALL

PATCH In review Ross Lagerwall 3 participants 3 messages Nov 20

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/nestedsvm: Inject #UD for not-intercepted VMMCALL

Rather than always forwarding VMMCALL to L1, follow the APM Vol 2 Rev 3.46 15.18 "VMMCALL Instruction" and inject #UD for a not-intercepted VMMCALL.

---
 xen/arch/x86/hvm/svm/nestedsvm.c | 3 ---
 xen/arch/x86/hvm/svm/svm.c       | 7 ++++++-
 2 files changed, 6 insertions(+), 4 deletions(-)
xen/arch/x86/hvm/svm/nestedsvm.c +0 -3
index 366178ff54a7..7bc5710c8294 100644
@@ -1261,9 +1261,6 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
             return NESTEDHVM_VMEXIT_HOST;
         return NESTEDHVM_VMEXIT_INJECT;
 
-    case VMEXIT_VMMCALL:
-        /* Always let the guest handle VMMCALL/VMCALL */
-        return NESTEDHVM_VMEXIT_INJECT;
     default:
         break;
     }
xen/arch/x86/hvm/svm/svm.c +6 -1
index bfca1eda4af5..ef42d5eb981d 100644
@@ -2924,9 +2924,14 @@ void asmlinkage svm_vmexit_handler(void)
         break;
 
     case VMEXIT_VMMCALL:
+        if ( vcpu_guestmode )
+        {
+            hvm_inject_hw_exception(X86_EXC_UD, X86_EVENT_NO_EC);
+            break;
+        }
+
         if ( (insn_len = svm_get_insn_len(v, INSTR_VMCALL)) == 0 )
             break;
-        BUG_ON(vcpu_guestmode);
         TRACE(TRC_HVM_VMMCALL, regs->eax);
 
         if ( hvm_hypercall(regs) == HVM_HCALL_completed )
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ross Lagerwall

Le 20/11/2026 à 12:11, Ross Lagerwall a écrit :

Quoted 34 lines

Rather than always forwarding VMMCALL to L1, follow the APM Vol 2 Rev 3.46 15.18 "VMMCALL Instruction" and inject #UD for a not-intercepted VMMCALL.

---
  xen/arch/x86/hvm/svm/nestedsvm.c | 3 ---
  xen/arch/x86/hvm/svm/svm.c       | 7 ++++++-
  2 files changed, 6 insertions(+), 4 deletions(-)
xen/arch/x86/hvm/svm/nestedsvm.c +0 -3
index 366178ff54a7..7bc5710c8294 100644
@@ -1261,9 +1261,6 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
              return NESTEDHVM_VMEXIT_HOST;
          return NESTEDHVM_VMEXIT_INJECT;
 
-    case VMEXIT_VMMCALL:
-        /* Always let the guest handle VMMCALL/VMCALL */
-        return NESTEDHVM_VMEXIT_INJECT;
      default:
          break;
      }
xen/arch/x86/hvm/svm/svm.c +2 -0
index bfca1eda4af5..ef42d5eb981d 100644
@@ -2924,9 +2924,14 @@ void asmlinkage svm_vmexit_handler(void)
          break;
 
      case VMEXIT_VMMCALL:
+        if ( vcpu_guestmode )
+        {

xen/arch/x86/hvm/svm/svm.c void asmlinkage svm_vmexit_handler(void) · line 2937

Quoted 10 lines
xen/arch/x86/hvm/svm/svm.c +4 -1
+            hvm_inject_hw_exception(X86_EXC_UD, X86_EVENT_NO_EC);
+            break;
+        }
+
          if ( (insn_len = svm_get_insn_len(v, INSTR_VMCALL)) == 0 )
              break;
-        BUG_ON(vcpu_guestmode);
          TRACE(TRC_HVM_VMMCALL, regs->eax);
 
          if ( hvm_hypercall(regs) == HVM_HCALL_completed )

Teddy