NetBSD Problem Report #51919

From paul@whooppee.com  Thu Jan 26 04:38:52 2017
Return-Path: <paul@whooppee.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 8A7407A26D
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 26 Jan 2017 04:38:52 +0000 (UTC)
Message-Id: <20170126043849.BAEF416E62@speedy.whooppee.com>
Date: Thu, 26 Jan 2017 12:38:49 +0800 (PHT)
From: paul@whooppee.com
Reply-To: paul@whooppee.com
To: gnats-bugs@NetBSD.org
Subject: boot-loader doesn't differentiate XEN and PAE module versions
X-Send-Pr-Version: 3.95

>Number:         51919
>Category:       port-amd64
>Synopsis:       boot-loader doesn't differentiate XEN and PAE module version
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 26 04:40:00 +0000 2017
>Last-Modified:  Thu Jan 26 08:15:01 +0000 2017
>Originator:     Paul Goyette
>Release:        NetBSD 7.99.53
>Organization:
+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+
>Environment:


System: NetBSD speedy.whooppee.com 7.99.53 NetBSD 7.99.53 (SPEEDY 2016-12-31 23:00:24) #1: Sun Jan 1 01:39:34 UTC 2017 paul@speedy.whooppee.com:/build/netbsd-local/obj/amd64/sys/arch/amd64/compile/SPEEDY amd64
Architecture: x86_64
Machine: amd64
>Description:
(Note that although this is filed in the port-amd64 category, it applies
equally to port-i386.)

During normal operation, the default path from which modules are loaded
varies (for x86_64 platforms) depending on whether the kernel is a XEN
or PAE kernel.

However, for modules that are loaded by the boot loader itself (as a
result of being listed in /boot.cfg) and "pushed" to the kernel, no such
distinction is made.  Thus, modules pushed to XEN or PAE kernels would
hve an incorrect ABI, and all sorts of bad stuff can happen.


>How-To-Repeat:
Install a XEN kernel, add a 'load=<module>' command to /boot.cfg (specify
a module that is not already built-in to the kernel), and reboot.  The
non-XEN version of the module will be pushed into the kernel.

>Fix:
In file sys/arch/i386/stand/lib/exec.c differentiate between XEN, PAE, and
"normal" kernels, similar to what is done in sys/arch/x86/x86/x86_machdep.c
(where module_machine is conditionally defined before its use in
routine module_init() in sys/kern/kern_module.c


>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-amd64/51919: boot-loader doesn't differentiate XEN and PAE
 module versions
Date: Thu, 26 Jan 2017 06:33:13 +0100

 I wonder if it would be better/simpler to add a boot.cfg option to override
 machine here (and while there, also the module path as discussed before
 elsewhere ;-})

 The DomU kernels have a special section marking them:

   [17] __xen_guest       PROGBITS        00000000 433db2 0000c3 00      0   0  1

 and Dom0 seem to have:

   [18] .note.Xen         NOTE             0000000000000000  00cc2ec8

 but I don't know if both are required or the bootloader can rely on them
 to differentiate the two cases.

 Martin

From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, port-amd64-maintainer@netbsd.org,
        gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, paul@whooppee.com
Cc: 
Subject: Re: port-amd64/51919: boot-loader doesn't differentiate XEN and PAE module versions
Date: Wed, 25 Jan 2017 22:19:01 -0800

 On Jan 26,  5:35am, Martin Husemann wrote:
 }
 } The following reply was made to PR port-amd64/51919; it has been noted by GNATS.
 } 
 } From: Martin Husemann <martin@duskware.de>
 }  module versions
 } Date: Thu, 26 Jan 2017 06:33:13 +0100
 } 
 }  I wonder if it would be better/simpler to add a boot.cfg option to override
 }  machine here (and while there, also the module path as discussed before

      Possibly.

 }  elsewhere ;-})
 }  
 }  The DomU kernels have a special section marking them:

      DomU kernels are loaded by Xen itself, the boot loader isn't
 involved at all.

 }  and Dom0 seem to have:
 }  
 }    [18] .note.Xen         NOTE             0000000000000000  00cc2ec8

      Do you know how to read these notes or at least check for
 their existance from the bootloader?  Also, the Dom0 kernel has to
 be loaded using the multiboot protocol and I don't think we have
 support for boot time loading of modules when using the multiboot
 protocol.

 }  but I don't know if both are required or the bootloader can rely on them
 }  to differentiate the two cases.
 }  
 }-- End of excerpt from Martin Husemann

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-amd64/51919: boot-loader doesn't differentiate XEN and PAE
 module versions
Date: Thu, 26 Jan 2017 08:57:31 +0100

 On Thu, Jan 26, 2017 at 06:05:01AM +0000, John Nemeth wrote:
 >       DomU kernels are loaded by Xen itself, the boot loader isn't
 >  involved at all.
 [..]
 >       Do you know how to read these notes or at least check for
 >  their existance from the bootloader?  Also, the Dom0 kernel has to
 >  be loaded using the multiboot protocol and I don't think we have
 >  support for boot time loading of modules when using the multiboot
 >  protocol.

 In that case there seems to be no point in this PR, or am I missing something?

 Martin

From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@NetBSD.org
Cc: port-amd64-maintainer@netbsd.org, gnats-admin@netbsd.org, 
    netbsd-bugs@netbsd.org
Subject: Re: port-amd64/51919: boot-loader doesn't differentiate XEN and PAE
 module versions
Date: Thu, 26 Jan 2017 16:12:11 +0800 (PHT)

 On Thu, 26 Jan 2017, Martin Husemann wrote:

 > >  ...                                 Also, the Dom0 kernel has to
 > >  be loaded using the multiboot protocol and I don't think we have
 > >  support for boot time loading of modules when using the multiboot
 > >  protocol.
 >
 > In that case there seems to be no point in this PR, or am I missing
 > something?

 Perhaps no point for XEN kernels.

 But do we need to be concerned about i386/PAE kernels?


 If not, please feel free to close the PR.



 +------------------+--------------------------+------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 +------------------+--------------------------+------------------------+

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.