x86: Set the correct srcbusirq of pci irq mptable
PATCH 1/4 x86: Set the correct srcbusirq of pci irq mptable
The srcbusirq should be pci device number where the
interrupt originates. Fix it.
--- x86/mptable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/mptable.c +1 -1
@@ -180,7 +180,7 @@ int mptable__init(struct kvm *kvm)unsigned char srcbusirq;struct pci_device_header *pci_hdr = dev_hdr->data; - srcbusirq = (pci_hdr->subsys_id <<2 ) | (pci_hdr->irq_pin -1 ); + srcbusirq = (dev_hdr->dev_num <<2 ) | (pci_hdr->irq_pin -1 ); mpc_intsrc = last_addr;mptable_add_irq_src (mpc_intsrc, pcibusid, srcbusirq, ioapicid, pci_hdr->irq_line);
Signature · 1 line
2.44.0
PATCH 2/4 x86: Add the ISA I/O interrupt assignment entries of mptable
According to Intel MultiProcessor Specification:
"There is one entry for each I/O APIC interrupt input that is connected."
Missing this will cause the guest kernel to report some warnings or errors when enabling the io apic.
--- x86/mptable.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
x86/mptable.c +18 -3
@@ -171,10 +171,8 @@ int mptable__init(struct kvm *kvm) nentries++;/* -* IRQ sources. -* Also note we use PCI irqs here, no for ISA bus yet. +* PCI IRQ sources. */ - dev_hdr =device__first_dev (DEVICE_BUS_PCI );while (dev_hdr) {unsigned char srcbusirq;
@@ -189,6 +187,23 @@ int mptable__init(struct kvm *kvm) dev_hdr =device__next_dev (dev_hdr); } +/* +* ISA IRQ sources. +*/ +for (i =0 ; i <16 ; i++) { +if (i ==2 ) +continue ; + + mpc_intsrc = last_addr; +if (i ==0 ) +mptable_add_irq_src (mpc_intsrc, isabusid, i, ioapicid,2 ); +else +mptable_add_irq_src (mpc_intsrc, isabusid, i, ioapicid, i); + + last_addr = (void *)&mpc_intsrc[1 ]; + nentries++; + } +/* * Local IRQs assignment (LINT0, LINT1) */
Signature · 1 line
2.44.0
PATCH 3/4 x86: Remove the noapic option from the kernel command line
In reply to Dongli SiWhen running guest kernel 6.9 and later and above and the number of vCPUs is greater than 1, dmesg reports:
[ 0.009932] CPU topo: CPU limit of 1 reached. Ignoring further CPUs
Only one CPU is available at this point, solve this problem by enabling io apic.
--- x86/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/kvm.c +1 -1
@@ -130,7 +130,7 @@ void kvm__init_ram(struct kvm *kvm)/* Arch-specific commandline setup */ void kvm__arch_set_cmdline (char *cmdline,bool video) { -strcpy (cmdline,"noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 " +strcpy (cmdline,"noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 " "i8042.dumbkbd=1 i8042.nopnp=1" );if (video)strcat (cmdline," video=vesafb" );
Signature · 1 line
2.44.0
PATCH 4/4 x86: Disable Topology Extensions on AMD processors in cpuid
In reply to Dongli SiWhen running guest kernel 6.9 and later on AMD processors, dmesg reports:
[ 0.001987] [Firmware Bug]: CPU 1: APIC ID mismatch. CPUID: 0x0000 APIC: 0x0001
This is because kvmtool does not support topoext but does not tell the guest, causing the guest kernel to read the wrong Extended APIC ID.
--- x86/cpuid.c | 3 +++ 1 file changed, 3 insertions(+)
x86/cpuid.c +3 -0
@@ -56,6 +56,9 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid, int cpu_id) }break ; } +case 0x80000001 : + entry->ecx &= ~(1 <<22 ); +break ;default :/* Keep the CPUID function as -is */ break ;
Signature · 1 line
2.44.0