All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN][PATCH] x86/hvm: vlapic: fix RO bits emulation in LVTx regs
@ 2025-09-25 19:55 Grygorii Strashko
  2025-09-26  8:17 ` Jan Beulich
  0 siblings, 1 reply; 8+ messages in thread
From: Grygorii Strashko @ 2025-09-25 19:55 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Alejandro Vallejo, Jason Andryuk

From: Grygorii Strashko <grygorii_strashko@epam.com>

The LAPIC LVTx registers have two RO bits:
- all: Delivery Status (DS) bit 12
- LINT0/LINT1: Remote IRR Flag (RIR) bit 14.
  This bit is reserved for other LVTx regs with RAZ/WI access type (MMIO), while
  WRMSR (guest_wrmsr_x2apic()) has appropiate checks for reserved bits
  (MBZ access type).
and the current vLAPIC implementations allows guest to write to these RO bits.

The Delivery Status (DS) is not emulated by Xen - there is no IRQ msg bus, and
the IRQ is:
- or accepted at destination and appears as pending
  (vLAPIC Interrupt Request Register (IRR))
- or get rejected immediately.

The Remote IRR Flag (RIR) behavior emulation is not implemented for LINT0/LINT1
in Xen for now.

Hence it is definitely wrong to allow guest to write to LVTx regs RO bits,
fix it by unconditionally cleaning up those bits in vlapic_reg_write().

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
 xen/arch/x86/hvm/vlapic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 79697487ba90..78162afe7711 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -880,6 +880,7 @@ void vlapic_reg_write(struct vcpu *v, unsigned int reg, uint32_t val)
         if ( vlapic_sw_disabled(vlapic) )
             val |= APIC_LVT_MASKED;
         val &= array_access_nospec(vlapic_lvt_mask, (reg - APIC_LVTT) >> 4);
+        val &= ~(APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING);
         vlapic_set_reg(vlapic, reg, val);
         if ( reg == APIC_LVT0 )
         {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-09-26 12:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-25 19:55 [XEN][PATCH] x86/hvm: vlapic: fix RO bits emulation in LVTx regs Grygorii Strashko
2025-09-26  8:17 ` Jan Beulich
2025-09-26 10:38   ` Grygorii Strashko
2025-09-26 10:52     ` Jan Beulich
2025-09-26 11:12       ` Alejandro Vallejo
2025-09-26 12:28         ` Grygorii Strashko
2025-09-26 11:34       ` Grygorii Strashko
2025-09-26 12:00         ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.