Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Feb 2023 15:40:33 -0800
From:      Kevin Oberman <rkoberman@gmail.com>
To:        Brooks Davis <brooks@freebsd.org>
Cc:        "freebsd-emulation@freebsd.org" <emulation@freebsd.org>
Subject:   Re: virtualbon-ose-kmod build fails with 14-CURRENT and llvm15
Message-ID:  <CAN6yY1tQ3617Q3GkR0-RKjuJtYX5UDNHLFrFjR%2BEkrbt8NyPRw@mail.gmail.com>
In-Reply-To: <Y/04blSCUsZ3JknV@spindle.one-eyed-alien.net>
References:  <CAN6yY1td9cRtj3BzMw-eAHS4HCAv049w3rjOpmjq-fCpmfp2Pw@mail.gmail.com> <Y/z2AGoKZ5gtu0Ks@spindle.one-eyed-alien.net> <CAN6yY1sSD6i85Bc8K409wR4W%2Bperxk-A5OM5KQg8m5yaKfdXxQ@mail.gmail.com> <Y/04blSCUsZ3JknV@spindle.one-eyed-alien.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000004f4fba05f5b702b2
Content-Type: text/plain; charset="UTF-8"

Thanks, Brooks! That seems to have been the right cast. At least it
compiles correctly. I'll  test it after I reboot the new kernel and
installworld, probably this evening.

I was a bit confused by what appeared as a cast of a void to a void, but
assumed I was just not understanding.

On Mon, Feb 27, 2023 at 3:10 PM Brooks Davis <brooks@freebsd.org> wrote:

