Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jun 2014 01:09:32 +0200
From:      Michael Tuexen <tuexen@freebsd.org>
To:        Mark R V Murray <markm@FreeBSD.org>
Cc:        Hans Petter Selasky <hps@selasky.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r266083 - in head/sys/arm: arm include
Message-ID:  <F4AF9256-C548-457A-965B-9C3771B45E51@freebsd.org>
In-Reply-To: <06BB0F4F-44D8-4529-9717-474A137CB60A@freebsd.org>
References:  <201405141911.s4EJBFZZ097826@svn.freebsd.org> <537D0952.2040001@selasky.org> <7610C8E6-3F01-4317-BC1A-67645A162CD7@FreeBSD.org> <53871493.2010502@selasky.org> <EE7E19AA-BE18-4740-A636-4DA3023A5392@FreeBSD.org> <9412A358-EBCB-4A5A-B728-2A15C50FC217@fh-muenster.de> <D118F546-0F32-429F-86F2-69BEE0EC2D2F@FreeBSD.org> <CC36082E-1DFD-4576-9653-970F93A3699C@fh-muenster.de> <FD5DF228-1B2B-48F9-8445-54BF5959FEDA@FreeBSD.org> <9B438991-C970-46A7-8116-A490E02D7139@fh-muenster.de> <3841D090-5973-40B0-B61C-F15E8C1978C9@FreeBSD.org> <3664DBD3-7CEA-43E8-9757-E835BB21FE9E@freebsd.org> <5F36DFA5-C5B1-4E5D-88EE-9D60240B40FD@FreeBSD.org> <494BE7DA-26BC-43A7-8BC0-ECAE8A75E1EF@freebsd.org> <6268E444-F6C7-4B8B-86B7-244A2BB3C4DE@FreeBSD.org> <44F7EEB4-46D1-49C7-A4CA-4EA5D41BDF31@freebsd.org> <C2B493ED-DF51-4EC4-9655-EB14499E44C2@FreeBSD.org> <06BB0F4F-44D8-4529-9717-474A137CB60A@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 16 Jun 2014, at 22:41, Michael Tuexen <tuexen@freebsd.org> wrote:

>=20
> On 16 Jun 2014, at 22:13, Mark R V Murray <markm@FreeBSD.org> wrote:
>=20
>>=20
>> On 16 Jun 2014, at 20:38, Michael Tuexen <tuexen@freebsd.org> wrote:
>>> Hmm, the documentation reads
>>=20
>> Which docs are you using?
>>=20
>> I=92m using DDI0360F. (And that could easily be a wrong choice).
> That is what I'm also looking at. Selecting ARM1176...
>=20
> The code regarding _PMC_USER_READ_WRITE_ also needs to be adopted.
> I need to test it... I'll come back in a couple of hours...
Using the following updated patch in addition to your patch:

Index: cpufunc.c
=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
--- cpufunc.c	(revision 267555)
+++ cpufunc.c	(working copy)
@@ -1409,7 +1409,20 @@
  * BEWARE! This gives write access also, which may not be what
  * you want!
  */
+#if defined(CPU_ARM1136) || defined(CPU_ARM1176)
 #ifdef _PMC_USER_READ_WRITE_
+	/* Use Secure User and Non-secure Access Validation Control =
Register
+	   to allow userland access */
+	__asm volatile ("mcr	p15, 0, %0, c15, c9, 0\n\t"
+			:
+			: "r"(0x00000001));
+#endif
+	/* Set PMCR[2,0] to enable counters and reset CCNT */
+	__asm volatile ("mcr	p15, 0, %0, c15, c12, 0\n\t"
+			:
+			: "r"(0x00000005));
+#else
+#ifdef _PMC_USER_READ_WRITE_
 	/* Set PMUSERENR[0] to allow userland access */
 	__asm volatile ("mcr	p15, 0, %0, c9, c14, 0\n\t"
 			:
@@ -1426,6 +1439,7 @@
 			: "r"(0xFFFFFFFF),
 			  "r"(0x00000005),
 			  "r"(0x80000000));
+#endif
 }
 #endif

allows your test program to run successfully without root privileges, if =
I compile the
kernel with _PMC_USER_READ_WRITE_ defined.

Best regards
Michael
>=20
> Best regards
> Michael=20
>>=20
>> M
>> --=20
>> Mark R V Murray
>>=20
>>=20
>=20
>=20
>=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F4AF9256-C548-457A-965B-9C3771B45E51>