Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2014 07:08:01 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Attilio Rao <attilio@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r267651 - in head: share/man/man4 sys/dev/cpuctl sys/sys usr.sbin/cpucontrol
Message-ID:  <20140620040801.GA3991@kib.kiev.ua>
In-Reply-To: <201406192154.s5JLsfed074305@svn.freebsd.org>
References:  <201406192154.s5JLsfed074305@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--Bdv4BQVKRoKl8WEC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jun 19, 2014 at 09:54:41PM +0000, Attilio Rao wrote:
> Author: attilio
> Date: Thu Jun 19 21:54:41 2014
> New Revision: 267651
> URL: http://svnweb.freebsd.org/changeset/base/267651
>=20
> Log:
>   Following comments in r242565 add the possibility to specify ecx when
>   performing cpuid calls.
>   Add also a new way to specify the level type to cpucontrol(8) as
>   reported in the manpage.
>  =20
>   Sponsored by:	EMC / Isilon storage division
>   Reviewed by:	bdrewery, gcooper
>   Testerd by:	bdrewery
> Modified: head/sys/sys/cpuctl.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=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/sys/cpuctl.h	Thu Jun 19 21:05:07 2014	(r267650)
> +++ head/sys/sys/cpuctl.h	Thu Jun 19 21:54:41 2014	(r267651)
> @@ -35,7 +35,8 @@ typedef struct {
>  } cpuctl_msr_args_t;
> =20
>  typedef struct {
> -	int		level;	/* CPUID level */
> +	int		level;		/* CPUID level */
> +	int		level_type;	/* CPUID level type */
>  	uint32_t	data[4];
>  } cpuctl_cpuid_args_t;
> =20
> @@ -50,5 +51,6 @@ typedef struct {
>  #define	CPUCTL_UPDATE	_IOWR('c', 4, cpuctl_update_args_t)
>  #define	CPUCTL_MSRSBIT	_IOWR('c', 5, cpuctl_msr_args_t)
>  #define	CPUCTL_MSRCBIT	_IOWR('c', 6, cpuctl_msr_args_t)
> +#define	CPUCTL_CPUID_COUNT _IOWR('c', 7, cpuctl_cpuid_args_t)
> =20
>  #endif /* _CPUCTL_H_ */

The cpuctl(4) is used by third-party code, and this change breaks its
ABI. The numeric value for CPUCTL_CPUID is changed, which means that
old binaries call non-existing ioctl now. This is at least a visible
breakage, since the argument for the ioctl changed the layout as well.

The following patch restored the CPUCTL_CPUID for me.  I considered
naming its argument differently, instead of renaming the argument
of CPUCTL_CPUID_COUNT (which you tried to do ?), but decided not,
to preserve the API as well.

Do you agree with the change ?

diff --git a/sys/dev/cpuctl/cpuctl.c b/sys/dev/cpuctl/cpuctl.c
index 63187bd..9832933 100644
--- a/sys/dev/cpuctl/cpuctl.c
+++ b/sys/dev/cpuctl/cpuctl.c
@@ -69,7 +69,7 @@ static int cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data=
, u_long cmd,
     struct thread *td);
 static int cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data,
     struct thread *td);
-static int cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_args_t *data,
+static int cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
     struct thread *td);
 static int cpuctl_do_update(int cpu, cpuctl_update_args_t *data,
     struct thread *td);
@@ -180,8 +180,8 @@ cpuctl_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
 		ret =3D cpuctl_do_update(cpu, (cpuctl_update_args_t *)data, td);
 		break;
 	case CPUCTL_CPUID_COUNT:
-		ret =3D cpuctl_do_cpuid_count(cpu, (cpuctl_cpuid_args_t *)data,
-		    td);
+		ret =3D cpuctl_do_cpuid_count(cpu,
+		    (cpuctl_cpuid_count_args_t *)data, td);
 		break;
 	default:
 		ret =3D EINVAL;
@@ -195,7 +195,8 @@ fail:
  * Actually perform cpuid operation.
  */
 static int
-cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_args_t *data, struct thread *t=
d)
+cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
+    struct thread *td)
 {
 	int is_bound =3D 0;
 	int oldcpu;
@@ -218,10 +219,15 @@ cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_args_t *d=
ata, struct thread *td)
 static int
 cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data, struct thread *td)
 {
+	cpuctl_cpuid_count_args_t cdata;
+	int error;
=20
+	cdata.level =3D data->level;
 	/* Override the level type. */
-	data->level_type =3D 0;
-	return (cpuctl_do_cpuid_count(cpu, data, td));
+	cdata.level_type =3D 0;
+	error =3D cpuctl_do_cpuid_count(cpu, &cdata, td);
+	bcopy(cdata.data, data->data, sizeof(data->data)); /* Ignore error */
+	return (error);
 }
=20
 /*
diff --git a/sys/sys/cpuctl.h b/sys/sys/cpuctl.h
index 4220dee..30af524 100644
--- a/sys/sys/cpuctl.h
+++ b/sys/sys/cpuctl.h
@@ -36,11 +36,16 @@ typedef struct {
=20
 typedef struct {
 	int		level;		/* CPUID level */
-	int		level_type;	/* CPUID level type */
 	uint32_t	data[4];
 } cpuctl_cpuid_args_t;
=20
 typedef struct {
+	int		level;		/* CPUID level */
+	int		level_type;	/* CPUID level type */
+	uint32_t	data[4];
+} cpuctl_cpuid_count_args_t;
+
+typedef struct {
 	void	*data;
 	size_t	size;
 } cpuctl_update_args_t;
@@ -51,6 +56,6 @@ typedef struct {
 #define	CPUCTL_UPDATE	_IOWR('c', 4, cpuctl_update_args_t)
 #define	CPUCTL_MSRSBIT	_IOWR('c', 5, cpuctl_msr_args_t)
 #define	CPUCTL_MSRCBIT	_IOWR('c', 6, cpuctl_msr_args_t)
-#define	CPUCTL_CPUID_COUNT _IOWR('c', 7, cpuctl_cpuid_args_t)
+#define	CPUCTL_CPUID_COUNT _IOWR('c', 7, cpuctl_cpuid_count_args_t)
=20
 #endif /* _CPUCTL_H_ */

--Bdv4BQVKRoKl8WEC
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJTo7OhAAoJEJDCuSvBvK1BTQcP/0aW5LRHF7bbeuhvmbFi021k
BAr6TP8njxSAQGkyROODEgJP1VBC+WTmAPwFTGYeC1GwQ65mX6HgBFbJbXtI98Tn
dpqgtshD+Fb36fHi2IJld/FPp53cH+VzS78p1e1ldYyeSmkR/xoRu+r8a9HMy/2M
6dyVhDXE8Sj7pGg/5gvRQURm9CW4goHeeUkXLTkGHuwgVi6hm9fTzNcVsNdZYqer
YYsXWOMk55DyEtj7Id0UW8T0OyE1pd0T3J9TC25JjBljjy5R5QOgeVg6lo2Skv5J
ACzaaq6UbFvu6oOWYHrtvuAOfY8f0DaaVwmLhjHDEWkY6JszW4ZVC9xEcE4e6ZbT
aoHJhOhPK+sNscMq5doUtOHQVnLNCkM8ISo4Gw0pZrcRDl1tqTRjEiSG8G0OKVA9
k4NZfwyWcYCIO3OZyinubNqmyOH0MIj7boVNSn4w3YlW7QZt6702HQyN17lvTk1X
dwyyitucMOAji59Xn0AbTchd1pucJ7e3mP6wKgo4BQpUMX64dTixUPe+ZhWzXV3z
s0ts3OIJ0oQ9NdjvN/ZwHl57oSk5RcPUutLLig1E+3xsgOg73W6FRYlCpK51xqaI
9INLb53Cd7Ua7V+TR6iI2+Mtj6Us1fhwQmjx10QeH9fEFpk6GMJHfDxUItGxZWlC
Xec/hv+vu/sfKKkZlpwy
=lxoC
-----END PGP SIGNATURE-----

--Bdv4BQVKRoKl8WEC--



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