Date: Tue, 11 Nov 2014 08:22:31 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Adrian Chadd <adrian@FreeBSD.org> Cc: "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, Luigi Rizzo <rizzo@iet.unipi.it>, John Baldwin <jhb@freebsd.org> Subject: Re: svn commit: r273266 - in head: lib/libkvm sys/compat/freebsd32 sys/kern sys/sys Message-ID: <23CF9B7D-5AB1-4A16-AC1D-6739B3164771@FreeBSD.org> In-Reply-To: <CAJ-VmonuyBkHD1grJCQ=7R4U3z0z8d%2BqdoKY4i7%2BcJv6vjLqqw@mail.gmail.com> References: <201410181936.s9IJaCwu018930@svn.freebsd.org> <CAJ-VmomFjkw5iS51qDbG3RTVYa66FNDiSCYuX%2B-o5iGAQxzSuA@mail.gmail.com> <C0A6FC3B-DF34-441E-8EDD-408F61B579A9@FreeBSD.org> <3279406.bOBVrcribU@ralph.baldwin.cx> <CAJ-VmonuyBkHD1grJCQ=7R4U3z0z8d%2BqdoKY4i7%2BcJv6vjLqqw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_BAF2B536-5000-401D-B0A4-A69E296D9104
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
It is indeed used to calculate an address offset, but as it is already
checked against NOCPU, it should be good:
gnu/usr.bin/gdb/kgdb/kthr.c: kt->cpu =3D td.td_oncpu;
gnu/usr.bin/gdb/kgdb/trgt_i386.c: if (kt =3D=3D NULL || kt->cpu =3D=3D=
NOCPU)
gnu/usr.bin/gdb/kgdb/trgt_i386.c: addr +=3D (kt->cpu * NGDT + =
GPROC0_SEL) * sizeof(sd);
Maybe the test could be strengthened to check that kt->cpu >=3D 0, but =
it
might be overkill.
-Dimitry
> On 11 Nov 2014, at 00:17, Adrian Chadd <adrian@FreeBSD.org> wrote:
>=20
> just double-check that the cpu id isn't used to size anything; I've
> seen it used as an offset into stuff, and NOCPU would've been entry
> 255 in the array, not -1.
>=20
> Ian pointed this out to me recently and I've only just started digging =
into it.
>=20
>=20
>=20
> -adrian
>=20
>=20
> On 10 November 2014 12:35, John Baldwin <jhb@freebsd.org> wrote:
>> On Monday, November 10, 2014 09:13:08 PM Dimitry Andric wrote:
>>> I noted something similar for kgdb, when compiled with gcc:
>>>=20
>>> cc1: warnings being treated as errors
>>> /usr/src/gnu/usr.bin/gdb/kgdb/trgt_i386.c: In function
>>> 'kgdb_trgt_fetch_tss': =
/usr/src/gnu/usr.bin/gdb/kgdb/trgt_i386.c:142:
>>> warning: comparison is always false due to limited range of data =
type
>>>=20
>>> In gnu/usr.bin/gdb/kgdb/kgdb.h, there is:
>>>=20
>>> struct kthr {
>>> struct kthr *next;
>>> uintptr_t paddr;
>>> uintptr_t kaddr;
>>> uintptr_t kstack;
>>> uintptr_t pcb;
>>> int tid;
>>> int pid;
>>> u_char cpu;
>>> };
>>>=20
>>> The cpu field is assigned from td.td_oncpu (which is an int) in
>>> kgdb_thr_add_procs(), so I think it should be safe to change it to =
an
>>> int too:
>>>=20
>>> Index: gnu/usr.bin/gdb/kgdb/kgdb.h
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>>> --- gnu/usr.bin/gdb/kgdb/kgdb.h (revision 274350)
>>> +++ gnu/usr.bin/gdb/kgdb/kgdb.h (working copy)
>>> @@ -41,7 +41,7 @@
>>> uintptr_t pcb;
>>> int tid;
>>> int pid;
>>> - u_char cpu;
>>> + int cpu;
>>> };
>>>=20
>>> extern struct kthr *curkthr;
>>=20
>> Yes, please commit.
>>=20
>> --
>> John Baldwin
--Apple-Mail=_BAF2B536-5000-401D-B0A4-A69E296D9104
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.26
iEYEARECAAYFAlRhuTsACgkQsF6jCi4glqMwGwCgy/uDSpIvgrmjqZykyBOB71FO
aJYAoPysTm2dAAiqQR7Cclu2Nqg1FqHm
=EfcO
-----END PGP SIGNATURE-----
--Apple-Mail=_BAF2B536-5000-401D-B0A4-A69E296D9104--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?23CF9B7D-5AB1-4A16-AC1D-6739B3164771>
