svn commit: r328829 - in head/sys: conf geom/label

2018-02-03 Thread Xin LI
Author: delphij
Date: Sat Feb  3 09:15:13 2018
New Revision: 328829
URL: https://svnweb.freebsd.org/changeset/base/328829

Log:
  After r328426, g_label depends on UFS (option FFS) code to read UFS
  superblock, and the kernel will fail to link when UFS is not built
  in.  This commit makes it depend on a small portion of FFS bits and
  thereby fixes build for this situation.
  
  This is intended as an interim bandaid, and the actual superblock
  reading code should probably be made independent of UFS, so we do
  not need to depend on it (see kib@'s comment in the review for
  details), and we will revisit this once the superblock check hashes
  are all in place.
  
  Differential Revision:https://reviews.freebsd.org/D14092

Modified:
  head/sys/conf/files
  head/sys/geom/label/g_label_ufs.c

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sat Feb  3 02:17:25 2018(r328828)
+++ head/sys/conf/files Sat Feb  3 09:15:13 2018(r328829)
@@ -4814,8 +4814,8 @@ ufs/ffs/ffs_balloc.c  optional ffs
 ufs/ffs/ffs_inode.coptional ffs
 ufs/ffs/ffs_snapshot.c optional ffs
 ufs/ffs/ffs_softdep.c  optional ffs
-ufs/ffs/ffs_subr.c optional ffs
-ufs/ffs/ffs_tables.c   optional ffs
+ufs/ffs/ffs_subr.c optional ffs | geom_label
+ufs/ffs/ffs_tables.c   optional ffs | geom_label
 ufs/ffs/ffs_vfsops.c   optional ffs
 ufs/ffs/ffs_vnops.coptional ffs
 ufs/ffs/ffs_rawread.c  optional ffs directio