> On Mon, Feb 27, 2023 at 02:58:44PM -0800, Kevin Oberman wrote:
> > On Mon, Feb 27, 2023 at 10:27 AM Brooks Davis <brooks@freebsd.org>
> wrote:
> >
> > > On Sun, Feb 26, 2023 at 09:45:34AM -0800, Kevin Oberman wrote:
> > > > I updated my system yesterday. I then tried to rebuild
> > > virtualbox-ose-kmod.
> > > > This fails under llvm15. The same source code built successfully with
> > > > llvm14, so I assume that the code has a problem with 15. I suspect
> that
> > > 15
> > > > changed some default and declared this as an error, but may be
> "fixed"
> > > with
> > > > the proper build option.
> > > >
> > > > Here is the command and error that I see:
> > > >
> > > > cc  -O2 -pipe -fno-strict-aliasing -DRT_OS_FREEBSD -DIN_RING0
> -DIN_RT_R0
> > > > -DIN_SUP_R0 -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX -DRT_WITH_VBOX -w
> > > > -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS -DRT_ARCH_AMD64
> -Werror
> > > > -D_KERNEL -DKLD_MODULE -nostdinc  -Iinclude -I. -Ir0drv -include
> > > >
> > >
> /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/out/freebsd.amd64/release/bin/src/vboxdrv/opt_global.h
> > > > -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common
> > > >  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
> > > > -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include
> > > > -fdebug-prefix-map=./x86=/usr/src/sys/x86/include
> > > > -fdebug-prefix-map=./i386=/usr/src/sys/i386/include     -MD
> > > >  -MF.depend.SUPDrv-freebsd.o -MTSUPDrv-freebsd.o -mcmodel=kernel
> > > > -mno-red-zone -mno-mmx -mno-sse -msoft-float
> > > >  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv
> -fstack-protector
> > > > -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes
> > > > -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign
> > > > -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs
> > > > -fdiagnostics-show-option -Wno-unknown-pragmas
> > > > -Wno-error=tautological-compare -Wno-error=empty-body
> > > > -Wno-error=parentheses-equality -Wno-error=unused-function
> > > > -Wno-error=pointer-sign -Wno-error=shift-negative-value
> > > > -Wno-address-of-packed-member -Wno-error=array-parameter
> > > > -Wno-error=deprecated-non-prototype -Wno-error=strict-prototypes
> > > > -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes
> > > > -mno-avx  -std=iso9899:1999 -c
> > > >
> > >
> /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/out/freebsd.amd64/release/bin/src/vboxdrv/freebsd/SUPDrv-freebsd.c
> > > > -o SUPDrv-freebsd.o
> > > >
> > >
> /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/out/freebsd.amd64/release/bin/src/vboxdrv/freebsd/SUPDrv-freebsd.c:433:50:
> > > > error: incompatible pointer to integer conversion passing 'void *' to
> > > > parameter of type 'RTR3PTR' (aka 'unsigned long') [-Wint-conversion]
> > > >         if (RT_FAILURE(RTR0MemUserCopyFrom(&Hdr, pvUser,
> sizeof(Hdr))))
> > > >                                                  ^~~~~~
> > > > include/iprt/errcore.h:99:58: note: expanded from macro 'RT_FAILURE'
> > > >
> > > > Any help appreciated. I really need virtualbox. I think I may force
> it to
> > > > build with llvm14, but I's prefer a fix to build with llvm15.
> > >
> > > Assuming the code works in practice, it should just be a matter of
> > > adding a cast (void *)(uintptr_t)pvUser.
> > >
> > > -- Brooks
> > >
> >
> > Thanks to both of you. Fixing the code seems preferable to patching and
> > rebuilding llvm15, so I tried, but it made no difference, other than the
> > cast, but I may have truncated the error message too soon. Here is the
> > complete message after the patch:
> >
> /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/out/freebsd.amd64/release/bin/src/vboxdrv/freebsd/SUPDrv-freebsd.c:433:50:
> > error: incompatible pointer to integer conversion passing 'void *' to
> > parameter of type 'RTR3PTR' (aka 'unsigned long') [-Wint-conversion]
> >         if (RT_FAILURE(RTR0MemUserCopyFrom(&Hdr, (void
> *)(uintptr_t)pvUser,
> > sizeof(Hdr))))
> >
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> > include/iprt/errcore.h:99:58: note: expanded from macro 'RT_FAILURE'
> > #define RT_FAILURE(rc)      ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) )
> >                                                          ^~
> > include/iprt/errcore.h:80:38: note: expanded from macro 'RT_SUCCESS_NP'
> > # define RT_SUCCESS_NP(rc)   ( (int)(rc) >= VINF_SUCCESS )
> >                                      ^~
> > include/iprt/cdefs.h:1826:53: note: expanded from macro 'RT_UNLIKELY'
> > #  define RT_UNLIKELY(expr)     __builtin_expect(!!(expr), 0)
> >                                                     ^~~~
> > include/iprt/mem.h:756:56: note: passing argument to parameter 'R3PtrSrc'
> > here
> > RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t
> cb);
> >                                                        ^
> >
> > Please understand that I am not a C programmer.  Looking at this leaves
> me
> > a bit lost.
>
> Sorry, I misread the error message and lead you astray by suggesting
> the opposite of the correct thing.  The correct cast is probably
> (uintptr_t)pvUser.
>
> -- Brooks
>


-- 
Kevin Oberman, Part time kid herder and retired Network Engineer
E-mail: rkoberman@gmail.com
PGP Fingerprint: D03FB98AFA78E3B78C1694B318AB39EF1B055683

--0000000000004f4fba05f5b702b2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:tahoma,s=
ans-serif;font-size:small">Thanks, Brooks! That seems to have been the righ=
t cast. At least it compiles correctly. I&#39;ll=C2=A0 test it after I rebo=
ot the new kernel and installworld, probably this evening.</div><div class=
=3D"gmail_default" style=3D"font-family:tahoma,sans-serif;font-size:small">=
<br></div><div class=3D"gmail_default" style=3D"font-family:tahoma,sans-ser=
if;font-size:small">I was a bit confused by what appeared as a cast of a vo=
id to a void, but assumed I was just not understanding.<br></div></div><br>=
<div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, Fe=
b 27, 2023 at 3:10 PM Brooks Davis &lt;<a href=3D"mailto:brooks@freebsd.org=
">brooks@freebsd.org</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
);padding-left:1ex">On Mon, Feb 27, 2023 at 02:58:44PM -0800, Kevin Oberman=
 wrote:<br>
