From f77a0a6c8668626b613934196cb7803552b63864 Mon Sep 17 00:00:00 2001 From: aoyama Date: Sun, 18 Dec 2022 13:18:36 +0000 Subject: [PATCH] Do not save bootdev and boothowto when invalid value has passed. This occurs the kernel has booted from old boot loader or directly booted by command line parameter on emulator. Tested by LUNA-88K2 and nono emulator. --- sys/arch/luna88k/luna88k/locore0.S | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/arch/luna88k/luna88k/locore0.S b/sys/arch/luna88k/luna88k/locore0.S index 7bc752d24ad..a0e84242a15 100644 --- a/sys/arch/luna88k/luna88k/locore0.S +++ b/sys/arch/luna88k/luna88k/locore0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore0.S,v 1.6 2022/12/06 18:50:59 guenther Exp $ */ +/* $OpenBSD: locore0.S,v 1.7 2022/12/18 13:18:36 aoyama Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -60,6 +60,8 @@ #include "assym.h" #include "ksyms.h" +#include /* B_DEVMAGIC, B_MAGICMASK */ + #include #include #include @@ -197,11 +199,20 @@ ASLOCAL(main_init) or.u %r5, %r0, %hi16(first_addr) st %r4, %r5, %lo16(first_addr) + /* check bootdev (saved in %r24) magic number */ + or.u %r10, %r0, %hi16(B_MAGICMASK) + or %r10, %r10, %lo16(B_MAGICMASK) + and %r11, %r24, %r10 + or.u %r10, %r0, %hi16(B_DEVMAGIC) + or %r10, %r10, %lo16(B_DEVMAGIC) + cmp %r11, %r10, %r11 + bb1 ne, %r11, 1f /* no magic, skip */ + or.u %r5, %r0, %hi16(bootdev) st %r24, %r5, %lo16(bootdev) or.u %r5, %r0, %hi16(boothowto) st %r25, %r5, %lo16(boothowto) - +1: /* * Have curcpu() point to a valid cpuinfo structure, * and initialize cr17. -- 2.20.1