public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Marcelo Tosatti <marcelo@hera.kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: linux-2.4.26 released
Date: Tue, 20 Apr 2004 16:23:12 -0700	[thread overview]
Message-ID: <20040420232312.GQ743@holomorphy.com> (raw)
In-Reply-To: <200404141314.i3EDEbxv023592@hera.kernel.org>

On Wed, Apr 14, 2004 at 06:14:37AM -0700, Marcelo Tosatti wrote:
> final:
> - 2.4.26-rc4 was released as 2.4.26 with no changes.

Spotted by Joel Becker. Lookup through raw_phys_apicid[] needs bounds
checks, otherwise the APIC ID returned may be fetched from memory
beyond the end of the array resulting in various boot-time catastrophes.
I took the liberty of slightly rearranging cpu_present_to_apicid() in
the interest of clarity and/or Documentation/CodingStyle in the process.


-- wli


diff -puN include/asm-i386/smpboot.h~smp_boot_cpus include/asm-i386/smpboot.h
--- linux-2.4.21/include/asm-i386/smpboot.h~smp_boot_cpus	2004-04-20 15:52:15.000000000 -0700
+++ linux-2.4.21-wli/include/asm-i386/smpboot.h	2004-04-20 16:00:02.000000000 -0700
@@ -73,11 +73,18 @@ extern unsigned char raw_phys_apicid[NR_
  */
 static inline int cpu_present_to_apicid(int mps_cpu)
 {
-	if (clustered_apic_mode == CLUSTERED_APIC_XAPIC)
-		return raw_phys_apicid[mps_cpu];
-	if(clustered_apic_mode == CLUSTERED_APIC_NUMAQ)
-		return (mps_cpu/4)*16 + (1<<(mps_cpu%4));
-	return mps_cpu;
+	switch (clustered_apic_mode) {
+		case CLUSTERED_APIC_XAPIC:
+			if (mps_cpu >= NR_CPUS)
+				return BAD_APICID;
+			else
+				return raw_phys_apicid[mps_cpu];
+		case CLUSTERED_APIC_NUMAQ:
+			return (mps_cpu & ~0x3) << 2 | 1 << (mps_cpu & 0x3);
+		case CLUSTERED_APIC_NONE:
+		default:
+			return mps_cpu;
+	}
 }
 
 static inline unsigned long apicid_to_phys_cpu_present(int apicid)

_

  reply	other threads:[~2004-04-20 23:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-14 13:14 linux-2.4.26 released Marcelo Tosatti
2004-04-20 23:23 ` William Lee Irwin III [this message]
2004-04-21  4:53   ` Willy Tarreau
2004-04-21  8:25     ` Axel Weiß
2004-04-21 10:12     ` William Lee Irwin III
2004-04-21 10:42       ` Willy Tarreau

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=20040420232312.GQ743@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@hera.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