Re: Size of EFI system partition is much smaller when it is mounted

2020-11-30 Thread Yasuhiro KIMURA
From: Warner Losh 
Subject: Re: Size of EFI system partition is much smaller when it is mounted
Date: Mon, 30 Nov 2020 21:44:58 -0700

> 11.x puts a pre-canned image into the ESP that's tiny, regardless of the
> size, while 12.x does a newfs_msdos and sizes it properly. It's kinda hard
> to fix in 11.x since there's a number of changes in a number of places.
> 
> You can, though, on 11.x, newfs_msdos the filesystem and copy boot1.efi
> from FreeBSD's /boot to the ESP's \efi\boot\bootx64.efi if you need more
> space on the ESP for some reason.

Thank you for explanation. What I would like do is to update loader
file keeping old one as backup after freebsd-update, something like

# mount -t msdosfs /dev/ada0p1 /mnt
# cd /mnt/efi/boot
# mv bootx64.efi bootx64.efi.old
# install -m 755 -p /boot/loader.efi bootx64.efi

And 779KB is too small to put 2 loader files. So I'll try reformatting
EFI system partition.

---
Yasuhiro KIMURA
___
freebsd-stable@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"


Re: Size of EFI system partition is much smaller when it is mounted

2020-11-30 Thread Warner Losh
On Mon, Nov 30, 2020 at 5:35 PM Yasuhiro KIMURA  wrote:

> I made clean install of 11.4-RELEASE amd64 with ZFS root and UEFI boot
> mode. 'Auto (ZFS)' was used at disk setup phase and disk was
> partitioned as following.
>
> --
> root@rolling-vm-freebsd3[80]# uname -a
> FreeBSD rolling-vm-freebsd3.home.utahime.org 11.4-RELEASE-p3 FreeBSD
> 11.4-RELEASE-p3 #0: Tue Sep  1 08:22:33 UTC 2020
>  r...@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
> root@rolling-vm-freebsd3[81]# gpart show ada0
> =>   40  209715120  ada0  GPT  (100G)
>  40 409600 1  efi  (200M)
>  409640   2008- free -  (1.0M)
>  411648   16777216 2  freebsd-swap  (8.0G)
>17188864  192524288 3  freebsd-zfs  (92G)
>   209713152   2008- free -  (1.0M)
> --
>
> According to it the size of EFI system partition is 200MB. But if I
> mount it to filesystem and check its size with df(1), then it is much
> smaller than 200MB.
>
> --
> root@rolling-vm-freebsd3[82]# mount -t msdosfs /dev/ada0p1 /mnt
> root@rolling-vm-freebsd3[83]# df -k /mnt
> Filesystem  1024-blocks Used Avail Capacity  Mounted on
> /dev/ada0p1 779  384   39549%/mnt
> --
>
> And if I try to copy large file to /mnt then it fails.
>
> --
> root@rolling-vm-freebsd3[94]# ls -l dummy.1MB.date
> -rw-r--r--  1 root  wheel  1048576 Nov 29 10:39 dummy.1MB.date
> root@rolling-vm-freebsd3[95]# cp dummy.1MB.date /mnt
> cp: /mnt/dummy.1MB.date: No space left on device
> --
>
> So it seems kernel(?) really regards the size of mounted EFI system
> part as only 779KB.
>
> I also tried it with 12.2-RELEASE and df(1) reported correctly.
>
> --
> root@eastasia[1002]# uname -a
> FreeBSD eastasia.home.utahime.org 12.2-RELEASE FreeBSD 12.2-RELEASE
> r366954 GENERIC  amd64
> root@eastasia[1003]# gpart show ada0
> =>40  1953525088  ada0  GPT  (932G)
>   40  409600 1  efi  (200M)
>   4096402008- free -  (1.0M)
>   41164816777216 2  freebsd-swap  (8.0G)
> 17188864  1936334848 3  freebsd-zfs  (923G)
>   19535237121416- free -  (708K)
>
> root@eastasia[1004]# mount -t msdosfs /dev/ada0p1 /mnt
> root@eastasia[1005]# df -k /mnt
> Filesystem  1024-blocks Used  Avail Capacity  Mounted on
> /dev/ada0p1  204696  976 203720 0%/mnt
> --
>
> Is there any bug fix about it that is merged to 12.x but not 11.x?
>

