From owner-freebsd-arch@FreeBSD.ORG Mon Jul 19 21:52:35 2010 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A3FF1065670 for ; Mon, 19 Jul 2010 21:52:35 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.freebsd.org (Postfix) with ESMTP id 102F68FC19 for ; Mon, 19 Jul 2010 21:52:34 +0000 (UTC) Received: from [127.0.0.1] (pooker.samsco.org [168.103.85.57]) (authenticated bits=0) by pooker.samsco.org (8.14.4/8.14.4) with ESMTP id o6JLqVAv066358; Mon, 19 Jul 2010 15:52:31 -0600 (MDT) (envelope-from scottl@samsco.org) Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii From: Scott Long In-Reply-To: <20100719213054.GB2381@deviant.kiev.zoral.com.ua> Date: Mon, 19 Jul 2010 15:52:31 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20100719213054.GB2381@deviant.kiev.zoral.com.ua> To: Kostik Belousov X-Mailer: Apple Mail (2.1078) X-Spam-Status: No, score=-50.0 required=3.8 tests=ALL_TRUSTED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.0 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on pooker.samsco.org Cc: amd64@freebsd.org, arch@freebsd.org Subject: Re: uname -m/-p for compat32 binaries X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2010 21:52:35 -0000 We do something similar at yahoo, and it's code that we're working on = packaging up to put back into FreeBSD. I don't know how your code = differs from ours, and I obviously cannot stop you from committing = yours, but you're welcome to look at our code. Scott On Jul 19, 2010, at 3:30 PM, Kostik Belousov wrote: > Hi, > I intend to commit the following change, that makes sysctls > hw.machine_arch and hw.machine to return "i386" for 32 bit > binaries run on amd64. In particular, 32 bit uname -m and uname -p > print "i386", that is good for i386 jails on amd64 kernels. >=20 > I find the change very useful for me, but I wonder why such trivial > modification is not yet done. Can anybody note a possible fallout from > it ? >=20 > diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c > index 52e7568..68de22b 100644 > --- a/sys/amd64/amd64/identcpu.c > +++ b/sys/amd64/amd64/identcpu.c > @@ -76,8 +76,26 @@ static void print_via_padlock_info(void); >=20 > int cpu_class; > char machine[] =3D "amd64"; > -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,=20 > - machine, 0, "Machine class"); > + > +static int > +sysctl_hw_machine(SYSCTL_HANDLER_ARGS) > +{ > +#ifdef SCTL_MASK32 > + static const char machine32[] =3D "i386"; > +#endif > + int error; > + > +#ifdef SCTL_MASK32 > + if ((req->flags & SCTL_MASK32) !=3D 0) > + error =3D SYSCTL_OUT(req, machine32, sizeof(machine32)); > + else > +#endif > + error =3D SYSCTL_OUT(req, machine, sizeof(machine)); > + return (error); > + > +} > +SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD, > + NULL, 0, sysctl_hw_machine, "A", "Machine class"); >=20 > static char cpu_model[128]; > SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,=20 > diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c > index 7ef580f..0b7d27f 100644 > --- a/sys/kern/kern_mib.c > +++ b/sys/kern/kern_mib.c > @@ -232,9 +232,31 @@ sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS) > SYSCTL_PROC(_hw, OID_AUTO, pagesizes, CTLTYPE_ULONG | CTLFLAG_RD, > NULL, 0, sysctl_hw_pagesizes, "LU", "Supported page sizes"); >=20 > -static char machine_arch[] =3D MACHINE_ARCH; > -SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD, > - machine_arch, 0, "System architecture"); > +static int > +sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS) > +{ > + static const char machine_arch[] =3D MACHINE_ARCH; > +#ifdef SCTL_MASK32 > + static const char machine_arch32[] =3D=20 > +#if defined(__amd64__) || defined(__ia64__) > + "i386"; > +#else > + MACHINE_ARCH; > +#endif > +#endif > + int error; > + > +#ifdef SCTL_MASK32 > + if ((req->flags & SCTL_MASK32) !=3D 0) > + error =3D SYSCTL_OUT(req, machine_arch32, = sizeof(machine_arch32)); > + else > +#endif > + error =3D SYSCTL_OUT(req, machine_arch, = sizeof(machine_arch)); > + return (error); > + > +} > +SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | = CTLFLAG_RD, > + NULL, 0, sysctl_hw_machine_arch, "A", "System architecture"); >=20 > static int > sysctl_hostname(SYSCTL_HANDLER_ARGS)