Skip to contentSkip to conversation

Allow PIR read in privileged mode

PATCH Superseded luporl 3 participants 8 messages May 7, 2018 – Jun 8, 2018

lore
Share & tools
lore

luporl

author
#0 lore raw

PATCH 1/1 Allow PIR read in privileged mode

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

---
 target/ppc/translate_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/translate_init.c +1 -1
index a72be6d121..7b56e3ffb9 100644
@@ -7816,7 +7816,7 @@ static void gen_spr_book3s_ids(CPUPPCState *env)
     /* Processor identification */
     spr_register_hv(env, SPR_PIR, "PIR",
                  SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_generic, SPR_NOACCESS,
                  &spr_read_generic, NULL,
                  0x00000000);
     spr_register_hv(env, SPR_HID0, "HID0",
Signature · 1 line
2.11.0
Reviewed-by Jose Ricardo Ziviani Reviewed-by on v1 1/1
#1 lore raw

Hi Leandro,

You seem to be a newcomer to QEMU development. Welcome ! :)

Please find a few remarks below, so that you can improve your patch submission skills.

First, it is good practice to provide the subsystem name in the subject, as stated in:

https://wiki.qemu.org/Contribute/SubmitAPatch#Write_a_meaningful_commit_message

ie,

[PATCH] target/ppc: Allow PIR read in privileged mode

Then, this is your second shot for this patch, so you should have added:

- a version tag, as stated in:

https://wiki.qemu.org/Contribute/SubmitAPatch#When_resending_patches_add_a_version_tag

ie,

[PATCH v2] target/ppc: Allow PIR read in privileged mode

- a summary of changes since previous versions, as stated in:

https://wiki.qemu.org/Contribute/SubmitAPatch#Include_version_history_in_patchset_revisions

ie,

---
Changes in v2:
- added my Signed-off-by, maintainers CC and Jose's Reviewed-by tags

Pay attention that this summary of changes MUST be added below the '---', because it is only relevant for the review process and we don't want to record in the git changelog.

Quoted 3 lines · On Mon, 7 May 2018 10:48:06 -0300 luporl <[email protected]> wrote:

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

True.

PowerISA 3.0 - 4.3.3 Processor Identification Register

"Read access to the PIR is privileged; write access is not provided."

Quoted 6 lines

---

Quoted 16 lines
 target/ppc/translate_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/translate_init.c +1 -1
