@samitouri / QOSamiQemu / commits / 6ef6a0f04e

whpx: i386: remove SIPI trapping

The implementation in Hyper-V works fine and the code currently present doesn't handle x2APIC correctly anyway, so remove it and use the implementation in Hyper-V. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260307181856.2209-10-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Mar 7, 2026 at 19:18 UTC 6ef6a0f04e5ea10e5c9aa31de939e5dcdfe4a58f
1 file changed -97
target/i386/whpx/whpx-all.c
-97
@@ -1692,100 +1692,6 @@ int whpx_vcpu_run(CPUState *cpu)
1692 ret = whpx_handle_halt(cpu);
1693 break;
1694
1695 - case WHvRunVpExitReasonX64ApicInitSipiTrap: {
1696 - WHV_INTERRUPT_CONTROL ipi = {0};
1697 - uint64_t icr = vcpu->exit_ctx.ApicInitSipi.ApicIcr;
1698 - uint32_t delivery_mode =
1699 - (icr & APIC_ICR_DELIV_MOD) >> APIC_ICR_DELIV_MOD_SHIFT;
1700 - int dest_shorthand =
1701 - (icr & APIC_ICR_DEST_SHORT) >> APIC_ICR_DEST_SHORT_SHIFT;
1702 - bool broadcast = false;
1703 - bool include_self = false;
1704 - uint32_t i;
1705 -
1706 - /* We only registered for INIT and SIPI exits. */
1707 - if ((delivery_mode != APIC_DM_INIT) &&
1708 - (delivery_mode != APIC_DM_SIPI)) {
1709 - error_report(
1710 - "WHPX: Unexpected APIC exit that is not a INIT or SIPI");
1711 - break;
1712 - }
1713 -
1714 - if (delivery_mode == APIC_DM_INIT) {
1715 - ipi.Type = WHvX64InterruptTypeInit;
1716 - } else {
1717 - ipi.Type = WHvX64InterruptTypeSipi;
1718 - }
1719 -
1720 - ipi.DestinationMode =
1721 - ((icr & APIC_ICR_DEST_MOD) >> APIC_ICR_DEST_MOD_SHIFT) ?
1722 - WHvX64InterruptDestinationModeLogical :
1723 - WHvX64InterruptDestinationModePhysical;
1724 -
1725 - ipi.TriggerMode =
1726 - ((icr & APIC_ICR_TRIGGER_MOD) >> APIC_ICR_TRIGGER_MOD_SHIFT) ?
1727 - WHvX64InterruptTriggerModeLevel :
1728 - WHvX64InterruptTriggerModeEdge;
1729 -
1730 - ipi.Vector = icr & APIC_VECTOR_MASK;
1731 - switch (dest_shorthand) {
1732 - /* no shorthand. Bits 56-63 contain the destination. */
1733 - case 0:
1734 - ipi.Destination = (icr >> 56) & APIC_VECTOR_MASK;
1735 - hr = whp_dispatch.WHvRequestInterrupt(whpx->partition,
1736 - &ipi, sizeof(ipi));
1737 - if (FAILED(hr)) {
1738 - error_report("WHPX: Failed to request interrupt hr=%08lx",
1739 - hr);
1740 - }
1741 -
1742 - break;
1743 -
1744 - /* self */
1745 - case 1:
1746 - include_self = true;
1747 - break;
1748 -
1749 - /* broadcast, including self */
1750 - case 2:
1751 - broadcast = true;
1752 - include_self = true;
1753 - break;
1754 -
1755 - /* broadcast, excluding self */
1756 - case 3:
1757 - broadcast = true;
1758 - break;
1759 - }
1760 -
1761 - if (!broadcast && !include_self) {
1762 - break;
1763 - }
1764 -
1765 - for (i = 0; i <= max_vcpu_index; i++) {
1766 - if (i == cpu->cpu_index && !include_self) {
1767 - continue;
1768 - }
1769 -
1770 - /*
1771 - * Assuming that APIC Ids are identity mapped since
1772 - * WHvX64RegisterApicId & WHvX64RegisterInitialApicId registers
1773 - * are not handled yet and the hypervisor doesn't allow the
1774 - * guest to modify the APIC ID.
1775 - */
1776 - ipi.Destination = i;
1777 - hr = whp_dispatch.WHvRequestInterrupt(whpx->partition,
1778 - &ipi, sizeof(ipi));
1779 - if (FAILED(hr)) {
1780 - error_report(
1781 - "WHPX: Failed to request SIPI for %d, hr=%08lx",
1782 - i, hr);
1783 - }
1784 - }
1785 -
1786 - break;
1787 - }
1788 -
1695 case WHvRunVpExitReasonCanceled:
1696 if (exclusive_step_mode != WHPX_STEP_NONE) {
1697 /*
@@ -2249,9 +2155,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2155 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
2156 prop.ExtendedVmExits.X64MsrExit = 1;
2157 prop.ExtendedVmExits.ExceptionExit = 1;
2252 - if (whpx_irqchip_in_kernel()) {
2253 - prop.ExtendedVmExits.X64ApicInitSipiExitTrap = 1;
2254 - }
2158
2159 hr = whp_dispatch.WHvSetPartitionProperty(
2160 whpx->partition,