11.x puts a pre-canned image into the ESP that's tiny, regardless of the
size, while 12.x does a newfs_msdos and sizes it properly. It's kinda hard
to fix in 11.x since there's a number of changes in a number of places.

You can, though, on 11.x, newfs_msdos the filesystem and copy boot1.efi
from FreeBSD's /boot to the ESP's \efi\boot\bootx64.efi if you need more
space on the ESP for some reason.

Warner
___
freebsd-stable@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"


Size of EFI system partition is much smaller when it is mounted

2020-11-30 Thread Yasuhiro KIMURA
I made clean install of 11.4-RELEASE amd64 with ZFS root and UEFI boot
mode. 'Auto (ZFS)' was used at disk setup phase and disk was
partitioned as following.

--
root@rolling-vm-freebsd3[80]# uname -a
FreeBSD rolling-vm-freebsd3.home.utahime.org 11.4-RELEASE-p3 FreeBSD 
11.4-RELEASE-p3 #0: Tue Sep  1 08:22:33 UTC 2020 
r...@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
root@rolling-vm-freebsd3[81]# gpart show ada0
=>   40  209715120  ada0  GPT  (100G)
 40 409600 1  efi  (200M)
 409640   2008- free -  (1.0M)
 411648   16777216 2  freebsd-swap  (8.0G)
   17188864  192524288 3  freebsd-zfs  (92G)
  209713152   2008- free -  (1.0M)
--

According to it the size of EFI system partition is 200MB. But if I
mount it to filesystem and check its size with df(1), then it is much
smaller than 200MB.

--
root@rolling-vm-freebsd3[82]# mount -t msdosfs /dev/ada0p1 /mnt
root@rolling-vm-freebsd3[83]# df -k /mnt
Filesystem  1024-blocks Used Avail Capacity  Mounted on
/dev/ada0p1 779  384   39549%/mnt
--

And if I try to copy large file to /mnt then it fails.

--
root@rolling-vm-freebsd3[94]# ls -l dummy.1MB.date
-rw-r--r--  1 root  wheel  1048576 Nov 29 10:39 dummy.1MB.date
root@rolling-vm-freebsd3[95]# cp dummy.1MB.date /mnt
cp: /mnt/dummy.1MB.date: No space left on device
--

So it seems kernel(?) really regards the size of mounted EFI system
part as only 779KB.

I also tried it with 12.2-RELEASE and df(1) reported correctly.

--
root@eastasia[1002]# uname -a
FreeBSD eastasia.home.utahime.org 12.2-RELEASE FreeBSD 12.2-RELEASE r366954 
GENERIC  amd64
root@eastasia[1003]# gpart show ada0
=>40  1953525088  ada0  GPT  (932G)
  40  409600 1  efi  (200M)
  4096402008- free -  (1.0M)
  41164816777216 2  freebsd-swap  (8.0G)
17188864  1936334848 3  freebsd-zfs  (923G)
  19535237121416- free -  (708K)

root@eastasia[1004]# mount -t msdosfs /dev/ada0p1 /mnt
root@eastasia[1005]# df -k /mnt
Filesystem  1024-blocks Used  Avail Capacity  Mounted on
/dev/ada0p1  204696  976 203720 0%/mnt
--

Is there any bug fix about it that is merged to 12.x but not 11.x?

Best Regards.

---
Yasuhiro KIMURA
___
freebsd-stable@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"


Re: 12-STABLE try to init thead-using libraries before threads and program crashes

2020-11-30 Thread Lev Serebryakov

On 27.11.2020 20:03, Konstantin Belousov wrote:

On Fri, Nov 27, 2020 at 06:03:13PM +0300, Lev Serebryakov wrote:


  I have locally-built net/samba413 port on 12-STABLE (r367937) which crashes 
in library initialization code due to wrong library initialization order:

(No debugging symbols found in /usr/local/bin/testparm)
(gdb) b  _libpthread_init
Function "_libpthread_init" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (_libpthread_init) pending.
(gdb) run
Starting program: /usr/local/bin/testparm