&gt; On Mon, Feb 27, 2023 at 10:27 AM Brooks Davis &lt;<a href=3D"mailto:br=
ooks@freebsd.org" target=3D"_blank">brooks@freebsd.org</a>&gt; wrote:<br>
&gt; <br>
&gt; &gt; On Sun, Feb 26, 2023 at 09:45:34AM -0800, Kevin Oberman wrote:<br=
>
&gt; &gt; &gt; I updated my system yesterday. I then tried to rebuild<br>
&gt; &gt; virtualbox-ose-kmod.<br>
&gt; &gt; &gt; This fails under llvm15. The same source code built successf=
ully with<br>
&gt; &gt; &gt; llvm14, so I assume that the code has a problem with 15. I s=
uspect that<br>
&gt; &gt; 15<br>
&gt; &gt; &gt; changed some default and declared this as an error, but may =
be &quot;fixed&quot;<br>
&gt; &gt; with<br>
&gt; &gt; &gt; the proper build option.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Here is the command and error that I see:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; cc=C2=A0 -O2 -pipe -fno-strict-aliasing -DRT_OS_FREEBSD -DIN=
_RING0 -DIN_RT_R0<br>
&gt; &gt; &gt; -DIN_SUP_R0 -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX -DRT_WITH_VB=
OX -w<br>
&gt; &gt; &gt; -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS -DRT_ARCH_A=
MD64=C2=A0 -Werror<br>
&gt; &gt; &gt; -D_KERNEL -DKLD_MODULE -nostdinc=C2=A0 -Iinclude -I. -Ir0drv=
 -include<br>
&gt; &gt; &gt;<br>
&gt; &gt; /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/o=
ut/freebsd.amd64/release/bin/src/vboxdrv/opt_global.h<br>
&gt; &gt; &gt; -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-co=
mmon<br>
&gt; &gt; &gt;=C2=A0 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer<b=
r>
&gt; &gt; &gt; -fdebug-prefix-map=3D./machine=3D/usr/src/sys/amd64/include<=
br>
&gt; &gt; &gt; -fdebug-prefix-map=3D./x86=3D/usr/src/sys/x86/include<br>
&gt; &gt; &gt; -fdebug-prefix-map=3D./i386=3D/usr/src/sys/i386/include=C2=
=A0 =C2=A0 =C2=A0-MD<br>
&gt; &gt; &gt;=C2=A0 -MF.depend.SUPDrv-freebsd.o -MTSUPDrv-freebsd.o -mcmod=
el=3Dkernel<br>
&gt; &gt; &gt; -mno-red-zone -mno-mmx -mno-sse -msoft-float<br>
&gt; &gt; &gt;=C2=A0 -fno-asynchronous-unwind-tables -ffreestanding -fwrapv=
 -fstack-protector<br>
