Re: CVS commit: src/sys

2020-01-03 Thread Simon Burge
Hey Jason,

Jason Thorpe wrote:

> > On Jan 3, 2020, at 10:11 AM, Frank Kardel  wrote:
> > 
> > Hi Jason !
> > 
> > Could you please check that kmem using tools can cope with the missing 
> > _boottime symbol.
>
> Hey Frank... this should fix it:
>
>   $NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $

Is it worth keeping the boottime symbol about so that a netbsd-9 vmstat
binary will still work with a -current kernel?  We could possibly wrap
boottime with a COMPAT_90 check too?.

Cheers,
Simon.


Re: CVS commit: src/sys

2020-01-03 Thread Simon Burge
Jason Thorpe wrote:

> > Is it worth keeping the boottime symbol about so that a netbsd-9 vmstat
> > binary will still work with a -current kernel?  We could possibly wrap
> > boottime with a COMPAT_90 check too?.
>
> Define "work".  A dummy symbol would have no valid contents.  I guess
> if you call that "work" then go ahead?
>
> The real problem here is that vmstat insists on finding the kernel
> symbols even if it's not going to use them, which is kind of silly.

That is indeed the silly(TM) thing.  Against a live kernel, it just
needs the boottime symbol to exist.  It uses the kern.boottime sysctl
to get the boottime from a live kernel.

Cheers,
Simon.


Re: CVS commit: src/sys/arch/amd64

2020-01-03 Thread Emmanuel Dreyfus
On Tue, Dec 31, 2019 at 09:32:05AM +0100, Maxime Villard wrote:
> I think max-page-size=0x1000 is the right thing to do, but someone needs to
> verify that the resulting binary is correct and that the resulting in-memory
> layout is correct too.

Attached is an updated patch with this approach. I tested at mine and
it seems fine.

I am especially interested by feedback from msaitoh@ who reported the
crash at cpu attacch that I suspect to be the (probably unrelated) 
problem describred here:
http://mail-index.netbsd.org/tech-kern/2020/01/02/msg025911.html

-- 
Emmanuel Dreyfus
m...@netbsd.org
Index: sys/arch/amd64/amd64/locore.S
===
RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
retrieving revision 1.195
diff -U4 -r1.195 locore.S
--- sys/arch/amd64/amd64/locore.S   15 Dec 2019 02:58:21 -  1.195
+++ sys/arch/amd64/amd64/locore.S   4 Jan 2020 01:48:11 -
@@ -431,10 +431,10 @@
.size   tmpstk, tmpstk - .
.space  512
 tmpstk:
 
-.section multiboot,"a"
 #if defined(MULTIBOOT)
+.section multiboot,"",@note
.align  8
.globl  Multiboot2_Header
 _C_LABEL(Multiboot2_Header):
.intMULTIBOOT2_HEADER_MAGIC
Index: sys/arch/amd64/conf/GENERIC
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.551
diff -U4 -r1.551 GENERIC
--- sys/arch/amd64/conf/GENERIC 14 Dec 2019 07:45:20 -  1.551
+++ sys/arch/amd64/conf/GENERIC 4 Jan 2020 01:48:11 -
@@ -25,9 +25,9 @@
 #ident "GENERIC-$Revision: 1.551 $"
 
 maxusers   64  # estimated number of users
 
-#options   MULTIBOOT   # Multiboot support (see multiboot(8)) 
+optionsMULTIBOOT   # Multiboot support (see multiboot(8)) 
 
 # delay between "rebooting ..." message and hardware reset, in milliseconds
 #options   CPURESET_DELAY=2000
 
Index: sys/arch/amd64/conf/Makefile.amd64
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/Makefile.amd64,v
retrieving revision 1.80
diff -U4 -r1.80 Makefile.amd64
--- sys/arch/amd64/conf/Makefile.amd64  14 Nov 2019 16:23:52 -  1.80
+++ sys/arch/amd64/conf/Makefile.amd64  4 Jan 2020 01:48:11 -
@@ -90,12 +90,12 @@
 ## (5) link settings
 ##
 TEXTADDR?= 0x8020
 .if defined(KASLR)
-EXTRA_LINKFLAGS=   --split-by-file=0x10 -r -d
+EXTRA_LINKFLAGS=   --split-by-file=0x10 -z max-page-size=0x1000 -r -d
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
 .else
-EXTRA_LINKFLAGS=   -z max-page-size=0x20
+EXTRA_LINKFLAGS=   -z max-page-size=0x1000
 KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
 .endif
 LINKFLAGS_NORMAL=  -X
 
