From patchwork Sat Sep 7 02:13:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Si X-Patchwork-Id: 13794909 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16DF0171BB for ; Sat, 7 Sep 2024 02:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675214; cv=none; b=flULHVQkd+0zitlKiuVosmtV9Yx6ibIjL8whhSY6k0QzLe9LJ85gvY32+CyCjVTUF5CsMT8XVMsp3+om4TYIJ3AHR3Sdh89A8bGSvrq0E/0dTTxuMaC22g4MAVNlSOjNux6gVwKJ7DEME8wcVk3d3FM/8Cgz/DTDRAgOfe9ocQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675214; c=relaxed/simple; bh=2kzd7G/Pe4tgcXPkQ62/SfYOrC0tBK4PckC6GHZzlpQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZrFPp2wMsOJgKNgGkBbzwcwW09c62WjZO0LN0lFTGu75jxkn49m9ONBMa311WlVY8p8NvO18M/t1eo69PjHCP7FwFSZhLwwNiOkGabxWGpghGqsEOsy1uC3OaJNuFkYfTJ08+K9akY1QB1i6tRFbStdCtnC9MpGfp9ZKutnvVGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FxsjOv5B; arc=none smtp.client-ip=209.85.214.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FxsjOv5B" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-206e614953aso20068295ad.1 for ; Fri, 06 Sep 2024 19:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725675212; x=1726280012; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/E8CEOT1/HPFlUo2VocSkNU3W/VJweNzQb1pGEp2ypE=; b=FxsjOv5B+NbDML7YvFcZWk048atIWJOETSI18FTeCfcPDGVzxBSn6ZbjO7NvlUj/3S VK26MoaZR1xPqry9eyibqvkvJZ6nleo40836Rx3iUk2gRv+smXlJMWf2FAk7KWnVuZWi 8cFk622DWO8q9BPxGIQEt8wQ9TsjjyB+ykbO/Vl9IKU6MJs7J9GfDlTnog7aY3CYzjTw rBtf0OwSBohncJVr59ZfNSY+9VyzvNxjg6R9DdV4WkxCYKxGvwHoTxit9cpOpPEpTX3A gmh5XUPCXJVWH5htJxBObzK8W7phv3xW5tEVZF8qTYnkP0dY48AdEezwAPTXFchWFUHL 7CyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725675212; x=1726280012; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/E8CEOT1/HPFlUo2VocSkNU3W/VJweNzQb1pGEp2ypE=; b=nK/V+IQUAUJ6R0hMUnNvHj17nmU9q2DKkApTdTInP+ftX77fmKKmLHM80yFiWmHu5a quvT6zHOF7+a3TDxnmkjqlldzYsTFAiuVlhAoDub6G/RsQLkTGXDpBkqmYGJfHqNgII+ UbkdleZYRn+26nAHPxMX5DEY8XxUToT03x2m/tkPCc9FHnEQ3cLWD7IDW9x7ufvZncQt lluJyVYZ6HXSdYcvA+PRIivFGF7i3UNm4Rq2nELOI/iTWov8FAn1dFZv8U7CMWJW/71s 8IrV0BucWvFgmssnfOqR60nyd/GhyIMQHnXShccEyb1dkMI59/iydrXDfmTCij/WY/HI jGSw== X-Gm-Message-State: AOJu0YxpIkDDp5Dr8bGu4W8N+07ccmgALVnrJlCPtt84a/relGlbdGZw 2P+YplYIF89/GzUpFf0Y/OEUSWbSNuSQXWMRqM8nl50dYJfb9F/CMNlBnM4TCeBMNw== X-Google-Smtp-Source: AGHT+IF6i4fuIfCs7KqxVZzdo78J/2sg/wIfq1IKL+WntEwhv7G/Wbrw8ObdfxEZ0JIL08LvoE2Wxw== X-Received: by 2002:a17:902:f68e:b0:202:9b7:1dc with SMTP id d9443c01a7336-2070c1c74c7mr14217415ad.54.1725675211867; Fri, 06 Sep 2024 19:13:31 -0700 (PDT) Received: from localhost.localdomain ([14.154.195.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f20104sm1215845ad.233.2024.09.06.19.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 19:13:31 -0700 (PDT) From: Dongli Si To: kvm@vger.kernel.org Subject: [PATCH kvmtool v2 1/4] x86: Set the correct srcbusirq of pci irq mptable Date: Sat, 7 Sep 2024 10:13:18 +0800 Message-ID: <20240907021321.30222-2-sidongli1997@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240907021321.30222-1-sidongli1997@gmail.com> References: <20240907021321.30222-1-sidongli1997@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The srcbusirq should be pci device number where the interrupt originates. Fix it. Fixes: f83cd16 ("kvm tools: irq: replace the x86 irq rbtree with the PCI device tree") Signed-off-by: Dongli Si --- x86/mptable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/mptable.c b/x86/mptable.c index f13cf0f..f4753bd 100644 --- a/x86/mptable.c +++ b/x86/mptable.c @@ -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); From patchwork Sat Sep 7 02:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Si X-Patchwork-Id: 13794910 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9287BB657 for ; Sat, 7 Sep 2024 02:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675216; cv=none; b=Ax2Vzx+25Ww1Jy0eQtchCJxG6FqBB+BedR+Dz1oPQoM4E5QOIP+cBcftTHVT6mtuiaJkYqKcMB4S/5fmUcKrS1Mo0Wlh263u5dhlVZH7DH8WdDu+H6y3dAswchWpoQMEo5FWjKUujSju1JiFt6RPyQOayGKk1YZDbUgvwdS/eXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675216; c=relaxed/simple; bh=zgEzgYLSAchG5PJB2AbhaR1UbSHiMBkVsMmMzgtnIkk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aSFlTKAGndtV2KACFp9wgbhfXnbig97TkdE1pBPMFVCg1hgtJ4kSUwiPcxIUUyS3X7exSOgPVnY5wxZ8dc3/faRQttrzCN6xkn8b8LjODWJeyGGxJzBC3sGyxTPez9sk5evO1dTP5WXDFnvtU2OJPFLmEf3qYr8gTvkiGu8b8Pk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V1hksnPQ; arc=none smtp.client-ip=209.85.215.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V1hksnPQ" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-7b0c9bbddb4so1960998a12.3 for ; Fri, 06 Sep 2024 19:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725675214; x=1726280014; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fBGwH5aWbuMHbi0Io1NaVUmOBYWFUf8E5xda+muzUlU=; b=V1hksnPQWFYxOZdBmouSFQIayGWJsLdBHJ7IEGkIH9wlFclSPvvBJoqErFIO4tKuBJ R/fQT+unT3nXBpw0lxDgk7+RUkQDPcPyJ8u+wLMGwW9fTB9gibwz7QRd8oOtv3ScFMIq vUG1SL1ZxxLZryXn723sz8ZwZZZwu+uD1zh6yWdYRSVLzQB9mnYeLK3EVrQtMdyLb1go L5z9DVrMXPGY4xwhre30Y6ckfcgqCzIQU3JX8zotCJK4iJulSeXfdRsMICpIGtYth+9l TSM3n19R0XGyfTsgeB17/LFI0tdj9hUHJr33BZLz5zPGtQEuMYif5okUf90r//jdsxFd bRBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725675214; x=1726280014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fBGwH5aWbuMHbi0Io1NaVUmOBYWFUf8E5xda+muzUlU=; b=po6B19rXPCZw18KZQUcwAboNL0uYdJnFLStF9UWAl42v7Foy9rqQYVqla5Br3jlErc VISjcIZZDdgyThxEObTf2R6TAWuqDsy3GsVIfSNZM67PLlttsn/d3VCRoJjWdY8bvQw3 NB3opex+i9Lg2xaw6Zvcd+sHKwXvRKGTQVdoR/5LTVIuhP+FuNhnZ5UXU/awg0rCZ1zA duWKKkARxEcyPeXYlPUw+1gRgVX2GUE2DhW4i6lJR9H4B7Q+Q+qWNvxEme10GBrHe4Wg WzaJzVz/Cw6rwWujX/4VPPkDqPqDDWNgPLd9iauxSXmhuEMlCYRduBRs1s02zlVJXmoS 0a+Q== X-Gm-Message-State: AOJu0Yy2IkBBwzmBBrHcFR3qJBFqI14oMIfwErTMzlAbgN6AX13VDAJH yEd7xkKnSjFNXEL7jMSgVRN/igPj5++lz6Cg6iIqaEPwYvxgua+ufjz4ndXwGyoAMA== X-Google-Smtp-Source: AGHT+IHQT2uPrHRywLkhuJoHLE16hMx9eNG44SsAiV6yjVlv2a+C4PIVODDLy8PoMJZxEMEolw42mw== X-Received: by 2002:a17:903:110e:b0:207:14a8:4e9e with SMTP id d9443c01a7336-20714a84ff6mr128985ad.29.1725675213249; Fri, 06 Sep 2024 19:13:33 -0700 (PDT) Received: from localhost.localdomain ([14.154.195.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f20104sm1215845ad.233.2024.09.06.19.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 19:13:33 -0700 (PDT) From: Dongli Si To: kvm@vger.kernel.org Subject: [PATCH kvmtool v2 2/4] x86: Add the ISA IRQ entries of mptable Date: Sat, 7 Sep 2024 10:13:19 +0800 Message-ID: <20240907021321.30222-3-sidongli1997@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240907021321.30222-1-sidongli1997@gmail.com> References: <20240907021321.30222-1-sidongli1997@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Missing ISA IRQ entries will cause the guest kernel to report some warnings or errors, for examples: 1, If none of the pci devices are registered, the guest kernel will report: [ 0.022503] BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor) 2, If the guest kernel cmdline does not have the "noapic" parameter and one or more pci devices are registered, the guest kernel will report: [ 0.033913] BUG: kernel NULL pointer dereference, address: 0000000000000004 [ 0.034313] #PF: supervisor read access in kernel mode [ 0.034614] #PF: error_code(0x0000) - not-present page [ 0.034911] PGD 0 P4D 0 [ 0.035062] Oops: Oops: 0000 [#1] SMP [ 0.035277] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.10.0 #95 [ 0.035628] RIP: 0010:setup_IO_APIC+0x23e/0x7e0 [ 0.035892] Code: ff e8 16 f6 ff ff 89 45 88 e8 5e f6 ff ff 83 3d e3 93 e1 ff 00 8b 1d d9 23 f1 ff 89 85 78 ff ff ff 44 8b 25 d0 23 f1 ff 78 1b <41> 8b 76 04 8b 4d 88 41 89 d9 45 89 e0 89 c2 48 c7 c7 70 fe 8e 81 [ 0.036965] RSP: 0000:ffffffff81a03e20 EFLAGS: 00010002 [ 0.037267] RAX: 00000000ffffffff RBX: 00000000ffffffff RCX: 0000000000000001 [ 0.037681] RDX: 0000000000000001 RSI: 0000000000000001 RDI: 0000000000000000 [ 0.038092] RBP: ffffffff81a03eb0 R08: 0000000000052da5 R09: 0000000000000000 [ 0.038503] R10: ffffffff81a920c0 R11: 0000000000000000 R12: 00000000ffffffff [ 0.038918] R13: ffff88800205f628 R14: 0000000000000000 R15: 0000000000000005 [ 0.039329] FS: 0000000000000000(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000 [ 0.039798] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 0.040130] CR2: 0000000000000004 CR3: 0000000001a13000 CR4: 00000000000000b0 [ 0.040542] Call Trace: [ 0.040692] [ 0.040818] ? show_regs.part.0+0x1d/0x20 [ 0.041053] ? __die+0x52/0x91 [ 0.041234] ? page_fault_oops+0x56/0x1b0 [ 0.041469] ? exc_page_fault+0x3d9/0x5f0 [ 0.041707] ? asm_exc_page_fault+0x27/0x30 [ 0.041952] ? setup_IO_APIC+0x23e/0x7e0 [ 0.042181] ? clear_IO_APIC_pin+0x127/0x1f0 [ 0.042430] ? clear_IO_APIC+0x34/0x60 [ 0.042656] apic_intr_mode_init+0xb5/0xc0 [ 0.042896] x86_late_time_init+0x16/0x30 [ 0.043131] start_kernel+0x546/0x5b0 [ 0.043345] x86_64_start_reservations+0x29/0x30 [ 0.043619] x86_64_start_kernel+0x78/0x80 [ 0.043858] common_startup_64+0x13b/0x148 [ 0.044097] This is because there is no ISA IRQ 0 entry in the mptable which is required by the PIT. In addition, interrupts for the 8250 serial device will also be unavailable because there is also no ISA IRQ 4 entry in mptable. Solve the above problem by adding all standard ISA IRQ entries. Fixes: 0c7c14a7 ("kvm tools: Add MP tables support") Signed-off-by: Dongli Si --- x86/mptable.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/x86/mptable.c b/x86/mptable.c index f4753bd..82b692e 100644 --- a/x86/mptable.c +++ b/x86/mptable.c @@ -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) */ From patchwork Sat Sep 7 02:13:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Si X-Patchwork-Id: 13794911 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D3931798C for ; Sat, 7 Sep 2024 02:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675216; cv=none; b=MO5/SSRWiH2BX3X1yo2sDKshg1XT/xXVS7hQ9NCECe8gV9holDxQ/dYrP7uqGkGpiTXxVhmQJnX4WdvjuvYdrS0j2u46RYaUWCHb8Df3j/5aWz8xSV4fFkSoV1uppFfGKfx1nXLCn1douc2qiOBPc3ySv4Z9wA89NpQ+wQFmxLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675216; c=relaxed/simple; bh=pgzKJKQsDhk64TV0oaUIuIF03fCRU69OvK3SFvBpjJY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CbsEwIL+qpu++vl5xtDZ6dWcsDv2sq+y+vhv/lbOM58DT94rITt+NEEGWE3EooRS/jw9X7fQEOuSoUdX8NuQx3szs3ookH3LzZH0HoCTQKx0nuxqnbTbCcCjQ7NvaTXn3OvXP5mlrCi2mktrkE10hiSvk7HVWZPFHWkwgFFpGlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RU83MqBG; arc=none smtp.client-ip=209.85.214.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RU83MqBG" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-2057c6c57b5so14766955ad.1 for ; Fri, 06 Sep 2024 19:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725675215; x=1726280015; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9Ppll5og+7MZitnS1Ultyinon8CAl/ja+joa5yj6w7A=; b=RU83MqBG/0ZHPp85ZjdZkfgAwfZffa2vulIZGdwHnDS+QhLRhveypokM36F4nT2qU1 7KvKDjldlpg7ZH/uyp5+NSkMm4dpe/WdhJZZZ/yjYnOjpBig2Quy72LNC5fSCg5tfzEZ kKiVLXgaNeXjSwY0grA/AUVYGVkepBvm1MXVlVITS+w+lH0SsHisWmDALPJ5nfjdzk9q F98ar3Wu0HyCaTx1PuX1M3PC2HSpMTlvy/kQmwTlX0TMgUDwrRD41kMydmaeP0hVdTVA CQ9Fsl5anQgQLmjrmxkY62RyhJXHXm2m6JHGCfnb2mf5ikfs79rHzVln+q5b08mijXLR 6hHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725675215; x=1726280015; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Ppll5og+7MZitnS1Ultyinon8CAl/ja+joa5yj6w7A=; b=IAMCw9GhaIFo/fg3h9w9kVQP6APkwGPU7M0KclRbrRgAAmXiG4OnXV63vPBDCV+74e BYgiXDOqVdp5U+MRSgRSKtI1/BQC8jEYAMStJEHgEGzf7mF0IDBhcsgyQGZM/BoCi9/Q V494MKQiqVDU+/B0Ly/I6/RxAEZ2z6ZK69fTo+36UmsU+0BiNnwoHtvnCGSH05cM1P0Q BYtiQXjrfIBKNzZ3hVTIAA/AcH2AIwwot4XckeZecWL3W1ezFCdWLHpmJG3VzunbG/Vy 5WoJKvAtGp3hA8RDkSN2cKwifRJYE+Lbw67ApK6TBK9a2/Yty5hpp0uHZsQa49fwIlbt HCYA== X-Gm-Message-State: AOJu0YzrLUc5zpKQ/+k7dlCfl+DQpv+UkXFz67I/S+85oxNqXML7j5GJ BS6INpMHhcsz6U2EfEsnhWXrhkQvIbslp1iBMsXULkRuinO5JzkHbWSjUuv4cgunbQ== X-Google-Smtp-Source: AGHT+IFJDdU+KLw+QiLf3hkCmbQZRRBViQHuFKUXlz7OLU95cI6EBCyTFSFMtTT+yfjvY1myft0tMA== X-Received: by 2002:a17:902:ec87:b0:205:4d27:616e with SMTP id d9443c01a7336-206eeb7a94cmr65661985ad.22.1725675214519; Fri, 06 Sep 2024 19:13:34 -0700 (PDT) Received: from localhost.localdomain ([14.154.195.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f20104sm1215845ad.233.2024.09.06.19.13.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 19:13:34 -0700 (PDT) From: Dongli Si To: kvm@vger.kernel.org Subject: [PATCH kvmtool v2 3/4] x86: Remove the "noapic" kernel cmdline parameter (for enable the IO APIC) Date: Sat, 7 Sep 2024 10:13:20 +0800 Message-ID: <20240907021321.30222-4-sidongli1997@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240907021321.30222-1-sidongli1997@gmail.com> References: <20240907021321.30222-1-sidongli1997@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When 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. Signed-off-by: Dongli Si --- x86/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/kvm.c b/x86/kvm.c index 71ebb1e..e07d964 100644 --- a/x86/kvm.c +++ b/x86/kvm.c @@ -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"); From patchwork Sat Sep 7 02:13:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Si X-Patchwork-Id: 13794912 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 069ED18EA8 for ; Sat, 7 Sep 2024 02:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675218; cv=none; b=tffCQQrlxhDk/l3ezfh6RPTGMAhfLXFFAtiHW1zMlaJBjx08J8TmyO0+drYPgxwlhvsjWnGSoMTTnKfbGZcbaQW3IU0icr/zNpe5drDz/zOLIi38MK5zeDUD77TwaMa+lfNSQtS1LLP12GHNBeugzKnZ9uBsjOOIDrEdLZU4UiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725675218; c=relaxed/simple; bh=4hklxyNUlvbMhY5isYEfK16mjKhTfZdZJYUzsuumq38=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qaFnT/o4io1G46tJXgnoSuxD/hetmvriNwqBJcJvusFy/dB8kzicDSa5mSyS4jUJ7MPjJFe8BMb6/VxwBbcbzw9+qy4rZArB2MCzbR4ZDeFd0M8jEGvb9pVtZEZ6xw5KHY6Be/IU72bd35EQ5kNzMHAPucxxkTMjkdjFSf1jIsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aSmrPDgc; arc=none smtp.client-ip=209.85.210.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aSmrPDgc" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-718e3c98b5aso287013b3a.0 for ; Fri, 06 Sep 2024 19:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725675216; x=1726280016; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=gsKMTLFsabjdxtWobRt89f6wrjqfDU4EnRWT7bF37OA=; b=aSmrPDgcijaAi31wDYy1K61vTWnQRxPzvnLgxlgBWySdUN8+SayPJDWiOmgNq1vhHe /PucLAU/zln6JOYU3GNPLUCbgvsP2ql0RxRYb5SpcVJde2UTmPrSAwo32Nx7aEV2BJR0 hS2KN0YGiMAGbKtTvFIOo8nTRzwJZPZv8Q0YBq8bkohQNhO0jiVBpAjRSCzZNpji6Mu8 tcS33hupzVylP3wN5GjTzzZEE5PYeBKPsHD3hzMH7GqnpCtwytA75fnsCD8s91Ned74t 9zkMbL1b+bVjuNaHdK1XYQlwchZj47vwafLqxfopyr5iPDlSlTx5TbXhvPG8OVMPZAAe Q+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725675216; x=1726280016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gsKMTLFsabjdxtWobRt89f6wrjqfDU4EnRWT7bF37OA=; b=crGFhrVjVfI9v6JT8JN6OJwdUZId9H2quP64g7OcUm5jGPlSad0i2UkRegoTkf/c0D X0zFSw1k3iTy7P/HMP82FO4TIepNsjZ1xxQ6RO5asxT9HBr5ModpujOD+KzvDi68CrUY PNmCfv7+PjZzGwa5QivNpacqzYQaeblpbsyb0O7t1jMz9P1+VZUAkHYr009nx9N84Ezf umGItd0nZwC7P4OKVEVumuKvH/lG2wTGkUbSs4GyW3yb0K6vZYEtnwrst7MgiLMlsdI1 vr3f25459iPhsgVC5G9r6Q7rKLO18ZbOubIdWKjGxLwc0v6oC/BBnJfFi+9K7WWNfp6R 2KcA== X-Gm-Message-State: AOJu0Yzfx4Lw9OywZOA1K5mRxCBtJd9llRWMvi6ag7d/FkhFNddYINYH DuQbxj1ZLU8J7uLWjYMz8MhcaNumXw9ElLBrUx1WSU+CheDcHEtf87zEDV0IGiHj8Q== X-Google-Smtp-Source: AGHT+IHvFRAJR2mp8rl0Uoq/JcI20c+8wVopVX5QJKkPiUC0Nj9maPiR2NTc+4irpP/Nl8sq0m+2nw== X-Received: by 2002:a05:6a20:d492:b0:1cf:2aaf:6d7a with SMTP id adf61e73a8af0-1cf2aafa123mr1284006637.17.1725675215861; Fri, 06 Sep 2024 19:13:35 -0700 (PDT) Received: from localhost.localdomain ([14.154.195.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f20104sm1215845ad.233.2024.09.06.19.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 19:13:35 -0700 (PDT) From: Dongli Si To: kvm@vger.kernel.org Subject: [PATCH kvmtool v2 4/4] x86: Disable Topology Extensions on AMD processors in cpuid Date: Sat, 7 Sep 2024 10:13:21 +0800 Message-ID: <20240907021321.30222-5-sidongli1997@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240907021321.30222-1-sidongli1997@gmail.com> References: <20240907021321.30222-1-sidongli1997@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When 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. Signed-off-by: Dongli Si --- x86/cpuid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x86/cpuid.c b/x86/cpuid.c index f4347a8..fd23429 100644 --- a/x86/cpuid.c +++ b/x86/cpuid.c @@ -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;