On amd64 support installation with a KASLR kernel, via "custom install"

and selecting the GENERIC_KASLR kernel set.
Setup /prekern and boot.cfg accordingly.
This commit is contained in:
martin 2019-11-16 21:25:14 +00:00
parent 7ca7eecae1
commit 2f0931afd6
9 changed files with 50 additions and 11 deletions

View File

@ -1,5 +1,22 @@
/* $NetBSD: md.c,v 1.1 2014/07/26 19:30:44 dholland Exp $ */
/* $NetBSD: md.c,v 1.2 2019/11/16 21:25:14 martin Exp $ */
/* md.c -- Machine specific code for amd64 */
#include "../i386/md.c"
void amd64_md_boot_cfg_finalize(const char *path);
void
amd64_md_boot_cfg_finalize(const char *path)
{
char buf[MAXPATHLEN];
if (get_kernel_set() != SET_KERNEL_2)
return;
run_program(RUN_CHROOT|RUN_FATAL,
"sh -c 'sed -e \"s:;boot:;pkboot:\" "
"< %s > %s.1", path, path);
snprintf(buf, sizeof buf, "%s.1", path);
mv_within_target_or_die(buf, path);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.7 2019/10/02 11:16:01 maya Exp $ */
/* $NetBSD: md.h,v 1.8 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -85,6 +85,7 @@
* from floppy.
*/
#define SET_KERNEL_1_NAME "kern-GENERIC"
#define SET_KERNEL_2_NAME "kern-GENERIC_KASLR"
#define SET_KERNEL_GENERIC SET_KERNEL_1
@ -117,9 +118,13 @@ extern struct mbr_bootsel *mbs;
*/
void x86_md_part_defaults(struct pm_devs*, struct part_usage_info**,
size_t *num_usage_infos);
#define MD_PART_DEFAULTS(A,B,C) x86_md_part_defaults(A,&(B),&(C))
/* no need to install bootblock if installing for UEFI */
bool x86_md_need_bootblock(struct install_partition_desc *install);
#define MD_NEED_BOOTBLOCK(A) x86_md_need_bootblock(A)
/* post-process boot.cfg for KASLR if that kernel has been selected */
void amd64_md_boot_cfg_finalize(const char*);
#define MD_BOOT_CFG_FINALIZE(P) amd64_md_boot_cfg_finalize(P)

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.23 2019/11/16 18:08:36 martin Exp $ */
/* $NetBSD: md.c,v 1.24 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -376,6 +376,13 @@ md_post_newfs_uefi(struct install_partition_desc *install)
int
md_post_newfs(struct install_partition_desc *install)
{
#if defined(__amd64__)
int ret;
ret = cp_to_target("/usr/mdec/prekern", "/prekern");
if (ret)
return ret;
#endif
return uefi_boot ? md_post_newfs_uefi(install)
: md_post_newfs_bios(install);
@ -911,5 +918,3 @@ x86_md_need_bootblock(struct install_partition_desc *install)
return !uefi_boot;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.de,v 1.3 2019/11/16 17:53:02 martin Exp $ */
/* $NetBSD: msg.md.de,v 1.4 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -165,3 +165,4 @@ message updatembr
NetBSD Bootcodes updaten?}
message set_kernel_1 {Kernel (GENERIC)}
message set_kernel_2 {Kernel (GENERIC_KASLR)}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.en,v 1.3 2019/11/16 17:53:02 martin Exp $ */
/* $NetBSD: msg.md.en,v 1.4 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -161,3 +161,4 @@ message updatembr
the latest version of the NetBSD bootcode?}
message set_kernel_1 {Kernel (GENERIC)}
message set_kernel_2 {Kernel (GENERIC_KASLR)}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.es,v 1.3 2019/11/16 17:53:02 martin Exp $ */
/* $NetBSD: msg.md.es,v 1.4 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -162,3 +162,4 @@ message updatembr
Record a la ultima versión del código de arranque de NetBSD?}
message set_kernel_1 {Núcleo (GENERIC)}
message set_kernel_2 {Kernel (GENERIC_KASLR)}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.fr,v 1.3 2019/11/16 17:53:02 martin Exp $ */
/* $NetBSD: msg.md.fr,v 1.4 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -157,3 +157,4 @@ message updatembr
avec la dernière version du code d'amorçage de NetBSD ?}
message set_kernel_1 {Kernel (GENERIC)}
message set_kernel_2 {Kernel (GENERIC_KASLR)}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.pl,v 1.3 2019/11/16 17:53:02 martin Exp $ */
/* $NetBSD: msg.md.pl,v 1.4 2019/11/16 21:25:14 martin Exp $ */
/* Based on english version: */
/* NetBSD: msg.md.en,v 1.24 2001/01/27 07:34:39 jmc Exp */
@ -156,3 +156,4 @@ message updatembr
kodu rozruchowego NetBSD?}
message set_kernel_1 {Kernel (GENERIC)}
message set_kernel_2 {Kernel (GENERIC_KASLR)}

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.39 2019/11/16 20:26:59 martin Exp $ */
/* $NetBSD: util.c,v 1.40 2019/11/16 21:25:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -1151,9 +1151,16 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_
"> /tmp/boot.cfg.tmp'");
mv_within_target_or_die("/tmp/boot.cfg.tmp",
"/boot.cfg");
}
}
#ifdef MD_BOOT_CFG_FINALIZE
if (target_file_exists_p("/boot.cfg")) {
MD_BOOT_CFG_FINALIZE("/boot.cfg");
}
#endif
/* Save keyboard type */
save_kb_encoding();