Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Jul 2024 02:01:22 +0900 (JST)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        zlei@FreeBSD.org
Cc:        imp@freebsd.org, jhb@FreeBSD.org, freebsd-usb@freebsd.org
Subject:   Re: How to test stand/usb
Message-ID:  <20240702.020122.1030553811647103008.hrs@FreeBSD.org>
In-Reply-To: <6B9A293F-18CF-4FB2-B095-BC468354BCA8@FreeBSD.org>
References:  <6B9A293F-18CF-4FB2-B095-BC468354BCA8@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----Security_Multipart(Tue_Jul__2_02_01_22_2024_397)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

Zhenlei Huang <zlei@FreeBSD.org> wrote
  in <6B9A293F-18CF-4FB2-B095-BC468354BCA8@FreeBSD.org>:

zl> I'm recently working on cleaning up malloc(M_WAITOK), and found that the sys/dev/usb
zl> stack is also used by bootloader. Currently stand/usb fails to compile ( since the
zl> commit 9e4e7bcaef3f 2022/8/23 ) and I have some WIP patches. I do not find a good
zl> page about its usage. How can I test stand/usb ? Or it has no usage any more and should
zl> be retired ?

The stand/usb directory is used to build the libusbboot.a library
containing the devsw for umass(4).  The following patch (against a bit
old tree) should fix the build errors at least:

 https://people.allbsd.org/~hrs/FreeBSD/kshim-fix.20240702-1.diff

To compile a loader with libusbboot.a, you need to build a
libusbboot.a with some flags first and link it with a loader.  On the
loader side, you need to edit conf.c and Makefile.  The above patch
includes changes for i386/loader, and the following command lines
should build both (MK_LOADER_ZFS=no because libusbboot.a is too
large):

# cd /usr/src/stand/usb/tools && make && make install
% cd /usr/src/stand/usb && \
    make obj && \
    make -DHAVE_UMASS_LOADER -DHAVE_EHCI depend && \
    make -DHAVE_UMASS_LOADER -DHAVE_EHCI
% cd /usr/src/stand/i386/loader && \
    make obj && \
    make MK_LOADER_ZFS=no depend && \
    make MK_LOADER_ZFS=no
# cd /usr/src/stand/i386/loader && \
    make MK_LOADER_ZFS=no DESTDIR=/tmp install

and you should be able to find a legacy BIOS loader in
/tmp/boot/loader.  I did not test whether the build result works
actually, though.  Note that the first command builds "sysinit" tool
and installs it into /usr/bin.  You can remove it after testing.

Also note that the kernel source files used by ones under usb/ will
use a different malloc implementation defined in
kshim/bsd_kernel.[ch].  So, malloc(9) flags are simply ignored.  If
your work intends to check if rewriting of malloc(M_WAITOK) works or
not, I think you can consider it does not affect the loaders using the
libusbboot library.

Although the files under kshim/ and usb/ are not maintained well, I
personally think they are still worth keeping.

-- Hiroki

----Security_Multipart(Tue_Jul__2_02_01_22_2024_397)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iMoEABMKAC4WIQRsDSNTJ8+Ax5Ae/dLbsH3Gbx9zfwUCZoLg4hAcaHJzQGZyZWVi
c2Qub3JnAAoJENuwfcZvH3N/ibgCCQE5UA7kL7XCf4JBXSXVoAvT3O5wntTC1jTm
15Mz3pSr1a2DkHuxXgjqV1+Eh81RlLcg5huEY27eDpbY7rYmla7gzAIJARQKmsQ6
fh6NYWgJ0Y/Qj6q04lxKAGiQWwR4paxmhiCEe9WHNCJmLlS3d7gSyoVmdagxWRpu
Z3QB+IvQNBPdgYyH
=lUTZ
-----END PGP SIGNATURE-----

----Security_Multipart(Tue_Jul__2_02_01_22_2024_397)----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20240702.020122.1030553811647103008.hrs>