Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756603AbYFIRkY (ORCPT ); Mon, 9 Jun 2008 13:40:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753089AbYFIRkN (ORCPT ); Mon, 9 Jun 2008 13:40:13 -0400 Received: from accolon.hansenpartnership.com ([76.243.235.52]:48297 "EHLO accolon.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbYFIRkM (ORCPT ); Mon, 9 Jun 2008 13:40:12 -0400 Subject: Re: [PATCH 03/15] x86: remove early_gdt_descr reference From: James Bottomley To: Glauber Costa Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, tglx@linutronix.de, mingo@elte.hu, hugh@veritas.com In-Reply-To: <484D670C.6050203@redhat.com> References: <1213021018-14159-1-git-send-email-gcosta@redhat.com> <1213021018-14159-2-git-send-email-gcosta@redhat.com> <1213021018-14159-3-git-send-email-gcosta@redhat.com> <1213021018-14159-4-git-send-email-gcosta@redhat.com> <1213024983.3508.28.camel@localhost.localdomain> <484D5119.5020206@redhat.com> <1213032042.3508.54.camel@localhost.localdomain> <484D670C.6050203@redhat.com> Content-Type: text/plain Date: Mon, 09 Jun 2008 12:40:02 -0500 Message-Id: <1213033202.3508.60.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 (2.22.2-2.fc9) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2615 Lines: 54 On Mon, 2008-06-09 at 14:23 -0300, Glauber Costa wrote: > James Bottomley wrote: > > On Mon, 2008-06-09 at 12:49 -0300, Glauber Costa wrote: > >> James Bottomley wrote: > >>> On Mon, 2008-06-09 at 11:16 -0300, Glauber Costa wrote: > >>>> since we use switch_to_new_gdt, there is no point > >>>> in assigning early_gdt_descr except for the first > >>>> assignment, which is done manually. > >>> What makes you think you can do this? If you don't update the early > >>> boot gdt, they all end up using the Boot CPU one. The problem with this > >>> is that there's a time from start_secondary to switch_to_new_gdt where > >>> the per cpu selector (%fs) and the pda selector (%gs) are those of the > >>> boot CPU. The former isn't a problem but the CPU number is in the > >>> latter, and it's used in that path before we get to the initialisation. > >> You are right, I missed it. > >> > >> However, it only seem to be used in cpu_init, and very early. Sure there > >> are some users _before_ we load the new gdt, but nothing prevents them > >> to be moved after it. (Of course, this patch is wrong anyway). > >> > >> And if we do that, we can even take the %fs loading out of head_32.S > >> Of course, it's only valid if those are indeed the only early users of it. > >> > >> Is there any other use I'm missing? > > > > Well, %fs loading there is done for the boot CPU. To eliminate that you > > have to not only verify that start_secondary doesn't use anything in > > per_cpu areas, but also verify that nothing in start_kernel() up until > > boot_cpu_init() does ... That's a lot of smp_processor_id() references > > to convert. > Yes, after a second look, it would be tricky indeed. But only for cpu0. > For all the others, I still think we could get rid of the problem by > switching to the new gdt earlier in cpu_init. > > What do you think? Operating a CPU with a bogus GDT is very fragile. You can fix all the current issues with the secondary CPUs, but it gives a critical section within which none of the per_cpu operations will work. It only takes one patch violating this rule and we have a very subtle bug introduced. It looks to me like the better fix might be just to initialise the gdt completely and properly in do_boot_cpu and just have the single switch in head_32.S be the correct one. That way there's no problem critical region. James -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/