index a72be6d121..7b56e3ffb9 100644
@@ -7816,7 +7816,7 @@ static void gen_spr_book3s_ids(CPUPPCState *env)
     /* Processor identification */
     spr_register_hv(env, SPR_PIR, "PIR",
                  SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_generic, SPR_NOACCESS,
                  &spr_read_generic, NULL,
                  0x00000000);
     spr_register_hv(env, SPR_HID0, "HID0",
author
#2 lore raw

PATCH v3 1/1 target/ppc: Allow PIR read in privileged mode

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

PowerISA 3.0 - 4.3.3 Processor Identification Register

"Read access to the PIR is privileged; write access is not provided."

---
Changes in v2:
- added my Signed-off-by, maintainers CC and Jose's Reviewed-by tags

Changes in v3:
- added subsystem name, version tag and summary of changes
- added the section of PowerISA that describes PIR access privileges

 target/ppc/translate_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/translate_init.c +1 -1
index a72be6d121..7b56e3ffb9 100644
@@ -7816,7 +7816,7 @@ static void gen_spr_book3s_ids(CPUPPCState *env)
     /* Processor identification */
     spr_register_hv(env, SPR_PIR, "PIR",
                  SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_generic, SPR_NOACCESS,
                  &spr_read_generic, NULL,
                  0x00000000);
     spr_register_hv(env, SPR_HID0, "HID0",
Signature · 1 line
2.11.0
#3 lore raw

Re: [Qemu-devel] [PATCH v3] target/ppc: Allow PIR read in privileged mode

Quoted 7 lines · luporl

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

PowerISA 3.0 - 4.3.3 Processor Identification Register

"Read access to the PIR is privileged; write access is not provided."

Yes... but a little further down it says "The PIR is a hypervisor resource". Looking at the older 2.07 ISA, it says that guest-supervisor mode reads to the PIR should be redirected to the GPIR register, which this change won't accomplish.

So, I'm not sure what to make of this.

Quoted 31 lines

---
Changes in v2:
- added my Signed-off-by, maintainers CC and Jose's Reviewed-by tags

Changes in v3:
- added subsystem name, version tag and summary of changes
- added the section of PowerISA that describes PIR access privileges

 target/ppc/translate_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/translate_init.c +1 -1
index a72be6d121..7b56e3ffb9 100644
@@ -7816,7 +7816,7 @@ static void gen_spr_book3s_ids(CPUPPCState *env)
     /* Processor identification */
     spr_register_hv(env, SPR_PIR, "PIR",
                  SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_generic, SPR_NOACCESS,
                  &spr_read_generic, NULL,
                  0x00000000);
     spr_register_hv(env, SPR_HID0, "HID0",
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw

Re: [Qemu-devel] [PATCH v3] target/ppc: Allow PIR read in privileged mode

Quoted 6 lines · On Mon, 4 Jun 2018 10:53:22 +1000 David Gibson <[email protected]>…
Quoted 5 lines · luporl

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

PowerISA 3.0 - 4.3.3 Processor Identification Register

Quoted 8 lines
Quoted 2 lines

"Read access to the PIR is privileged; write access is not provided."

Yes... but a little further down it says "The PIR is a hypervisor resource". Looking at the older 2.07 ISA, it says that guest-supervisor mode reads to the PIR should be redirected to the GPIR register, which this change won't accomplish.

Hmmm, there are two definitions for the PIR, one in Book III-S (4.3.3) and one in Book III-E (5.3.3). It looks like you're referring to the latter...

[Category:Embedded.Hypervisor]
Read accesses to the PIR in guest supervisor state are mapped to the GPIR.

The Book III-S definition doesn't mention the GPIR.

Quoted 34 lines

So, I'm not sure what to make of this.

Quoted 31 lines

---
Changes in v2:
- added my Signed-off-by, maintainers CC and Jose's Reviewed-by tags

Changes in v3:
- added subsystem name, version tag and summary of changes
- added the section of PowerISA that describes PIR access privileges

 target/ppc/translate_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/translate_init.c +1 -1
index a72be6d121..7b56e3ffb9 100644
@@ -7816,7 +7816,7 @@ static void gen_spr_book3s_ids(CPUPPCState *env)
     /* Processor identification */
     spr_register_hv(env, SPR_PIR, "PIR",
                  SPR_NOACCESS, SPR_NOACCESS,
-                 SPR_NOACCESS, SPR_NOACCESS,
+                 &spr_read_generic, SPR_NOACCESS,
                  &spr_read_generic, NULL,
                  0x00000000);
     spr_register_hv(env, SPR_HID0, "HID0",  
#5 lore raw

Re: [Qemu-devel] [PATCH v3] target/ppc: Allow PIR read in privileged mode

Quoted 22 lines · Greg Kurz
Quoted 6 lines · On Mon, 4 Jun 2018 10:53:22 +1000 David Gibson <[email protected]>…
Quoted 5 lines · luporl

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

PowerISA 3.0 - 4.3.3 Processor Identification Register

Quoted 8 lines
Quoted 2 lines

"Read access to the PIR is privileged; write access is not provided."

Yes... but a little further down it says "The PIR is a hypervisor resource". Looking at the older 2.07 ISA, it says that guest-supervisor mode reads to the PIR should be redirected to the GPIR register, which this change won't accomplish.

Hmmm, there are two definitions for the PIR, one in Book III-S (4.3.3) and one in Book III-E (5.3.3). It looks like you're referring to the latter...

Quoted 5 lines

[Category:Embedded.Hypervisor]
Read accesses to the PIR in guest supervisor state are mapped to the GPIR.

The Book III-S definition doesn't mention the GPIR.

Oops, sorry. Yes the GPIR stuff is only for BookE. The statement about the PIR being a hypervisor resource is definitely in the BookS section, however (both 2.07 and 3.0).

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#6 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v3] target/ppc: Allow PIR read in privileged mode

Quoted 27 lines · On Wed, 6 Jun 2018 10:53:17 +1000 David Gibson <[email protected]>…
Quoted 26 lines · Greg Kurz
Quoted 6 lines · On Mon, 4 Jun 2018 10:53:22 +1000 David Gibson <[email protected]>…
Quoted 5 lines · luporl

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

PowerISA 3.0 - 4.3.3 Processor Identification Register

Quoted 8 lines
Quoted 2 lines

"Read access to the PIR is privileged; write access is not provided."

Yes... but a little further down it says "The PIR is a hypervisor resource". Looking at the older 2.07 ISA, it says that guest-supervisor mode reads to the PIR should be redirected to the GPIR register, which this change won't accomplish.

Hmmm, there are two definitions for the PIR, one in Book III-S (4.3.3) and one in Book III-E (5.3.3). It looks like you're referring to the latter...

[Category:Embedded.Hypervisor]
Read accesses to the PIR in guest supervisor state are mapped to the GPIR.

Quoted 6 lines
Quoted 1 line

The Book III-S definition doesn't mention the GPIR.

Oops, sorry. Yes the GPIR stuff is only for BookE. The statement about the PIR being a hypervisor resource is definitely in the BookS section, however (both 2.07 and 3.0).

Yes it is, but IIUC, this means that the guest cannot modify it, eg, do mtspr. Section 4.4.4 in Book III-S has a list of SPRs that seem to indicate that mfspr doesn't require hypervisor state with the PIR.

FWIW, this can be verified with xmon in a KVM guest:

0:mon> S
...

srr0   = c0000000000cd06c  srr1  = 8000000000001033 dsisr  = 00000000
dscr   = 0000000000000000  ppr   = 0010000000000000 pir    = 00000020

...
0:mon> Sr 3ff
SPR 0x3ff (1023) = 0x20

but with TCG xmon hits a program check:

0:mon> S
...
srr0 = c0000000000ef204 srr1 = 8000000000041033 dsisr = 40000000
cpu 0x0: Vector: 700 (Program Check) at [c00000003ffdf510]
...
cpu 0x0: Exception 700 (Program Check) in xmon, returning to main loop
...
0:mon> Sr 3ff
SPR 0x3ff (1023) Faulted during read

This patch makes xmon happy under TCG.

#7 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v3] target/ppc: Allow PIR read in privileged mode

Quoted 32 lines · Greg Kurz
Quoted 29 lines · On Wed, 6 Jun 2018 10:53:17 +1000 David Gibson <[email protected]>…
Quoted 27 lines · Greg Kurz
Quoted 6 lines · On Mon, 4 Jun 2018 10:53:22 +1000 David Gibson <[email protected]>…
Quoted 5 lines · luporl

According to PowerISA, the PIR register should be readable in privileged mode also, not only in hypervisor privileged mode.

PowerISA 3.0 - 4.3.3 Processor Identification Register

Quoted 8 lines
Quoted 2 lines

"Read access to the PIR is privileged; write access is not provided."

Yes... but a little further down it says "The PIR is a hypervisor resource". Looking at the older 2.07 ISA, it says that guest-supervisor mode reads to the PIR should be redirected to the GPIR register, which this change won't accomplish.

Hmmm, there are two definitions for the PIR, one in Book III-S (4.3.3) and one in Book III-E (5.3.3). It looks like you're referring to the latter...

[Category:Embedded.Hypervisor]
Read accesses to the PIR in guest supervisor state are mapped to the GPIR.

The Book III-S definition doesn't mention the GPIR.

Quoted 8 lines
Quoted 4 lines

Oops, sorry. Yes the GPIR stuff is only for BookE. The statement about the PIR being a hypervisor resource is definitely in the BookS section, however (both 2.07 and 3.0).

Yes it is, but IIUC, this means that the guest cannot modify it, eg, do mtspr. Section 4.4.4 in Book III-S has a list of SPRs that seem to indicate that mfspr doesn't require hypervisor state with the PIR.

Ah, yes, I was looking for a summary that covered that, but hadn't found it yet.

The patch doesn't actually apply clean to the current tree any more, due to a rename. So can you repost, and I'll apply.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson