Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able to self relocate, we can tell it needs a kernel built with the SELFRELOC option. This keeps the reader from wondering what could make a kernel able to self relocate.
This commit is contained in:
parent
ef3bc782c6
commit
9754ab85fc
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: options.4,v 1.523 2022/08/28 14:29:05 riastradh Exp $
|
||||
.\" $NetBSD: options.4,v 1.524 2023/05/05 00:34:41 manu Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996
|
||||
.\" Perry E. Metzger. All rights reserved.
|
||||
|
@ -1307,6 +1307,14 @@ See
|
|||
and
|
||||
.Xr vnconfig 8
|
||||
for more information.
|
||||
.It Cd options SELFRELOC
|
||||
Make the kernel able to self relocate at bootstrap, so that it can
|
||||
run whatever its load address is.
|
||||
This is intented to be used withe the
|
||||
.Ic reloc
|
||||
boostrap command documented in
|
||||
.Xr x86/boot 8 ,
|
||||
to workaround UEFI bugs, and is only available on amd64.
|
||||
.It Cd options SPLDEBUG
|
||||
Help the kernel programmer find bugs related to the interrupt priority
|
||||
level.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: boot.8,v 1.27 2023/04/24 13:55:45 manu Exp $
|
||||
.\" $NetBSD: boot.8,v 1.28 2023/05/05 00:34:40 manu Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -655,8 +655,10 @@ Reboot the system.
|
|||
.It Ic reloc Op Va default No \(or Va none No \(or Va address
|
||||
[Only UEFI boot] Sets where the kernel is copied by bootstrap
|
||||
before it is started. Values other than default require a kernel
|
||||
that can relocate itself at the right address, otherwise a crash
|
||||
occurs at boot time.
|
||||
built with the
|
||||
.Cd SELFRELOC
|
||||
option, so that can relocate itself at the right address,
|
||||
otherwise a crash occurs at boot time.
|
||||
.Bl -tag -width default
|
||||
.It Va default
|
||||
Copy the kernel at ELF header load address, this is the historical
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: locore.S,v 1.219 2023/04/20 00:42:23 manu Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.220 2023/05/05 00:34:41 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright-o-rama!
|
||||
|
@ -156,6 +156,7 @@
|
|||
#include "opt_ddbparam.h"
|
||||
#include "opt_modular.h"
|
||||
#include "opt_realmem.h"
|
||||
#include "opt_selfreloc.h"
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_compat_netbsd32.h"
|
||||
|
@ -456,6 +457,7 @@ ENTRY(start)
|
|||
#ifndef XENPV
|
||||
.code32
|
||||
|
||||
#ifdef SELFRELOC
|
||||
call next
|
||||
next: pop %edi
|
||||
sub $(next - kernel_text), %edi
|
||||
|
@ -463,6 +465,7 @@ next: pop %edi
|
|||
/* If not KERNBASE, reloc ourselves to KERNBASE */
|
||||
cmpl $(KERNTEXTOFF_LO - KERNBASE_LO), %edi
|
||||
jne selfreloc_start
|
||||
#endif /* SELFRELOC */
|
||||
|
||||
/* Warm boot */
|
||||
movw $0x1234,0x472
|
||||
|
@ -1766,6 +1769,7 @@ LABEL(nomds_leave)
|
|||
NOMDS_LEAVE
|
||||
LABEL(nomds_leave_end)
|
||||
|
||||
#ifdef SELFRELOC
|
||||
/*
|
||||
* selfreloc(loadddr edi)
|
||||
* This is adapted from sys/arch/i386/i386/locore.S
|
||||
|
@ -1900,3 +1904,4 @@ gdtr:
|
|||
gdtrr:
|
||||
.quad
|
||||
END(selfreloc_start)
|
||||
#endif /* SELFRELOC */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.amd64,v 1.120 2020/10/21 13:31:51 christos Exp $
|
||||
# $NetBSD: files.amd64,v 1.121 2023/05/05 00:34:41 manu Exp $
|
||||
#
|
||||
# new style config file for amd64 architecture
|
||||
#
|
||||
|
@ -20,6 +20,9 @@ defparam opt_physmem.h PHYSMEM_MAX_ADDR PHYSMEM_MAX_SIZE
|
|||
# Enable GCC spectre V2 mitigation options
|
||||
defflag opt_spectre.h SPECTRE_V2_GCC_MITIGATION
|
||||
|
||||
# Enable kernel self-relocation at bootstrap
|
||||
defflag opt_selfreloc.h SELFRELOC
|
||||
|
||||
#
|
||||
# XXX these are just here at the moment so that we can share files
|
||||
# with the i386 (they include the opt_*.h for these)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: std.amd64,v 1.12 2020/04/25 15:26:16 bouyer Exp $
|
||||
# $NetBSD: std.amd64,v 1.13 2023/05/05 00:34:41 manu Exp $
|
||||
#
|
||||
# standard, required NetBSD/amd64 'options'
|
||||
|
||||
|
@ -15,6 +15,8 @@ options MULTIPROCESSOR
|
|||
options CHILD_MAX=1024 # 160 is too few
|
||||
options OPEN_MAX=1024 # 128 is too few
|
||||
|
||||
options SELFRELOC
|
||||
|
||||
mainbus0 at root
|
||||
cpu* at mainbus?
|
||||
ioapic* at mainbus? apid ?
|
||||
|
|
Loading…
Reference in New Issue