&gt; &gt; &gt; -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototy=
pes<br>
&gt; &gt; &gt; -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign<br>
&gt; &gt; &gt; -D__printf__=3D__freebsd_kprintf__ -Wmissing-include-dirs<br=
>
&gt; &gt; &gt; -fdiagnostics-show-option -Wno-unknown-pragmas<br>
&gt; &gt; &gt; -Wno-error=3Dtautological-compare -Wno-error=3Dempty-body<br=
>
&gt; &gt; &gt; -Wno-error=3Dparentheses-equality -Wno-error=3Dunused-functi=
on<br>
&gt; &gt; &gt; -Wno-error=3Dpointer-sign -Wno-error=3Dshift-negative-value<=
br>
&gt; &gt; &gt; -Wno-address-of-packed-member -Wno-error=3Darray-parameter<b=
r>
&gt; &gt; &gt; -Wno-error=3Ddeprecated-non-prototype -Wno-error=3Dstrict-pr=
ototypes<br>
&gt; &gt; &gt; -Wno-error=3Dunused-but-set-variable -Wno-format-zero-length=
=C2=A0 =C2=A0-mno-aes<br>
&gt; &gt; &gt; -mno-avx=C2=A0 -std=3Diso9899:1999 -c<br>
&gt; &gt; &gt;<br>
&gt; &gt; /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/o=
ut/freebsd.amd64/release/bin/src/vboxdrv/freebsd/SUPDrv-freebsd.c<br>
&gt; &gt; &gt; -o SUPDrv-freebsd.o<br>
&gt; &gt; &gt;<br>
&gt; &gt; /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/o=
ut/freebsd.amd64/release/bin/src/vboxdrv/freebsd/SUPDrv-freebsd.c:433:50:<b=
r>
&gt; &gt; &gt; error: incompatible pointer to integer conversion passing &#=
39;void *&#39; to<br>
&gt; &gt; &gt; parameter of type &#39;RTR3PTR&#39; (aka &#39;unsigned long&=
#39;) [-Wint-conversion]<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (RT_FAILURE(RTR0MemUserC=
opyFrom(&amp;Hdr, pvUser, sizeof(Hdr))))<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^~~~~~<br>
&gt; &gt; &gt; include/iprt/errcore.h:99:58: note: expanded from macro &#39=
;RT_FAILURE&#39;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Any help appreciated. I really need virtualbox. I think I ma=
y force it to<br>
&gt; &gt; &gt; build with llvm14, but I&#39;s prefer a fix to build with ll=
vm15.<br>
&gt; &gt;<br>
&gt; &gt; Assuming the code works in practice, it should just be a matter o=
f<br>
&gt; &gt; adding a cast (void *)(uintptr_t)pvUser.<br>
&gt; &gt;<br>
&gt; &gt; -- Brooks<br>
&gt; &gt;<br>
&gt; <br>
&gt; Thanks to both of you. Fixing the code seems preferable to patching an=
d<br>
&gt; rebuilding llvm15, so I tried, but it made no difference, other than t=
he<br>
&gt; cast, but I may have truncated the error message too soon. Here is the=
<br>
&gt; complete message after the patch:<br>
&gt; /usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-6.1.36/out/fr=
eebsd.amd64/release/bin/src/vboxdrv/freebsd/SUPDrv-freebsd.c:433:50:<br>
&gt; error: incompatible pointer to integer conversion passing &#39;void *&=
#39; to<br>
&gt; parameter of type &#39;RTR3PTR&#39; (aka &#39;unsigned long&#39;) [-Wi=
nt-conversion]<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (RT_FAILURE(RTR0MemUserCopyFrom(&a=
mp;Hdr, (void *)(uintptr_t)pvUser,<br>
&gt; sizeof(Hdr))))<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^~~~~~~~~~~~~~~~~~~~~~~~~<br>
&gt; include/iprt/errcore.h:99:58: note: expanded from macro &#39;RT_FAILUR=
E&#39;<br>
&gt; #define RT_FAILURE(rc)=C2=A0 =C2=A0 =C2=A0 ( RT_UNLIKELY(!RT_SUCCESS_N=
P(rc)) )<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^~<br>
&gt; include/iprt/errcore.h:80:38: note: expanded from macro &#39;RT_SUCCES=
S_NP&#39;<br>
&gt; # define RT_SUCCESS_NP(rc)=C2=A0 =C2=A0( (int)(rc) &gt;=3D VINF_SUCCES=
S )<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^~<br>
&gt; include/iprt/cdefs.h:1826:53: note: expanded from macro &#39;RT_UNLIKE=
LY&#39;<br>
&gt; #=C2=A0 define RT_UNLIKELY(expr)=C2=A0 =C2=A0 =C2=A0__builtin_expect(!=
!(expr), 0)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^~~~<br>
&gt; include/iprt/mem.h:756:56: note: passing argument to parameter &#39;R3=
PtrSrc&#39;<br>
&gt; here<br>
&gt; RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_=
t cb);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^<br>
&gt; <br>
&gt; Please understand that I am not a C programmer.=C2=A0 Looking at this =
leaves me<br>
&gt; a bit lost.<br>
<br>
Sorry, I misread the error message and lead you astray by suggesting<br>
the opposite of the correct thing.=C2=A0 The correct cast is probably<br>
(uintptr_t)pvUser.<br>
<br>
-- Brooks<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr=
"><div><div dir=3D"ltr">Kevin Oberman, Part time kid herder and retired Net=
work Engineer<br>E-mail: <a href=3D"mailto:rkoberman@gmail.com" target=3D"_=
blank">rkoberman@gmail.com</a><br></div><div>PGP Fingerprint: D03FB98AFA78E=
3B78C1694B318AB39EF1B055683</div></div></div></div></div></div></div></div>

--0000000000004f4fba05f5b702b2--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAN6yY1tQ3617Q3GkR0-RKjuJtYX5UDNHLFrFjR%2BEkrbt8NyPRw>