Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758260AbcLQT4l (ORCPT ); Sat, 17 Dec 2016 14:56:41 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:36159 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754212AbcLQT4j (ORCPT ); Sat, 17 Dec 2016 14:56:39 -0500 Subject: Re: What is the function of arch/x86/purgatory/purgatory.c? To: Al Viro References: <4c1d06ae-cb0f-3759-fc63-2a7de0f8f553@lwfinger.net> <20161217194645.GV1555@ZenIV.linux.org.uk> Cc: LKML , Vivek Goyal From: Larry Finger Message-ID: Date: Sat, 17 Dec 2016 13:56:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161217194645.GV1555@ZenIV.linux.org.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1346 Lines: 39 On 12/17/2016 01:46 PM, Al Viro wrote: > On Sat, Dec 17, 2016 at 11:52:05AM -0600, Larry Finger wrote: > >> Upon examination of the routine, I can see that if purgatory() should be >> static, then none of the code here will ever be accessed by any part of the >> kernel. Is there some bit of magic that is above my understanding, or is >> this a useless bit of code that has been forgotten and should be removed? > > I don't know what is and what is not above your understanding, but grepping > in that area (grep -w purgatory arch/x86/purgatory/*) does catch this: > arch/x86/purgatory/setup-x86_64.S: call purgatory > which is hardly magic - looks like a function call. Looking into that > file shows > purgatory_start: > .code64 > > /* Load a gdt so I know what the segment registers are */ > lgdt gdt(%rip) > > /* load the data segments */ > movl $0x18, %eax /* data segment */ > movl %eax, %ds > movl %eax, %es > movl %eax, %ss > movl %eax, %fs > movl %eax, %gs > > /* Setup a stack */ > leaq lstack_end(%rip), %rsp > > /* Call the C code */ > call purgatory > jmp entry64 > > which pretty much confirms that - it's called from purgatory_start(). Thanks for the explanation. Larry