<[email protected]> writes:
> Hi bugs@,
>
> Something weird is going on with one of my 7.9-on-7.9 VMM guests.
> I migrated one of my OpenBSD guests from an Intel 7.8 host to a
> AMD 7.9 host with scp on the disk image.
>
> Guest is running nsd, Caddy, httpd, and Prosody. After a few days
> running, I started having some issues with it.
>
> Caddy is responsive. SSH never finishes the handshake, but readily
> returns the header. ICMPv6 echo is replied to.
>
> Guest was stable for a few days. And on the prior host, stable for
> several months.
>
> I'm able to login to the guest via the serial console and this is
> what I found:
>
> potato# w
> 9:15PM up 3 days, 21:31, 1 user, load averages: 0.32, 0.09, 0.02
> USER TTY FROM LOGIN@ IDLE WHAT
> root 00 - 9:15PM 0 w
> potato# w
> 9:15PM up 3 days, 21:31, 1 user, load averages: 0.32, 0.09, 0.02
> USER TTY FROM LOGIN@ IDLE WHAT
> root 00 - 9:15PM 0 w
> potato# w
> 9:15PM up 3 days, 21:31, 1 user, load averages: 0.32, 0.09, 0.02
> USER TTY FROM LOGIN@ IDLE WHAT
> root 00 - 9:15PM 0 w
> potato# w
> 9:15PM up 3 days, 21:31, 1 user, load averages: 0.32, 0.09, 0.02
> USER TTY FROM LOGIN@ IDLE WHAT
> root 00 - 9:15PM 0 w
> potato# date
> Fri Aug 28 21:15:22 UTC 2026
> potato# date
> Fri Aug 28 21:15:20 UTC 2026
> potato# date
> Fri Aug 28 21:15:21 UTC 2026
> potato# date
> Fri Aug 28 21:15:21 UTC 2026
> potato# date
> Fri Aug 28 21:15:22 UTC 2026
> potato# date
> Fri Aug 28 21:15:23 UTC 2026
> potato# date
> Fri Aug 28 21:15:24 UTC 2026
> potato# date
> Fri Aug 28 21:15:20 UTC 2026
> potato# date
> Fri Aug 28 21:15:21 UTC 2026
> potato# date
> Fri Aug 28 21:15:22 UTC 2026
> potato# date
> Fri Aug 28 21:15:22 UTC 2026
> potato# date
> Fri Aug 28 21:15:22 UTC 2026
> potato# date
> Fri Aug 28 21:15:23 UTC 2026
> potato# date
> Fri Aug 28 21:15:23 UTC 2026
> potato# date
> Fri Aug 28 21:15:20 UTC 2026
> potato# date
>
> There is nothing interesting in the guest's dmesg.
>
> The load average never changes and the date is stuck looping. I
> killed ntpd and it's still doing it.
Is it still running? Try vmctl pause/unpause cycle.
If the pause/unpause works and this is reproduceable, see the diff
below. Another developer reported similar issues. This diff has had some
testing and haven't found regressions yet, but since I can't accurately
reproduce this issue it's hard for me to say it's correct in fixing it.
Having some confirmation this works (or at minimum doesn't break things)
would give me confidence to push for this as a reliability errata.
>
> I had a customer guest that I migrated from the same 7.8 Intel host
> to a 7.9 AMD host. That customer also experienced something weird,
> maybe the same thing, that I haven't been able to reproduce yet. I
> suspect it is the same issue for different reasons.
>
> I've had rock solid OpenBSD guests on my Intel hosts, and rock solid
> Debian guests on the AMD hosts. But it seems that something is
> strange on the AMD host. The time on the hosts is normal.
>
> My AMD hosts have 4162 EE Opterons, if it matters.
>
> I am quite confused on what is going on here.
>
> Thank you!
>
> -Slow Servers
>
> PS: I am not on this list, so please CC me on replies.
diffstat refs/heads/master refs/heads/vmm-intr
M sys/arch/amd64/amd64/vmm_machdep.c | 76+ 32-
M sys/arch/amd64/include/vmmvar.h | 1+ 1-
2 files changed, 77 insertions(+), 33 deletions(-)
diff refs/heads/master refs/heads/vmm-intr
commit - 483afb1274fb64b31f1c8ad519e341ae57f50e49
commit + fc8bd991144cb851cb2ea9699401bd5143278eb3
blob - f8ebc3262b6cf7f1ce6333a96d55b7c1cdbb1464
blob + 08e49c9f13a373780d5eb41219fed856aac96d1b
--- sys/arch/amd64/amd64/vmm_machdep.c
+++ sys/arch/amd64/amd64/vmm_machdep.c
@@ -491,19 +491,20 @@ vm_intr_pending(struct vm_intr_params *vip)
/* Find the desired VM */
error = vm_find(vip->vip_vm_id, &vm);
-
- /* Not found? exit. */
if (error != 0)
return (error);
vcpu = vm_find_vcpu(vm, vip->vip_vcpu_id);
-
if (vcpu == NULL) {
ret = ENOENT;
goto out;
}
- vcpu->vc_intr = vip->vip_intr;
+ /* Only set the flag and kick the VCPU if non-zero. */
+ if (vip->vip_intr == 0)
+ goto out;
+ WRITE_ONCE(vcpu->vc_intr, 1);
+
#ifdef MULTIPROCESSOR
ci = READ_ONCE(vcpu->vc_curcpu);
if (ci != NULL)
@@ -3403,6 +3404,9 @@ vm_run(struct vm_run_params *vrp)
}
WRITE_ONCE(vcpu->vc_curcpu, NULL);
+ /* Clear interrupt flag. */
+ WRITE_ONCE(vcpu->vc_intr, 0);
+
if (vcpu_rv == 0 || vcpu_rv == EAGAIN) {
/* vcpu requires useland assist or is yielding */
vrp->vrp_exit_reason = (vcpu_rv == 0) ? VM_EXIT_NONE
@@ -3675,16 +3679,8 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *
return (EINVAL);
}
- /*
- * If we are returning from userspace (vmd) because we exited
- * last time, fix up any needed vcpu state first. Which state
- * needs to be fixed up depends on what vmd populated in the
- * exit data structure.
- */
if (vrp->vrp_intr_pending)
- vcpu->vc_intr = 1;
- else
- vcpu->vc_intr = 0;
+ WRITE_ONCE(vcpu->vc_intr, 1);
switch (vcpu->vc_gueststate.vg_exit_reason) {
case VMX_EXIT_IO:
@@ -3718,7 +3714,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *
return (EINVAL);
}
- /* Interruptibility state 0x3 covers NMIs and STI */
+ /* Interruptibility state 0x3 covers MOV SS and STI */
if (!(int_st & 0x3) && vcpu->vc_irqready) {
eii = (uint64_t)vcpu->vc_inject.vie_vector;
eii |= (1ULL << 31); /* Valid */
@@ -3730,7 +3726,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *
vcpu->vc_inject.vie_type = VCPU_INJECT_NONE;
}
- } else if (!vcpu->vc_intr) {
+ } else if (!READ_ONCE(vcpu->vc_intr)) {
/*
* Disable window exiting
*/
@@ -3902,8 +3898,31 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *
/* Start / resume the VCPU */
- /* Disable interrupts and save the current host FPU state. */
+ /* Disable host interrupts */
s = intr_disable();
+
+ /* Check for potential interrupt state to inject. */
+ if (READ_ONCE(vcpu->vc_intr)) {
+ /* Enable interrupt window exiting. */
+ if (vmread(VMCS_PROCBASED_CTLS, &procbased)) {
+ printf("%s: can't read procbased ctls\n",
+ __func__);
+ ret = EINVAL;
+ intr_restore(s);
+ break;
+ } else {
+ procbased |= IA32_VMX_INTERRUPT_WINDOW_EXITING;
+ if (vmwrite(VMCS_PROCBASED_CTLS, procbased)) {
+ printf("%s: can't write procbased"
+ " ctls\n", __func__);
+ ret = EINVAL;
+ intr_restore(s);
+ break;
+ }
+ }
+ }
+
+ /* Save host FPU and restore guest FPU state. */
if ((ret = vmm_fpurestore(vcpu))) {
intr_restore(s);
break;
@@ -3989,16 +4008,26 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *
*/
ret = vmx_handle_exit(vcpu);
- if (vcpu->vc_gueststate.vg_rflags & PSL_I)
- vcpu->vc_irqready = 1;
- else
- vcpu->vc_irqready = 0;
+ vcpu->vc_irqready = 0;
+ if (vcpu->vc_gueststate.vg_rflags & PSL_I) {
+ if (vmread(VMCS_GUEST_INTERRUPTIBILITY_ST,
+ &int_st)) {
+ printf("%s: can't read interruptibility"
+ " state\n", __func__);
+ ret = EINVAL;
+ break;
+ }
+ /* If not blocking via MOV SS or STI. */
+ if (!(int_st & 0x3))
+ vcpu->vc_irqready = 1;
+ }
/*
* If not ready for interrupts, but interrupts pending,
* enable interrupt window exiting.
*/
- if (vcpu->vc_irqready == 0 && vcpu->vc_intr) {
+ if (vcpu->vc_irqready == 0 &&
+ READ_ONCE(vcpu->vc_intr)) {
if (vmread(VMCS_PROCBASED_CTLS, &procbased)) {
printf("%s: can't read procbased ctls "
"on intwin exit\n", __func__);
@@ -4022,7 +4051,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *
if (ret || vcpu_must_stop(vcpu))
break;
- if (vcpu->vc_intr && vcpu->vc_irqready) {
+ if (READ_ONCE(vcpu->vc_intr) && vcpu->vc_irqready) {
ret = EAGAIN;
break;
}
@@ -6653,9 +6682,7 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *
struct vmcb *vmcb = (struct vmcb *)vcpu->vc_control_va;
if (vrp->vrp_intr_pending)
- vcpu->vc_intr = 1;
- else
- vcpu->vc_intr = 0;
+ WRITE_ONCE(vcpu->vc_intr, 1);
/*
* If we are returning from userspace (vmd) because we exited
@@ -6786,8 +6813,21 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *
TRACEPOINT(vmm, guest_enter, vcpu, vrp);
/* Start / resume the VCPU */
- /* Disable interrupts and save the current host FPU state. */
+ /* Disable host interrupts. */
clgi();
+
+ /* Check for potential interrupt state to inject. */
+ if (READ_ONCE(vcpu->vc_intr)) {
+ /* Enable interrupt window exiting. */
+ vmcb->v_intercept1 |= SVM_INTERCEPT_VINTR;
+ vmcb->v_irq = 1;
+ vmcb->v_intr_misc = SVM_INTR_MISC_V_IGN_TPR;
+ vmcb->v_intr_vector = 0;
+ svm_set_dirty(vcpu, SVM_CLEANBITS_TPR |
+ SVM_CLEANBITS_I);
+ }
+
+ /* Save host FPU and restore guest FPU state. */
if ((ret = vmm_fpurestore(vcpu))) {
stgi();
break;
@@ -6855,16 +6895,20 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *
*/
ret = svm_handle_exit(vcpu);
- if (svm_get_iflag(vcpu, vcpu->vc_gueststate.vg_rflags))
- vcpu->vc_irqready = 1;
- else
- vcpu->vc_irqready = 0;
+ vcpu->vc_irqready = 0;
+ if (svm_get_iflag(vcpu,
+ vcpu->vc_gueststate.vg_rflags)) {
+ /* If not blocking via MOV SS or STI. */
+ if (!(vmcb->v_intr_shadow & 0x1))
+ vcpu->vc_irqready = 1;
+ }
/*
* If not ready for interrupts, but interrupts pending,
* enable interrupt window exiting.
*/
- if (vcpu->vc_irqready == 0 && vcpu->vc_intr) {
+ if (vcpu->vc_irqready == 0 &&
+ READ_ONCE(vcpu->vc_intr)) {
vmcb->v_intercept1 |= SVM_INTERCEPT_VINTR;
vmcb->v_irq = 1;
vmcb->v_intr_misc = SVM_INTR_MISC_V_IGN_TPR;
@@ -6880,7 +6924,7 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *
if (ret || vcpu_must_stop(vcpu))
break;
- if (vcpu->vc_intr && vcpu->vc_irqready) {
+ if (READ_ONCE(vcpu->vc_intr) && vcpu->vc_irqready) {
ret = EAGAIN;
break;
}
blob - 25b1618ad1ff6590eb030e9a89729da2c954c9d0
blob + 2735e6908664e2125290d2c4c38cd76ae51401f0
--- sys/arch/amd64/include/vmmvar.h
+++ sys/arch/amd64/include/vmmvar.h
@@ -975,7 +975,7 @@ struct vcpu {
struct cpu_info *vc_last_pcpu; /* [v] */
struct vm_exit vc_exit; /* [v] */
- uint16_t vc_intr; /* [v] */
+ uint16_t vc_intr; /* [a] */
uint8_t vc_irqready; /* [v] */
uint8_t vc_fpuinited; /* [v] */