On 3/17/2021 4:47 PM, Chenyi Qiang wrote:
[...]
  MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
  {
      X86CPU *x86_cpu = X86_CPU(cpu);
@@ -4236,6 +4271,11 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct 
kvm_run *run)
      } else {
          env->eflags &= ~IF_MASK;
      }
+    if (run->flags & KVM_RUN_X86_BUS_LOCK) {
+        kvm_cpu_synchronize_state(cpu);
+        warn_report("bus lock detected at rip: 0x%lx", env->eip);

Chenyi,

Let's drop the eip here since QEMU has no idea whether it points to the next instruction or the exact instruction acquires bus lock.

+        kvm_rate_limit_on_bus_lock();
+    }
/* We need to protect the apic state against concurrent accesses from
       * different threads in case the userspace irqchip is used. */
@@ -4594,6 +4634,10 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run 
*run)
          ioapic_eoi_broadcast(run->eoi.vector);
          ret = 0;
          break;
+    case KVM_EXIT_X86_BUS_LOCK:
+        /* already handled in kvm_arch_post_run */
+        ret = 0;
+        break;
      default:
          fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason);
          ret = -1;



Reply via email to