From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754718AbbCIQm5 (ORCPT ); Mon, 9 Mar 2015 12:42:57 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:43650 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753688AbbCIQmz (ORCPT ); Mon, 9 Mar 2015 12:42:55 -0400 Date: Mon, 9 Mar 2015 17:42:50 +0100 From: Ingo Molnar To: Denys Vlasenko Cc: Andy Lutomirski , Fengguang Wu , X86 ML , Linus Torvalds , LKP , "linux-kernel@vger.kernel.org" Subject: Re: [x86/asm/entry] BUG: unable to handle kernel paging request Message-ID: <20150309164249.GA24910@gmail.com> References: <20150306233033.GA3556@wfg-t540p.sh.intel.com> <20150309114618.GA18686@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Denys Vlasenko wrote: > On Mon, Mar 9, 2015 at 12:46 PM, Ingo Molnar wrote: > > > > * Andy Lutomirski wrote: > > > >> >> */ > >> >> unsigned long stack[64]; > >> >> > >> >> Last I checked, 0x100 != 64. Also, wow, this is kind of disgusting. :) > >> > > >> > > >> > Seems to be unused: I commented it out on "defconfig" build > >> > and got no build errors. > >> > >> It's used. On 32-bit, NMIs don't use task gates (I don't know why), > > > > So task gates were a sexy hardware acceleration feature, eons ago, and > > we used to rely on them a lot, > > IIRC task gates weren't used in Linux at first, [...] AFAIK task gates were used to demo i386 context switching between tasks, a certain famous ABABABAB... pair of tasks printing to the console :-) So task gates were used for context switching in Linux before it was called Linux! :-) Check out the first released version: https://www.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz It already does: /* * switch_to(n) should switch tasks to task nr n, first * checking that n isn't the current task, in which case it does nothing. * This also clears the TS-flag if the task we switched to has used * tha math co-processor latest. */ #define switch_to(n) {\ struct {long a,b;} __tmp; \ __asm__("cmpl %%ecx,_current\n\t" \ "je 1f\n\t" \ "xchgl %%ecx,_current\n\t" \ "movw %%dx,%1\n\t" \ "ljmp %0\n\t" \ "cmpl %%ecx,%2\n\t" \ "jne 1f\n\t" \ "clts\n" \ "1:" \ ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ "m" (last_task_used_math),"d" _TSS(n),"c" ((long) task[n])); \ } That LJMP is the TSS switch. And in kernel/sched.c we did: void sched_init(void) { int i; struct desc_struct * p; set_tss_desc(gdt+FIRST_TSS_ENTRY,&(init_task.task.tss)); :-) Thanks, Ingo