kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kaya, Metin" <metikaya@amazon.com>
To: "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: [kvm-unit-tests PATCH 3/3] x86/ioapic: use APIC ID map instead of hard-coded CPU index
Date: Mon, 24 Jan 2022 16:19:03 +0000	[thread overview]
Message-ID: <1643041143544.37758@amazon.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

If APIC IDs are not sequential (e.g., 0, 1, 2, 3), then hard-coding the
CPU indexes will break sending IRQs to correct CPUs.

Fixes: b2a1ee7ea179 ("x86: ioapic: Test physical and logical destination mode")

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-x86-ioapic-use-APIC-ID-map-instead-of-hard-coded-CPU.patch --]
[-- Type: text/x-patch; name="0003-x86-ioapic-use-APIC-ID-map-instead-of-hard-coded-CPU.patch", Size: 1396 bytes --]

From c5c23c8761db990fa25f5adb4c13a6c760e4c0f7 Mon Sep 17 00:00:00 2001
From: Metin Kaya <metikaya@amazon.com>
Date: Mon, 24 Jan 2022 11:38:38 +0000
Subject: [PATCH 3/3] x86/ioapic: use APIC ID map instead of hard-coded CPU
 index

If APIC IDs are not sequential (e.g., 0, 1, 2, 3), then hard-coding the
CPU indexes will break sending IRQs to correct CPUs.

Fixes: b2a1ee7ea179 ("x86: ioapic: Test physical and logical destination mode")
Signed-off-by: Metin Kaya <metikaya@amazon.com>
---
 x86/ioapic.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/x86/ioapic.c b/x86/ioapic.c
index 0adf323..0d37b37 100644
--- a/x86/ioapic.c
+++ b/x86/ioapic.c
@@ -423,7 +423,7 @@ static void test_ioapic_physical_destination_mode(void)
 		.vector = 0x85,
 		.delivery_mode = 0,
 		.dest_mode = 0,
-		.dest_id = 0x1,
+		.dest_id = id_map[1],
 		.trig_mode = TRIGGER_LEVEL,
 	};
 	handle_irq(0x85, ioapic_isr_85);
@@ -451,11 +451,14 @@ static void test_ioapic_logical_destination_mode(void)
 {
 	/* Number of vcpus which are configured/set in dest_id */
 	int nr_vcpus = 3;
+	uint8_t dest_id = (1U << id_map[0]) |
+					  (1U << id_map[2]) |
+					  (1U << id_map[3]);
 	ioapic_redir_entry_t e = {
 		.vector = 0x86,
 		.delivery_mode = 0,
 		.dest_mode = 1,
-		.dest_id = 0xd,
+		.dest_id = dest_id,
 		.trig_mode = TRIGGER_LEVEL,
 	};
 	handle_irq(0x86, ioapic_isr_86);
-- 
2.32.0


                 reply	other threads:[~2022-01-24 16:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1643041143544.37758@amazon.com \
    --to=metikaya@amazon.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).