Modified: head/sys/geom/label/g_label_ufs.c
==
--- head/sys/geom/label/g_label_ufs.c   Sat Feb  3 02:17:25 2018
(r328828)
+++ head/sys/geom/label/g_label_ufs.c   Sat Feb  3 09:15:13 2018
(r328829)
@@ -146,3 +146,5 @@ struct g_label_desc g_label_ufs_id = {
 
 G_LABEL_INIT(ufsid, g_label_ufs_id, "Create device nodes for UFS file system 
IDs");
 G_LABEL_INIT(ufs, g_label_ufs_volume, "Create device nodes for UFS volume 
names");
+
+MODULE_DEPEND(g_label, ufs, 1, 1, 1);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r328830 - in head/sys/dev/usb: . serial

2018-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Feb  3 09:43:32 2018
New Revision: 328830
URL: https://svnweb.freebsd.org/changeset/base/328830

Log:
  Add new USB ID.
  
  PR:   225641
  Submitted by: Ryan 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/usb/serial/uslcom.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/serial/uslcom.c
==
--- head/sys/dev/usb/serial/uslcom.cSat Feb  3 09:15:13 2018
(r328829)
+++ head/sys/dev/usb/serial/uslcom.cSat Feb  3 09:43:32 2018
(r328830)
@@ -313,6 +313,7 @@ static const STRUCT_USB_HOST_ID uslcom_devs[] = {
 USLCOM_DEV(SILABS, EMS_C1007),
 USLCOM_DEV(SILABS, HAMLINKUSB),
 USLCOM_DEV(SILABS, HELICOM),
+USLCOM_DEV(SILABS, HUBZ),
 USLCOM_DEV(SILABS, IMS_USB_RS422),
 USLCOM_DEV(SILABS, INFINITY_MIC),
 USLCOM_DEV(SILABS, INGENI_ZIGBEE),

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsSat Feb  3 09:15:13 2018(r328829)
+++ head/sys/dev/usb/usbdevsSat Feb  3 09:43:32 2018(r328830)
@@ -4238,6 +4238,7 @@ product SILABSAC_SERV_CAN 0x8664  AC-Services CAN 
Inte
 product SILABS AC_SERV_OBD 0x8665  AC-Services OBD Interface
 product SILABS MMB_ZIGBEE  0x88a4  MMB Networks ZigBee
 product SILABS INGENI_ZIGBEE   0x88a5  Planet Innovation Ingeni ZigBee
+product SILABS HUBZ0x8a2a  HubZ dual ZigBee and Z-Wave
 product SILABS CP2102  0xea60  SILABS USB UART
 product SILABS CP210X_20xea61  CP210x Serial
 product SILABS CP210X_30xea70  CP210x Serial
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r327495 - head/usr.sbin/rpcbind

2018-02-03 Thread Bruce Evans

On Tue, 2 Jan 2018, Conrad Meyer wrote:


Log:
 rpcbind: Fix race in signal termination


I have yet to see any application that was correctly converted from using
unsafe signal handlers to safe signal handlers that just set a flag.  That
is without even noticing this race problem before.


 If a signal was delivered while the main thread was not in poll(2) and after
 check was performed, we could reenter poll and never detect termination. Fix
 this with the pipefd trick.  (This race was introduced very recently, in
 r327482.)


poll() at least returns if the signal occurs after it is called.  Most other
syscalls related to i/o restart after a syscall when SA_RESTART is configured
for the syscall.  SA_RESTART is the default for BSD since handling EINTR after
any syscall is too hard.  Simple conversions from using unsafe conversions
break i/o by not turning off SA_RESTART (top(1) and rpcbind(8) are examples
-- details below).  Unsimple conversions do turn off SA_RESTART but this is
complicated and tends to give bugs (ping(8) is an example).  This race bug
shows that even turning off SA_RESTART doesn't help.  Since it doesn't help,
it just tends to gives bugs from its complications and shouldn't be used.

Today I learned from the POSIX list that the pselect() function is designed
to avoid this bug.  It takes a signal mask arg (like msleep() in the kernel).
The flag should only be checked while signals are masked, and signals must
not be unmasked before making any syscall that might sleep, but applications
rarely bother to mask signals before checking the flag, and there aren't
many i/o functions that take a signal mask.

I haven't noticed any function related to poll() or kevent that takes a
signal mask.

Programs broken by buggy conversion:
- top(1).  Run it interactively and type 's' followed by any non-null
  valid input (say '1').  Then try to abort it using ^C or ^\.  Neither
  works, because read() restarts.  You have to enter a newline to get
  read() to return.  The flag is then checked and top exits with the
  bogus exit status 0 and no message.  top still uses plain signal()
  so gets the default (SA_RESTART on BSD systems and possibly bugs
  from !SA_RESTART on non-BSD systems).  Races on all systems when the
  signal arrives between checking the flag and calling read().
- rpcbind(8).  This is not interactive and normally doesn't use ttys
  which might block.  However, the -d flag makes it do fprintf() to
  stderr.  This may block forever (e.g., for flow control), and you
  would like to be able to kill it using a signal.  But write() will
  restart.  rpcbind also uses plain signal() and doesn't know anything
  about SA_RESTART.
- ping(8).  This does know about SA_RESTART.  However, turning off
  SA_RESTART gives lots of EINTRs that few BSD programs and libraries
  handle properly and fewer libraries document their handling.  This
  caused hangs for some unreachable addresses.  The resolver library
  handled EINTR (from select() IIRC) by restarting, so ^C didn't work.
  It is unclear if either returning or restarting after EINTR is correct
  in a library function.  This was fixed long ago and I didn't know of
  any other similar bugs in ping.  It would be hard to check all syscalls
  in ping and library functions that it calls.  Now I know that there
  must be lots of races because turning off SA_RESTART doesn't really work.

I used to think that correct conversion required only the following modest
changes:
- don't change SA_RESTART or otherwise fiddle with signal handling global
- find all syscalls in the program and libraries that might block, and add
  turn off SA_RESTART around them.  Possibly also change other signal handling
  locally.

But this doesn't work since the race can be lost before making the syscalls.

Next try: add timeouts using alarm() or itimers to every syscall that might
block.  I think this fixes the race before calling syscalls too.

But this is too hard for most programs.  I think it is best to try to write
safe signal handlers.  Unfortunately, APIs support this negatively.  perror()
is broken as designed since it uses stdio, so it is unsafe in signal
handlers.  The err() family copies this bug.  Even *s*printf() is not
required to be safe in signal handlers.  I would fix the latter first.  Then
try to change the API of warn() and warnx() to be safe.  err() can't be
change since it has to keep calling exit(), but it is easy to use the safe
warn() followed by _exit() stdio is avoided, and important to know that it
is avoided.


...
Modified: head/usr.sbin/rpcbind/rpcb_svc_com.c
==
--- head/usr.sbin/rpcbind/rpcb_svc_com.cTue Jan  2 16:50:57 2018
(r327494)
+++ head/usr.sbin/rpcbind/rpcb_svc_com.cTue Jan  2 17:25:13 2018
(r327495)

@@ -1130,23 +1133,26 @@ my_svc_run(void)
fprintf(stderr, ">\n");
}
#endif
-   swit

Re: svn commit: r327495 - head/usr.sbin/rpcbind

2018-02-03 Thread Conrad Meyer
On Sat, Feb 3, 2018 at 6:46 AM, Bruce Evans  wrote:
> On Tue, 2 Jan 2018, Conrad Meyer wrote:
>> ...
> Today I learned from the POSIX list that the pselect() function is designed
> to avoid this bug.  It takes a signal mask arg (like msleep() in the
> kernel).
>
> I haven't noticed any function related to poll() or kevent that takes a
> signal mask.

There is the similar function ppoll(), although it complies only with
the Linux standard, not POSIX.

With kevent, you can simply mask all (or most) signals and watch on a
signal event.  Conversion to kevent is more complicated, though.

> Programs broken by buggy conversion:
> ...
> - rpcbind(8).  This is not interactive and normally doesn't use ttys
>   which might block.  However, the -d flag makes it do fprintf() to
>   stderr.  This may block forever (e.g., for flow control), and you
>   would like to be able to kill it using a signal.  But write() will
>   restart.  rpcbind also uses plain signal() and doesn't know anything
>   about SA_RESTART.

This was not broken by conversion -- it was already broken in this
case.  If the signal delivery raced with an fprintf, we ended up
invoking the stdio atexit handlers via exit(3) call in terminate(),
which of course encountered corrupted state.  Now it is broken in a
slightly different way, yes, if signal delivery races fprintf *and*
fprintf is blocked in flow control.  This might happen with a slow
serial for stderr but seems extraordinarily unlikely otherwise.

> ...
> But this is too hard for most programs.  I think it is best to try to write
> safe signal handlers.  Unfortunately, APIs support this negatively.

Agreed.  The signal abstraction is pretty awful.  I think the safest
way to handle them is to block them entirely, then watch using
kqueue()/kevent().  That way you never have to deal with signal
context.  But that kind of conversion is more work.  You also have to
deal with EINTR or be ok with blocking signal handling indefinitely.

> perror()
> is broken as designed since it uses stdio, so it is unsafe in signal
> handlers.  The err() family copies this bug.  Even *s*printf() is not
> required to be safe in signal handlers.  I would fix the latter first.

It does seem like the printf family of routines should be
signal-handler safe.  Unfortunately, they are implemented in terms of
the unsafe stdio streams :-(.

> Then
> try to change the API of warn() and warnx() to be safe.  err() can't be
> change since it has to keep calling exit(), but it is easy to use the safe
> warn() followed by _exit() stdio is avoided, and important to know that it
> is avoided.

That sounds nice.  I'm on board with that.

>> ... Non-functional change highlighted ...
>
> I think this is too specialized and complicated.
>
> ...
>
> 1 millisecond is usually too small, but 1 second seems reasonable for
> most cases.  The timeout is only used after rarely-lost races unless it
> is small.

Feel free to change it to 1s yourself, if you think it is important.

>> Modified: head/usr.sbin/rpcbind/rpcbind.c
>>
>> ==
>> --- head/usr.sbin/rpcbind/rpcbind.c Tue Jan  2 16:50:57 2018
>> (r327494)
>> +++ head/usr.sbin/rpcbind/rpcbind.c Tue Jan  2 17:25:13 2018
>> (r327495)
>> ...
>> @@ -761,8 +774,13 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct
>> net
>> static void
>> terminate(int signum)
>> {
>> +   char c = '\0';
>> +   ssize_t wr;
>>
>> doterminate = signum;
>> +   wr = write(terminate_wfd, &c, 1);
>
>
> Not async-signal-safe.  Acccesses in signal handlers to objects with
> static storage duration give undefined behaviour except for assignment to
> objects of type volatile sig_atomic_t, but the access to terminate_wfd is
> a read and the type is plain int.

The type can be changed to volatile sig_atomic_t if you believe plain
int will trigger nonsensical compiler behavior.  The value is
initialized once, before the signal handler is registered, so unless
the compiler does something totally insane it should be fine on all
architectures FreeBSD runs on.

>> +   if (wr < 1)
>> +   _exit(2);
>
>
> Best to not check for write errors, since the error handling of using
> _exit()
> is worse than none.  It loses stdio flushing to handle an almost-harmless
> error.  The main problem with keeping everything in a safe handler is that
> it
> is impossible to keep stdio flushing there and we would prefer to not lost
> the stdio flushing.

I don't necessarily agree.  If the write fails, we missed the signal
telling us to terminate the program and will never exit.  That said,
how would the write ever fail?

Conrad
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r328831 - head/share/man/man3

2018-02-03 Thread Eitan Adler
Author: eadler
Date: Sat Feb  3 20:50:46 2018
New Revision: 328831
URL: https://svnweb.freebsd.org/changeset/base/328831

Log:
  pthread: adding missing header to man page
  
  Reported by:  swild...@dragonflybsd.org

Modified:
  head/share/man/man3/pthread_join.3

Modified: head/share/man/man3/pthread_join.3
==
--- head/share/man/man3/pthread_join.3  Sat Feb  3 09:43:32 2018
(r328830)
+++ head/share/man/man3/pthread_join.3  Sat Feb  3 20:50:46 2018
(r328831)
@@ -30,7 +30,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 23, 2010
+.Dd February 3, 2018
 .Dt PTHREAD_JOIN 3
 .Os
 .Sh NAME
@@ -43,6 +43,7 @@
 .In pthread.h
 .Ft int
 .Fn pthread_join "pthread_t thread" "void **value_ptr"
+.In pthread_np.h
 .Ft int
 .Fn pthread_timedjoin_np "pthread_t thread" "void **value_ptr" "const struct 
timespec *abstime"
 .Sh DESCRIPTION
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r328832 - head/usr.sbin/newsyslog

2018-02-03 Thread Eitan Adler
Author: eadler
Date: Sat Feb  3 20:53:21 2018
New Revision: 328832
URL: https://svnweb.freebsd.org/changeset/base/328832

Log:
  newsyslog: fix typeo for 'zstd'
  
  Reported by:  swild...@dragonflybsd.org
  MFC After:1 week

Modified:
  head/usr.sbin/newsyslog/newsyslog.8

Modified: head/usr.sbin/newsyslog/newsyslog.8
==
--- head/usr.sbin/newsyslog/newsyslog.8 Sat Feb  3 20:50:46 2018
(r328831)
+++ head/usr.sbin/newsyslog/newsyslog.8 Sat Feb  3 20:53:21 2018
(r328832)
@@ -17,7 +17,7 @@
 .\" the suitability of this software for any purpose.  It is
 .\" provided "as is" without express or implied warranty.
 .\"
-.Dd May 19, 2017
+.Dd February 3, 2018
 .Dt NEWSYSLOG 8
 .Os
 .Sh NAME
@@ -289,7 +289,7 @@ accepted for backwards compatibility.
 .Xr bzip2 1 ,
 .Xr gzip 1 ,
 .Xr xz 1 ,
-.Xr zst 1 ,
+.Xr zstd 1 ,
 .Xr syslog 3 ,
 .Xr newsyslog.conf 5 ,
 .Xr chown 8 ,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r328833 - head/tools/tools/nanobsd

2018-02-03 Thread Warner Losh
Author: imp
Date: Sat Feb  3 21:56:38 2018
New Revision: 328833
URL: https://svnweb.freebsd.org/changeset/base/328833

Log:
  Fix backward conditional.
  
  Pointed out by: david boyer

Modified:
  head/tools/tools/nanobsd/legacy.sh

Modified: head/tools/tools/nanobsd/legacy.sh
==
--- head/tools/tools/nanobsd/legacy.sh  Sat Feb  3 20:53:21 2018
(r328832)
+++ head/tools/tools/nanobsd/legacy.sh  Sat Feb  3 21:56:38 2018
(r328833)
@@ -29,8 +29,8 @@
 #
 
 # Media geometry, only relevant if bios doesn't understand LBA.
-[ -z "$NANO_SECTS" ] || NANO_SECTS=63
-[ -z "$NANO_HEADS" ] || NANO_HEADS=16
+[ -n "$NANO_SECTS" ] || NANO_SECTS=63
+[ -n "$NANO_HEADS" ] || NANO_HEADS=16
 
 # Functions and variable definitions used by the legacy nanobsd
 # image building system.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r328834 - in head: lib/libc/sparc64/sys libexec/rtld-elf libexec/rtld-elf/aarch64 libexec/rtld-elf/amd64 libexec/rtld-elf/arm libexec/rtld-elf/i386 libexec/rtld-elf/mips libexec/rtld-el...

2018-02-03 Thread Marius Strobl
Author: marius
Date: Sat Feb  3 23:14:11 2018
New Revision: 328834
URL: https://svnweb.freebsd.org/changeset/base/328834

Log:
  o Let rtld(1) set up psABI user trap handlers prior to executing the
objects' init functions instead of doing the setup via a constructor
in libc as the init functions may already depend on these handlers
to be in place. This gets us rid of:
- the undefined order in which libc constructors as __guard_setup()
  and jemalloc_constructor() are executed WRT __sparc_utrap_setup(),
- the requirement to link libc last so __sparc_utrap_setup() gets
  called prior to constructors in other libraries (see r122883).
For static binaries, crt1.o still sets up the user trap handlers.
  o Move misplaced prototypes for MD functions in to the MD prototype
section of rtld.h.
  o Sprinkle nitems().

Modified:
  head/lib/libc/sparc64/sys/__sparc_utrap_setup.c
  head/libexec/rtld-elf/aarch64/reloc.c
  head/libexec/rtld-elf/amd64/reloc.c
  head/libexec/rtld-elf/arm/reloc.c
  head/libexec/rtld-elf/i386/reloc.c
  head/libexec/rtld-elf/mips/reloc.c
  head/libexec/rtld-elf/powerpc/reloc.c
  head/libexec/rtld-elf/powerpc64/reloc.c
  head/libexec/rtld-elf/riscv/reloc.c
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/rtld.h
  head/libexec/rtld-elf/sparc64/reloc.c

Modified: head/lib/libc/sparc64/sys/__sparc_utrap_setup.c
==
--- head/lib/libc/sparc64/sys/__sparc_utrap_setup.c Sat Feb  3 21:56:38 
2018(r328833)
+++ head/lib/libc/sparc64/sys/__sparc_utrap_setup.c Sat Feb  3 23:14:11 
2018(r328834)
@@ -29,13 +29,11 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
+#include 
 
 #include 
 #include 
 
-#include 
-
 #include "__sparc_utrap_private.h"
 
 static const struct sparc_utrap_args ua[] = {
@@ -47,10 +45,10 @@ static const struct sparc_utrap_args ua[] = {
 };
 
 static const struct sparc_utrap_install_args uia[] = {
-   { sizeof (ua) / sizeof (*ua), ua }
+   { nitems(ua), ua }
 };
 
-void __sparc_utrap_setup(void) __attribute__((constructor));
+void __sparc_utrap_setup(void);
 
 void
 __sparc_utrap_setup(void)

Modified: head/libexec/rtld-elf/aarch64/reloc.c
==
--- head/libexec/rtld-elf/aarch64/reloc.c   Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/aarch64/reloc.c   Sat Feb  3 23:14:11 2018
(r328834)
@@ -306,6 +306,13 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const 
 void
 ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
+
+}
+
+void
+pre_init(void)
+{
+
 }
 
 /*

Modified: head/libexec/rtld-elf/amd64/reloc.c
==
--- head/libexec/rtld-elf/amd64/reloc.c Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/amd64/reloc.c Sat Feb  3 23:14:11 2018
(r328834)
@@ -487,6 +487,12 @@ ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] 
 }
 
 void
+pre_init(void)
+{
+
+}
+
+void
 allocate_initial_tls(Obj_Entry *objs)
 {
 /*

Modified: head/libexec/rtld-elf/arm/reloc.c
==
--- head/libexec/rtld-elf/arm/reloc.c   Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/arm/reloc.c   Sat Feb  3 23:14:11 2018
(r328834)
@@ -478,6 +478,13 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const 
 void
 ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
+
+}
+
+void
+pre_init(void)
+{
+
 }
 
 void

Modified: head/libexec/rtld-elf/i386/reloc.c
==
--- head/libexec/rtld-elf/i386/reloc.c  Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/i386/reloc.c  Sat Feb  3 23:14:11 2018
(r328834)
@@ -473,6 +473,12 @@ ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] 
 }
 
 void
+pre_init(void)
+{
+
+}
+
+void
 allocate_initial_tls(Obj_Entry *objs)
 {
 void* tls;

Modified: head/libexec/rtld-elf/mips/reloc.c
==
--- head/libexec/rtld-elf/mips/reloc.c  Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/mips/reloc.c  Sat Feb  3 23:14:11 2018
(r328834)
@@ -745,6 +745,13 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const 
 void
 ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
+
+}
+
+void
+pre_init(void)
+{
+
 }
 
 void

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==
--- head/libexec/rtld-elf/powerpc/reloc.c   Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/powerpc/reloc.c   Sat Feb  3 23:14:11 2018
(r328834)
@@ -628,6 +628,13 @@ init_pltgot(Obj_Entry *obj)
 void
 ifunc_init(Elf_Auxinfo aux_info[_

svn commit: r328835 - in head/stand: ofw/common ofw/libofw powerpc/ofw

2018-02-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Feb  3 23:49:21 2018
New Revision: 328835
URL: https://svnweb.freebsd.org/changeset/base/328835

Log:
  Fix regression introduced in r328806, preventing boot at least on all
  PowerPC Apple hardware, and likely all Open Firmware systems.
  
  The loader would allocate memory for its heap at whatever address Open
  Firmware gave it, which would in general be the lowest unallocated address,
  usually starting a page or two above 0. As the kernel is linked at 1 MB,
  and loader insists on running the kernel at its link address, any heap
  larger than 1 MB would overlap the kernel, causing loader memory allocations
  to corrupt the kernel and vice versa.
  
  Although r328806 made this problem much worse by increasing the heap size
  to 8 MB, causing 88% of the loader heap to overlap with the kernel, the
  problem has always existed. The old heap size was 1 MB and, unless that
  started exactly at zero, which would cause other problems, some number of
  pages of the loader heap still overlapped with the kernel.
  
  This patch solves the issue in two ways and cleans up some related code:
  - Moves the loader heap inside of the loader. This guarantees that the
heap will be contiguous with the loader and simplifies the heap
allocation code at no cost, since the heap lives in BSS.
  - Moves the loader, previously at 28 MB and dangerously close to the kernel
it loads, a bit higher to 44 MB. This has the effect of breaking loader
on non-embedded PPC machines with < 48 MB of RAM, but we did not support
those anyway.
  
  The fundamental problem is that the way loader loads ELF files is
  incredibly fragile, but that can't be fixed without fundamental
  architectural changes.
  
  MFC after:10 days

Modified:
  head/stand/ofw/common/main.c
  head/stand/ofw/libofw/elf_freebsd.c
  head/stand/ofw/libofw/libofw.h
  head/stand/ofw/libofw/ofw_copy.c
  head/stand/ofw/libofw/ofw_memory.c
  head/stand/ofw/libofw/ppc64_elf_freebsd.c
  head/stand/powerpc/ofw/ldscript.powerpc

Modified: head/stand/ofw/common/main.c
==
--- head/stand/ofw/common/main.cSat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/common/main.cSat Feb  3 23:49:21 2018
(r328835)
@@ -43,22 +43,16 @@ u_int32_t   acells, scells;
 static char bootargs[128];
 
 #defineHEAP_SIZE   0x80
+static char heap[HEAP_SIZE]; // In BSS, so uses no space
 
 #define OF_puts(fd, text) OF_write(fd, text, strlen(text))
 
 void
 init_heap(void)
 {
-   void*base;
-   ihandle_t stdout;
+   bzero(heap, HEAP_SIZE);
 
-   if ((base = ofw_alloc_heap(HEAP_SIZE)) == (void *)0x) {
-   OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
-   OF_puts(stdout, "Heap memory claim failed!\n");
-   OF_enter();
-   }
-
-   setheap(base, (void *)((int)base + HEAP_SIZE));
+   setheap(heap, (void *)((int)heap + HEAP_SIZE));
 }
 
 uint64_t

Modified: head/stand/ofw/libofw/elf_freebsd.c
==
--- head/stand/ofw/libofw/elf_freebsd.c Sat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/libofw/elf_freebsd.c Sat Feb  3 23:49:21 2018
(r328835)
@@ -87,7 +87,6 @@ __elfN(ofw_exec)(struct preloaded_file *fp)
printf("Kernel entry at 0x%lx ...\n", e->e_entry);
 
dev_cleanup();
-   ofw_release_heap();
if (dtbp != 0) {
OF_quiesce();
((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 
0, 0,

Modified: head/stand/ofw/libofw/libofw.h
==
--- head/stand/ofw/libofw/libofw.h  Sat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/libofw/libofw.h  Sat Feb  3 23:49:21 2018
(r328835)
@@ -58,8 +58,6 @@ extern intofw_boot(void);
 extern int ofw_autoload(void);
 
 void   ofw_memmap(int);
-void   *ofw_alloc_heap(unsigned int);
-void   ofw_release_heap(void);
 
 struct preloaded_file;
 struct file_format;

Modified: head/stand/ofw/libofw/ofw_copy.c
==
--- head/stand/ofw/libofw/ofw_copy.cSat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/ofw/libofw/ofw_copy.cSat Feb  3 23:49:21 2018
(r328835)
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
 #defineREADIN_BUF  (4 * 1024)
 #definePAGE_SIZE   0x1000
 #definePAGE_MASK   0x0fff
-#define MAPMEM_PAGE_INC 16
+#defineMAPMEM_PAGE_INC 128 /* Half-MB at a time */
 
 
 #defineroundup(x, y)   x)+((y)-1))/(y))*(y))

Modified: head/stand/ofw/libofw/ofw_memory.c
==
--- head/stand/ofw/libofw/ofw_memory.c  Sat Feb  3 23:14:11 2018
(r328834)
+++ head/stand/of

svn commit: r328837 - stable/11/lib/libpmc

2018-02-03 Thread Justin Hibbits
Author: jhibbits
Date: Sun Feb  4 03:15:06 2018
New Revision: 328837
URL: https://svnweb.freebsd.org/changeset/base/328837

Log:
  MFC r327911:
  
Replace the PMC class struct copy with an explicit memcpy()

Modified:
  stable/11/lib/libpmc/libpmc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libpmc/libpmc.c
==
--- stable/11/lib/libpmc/libpmc.c   Sun Feb  4 02:58:12 2018
(r328836)
+++ stable/11/lib/libpmc/libpmc.c   Sun Feb  4 03:15:06 2018
(r328837)
@@ -3268,7 +3268,8 @@ pmc_init(void)
cpu_info.pm_npmc= op_cpu_info.pm_npmc;
cpu_info.pm_nclass  = op_cpu_info.pm_nclass;
for (n = 0; n < cpu_info.pm_nclass; n++)
-   cpu_info.pm_classes[n] = op_cpu_info.pm_classes[n];
+   memcpy(&cpu_info.pm_classes[n], &op_cpu_info.pm_classes[n],
+   sizeof(cpu_info.pm_classes[n]));
 
pmc_class_table = malloc(PMC_CLASS_TABLE_SIZE *
sizeof(struct pmc_class_descr *));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"