Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756753AbcLQTqv (ORCPT ); Sat, 17 Dec 2016 14:46:51 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:60462 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbcLQTqt (ORCPT ); Sat, 17 Dec 2016 14:46:49 -0500 Date: Sat, 17 Dec 2016 19:46:45 +0000 From: Al Viro To: Larry Finger Cc: LKML , Vivek Goyal Subject: Re: What is the function of arch/x86/purgatory/purgatory.c? Message-ID: <20161217194645.GV1555@ZenIV.linux.org.uk> References: <4c1d06ae-cb0f-3759-fc63-2a7de0f8f553@lwfinger.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4c1d06ae-cb0f-3759-fc63-2a7de0f8f553@lwfinger.net> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1214 Lines: 34 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().