Program received signal SIGSEGV, Segmentation fault.
thr_malloc_lock (curthread=0x801e077d0) at 
/usr/src/lib/libthr/thread/thr_malloc.c:66
66  curthread->locklevel++;
(gdb) bt
#0  thr_malloc_lock (curthread=0x801e077d0) at 
/usr/src/lib/libthr/thread/thr_malloc.c:66
#1  __thr_calloc (num=1, size=96) at /usr/src/lib/libthr/thread/thr_malloc.c:88
#2  0x000801474843 in mutex_init (mutex=0x801072008, mutex_attr=, 
calloc_cb=) at /usr/src/lib/libthr/thread/thr_mutex.c:295
#3  __Tthr_mutex_init (mutex=0x801072008, mutex_attr=) at 
/usr/src/lib/libthr/thread/thr_mutex.c:395
#4  0x0008016d62fc in ?? () from /usr/local/lib/libgnutls.so.30
#5  0x0008016cfcb3 in ?? () from /usr/local/lib/libgnutls.so.30
#6  0x0008016d0077 in ?? () from /usr/local/lib/libgnutls.so.30
#7  0x00080103730d in objlist_call_init (list=, 
lockstate=) at /usr/src/libexec/rtld-elf/rtld.c:2823
#8  0x00080103603d in _rtld (sp=0x7fffeb58, exit_proc=0x7fffeb20, 
objp=0x7fffeb28) at /usr/src/libexec/rtld-elf/rtld.c:811
#9  0x0008010338c9 in rtld_start () at 
/usr/src/libexec/rtld-elf/amd64/rtld_start.S:39
#10 0x in ?? ()
(gdb)

  Please note, that `_libpthread_init` HAS BEEN NOT CALLED before 
`_Tthr_mutex_init`.

  Looks like some corner-case problem in rtld?

  Link command for this program is:

[3517/3660] Linking bin/default/source3/utils/testparm
runner ['cc', 'source3/utils/testparm.c.41.o', 
'-o/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/source3/utils/testparm',
 '-Wl,-Bstatic', '-Wl,-Bdynamic', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/source4/heimdal_build',
 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/source4/lib/events',
 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib/tdb_wrap', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/libcli/security',
 '-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/librpc', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/libcli/registry',
 '-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib/dbwrap', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib/socket', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib/param', 
'-L/wrkdirs/usr/ports/net/

sam

ba413/work/samba-4.13.1/bin/default/lib/messaging', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib/util', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/libcli/util', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/lib/replace', 
'-L/wrkdirs/usr/ports/net/samba413/work/samba-4.13.1/bin/default/source3', 
'-L/usr/local/lib', '-L/usr/local/lib', '-L/usr/local/lib', '-L/usr/local/lib', 
'-L/usr/local/lib', '-L/usr/local/lib', '-lpopt-samba3-samba4', '-lsmbconf', 
'-lreplace-samba4', '-lsamba-errors', '-lcmdline-contexts-samba4', 
'-lsamba-util', '-lsamba3-util-samba4', '-lmessages-dgm-samba4', 
'-lsys-rw-samba4', '-lmessages-util-samba4', '-liov-buf-samba4', 
'-lsamba-hostconfig', '-lsocket-blocking-samba4', '-linterfaces-samba4', 
'-ldbwrap-samba4', '-ltevent-util', '-lsamba-sockets-samba4', 
'-lutil-reg-samba4', '-lutil-tdb-samba4', '-lndr', 
'-ltalloc-report-printf-samba4', '-lserver-id-db-samba4', 
'-lsamba-cluster-support-samba4', '-

lC

HARSET3-samba4', '-lsamba-security-samba4', '-lsmbd-s
him-samba4', '-lsamba-debug-samba4', '-lgenrand-samba4', '-ltime-basic-samba4', 
'-lutil-setid-samba4', '-lmsghdr-samba4', '-lserver-role-samba4', 
'-ltdb-wrap-samba4', '-levents-samba4', '-lndr-nbt', '-lroken-samba4', 
'-lexecinfo', '-ltevent', '-ltalloc', '-lpthread', '-lutil', 
'-lunwind-generic', '-lunwind', '-liconv', '-lz', '-ltdb', '-lpopt', 
'-lgnutls', '-ltalloc', '-fstack-protector-strong', '-L/usr/local/lib', '-pie', 
'-Wl,-z,relro,-z,now', '-Wl,-no-undefined', '-Wl,--export-dynamic']



libthr is cleanly linked too early, it should come after all consumers.

 I think, system should be resilent to such mistakes.


Anyway, try this.

diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 57984ef6d0e..303386db7fe 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -384,6 +384,8 @@ __Tthr_mutex_init(pthread_mutex_t * __restrict mutex,
struct pthread_mutex *pmtx;