From eugen@grosbein.net  Fri Nov 22 19:38:47 2013
Return-Path: <eugen@grosbein.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 6F3FCDC0
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Nov 2013 19:38:47 +0000 (UTC)
Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [IPv6:2a03:3100:c:13::5])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id B7D5029C1
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Nov 2013 19:38:46 +0000 (UTC)
Received: from grosbein.net (188-123-32-240.rdtc.ru [188.123.32.240] (may be forged))
	by eg.sd.rdtc.ru (8.14.7/8.14.7) with ESMTP id rAMJc8iF067947
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 23 Nov 2013 02:38:33 +0700 (NOVT)
	(envelope-from eugen@grosbein.net)
Received: from grosbein.net (localhost [127.0.0.1])
	by grosbein.net (8.14.7/8.14.7) with ESMTP id rAMJc8KI002635;
	Sat, 23 Nov 2013 02:38:08 +0700 (NOVT)
	(envelope-from eugen@grosbein.net)
Received: (from eugen@localhost)
	by grosbein.net (8.14.7/8.14.7/Submit) id rAMJc7jI002634;
	Sat, 23 Nov 2013 02:38:07 +0700 (NOVT)
	(envelope-from eugen)
Message-Id: <201311221938.rAMJc7jI002634@grosbein.net>
Date: Sat, 23 Nov 2013 02:38:07 +0700 (NOVT)
From: Eugene Grosbein <eugen@grosbein.net>
Reply-To: Eugene Grosbein <eugen@grosbein.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] [vimage] [kern] introduce new src.conf knob WITH_VIMAGE
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         184176
>Category:       kern
>Synopsis:       [patch] [vimage] introduce new src.conf knob WITH_VIMAGE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 22 19:40:02 UTC 2013
>Closed-Date:    
>Last-Modified:  Tue Mar  4 02:10:02 UTC 2014
>Originator:     Eugene Grosbein
>Release:        FreeBSD 9.2-STABLE amd64
>Organization:
RDTC JSC
>Environment:
System: FreeBSD grosbein.net 9.2-STABLE FreeBSD 9.2-STABLE #8 r256953M: Sat Nov 23 01:01:28 NOVT 2013 root@grosbein.net:/usr/obj/usr/local/src/sys/DADV amd64

>Description:
	Kernel modules ng_ether.ko and ng_gif.ko cannot be loaded
	if kernel is built with options VIMAGE and modules are built
	outside of kernel build enviroment (e.g. nanobsd & MODULES_WITH_WORLD):

# kldload ng_ether
kldload: can't load ng_ether: Exec format error
kernel: link_elf_obj: symbol ifnet undefined
kernel: linker_load_file: Unsupported file type

>How-To-Repeat:
	See above.
>Fix:

	Introduce new src.conf knob WITH_VIMAGE so modules can be built
	for such kernel and loaded successfully.

--- tools/build/options/WITH_VIMAGE.orig	2013-11-23 01:35:41.000000000 +0700
+++ tools/build/options/WITH_VIMAGE	2013-11-23 01:35:14.000000000 +0700
@@ -0,0 +1,2 @@
+.\" $FreeBSD$
+Set to build with the VIMAGE support.
--- share/mk/bsd.own.mk.orig	2013-10-21 21:02:06.000000000 +0700
+++ share/mk/bsd.own.mk	2013-11-23 02:08:02.000000000 +0700
@@ -450,7 +450,8 @@
     NMTREE \
     OFED \
     OPENSSH_NONE_CIPHER \
-    SHARED_TOOLCHAIN
+    SHARED_TOOLCHAIN \
+    VIMAGE
 
 #
 # Default behaviour of some options depends on the architecture.  Unfortunately
--- sys/modules/netgraph/ether/Makefile.orig	2013-11-23 01:22:58.000000000 +0700
+++ sys/modules/netgraph/ether/Makefile	2013-11-23 02:18:37.000000000 +0700
@@ -4,3 +4,9 @@
 SRCS= 	ng_ether.c
 
 .include <bsd.kmod.mk>
+
+.if !defined(KERNBUILDDIR)
+.if ${MK_VIMAGE} != "no"
+CFLAGS+=	-DVIMAGE
+.endif
+.endif
--- modules/netgraph/gif/Makefile.orig	2013-04-07 01:07:05.000000000 +0700
+++ modules/netgraph/gif/Makefile	2013-11-23 02:30:26.000000000 +0700
@@ -12,3 +12,9 @@
 .endif
 
 .include <bsd.kmod.mk>
+
+.if !defined(KERNBUILDDIR)
+.if ${MK_VIMAGE} != "no"
+CFLAGS+=	-DVIMAGE
+.endif
+.endif


>Release-Note:
>Audit-Trail:

From: Andriy Gapon <avg@FreeBSD.org>
To: bug-followup@FreeBSD.org, eugen@grosbein.net
Cc:  
Subject: Re: kern/184176: [patch] [vimage] [kern] introduce new src.conf knob
 WITH_VIMAGE
Date: Fri, 22 Nov 2013 22:08:56 +0200

 My humble opinion is that whenever you have to build some modules separately
 from kernel (for whatever reason), then it's better to provide KERNBUILDDIR to
 the module build.  Because you are absolutely correct that the kernel and the
 modules have to be compatible.
 -- 
 Andriy Gapon

From: Eugene Grosbein <eugen@grosbein.net>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: kern/184176: [patch] [vimage] [kern] introduce new src.conf knob
 WITH_VIMAGE
Date: Sat, 23 Nov 2013 03:02:08 +0700

 Forgot to note that tools/build/options/WITH_VIMAGE should be created also,
 containing two following lines:
 
 .\" $FreeBSD$
 Set to build with the VIMAGE support.
 
 And regenerate src.conf(5)
 

From: Eugene Grosbein <egrosbein@rdtc.ru>
To: bug-followup@FreeBSD.ORG
Cc: Andriy Gapon <avg@FreeBSD.org>, emulation@freebsd.org
Subject: Re: kern/184176: [patch] [vimage] introduce new src.conf knob WITH_VIMAGE
Date: Sat, 01 Mar 2014 22:59:22 +0700

 Hi!
 
 virtualbox-ose-4.3.6 built with virtualbox-ose-kmod-4.3.6 panices kernel
 at the moment of vboxnet initialization if kernel is built with options VIMAGE.
 
 We need WITH_VIMAGE make.conf knob at least for ports but several stock kernel modules
 like ng_ether.ko, if_gif.ko must be built with respect to VIMAGE and will benefit
 from new knob too.
 
 Please commit the patch from http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/184176
 
 Eugene Grosbein

From: Eugene Grosbein <eugen@grosbein.net>
To: bug-followup@FreeBSD.ORG
Cc: Andriy Gapon <avg@FreeBSD.org>, emulation@freebsd.org
Subject: Re: kern/184176: [patch] [vimage] introduce new src.conf knob WITH_VIMAGE
Date: Sat, 01 Mar 2014 22:59:28 +0700

 Hi!
 
 virtualbox-ose-4.3.6 built with virtualbox-ose-kmod-4.3.6 panices kernel
 at the moment of vboxnet initialization if kernel is built with options VIMAGE.
 
 We need WITH_VIMAGE make.conf knob at least for ports but several stock kernel modules
 like ng_ether.ko, if_gif.ko must be built with respect to VIMAGE and will benefit
 from new knob too.
 
 Please commit the patch from http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/184176
 
 Eugene Grosbein
>Unformatted:
