Home | History | Annotate | Download | only in netbsd32
History log of /src/sys/compat/netbsd32/netbsd32_sysctl.c
RevisionDateAuthorComments
 1.45  19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.44  21-Mar-2020  pgoyette branches: 1.44.4;
Restore code to sysctl_free() the compat32 shadow tree
 1.43  17-Mar-2020  pgoyette Remove a debug printf() that accidentally got committed. :(
 1.42  15-Mar-2020  pgoyette Use SYSCTL_SETUP mechanism to establish our sysctl tree, rather than
using explicit calls to netbsd32_sysctl_{init,fini}()
 1.41  02-Jan-2020  thorpej - Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.40  26-May-2018  kamil branches: 1.40.2;
Fix sysctl(3):vm.minaddress in compat_netbsd32(8)

Cast minaddress from LP64-specific long (64-bit) to 32-bit long (int).

This value is usually 0 or 0+PAGE_SIZE. There is need to change type in
order to keep original code functional, without prompting the value with
'long long' or a similar approach.


There are more CTLTYPE_LONG with a need for fixes in the compat code:

uipc_usrreq.c
1975 CTLTYPE_LONG, "sendspace",
1981 CTLTYPE_LONG, "recvspace",
1987 CTLTYPE_LONG, "sendspace",
1993 CTLTYPE_LONG, "recvspace",
vfs_bio.c
1921 CTLTYPE_LONG, "bufmem",
1928 CTLTYPE_LONG, "bufmem_lowater",
1935 CTLTYPE_LONG, "bufmem_hiwater",

Sponsored by <The NetBSD Foundation>
 1.39  26-May-2018  kamil Handle vm.maxaddress in compat_netbsd32(8)

Return VM_MAXUSER_ADDRESS32 instead of the 64-bit specific address.

Use CTLTYPE_INT instead of CTLTYPE_LONG in order to retain the same integer
type between 64-bit native kernel and 32-bit emulated program.

There probably should be CTLTYPE_LONG32 available for this purpose.

On NetBSD/i386:
vm.maxaddress=bfeff000

On NetBSD/amd64:
vm.maxaddress=7fbfdfeff000

On NetBSD/amd64 running i386 program:
vm.maxaddress=fffff000

A 32-bit program on the 64-bit kernel can use larger user space, this
difference is on purpose and expected.

Sponsored by <The NetBSD Foundation>
 1.38  31-Oct-2017  kre branches: 1.38.2;

unconst machine_arch32 for sysctl data .. pointed out by Riccardo Mottola
 1.37  31-Oct-2017  martin Allow architectures to define a macro PROC_MACHINE_ARCH(P) and
PROC_MACHINE_ARCH32(P) to override the value for sysctl hw.machine_arch
(native and netbsd32 commpat resp.).

Use these for arm and mips instead of the (not working, noisy, in case
of arm) sysctl override and #ifdef __mips__ in architecture neutral
code.
 1.36  17-May-2015  matt machine_arch on mips depends on the ABI so we need a routine to return
the right value.
 1.35  13-Jun-2014  joerg branches: 1.35.4;
Rename stack gap arguments.
 1.34  16-May-2014  martin Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.33  20-Jan-2012  joerg branches: 1.33.6; 1.33.10; 1.33.20;
Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.32  23-May-2011  joerg branches: 1.32.4; 1.32.8;
Use __UNCONST to get rid of const
 1.31  23-Apr-2010  rmind branches: 1.31.2;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.30  11-Jan-2009  christos branches: 1.30.4; 1.30.6;
merge christos-time_t
 1.29  19-Nov-2008  ad branches: 1.29.4;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.28  07-Jan-2008  ad branches: 1.28.6; 1.28.10; 1.28.12; 1.28.16; 1.28.18;
Patch up sysctl locking:

- Lock processes, credentials, filehead etc correctly.
- Acquire a read hold on sysctl_treelock if only doing a query.
- Don't wire down the output buffer. It doesn't work correctly and the code
regularly does long term sleeps with it held - it's not worth it.
- Don't hold locks other than sysctl_lock while doing copyout().
- Drop sysctl_lock while doing copyout / allocating memory in a few places.
- Don't take kernel_lock for sysctl.
- Fix a number of bugs spotted along the way
 1.27  20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.26  08-Dec-2007  dsl branches: 1.26.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.25  15-Aug-2007  ad branches: 1.25.2; 1.25.8; 1.25.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.24  18-Mar-2007  dsl branches: 1.24.4; 1.24.8;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.23  09-Feb-2007  ad branches: 1.23.2; 1.23.6; 1.23.8; 1.23.10;
Merge newlock2 to head.
 1.22  23-Sep-2006  manu Add sysctl tracing to emulations.
While we are there, fix a bug in FreeBSD sysctl emulation: use copyin for
moving data to the kernel
 1.21  11-Dec-2005  christos branches: 1.21.20; 1.21.22;
merge ktrace-lwp.
 1.20  19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.19  03-Jul-2005  cube branches: 1.19.2;
Constify machine32 and machine_arch32.
 1.18  03-Jul-2005  cube Make COMPAT_NETBSD32 emulate hw.machine. While it might seem wrong to do
so, it introduces breakage because a lot of applications make assumptions
from its value. It's especially bad in the sparc64 case, where 64-bits
instructions can be used in 32-bits addressing mode. However, there are
other means to know the capabilities of the CPU.
 1.17  22-Jun-2005  atatat Also fix (wrt the new const stuff) the one user of sysctl_locate()
outside of the main sysctl code.
 1.16  20-Jun-2005  atatat Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.15  27-Apr-2004  atatat Be consistent about using sysc_init_field()
 1.14  24-Mar-2004  atatat branches: 1.14.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.13  09-Mar-2004  atatat I obviously put this (__SYSCTL_PRIVATE) here, but I have no
recollection of what it was for and it's now just useless, so it goes.
 1.12  04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.11  21-Oct-2003  fvdl Fix some int vs. NULL comparisons.
 1.10  29-Jun-2003  fvdl branches: 1.10.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.9  29-Jun-2003  martin struct proc * -> struct lwp *
 1.8  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.7  23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.6  14-Jun-2002  eeh Provide the correct architecture for HW_MACHINE_ARCH so things like
"sysctl -p" can tell they are in 32-bit land.
 1.5  14-Feb-2002  chs branches: 1.5.4; 1.5.8; 1.5.10;
allow writing to write-only mappings. fixes PR 3493.
 1.4  13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.3  30-May-2001  mrg branches: 1.3.2;
use _KERNEL_OPT.
 1.2  15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.1  08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.8  11-Nov-2002  nathanw Catch up to -current
 1.1.4.7  23-Aug-2002  petrov lwpification.
 1.1.4.6  20-Jun-2002  nathanw Catch up to -current.
 1.1.4.5  29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.4  28-Feb-2002  nathanw Catch up to -current.
 1.1.4.3  14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2  21-Jun-2001  nathanw Catch up to -current.
 1.1.4.1  09-Apr-2001  nathanw Catch up with -current.
 1.1.2.3  27-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2  11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1  08-Feb-2001  bouyer file netbsd32_sysctl.c was added on branch thorpej_scsipi on 2001-02-11 19:14:21 +0000
 1.3.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2  16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.10.1  15-Jun-2002  lukem Pull up revision 1.6 (requested by eeh in ticket #275):
Provide the correct architecture for HW_MACHINE_ARCH so things like
"sysctl -p" can tell they are in 32-bit land.
 1.5.8.1  20-Jun-2002  gehenna catch up with -current.
 1.5.4.1  11-Mar-2002  thorpej Convert sysctl_memlock to an adaptive mutex.
 1.10.2.4  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1  03-Aug-2004  skrll Sync with HEAD
 1.14.2.1  29-Apr-2004  jmc Pullup rev 1.15 (requested by atatat in ticket #206)

Be consistent about using sysc_init_field()
 1.19.2.5  21-Jan-2008  yamt sync with head
 1.19.2.4  03-Sep-2007  yamt sync with head.
 1.19.2.3  26-Feb-2007  yamt sync with head.
 1.19.2.2  30-Dec-2006  yamt sync with head.
 1.19.2.1  21-Jun-2006  yamt sync with head.
 1.21.22.1  22-Oct-2006  yamt sync with head
 1.21.20.2  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.21.20.1  18-Nov-2006  ad Sync with head.
 1.23.10.1  29-Mar-2007  reinoud Pullup to -current
 1.23.8.1  11-Jul-2007  mjf Sync with head.
 1.23.6.2  20-Aug-2007  ad Sync with HEAD.
 1.23.6.1  10-Apr-2007  ad Sync with head.
 1.23.2.1  24-Mar-2007  yamt sync with head.
 1.24.8.2  09-Dec-2007  jmcneill Sync with HEAD.
 1.24.8.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.24.4.1  03-Sep-2007  skrll Sync with HEAD.
 1.25.10.1  26-Dec-2007  ad Sync with head.
 1.25.8.1  18-Feb-2008  mjf Sync with HEAD.
 1.25.2.1  09-Jan-2008  matt sync with HEAD
 1.26.4.2  08-Jan-2008  bouyer Sync with HEAD
 1.26.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.28.18.1  19-Jan-2009  skrll Sync with HEAD.
 1.28.16.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.28.12.2  14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.28.12.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.28.10.2  11-Aug-2010  yamt sync with head.
 1.28.10.1  04-May-2009  yamt sync with head.
 1.28.6.1  17-Jan-2009  mjf Sync with HEAD.
 1.29.4.2  04-Jan-2009  christos add new syscalls.
 1.29.4.1  19-Nov-2008  christos file netbsd32_sysctl.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.30.6.2  31-May-2011  rmind sync with head
 1.30.6.1  30-May-2010  rmind sync with head
 1.30.4.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.31.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.32.8.1  18-Feb-2012  mrg merge to -current.
 1.32.4.1  17-Apr-2012  yamt sync with head
 1.33.20.1  10-Aug-2014  tls Rebase.
 1.33.10.1  18-May-2014  rmind sync with head
 1.33.6.2  03-Dec-2017  jdolecek update from HEAD
 1.33.6.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.4.1  06-Jun-2015  skrll Sync with HEAD
 1.38.2.6  25-Jan-2019  pgoyette Revert previous change(s). There's no good reason to use the hook when
the required value is available locally (in the current module).

Thanks mrg@ for pointing this out.
 1.38.2.5  24-Jan-2019  pgoyette I must be getting tired - use the correct name of the hook
 1.38.2.4  24-Jan-2019  pgoyette I wrote this stuff, when will I ever learn to use MODULE_CALL_HOOK
instead of MODULE_HOOK_CALL ? :)
 1.38.2.3  24-Jan-2019  pgoyette Use the hook to get the value of machine32
 1.38.2.2  24-Jan-2019  pgoyette Found a couple other consumers of machine32 - adapt them to use the hook
 1.38.2.1  25-Jun-2018  pgoyette Sync with HEAD
 1.40.2.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.44.4.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed