[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <61e66ef579a86deb453bb25febd30f5aec7472fc.camel@intel.com>
Date: Thu, 16 Jan 2025 11:55:23 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kvm@...r.kernel.org" <kvm@...r.kernel.org>, "pbonzini@...hat.com"
<pbonzini@...hat.com>, "seanjc@...gle.com" <seanjc@...gle.com>,
"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>
CC: "Gao, Chao" <chao.gao@...el.com>, "Edgecombe, Rick P"
<rick.p.edgecombe@...el.com>, "Li, Xiaoyao" <xiaoyao.li@...el.com>, "Chatre,
Reinette" <reinette.chatre@...el.com>, "Zhao, Yan Y" <yan.y.zhao@...el.com>,
"Hunter, Adrian" <adrian.hunter@...el.com>, "tony.lindgren@...ux.intel.com"
<tony.lindgren@...ux.intel.com>, "Yamahata, Isaku"
<isaku.yamahata@...el.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 12/16] KVM: TDX: Inhibit APICv for TDX guest
On Mon, 2025-01-13 at 10:09 +0800, Binbin Wu wrote:
> Lazy check for pending APIC EOI when In-kernel IOAPIC
> -----------------------------------------------------
> In-kernel IOAPIC does not receive EOI with AMD SVM AVIC since the processor
> accelerates write to APIC EOI register and does not trap if the interrupt
> is edge-triggered. So there is a workaround by lazy check for pending APIC
> EOI at the time when setting new IOAPIC irq, and update IOAPIC EOI if no
> pending APIC EOI.
> KVM is also not be able to intercept EOI for TDX guests.
> - When APICv is enabled
> The code of lazy check for pending APIC EOI doesn't work for TDX because
> KVM can't get the status of real IRR and ISR, and the values are 0s in
> vIRR and vISR in apic->regs[], kvm_apic_pending_eoi() will always return
> false. So the RTC pending EOI will always be cleared when ioapic_set_irq()
> is called for RTC. Then userspace may miss the coalesced RTC interrupts.
> - When When APICv is disabled
> ioapic_lazy_update_eoi() will not be called,then pending EOI status for
> RTC will not be cleared after setting and this will mislead userspace to
> see coalesced RTC interrupts.
> Options:
> - Force irqchip split for TDX guests to eliminate the use of in-kernel IOAPIC.
> - Leave it as it is, but the use of RTC may not be accurate.
Looking at the code, it seems KVM only traps EOI for level-triggered interrupt
for in-kernel IOAPIC chip, but IIUC IOAPIC in userspace also needs to be told
upon EOI for level-triggered interrupt. I don't know how does KVM works with
userspace IOAPIC w/o trapping EOI for level-triggered interrupt, but "force
irqchip split for TDX guest" seems not right.
I think the problem is level-triggered interrupt, so I think another option is
to reject level-triggered interrupt for TDX guest.
Powered by blists - more mailing lists