From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NuYZk-0007Np-6X for qemu-devel@nongnu.org; Wed, 24 Mar 2010 17:57:20 -0400 Received: from [140.186.70.92] (port=43855 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuYZi-0007Nh-GV for qemu-devel@nongnu.org; Wed, 24 Mar 2010 17:57:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuYZg-0002J3-JQ for qemu-devel@nongnu.org; Wed, 24 Mar 2010 17:57:18 -0400 Received: from mail-ww0-f45.google.com ([74.125.82.45]:34653) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuYZg-0002Id-8A for qemu-devel@nongnu.org; Wed, 24 Mar 2010 17:57:16 -0400 Received: by wwb28 with SMTP id 28so415531wwb.4 for ; Wed, 24 Mar 2010 14:57:14 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <8F6B1156-5574-41A3-B2EE-978E77391EF7@suse.de> References: <4aa8564b0912011033n68653e6dufc4bd87ccaf030a5@mail.gmail.com> <8F6B1156-5574-41A3-B2EE-978E77391EF7@suse.de> From: Dmitry Ilyevsky Date: Thu, 25 Mar 2010 00:56:54 +0300 Message-ID: <4aa8564b1003241456y4851b964iafcc534324506666@mail.gmail.com> Subject: Re: [Qemu-devel] TBL register permissions for PPC Content-Type: multipart/mixed; boundary=0016e6d99c2c532ce904829303fc List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf , "Krumme, Chris" Cc: qemu-devel@nongnu.org --0016e6d99c2c532ce904829303fc Content-Type: multipart/alternative; boundary=0016e6d99c2c532ce004829303fa --0016e6d99c2c532ce004829303fa Content-Type: text/plain; charset=UTF-8 Hello All, Please review patch for TBL SPR read access for generic PPC. *Description:* POWER specification docs define TBL/TBU SPRs as readable in user and privileged modes. Therefore SPRs permissions were changed in gen_tbl function in target-ppc/translate_init.c file. *Testing:* Tested with vxworks-6.2 bsp and OS on custom qemu board that includes ppc405 emulated core BR, Dmitry Ilyevsky On Wed, Dec 2, 2009 at 2:23 AM, Alexander Graf wrote: > > On 01.12.2009, at 19:33, Dima Ilyevsky wrote: > > > Hello All, > > > > I have a question about read permissions of TBL SPR for all ppc > processors: > > I have discovered that my application, compiled by WindRiver diab > compiler and running in vxworks OS on ppc405 architecture bumps into > exception generated when trying to read TBL or TBU registers: > > Unless Linux does something funky, mftlb, mftbu (and mftb on 64 bit) are > readable from PR=1. > > int main() > { > long tbu=0, tbl=0; > > asm("mftbu %0" : "=r" (tbu)); > asm("mftbl %0" : "=r" (tbl)); > > printf("TB: %#x %#x\n", tbl, tbu); > } > > agraf@lychee:/tmp> ./mftb > TB: 0xc0397180 0x603 > > However it can't be written to: > > asm("mttbl %0" : : "r" (tbl)); > > agraf@lychee:/tmp> ./mftb > Illegal instruction > > > So yes, I'd suspect a bug in qemu here. Feel free to send a patch. > > Alex > --0016e6d99c2c532ce004829303fa Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Hello All,

Please review patch= for TBL SPR read access for generic PPC.

Descr= iption:

POWER specification docs define TBL/TB= U SPRs as readable in user and=C2=A0privileged=C2=A0modes. Therefore SPRs p= ermissions were changed in gen_tbl function in target-ppc/translate_init.c = file.

Testing:

Tested with vx= works-6.2 bsp and OS on custom qemu board that includes ppc405 emulated cor= e


BR,
Dmitry Ilyevsky

On Wed, Dec 2, 2009 at 2:23 AM, Alexander Graf <agraf@suse.de> wrote:

On 01.12.2009, at 19:33, Dima Ilyevsky wrote:

> Hello All,
>
> I have a question about read permissions of TBL SPR for all ppc proces= sors:
> I have discovered that my application, compiled by WindRiver diab comp= iler and running in vxworks OS on ppc405 architecture bumps into exception = generated when trying to read TBL or TBU registers:

Unless Linux does something funky, = mftlb, mftbu (and mftb on 64 bit) are readable from PR=3D1.

int main()
{
=C2=A0 =C2=A0long tbu=3D0, tbl=3D0;

=C2=A0 =C2=A0asm("mftbu %0" : "=3Dr" (tbu));
=C2=A0 =C2=A0asm("mftbl %0" : "=3Dr" (tbl));

=C2=A0 =C2=A0printf("TB: %#x %#x\n", tbl, tbu);
}

agraf@lychee:/tmp> ./mftb
TB: 0xc0397180 0x603

However it can't be written to:

asm("mttbl %0" : : "r" (tbl));

agraf@lychee:/tmp> ./mftb
Illegal instruction


So yes, I'd suspect a bug in qemu here. Feel free to send a patch.

Alex

--0016e6d99c2c532ce004829303fa-- --0016e6d99c2c532ce904829303fc Content-Type: text/x-patch; charset=US-ASCII; name="0001-Generic-PowerPC-time-base-SPR-should-be-accessible-i.patch" Content-Disposition: attachment; filename="0001-Generic-PowerPC-time-base-SPR-should-be-accessible-i.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g76ob8w00 RnJvbSAxNDFiZjI5ZjUzNTVmMTYzMjA1YzU3ZTk4NTkwNzMwZWQxNWJmYjg2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBuL2EgPGluc3RhbGxAdWJ1bnR1LWRlc2t0b3AuKG5vbmUpPgpE YXRlOiBUaHUsIDI1IE1hciAyMDEwIDAwOjIyOjI1ICswMzAwClN1YmplY3Q6IFtQQVRDSF0gR2Vu ZXJpYyBQb3dlclBDIHRpbWUgYmFzZSBTUFIgc2hvdWxkIGJlIGFjY2Vzc2libGUgaW4gdXNlci9w cml2IG1vZGVzIGZvciByZWFkaW5nCgotLS0KIHRhcmdldC1wcGMvdHJhbnNsYXRlX2luaXQuYyB8 ICAgIDggKysrKy0tLS0KIDEgZmlsZXMgY2hhbmdlZCwgNCBpbnNlcnRpb25zKCspLCA0IGRlbGV0 aW9ucygtKQoKZGlmZiAtLWdpdCBhL3RhcmdldC1wcGMvdHJhbnNsYXRlX2luaXQuYyBiL3Rhcmdl dC1wcGMvdHJhbnNsYXRlX2luaXQuYwppbmRleCBkYjRkYzE3Li5lOGVhZGY0IDEwMDY0NAotLS0g YS90YXJnZXQtcHBjL3RyYW5zbGF0ZV9pbml0LmMKKysrIGIvdGFyZ2V0LXBwYy90cmFuc2xhdGVf aW5pdC5jCkBAIC03NzcsMTYgKzc3NywxNiBAQCBzdGF0aWMgdm9pZCBnZW5fdGJsIChDUFVQUENT dGF0ZSAqZW52KQogICAgICAgICAgICAgICAgICAmc3ByX3JlYWRfdGJsLCBTUFJfTk9BQ0NFU1Ms CiAgICAgICAgICAgICAgICAgIDB4MDAwMDAwMDApOwogICAgIHNwcl9yZWdpc3RlcihlbnYsIFNQ Ul9UQkwsICAgIlRCTCIsCi0gICAgICAgICAgICAgICAgIFNQUl9OT0FDQ0VTUywgU1BSX05PQUND RVNTLAotICAgICAgICAgICAgICAgICBTUFJfTk9BQ0NFU1MsICZzcHJfd3JpdGVfdGJsLAorICAg ICAgICAgICAgICAgICAmc3ByX3JlYWRfdGJsLCBTUFJfTk9BQ0NFU1MsCisgICAgICAgICAgICAg ICAgICZzcHJfcmVhZF90YmwsICZzcHJfd3JpdGVfdGJsLAogICAgICAgICAgICAgICAgICAweDAw MDAwMDAwKTsKICAgICBzcHJfcmVnaXN0ZXIoZW52LCBTUFJfVlRCVSwgICJUQlUiLAogICAgICAg ICAgICAgICAgICAmc3ByX3JlYWRfdGJ1LCBTUFJfTk9BQ0NFU1MsCiAgICAgICAgICAgICAgICAg ICZzcHJfcmVhZF90YnUsIFNQUl9OT0FDQ0VTUywKICAgICAgICAgICAgICAgICAgMHgwMDAwMDAw MCk7CiAgICAgc3ByX3JlZ2lzdGVyKGVudiwgU1BSX1RCVSwgICAiVEJVIiwKLSAgICAgICAgICAg ICAgICAgU1BSX05PQUNDRVNTLCBTUFJfTk9BQ0NFU1MsCi0gICAgICAgICAgICAgICAgIFNQUl9O T0FDQ0VTUywgJnNwcl93cml0ZV90YnUsCisgICAgICAgICAgICAgICAgICZzcHJfcmVhZF90YnUs IFNQUl9OT0FDQ0VTUywKKyAgICAgICAgICAgICAgICAgJnNwcl9yZWFkX3RidSwgJnNwcl93cml0 ZV90YnUsCiAgICAgICAgICAgICAgICAgIDB4MDAwMDAwMDApOwogfQogCi0tIAoxLjcuMAoK --0016e6d99c2c532ce904829303fc--