Index: sys/arch/amd64/conf/kern.ldscript
===
RCS file: /cvsroot/src/sys/arch/amd64/conf/kern.ldscript,v
retrieving revision 1.30
diff -U4 -r1.30 kern.ldscript
--- sys/arch/amd64/conf/kern.ldscript   15 Dec 2019 02:56:40 -  1.30
+++ sys/arch/amd64/conf/kern.ldscript   4 Jan 2020 01:48:11 -
@@ -12,20 +12,11 @@
 
 ENTRY(_start)
 SECTIONS
 {
-   /*
-* multiboot (file_offset) : AT (load_address) 
-* file_offset must be below 32k for multiboot 2 specification
-* BIOS boot requires load_address above 0x20
-*/
-   multiboot 0x1000 : AT (0x20)
+   .text : AT (ADDR(.text) & 0x0fff)
{
-   . = ALIGN(8);
KEEP(*(multiboot));
-   }
-   .text : AT (0x20 + SIZEOF(multiboot))
-   {
. = ALIGN(__PAGE_SIZE);
__text_user_start = . ;
*(.text.user)
. = ALIGN(__PAGE_SIZE);


Re: CVS commit: src/sys

2020-01-03 Thread Jason Thorpe



> On Jan 3, 2020, at 5:08 PM, Simon Burge  wrote:
> 
> Hey Jason,
> 
> Jason Thorpe wrote:
> 
>>> On Jan 3, 2020, at 10:11 AM, Frank Kardel  wrote:
>>> 
>>> Hi Jason !
>>> 
>>> Could you please check that kmem using tools can cope with the missing 
>>> _boottime symbol.
>> 
>> Hey Frank... this should fix it:
>> 
>>  $NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $
> 
> Is it worth keeping the boottime symbol about so that a netbsd-9 vmstat
> binary will still work with a -current kernel?  We could possibly wrap
> boottime with a COMPAT_90 check too?.

Define "work".  A dummy symbol would have no valid contents.  I guess if you 
call that "work" then go ahead?

The real problem here is that vmstat insists on finding the kernel symbols even 
if it's not going to use them, which is kind of silly.

-- thorpej



Re: CVS commit: src/sys

2020-01-03 Thread Frank Kardel

Great. works again.

Frank


On 01/03/20 20:14, Jason Thorpe wrote:



On Jan 3, 2020, at 10:11 AM, Frank Kardel  wrote:

Hi Jason !

Could you please check that kmem using tools can cope with the missing 
_boottime symbol.

Hey Frank... this should fix it:

$NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $

-- thorpej





Re: CVS commit: src/sys/arch/zaurus/conf

2020-01-03 Thread Martin Husemann
On Sat, Jan 04, 2020 at 03:42:20AM +0900, Izumi Tsutsui wrote:
> The problem is caused by sys/arch/arm/conf/Makefile.arm.
> It defines "COPTS+= -mapcs-frame" in recent rev 1.52
>  
> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/arm/conf/Makefile.arm#rev1.52
> but MI sys/conf/Makefile.kern.inc defines COPTS+=-O2
> only if COPTS is empty.
>  
> This affects not only zaurus but all arm ports?

Yes! But only zaurus caused a build failure due to it.

> ---
> Index: sys/arch/arm/conf/Makefile.arm
> ===
> RCS file: /cvsroot/src/sys/arch/arm/conf/Makefile.arm,v
> retrieving revision 1.52
> diff -u -p -d -r1.52 Makefile.arm
> --- sys/arch/arm/conf/Makefile.arm2 Jan 2020 14:33:55 -   1.52
> +++ sys/arch/arm/conf/Makefile.arm3 Jan 2020 18:35:36 -
> @@ -78,7 +78,7 @@ CFLAGS+=-mno-unaligned-access
>  
>  OPT_DDB= %DDB%
>  .if !empty(OPT_DDB) && ${HAVE_GCC:U0} > 0
> -COPTS+=  -mapcs-frame
> +CFLAGS+= -mapcs-frame
>  .endif
>  
>  ##

I wonder if we should make the handling in sys/conf/Makefile.kern.inc
"better" and avoid this dance. If anyone fixes it, please feel free to
back out my bandaid in sys/arch/zaurus/conf/Makefile.zaurus.

Martin


re: CVS commit: src/sys

2020-01-03 Thread matthew green
Frank Kardel writes:
> Hi Jason !
> 
> Could you please check that kmem using tools can cope with the missing 
> _boottime symbol.
> 
> E.g.:
> 
> # vmstat -s
> vmstat: undefined symbols: _boottime
> #
> 
> This renders vmstat currently broken.
> 
> Best regards

ah, i wondered if this would happen.  i searched the tree and
didn't find anything, but i see my pattern was wrong and i 
needed to be looking for '"_boottime"', not just '"boottime".

vmstat appears to be the only problem here.


.mrg.


Re: CVS commit: src/sys

2020-01-03 Thread Jason Thorpe



> On Jan 3, 2020, at 10:11 AM, Frank Kardel  wrote:
> 
> Hi Jason !
> 
> Could you please check that kmem using tools can cope with the missing 
> _boottime symbol.

Hey Frank... this should fix it:

$NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $

-- thorpej



Re: CVS commit: src/sys/arch/zaurus/conf

2020-01-03 Thread Izumi Tsutsui
I wrote:
> > The missing COPTS was an accident or fallout from some other changes?
> 
> Isn't it specified in -current?

The problem is caused by sys/arch/arm/conf/Makefile.arm.
It defines "COPTS+= -mapcs-frame" in recent rev 1.52
 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/arm/conf/Makefile.arm#rev1.52
but MI sys/conf/Makefile.kern.inc defines COPTS+=-O2
only if COPTS is empty.
 
This affects not only zaurus but all arm ports?

---
Index: sys/arch/arm/conf/Makefile.arm
===
RCS file: /cvsroot/src/sys/arch/arm/conf/Makefile.arm,v
retrieving revision 1.52
diff -u -p -d -r1.52 Makefile.arm
--- sys/arch/arm/conf/Makefile.arm  2 Jan 2020 14:33:55 -   1.52
+++ sys/arch/arm/conf/Makefile.arm  3 Jan 2020 18:35:36 -
@@ -78,7 +78,7 @@ CFLAGS+=  -mno-unaligned-access
 
 OPT_DDB=   %DDB%
 .if !empty(OPT_DDB) && ${HAVE_GCC:U0} > 0
-COPTS+=-mapcs-frame
+CFLAGS+=   -mapcs-frame
 .endif
 
 ##

---
Izumi Tsutsui
 


Re: CVS commit: src/sys

2020-01-03 Thread Frank Kardel

Hi Jason !

Could you please check that kmem using tools can cope with the missing 
_boottime symbol.


E.g.:

# vmstat -s
vmstat: undefined symbols: _boottime
#

This renders vmstat currently broken.

Best regards

  Frank


On 01/02/20 16:42, Jason R Thorpe wrote:

Module Name:src
Committed By:   thorpej
Date:   Thu Jan  2 15:42:27 UTC 2020

Modified Files:
src/sys/compat/common: kern_info_43.c kern_time_50.c
src/sys/compat/netbsd32: netbsd32_sysctl.c
src/sys/external/bsd/drm2/include/linux: ktime.h
src/sys/fs/nfs/common: nfs_lock.c
src/sys/kern: init_main.c init_sysctl.c kern_rndq.c kern_tc.c
kern_time.c
src/sys/miscfs/fdesc: fdesc_vnops.c
src/sys/miscfs/kernfs: kernfs.h kernfs_vnops.c
src/sys/miscfs/procfs: procfs_linux.c
src/sys/nfs: nfs_serv.c
src/sys/rump/librump/rumpkern: cons.c emul.c rump.c
src/sys/sys: kernel.h timevar.h

Log Message:
- 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.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/compat/common/kern_info_43.c
cvs rdiff -u -r1.33 -r1.34 src/sys/compat/common/kern_time_50.c
cvs rdiff -u -r1.40 -r1.41 src/sys/compat/netbsd32/netbsd32_sysctl.c
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/include/linux/ktime.h
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/nfs/common/nfs_lock.c
cvs rdiff -u -r1.516 -r1.517 src/sys/kern/init_main.c
cvs rdiff -u -r1.222 -r1.223 src/sys/kern/init_sysctl.c
cvs rdiff -u -r1.95 -r1.96 src/sys/kern/kern_rndq.c
cvs rdiff -u -r1.53 -r1.54 src/sys/kern/kern_tc.c
cvs rdiff -u -r1.202 -r1.203 src/sys/kern/kern_time.c
cvs rdiff -u -r1.130 -r1.131 src/sys/miscfs/fdesc/fdesc_vnops.c
cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/kernfs/kernfs.h
cvs rdiff -u -r1.161 -r1.162 src/sys/miscfs/kernfs/kernfs_vnops.c
cvs rdiff -u -r1.79 -r1.80 src/sys/miscfs/procfs/procfs_linux.c
cvs rdiff -u -r1.177 -r1.178 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/librump/rumpkern/cons.c
cvs rdiff -u -r1.194 -r1.195 src/sys/rump/librump/rumpkern/emul.c
cvs rdiff -u -r1.338 -r1.339 src/sys/rump/librump/rumpkern/rump.c
cvs rdiff -u -r1.31 -r1.32 src/sys/sys/kernel.h
cvs rdiff -u -r1.39 -r1.40 src/sys/sys/timevar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.





Re: CVS commit: src/sys/arch/zaurus/conf

2020-01-03 Thread Izumi Tsutsui
> > - zbsdmod.o has 5MB buffers to store a copied kernel binary
> > - zbsdmod.o reads a kernel from the 5MB buffer and loads sections
> >   into the target addresses
> >  
> > https://nxr.netbsd.org/xref/src/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c?r=1.12#94
> 
> Ah ok - thanks for explanation. So the dropping of ctf sections makes sense.

Yes.

> The missing COPTS was an accident or fallout from some other changes?

Isn't it specified in -current?
I think -O2 comes from MI src/sys/conf/Makefile.kern.inc:
 https://nxr.netbsd.org/xref/src/sys/conf/Makefile.kern.inc?r=1.268#69

On netbsd-9, GENERIC build uses -O2:
---
% /s/netbsd-9/src/obj.zaurus/tooldir.NetBSD-9.0_RC1-i386/bin/nbmake-zaurus 
init_main.o
#   compile  GENERIC/init_main.o
/s/netbsd-9/src/obj.zaurus/tooldir.NetBSD-9.0_RC1-i386/bin/arm--netbsdelf-eabi-gcc
 -mfloat-abi=soft -ffreestanding -fno-zero-initialized-in-bss 
-fno-delete-null-pointer-checks -O2 -msoft-float -fno-strict-aliasing 
-fno-common -std=gnu99 -Werror -Wall -Wno-main -Wno-format-zero-length 
-Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition 
-Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code 
-Wno-pointer-sign -Wno-attributes -Wno-sign-compare -mcpu=xscale 
--sysroot=/s/netbsd-9/src/obj.zaurus/destdir.zaurus -Dzaurus -I. 
-I../../../../external/bsd/libnv/dist -I../../../../../common/lib/libx86emu 
-I../../../../../common/lib/libc/misc -I../../../../../common/include 
-I../../../../arch -I../../../.. -nostdinc -DCOMPAT_UTILS -DCOMPAT_44 
-DDIAGNOSTIC -DW100_LCD_WRITETHROUGH -D_KERNEL -D_KERNEL_OPT -std=gnu99 
-I../../../../lib/libkern/../../../common/lib/libc/quad 
-I../../../../lib/libkern/../../../common/lib/libc/string 
-I../../../../lib/libker!
 n/../../../common/lib/libc/arch/arm/string -c ../../../../kern/init_main.c -o 
init_main.o
/s/netbsd-9/src/obj.zaurus/tooldir.NetBSD-9.0_RC1-i386/bin/nbctfconvert -g -L 
VERSION init_main.o
---

zaurus/conf/INSTALL has COPTS="-Os" in its config, though.

---
Izumi Tsutsui


Re: CVS commit: src/sys/arch/zaurus/conf

2020-01-03 Thread Martin Husemann
On Fri, Jan 03, 2020 at 07:36:34PM +0900, Izumi Tsutsui wrote:
> - zbsdmod.o has 5MB buffers to store a copied kernel binary
> - zbsdmod.o reads a kernel from the 5MB buffer and loads sections
>   into the target addresses
>  
> https://nxr.netbsd.org/xref/src/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c?r=1.12#94

Ah ok - thanks for explanation. So the dropping of ctf sections makes sense.

The missing COPTS was an accident or fallout from some other changes?

Martin


Re: CVS commit: src/sys/arch/zaurus/conf

2020-01-03 Thread Izumi Tsutsui
martin@ wrote:

> Module Name:  src
> Committed By: martin
> Date: Fri Jan  3 10:01:07 UTC 2020
> 
> Modified Files:
>   src/sys/arch/zaurus/conf: Makefile.zaurus.inc ldscript.zaurus
> 
> Log Message:
> Drop CTF sections from this size restricted kernel (especially as the
> size check is on the total size of the binary, not any content/sections -
> is this a bug?)

No, it (checking the total size of the binary) is by design.

- a kernel binary is loaded by a Linux kernel module (named zbsdmod.o)
  on the native Zaurus Linux
- to load a NetBSD kernel, the whole binary is copied into /proc/zboot
  node, created by the zbsdmod.o module
- zbsdmod.o has 5MB buffers to store a copied kernel binary
- zbsdmod.o reads a kernel from the 5MB buffer and loads sections
  into the target addresses
 
https://nxr.netbsd.org/xref/src/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c?r=1.12#94

---
Izumi Tsutsui