Re: [PATCH kvmtool 2/2] kvm tools: avoid printing [Firmware Bug]: CPUx: APIC id mismatch. Firmware: x APIC: x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Would you mind rewording the commit subject to:

x86: Set the correct APIC ID

On Wed, Feb 16, 2022 at 12:38:34PM +0800, Muchun Song wrote:
> When I boot kernel, the dmesg will print the following message:
  ^^^^^^^^^^^^^^^^^^

Would you mind replacing that with "When kvmtool boots a kernel, [..]"?

> 
>   [Firmware Bug]: CPU1: APIC id mismatch. Firmware: 1 APIC: 30
> 
> Fix this by setting up correct initial_apicid to cpu_id.

Thank you for fixing this. I've always wanted to fix that error, but I didn't
know enough about the x86 architecture.

> 
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> ---
>  x86/cpuid.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/x86/cpuid.c b/x86/cpuid.c
> index c3b67d9..aa213d5 100644
> --- a/x86/cpuid.c
> +++ b/x86/cpuid.c
> @@ -8,7 +8,7 @@
>  
>  #define	MAX_KVM_CPUID_ENTRIES		100
>  
> -static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
> +static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid, int cpu_id)
>  {
>  	unsigned int signature[3];
>  	unsigned int i;
> @@ -28,6 +28,8 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
>  			entry->edx = signature[2];
>  			break;
>  		case 1:
> +			entry->ebx &= ~(0xff << 24);
> +			entry->ebx |= cpu_id << 24;
>  			/* Set X86_FEATURE_HYPERVISOR */
>  			if (entry->index == 0)
>  				entry->ecx |= (1 << 31);
> @@ -80,7 +82,7 @@ void kvm_cpu__setup_cpuid(struct kvm_cpu *vcpu)
>  	if (ioctl(vcpu->kvm->sys_fd, KVM_GET_SUPPORTED_CPUID, kvm_cpuid) < 0)
>  		die_perror("KVM_GET_SUPPORTED_CPUID failed");
>  
> -	filter_cpuid(kvm_cpuid);
> +	filter_cpuid(kvm_cpuid, vcpu->cpu_id);

Tested it and it works:

Tested-by: Alexandru Elisei <alexandru.elisei@xxxxxxx>

Thanks,
Alex

>  
>  	if (ioctl(vcpu->vcpu_fd, KVM_SET_CPUID2, kvm_cpuid) < 0)
>  		die_perror("KVM_SET_CPUID2 failed");
> -- 
> 2.11.0
> 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux