Project

General

Profile

Bug #8643

Fix misuse of _KMEMUSER in i86pc

Added by Gordon Ross about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
kernel
Start date:
2017-09-08
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

There was some discussion of this on the developers list. See the subject:
Request 417: 8007 uts: sysmacros.h should allow offsetof for early boot

Basically, some time (long ago) someone apparently hacked their way around
some kind of symbol exposure problem by adding -D_KMEMUSER in places that
really are not what that define was meant for, which is:
User-level code that needs to compile with some structures (etc.)
that would otherwise only be exposed when building kernel components.

Kernel components normally build with -D_KERNEL so in headers,
when defining structures etc, those are often inside an:

 #if defined(_KERNEL) || defined(_KMEMUSRER)

On the other hand, function prototypes etc. normall are in just:

 #if defined(_KERNEL)

Also relevant to this is "stand-alone" boot programs, which also
use many of the system heders with -D_BOOT which works similarly
to -D_KERNEL but may expose a different subset of things.

For that reason, many system headers have #if conditionals like:

 #if defined(_KERNEL) || defined(_KMEMUSRER) || defined(_BOOT)

Anyway, that's the normal purpose of all those defines.

The uts/i86pc code uses -D_KMEMUSER (apparently) to
work around some problems with missing symbols,
probably in sys/param.h and sys/cpuvar.h that
mostly affect the dboot code. If we add _BOOT to some
of those #if conditions, we can remove _KMEMUSER
from the i86pc Makefile.rules Seems more correct.

History

#1

Updated by Gordon Ross about 2 years ago

#2

Updated by Electric Monk about 2 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 3c4c5929f4f5a266089758e0d018685b379767ad

commit  3c4c5929f4f5a266089758e0d018685b379767ad
Author: Gordon Ross <gwr@nexenta.com>
Date:   2017-09-22T22:46:01.000Z

    8643 Fix misuse of _KMEMUSER in i86pc
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: Igor Kozhukhov <igor@dilos.org>
    Approved by: Garrett D'Amore <garrett@damore.org>

Also available in: Atom PDF