Skip to contentSkip to conversation

KVM: x86: Do not change ICR on write to APIC_SELF_IPI

PATCH In review Paolo Bonzini 3 participants 3 messages Feb 24, 2022 – Oct 23

Subsystems (3)
lore
Share & tools
lore

Paolo Bonzini

author maintainer
#0 lore raw

PATCH 1/1 KVM: x86: Do not change ICR on write to APIC_SELF_IPI

Emulating writes to SELF_IPI with a write to ICR has an unwanted side effect:
the value of ICR in vAPIC page gets changed. The lists SELF_IPI as write-only, with no associated MMIO offset, so any write should have no visible side effect in the vAPIC page.

---
 arch/x86/kvm/lapic.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kvm/lapic.c +3 -4
index ad8857359ad6..d5a33b6be7d5 100644
@@ -2120,10 +2120,9 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
 		break;
 
 	case APIC_SELF_IPI:
-		if (apic_x2apic_mode(apic)) {
-			kvm_lapic_reg_write(apic, APIC_ICR,
-					    APIC_DEST_SELF | (val & APIC_VECTOR_MASK));
-		} else
+		if (apic_x2apic_mode(apic))
+			kvm_apic_send_ipi(apic, APIC_DEST_SELF | (val & APIC_VECTOR_MASK), 0);
+		else
 			ret = 1;
 		break;
 	default:
Signature · 1 line
2.31.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Paolo Bonzini

Emulating writes to SELF_IPI with a write to ICR has an unwanted side effect:
the value of ICR in vAPIC page gets changed. The lists SELF_IPI as write-only,

                                                   ^
						   |- SDM
Quoted 6 lines

with no associated MMIO offset, so any write should have no visible side effect in the vAPIC page.

---

#2 lore raw
Quoted 6 lines · Paolo Bonzini
Quoted 5 lines

Emulating writes to SELF_IPI with a write to ICR has an unwanted side
effect: the value of ICR in vAPIC page gets changed. The lists
SELF_IPI as write-only, ^

					         |- SDM
Quoted 6 lines
Quoted 4 lines

with no associated MMIO offset, so any write should have no visible side effect in the vAPIC page. Reported-by: Chao Gao <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> ---

This patch was just attempted to be ported to Xen.

Contrary to the claim, Intel Core (P-cores) really do overwrite ICR when processing SELF_IPI.

~Andrew