From nobody@FreeBSD.org  Mon Mar  8 10:54:17 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 49372106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Mar 2010 10:54:17 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 37AB88FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Mar 2010 10:54:17 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o28AsHam006106
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 8 Mar 2010 10:54:17 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o28AsGLX006093;
	Mon, 8 Mar 2010 10:54:16 GMT
	(envelope-from nobody)
Message-Id: <201003081054.o28AsGLX006093@www.freebsd.org>
Date: Mon, 8 Mar 2010 10:54:16 GMT
From: Alexei Volkov <Alexei.Volkov@softlynx.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Automatic dual kernel cd boot amd64/i386
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         144548
>Category:       conf
>Synopsis:       [boot] [patch] Enable automatic detection of amd64/i386 at boot time
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brian
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 08 11:00:11 UTC 2010
>Closed-Date:    
>Last-Modified:  Sat Jun 19 09:43:29 UTC 2010
>Originator:     Alexei Volkov
>Release:        8.0-RELEASE-p28.0-RELEASE-p2
>Organization:
SoftLynx
>Environment:
FreeBSD host.softlynx.ru 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #1: Tue Jan 26 06:30:15 UTC 2010     root@builder8-amd64.softlynx.ru:/usr/obj/usr/src/sys/SOFTLYNX  amd64

>Description:
I wood like to to get bootable cd with auto selectable amd64/i386 boot kernel, but did not find any solution in current boot facilities.

For instance, if i have a bootable cd with two kernels located /boot/kernel.amd64
and /boot/kernel.i386 accordingly it looks pretty logical to have loader.conf  line like /kernel=kernel.${hw.machine} and it let boots up amd64 kernel if long mode supported.


>How-To-Repeat:
append loader.conf with line 

kernel=kernel.${hw.machine}

andd see nothing will happend event you have kernels in a assumed path.
>Fix:
I found that the boot facilities has everything to setup the hw.machine kernel environment variable, but does't do that.

Is it right to setup hw.machine kernel variable with a patch attached?

Patch attached with submission follows:

--- /usr/src/sys/boot/i386/loader/main.c        2010-02-10 12:36:20.468937250 +0300
+++ /usr/src/sys/boot/i386/loader/main.c        2010-02-10 12:36:49.796728917 +0300
@@ -185,6 +185,11 @@
     setenv("LINES", "24", 1);                  /* optional */

     bios_getsmap();
+
+    if (bi_checkcpu())
+       setenv("hw.machine","amd64",1);
+    else
+       setenv("hw.machine","i386",1);

     interact();                        /* doesn't return */

--- /usr/src/sys/boot/i386/libi386/bootinfo64.c    2010-02-10 12:36:32.213285664 +0300
+++ /usr/src/sys/boot/i386/libi386/bootinfo64.c    2010-02-10 12:19:17.000000000 +0300
@@ -129,7 +129,7 @@
 /*
  * Check to see if this CPU supports long mode.
  */
-static int
+int
 bi_checkcpu(void)
 {
     char *cpu_vendor;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Sat Jun 19 09:38:15 UTC 2010 
Responsible-Changed-Why:  
This might be a good way to solve some problems I'll be having in 
the near future! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144548 
>Unformatted:
