Skip to contentSkip to conversation

powerpc: add tests for XICS

RFC PATCH In review Laurent Vivier 4 participants 7 messages Oct 12, 2017 – Nov 23, 2017 KVM

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 powerpc: add tests for XICS

Check if we can set the xive server and priority, and check we get values that have been set.
Check we disable/enable interrupts.

This patch also increases NR_CPUS from 8 to 16
(maximum for KVM on POWER9, POWER8 allows 96)

---
Note: I send this as an RFC, because even if this test works well with TCG and POWER8 KVM hosts, it detects some problems with POWER9 KVM hosts

 lib/powerpc/asm/setup.h |   2 +-
 powerpc/rtas.c          | 146 ++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc/unittests.cfg   |   6 ++
 3 files changed, 153 insertions(+), 1 deletion(-)
lib/powerpc/asm/setup.h +1 -1
index 23b4156..f667aac 100644
@@ -7,7 +7,7 @@
  */
 #include <libcflat.h>
 
-#define NR_CPUS			8	/* arbitrarily set for now */
+#define NR_CPUS			16	/* Maximum supported by KVM on P9 */
 extern u32 cpus[NR_CPUS];
 extern int nr_cpus;
 
powerpc/rtas.c +146 -0

169 lines not on this page · raw message

powerpc/unittests.cfg +6 -0
index 4eda258..76ccb62 100644
@@ -57,6 +57,12 @@ extra_params = -append "set-time-of-day"
 timeout = 5
 groups = rtas
 
+[xics]
+file = rtas.elf
+extra_params = -smp 16 -append "xics"
+timeout = 5
+groups = rtas
+
 [emulator]
 file = emulator.elf
 
Signature · 1 line
2.13.6
#1 lore raw
Quoted 11 lines · Laurent Vivier

Check if we can set the xive server and priority, and check we get values that have been set.
Check we disable/enable interrupts.

This patch also increases NR_CPUS from 8 to 16
(maximum for KVM on POWER9, POWER8 allows 96)

---
Note: I send this as an RFC, because even if this test works well with TCG and POWER8 KVM hosts, it detects some problems with POWER9 KVM hosts

What kind of errors does it detect? Are they expected due to the different interrupt controllers?

powerpc/rtas.c int main(int argc, char **argv) · line 283

Quoted 6 lines

main(int argc, char **argv)

powerpc/rtas.c +2 -0
 		check_set_time_of_day();
 
+	} else if (strcmp(argv[1], "xics") = 0) {
+

Superfluous empty line?

powerpc/rtas.c int main(int argc, char **argv) · line 285

Quoted 2 lines
powerpc/rtas.c +2 -0
+		check_xics();
+

Thomas

#2 lore raw
Quoted 8 lines · Thomas Huth
Quoted 7 lines · Laurent Vivier

Check if we can set the xive server and priority, and check we get values that have been set.
Check we disable/enable interrupts.

This patch also increases NR_CPUS from 8 to 16
(maximum for KVM on POWER9, POWER8 allows 96)

Quoted 8 lines
Quoted 4 lines

---
Note: I send this as an RFC, because even if this test works well with TCG and POWER8 KVM hosts, it detects some problems with POWER9 KVM hosts

What kind of errors does it detect? Are they expected due to the different interrupt controllers?

[I cc' Sam as he already did a fix for this part in the kernel]

I have two kinds of error:

- "xics: get-xive: irq #4351, expected cpu 15 prio 255, had cpu 0 prio 255",
Priority 255 is set to disable the IRQs, I don't think it's really a problem at this level, it could be only cosmetic,

- "xics: int-on: irq #4351, ret = -3",
but here it becomes more serious: as the IRQ server has been lost, it seems we are not able to re-enable the interrupt.

I have no access to a POWER9 host to debug this at the kernel level for the moment, so I can't do more.

Thanks,
Laurent

#3 lore raw
Quoted 14 lines · Laurent Vivier
Quoted 13 lines · Thomas Huth
Quoted 11 lines · Laurent Vivier

Check if we can set the xive server and priority, and check we get values that have been set.
Check we disable/enable interrupts.

This patch also increases NR_CPUS from 8 to 16
(maximum for KVM on POWER9, POWER8 allows 96)

---
Note: I send this as an RFC, because even if this test works well with TCG and POWER8 KVM hosts, it detects some problems with POWER9 KVM hosts

Quoted 5 lines
Quoted 3 lines

What kind of errors does it detect? Are they expected due to the different interrupt controllers?

[I cc' Sam as he already did a fix for this part in the kernel]

I finally found some time to debug this.

Quoted 6 lines

I have two kinds of error:

- "xics: get-xive: irq #4351, expected cpu 15 prio 255, had cpu 0 prio 255",
Priority 255 is set to disable the IRQs, I don't think it's really a problem at this level, it could be only cosmetic,

In this case, we have set priority to 255 with set-xive, and in the emulation, 255 is the "MASKED" value and in this case set-xive doesn't store the interrupt server, so get-xive always returns an invalid server.

Quoted 3 lines

- "xics: int-on: irq #4351, ret = -3",
but here it becomes more serious: as the IRQ server has been lost, it seems we are not able to re-enable the interrupt.

int-on explicitly checks the priority value, and if the value is "MASKED" (255, the value we set previously with set-xive) it returns an error.

These errors can be fixed by two different ways:

A- don't allow set-xive to set the priority to 255 (the MASKED value)
and return an error value, and get-xive return an error value if priority is the MASKED value

B- store the server in set-xive even it the value is the MASKED one, so we can get it with get-xive and use it with int-on (with the saved priority value)

(A) follows the specs:

Linux on Power Architecture Platform Reference, v1.1 R1–7.3.10.2–5. For the PowerPC External Interrupt option: The
ibm,set-xive call must return the Status of -3 (Argument Error) for an unimplemented Interrupt number.

(B) would behave like XICS with P8 and TCG.

Any ideas?

Thanks,
Laurent

#4 lore raw
Quoted 12 lines · Laurent Vivier

These errors can be fixed by two different ways:

A- don't allow set-xive to set the priority to 255 (the MASKED value)
and return an error value, and get-xive return an error value if priority is the MASKED value

B- store the server in set-xive even it the value is the MASKED one, so we can get it with get-xive and use it with int-on (with the saved priority value)

(A) follows the specs:

Quoted 8 lines

Linux on Power Architecture Platform Reference, v1.1 R1–7.3.10.2–5. For the PowerPC External Interrupt option: The
ibm,set-xive call must return the Status of -3 (Argument Error) for an unimplemented Interrupt number.

(B) would behave like XICS with P8 and TCG.

Any ideas?

I don't see much point in supporting an unbalance where somebody masks with set_xive and unmasks with int_on...

These PAPR APIs originates from pre-historical times, it's a bit of a mess.

set_xive should be able to set a priority of 255, that's a requirement, but we could fix the emulation to store the server in that case I suppose.

Ben.

#5 lore raw
In reply to Thomas Huth
Quoted 20 lines · Thomas Huth
Quoted 11 lines · Laurent Vivier

Check if we can set the xive server and priority, and check we get values that have been set.
Check we disable/enable interrupts.

This patch also increases NR_CPUS from 8 to 16
(maximum for KVM on POWER9, POWER8 allows 96)

---
Note: I send this as an RFC, because even if this test works well with TCG and POWER8 KVM hosts, it detects some problems with POWER9 KVM hosts

What kind of errors does it detect? Are they expected due to the different interrupt controllers?

Quoted 4 lines

main(int argc, char **argv)

check_set_time_of_day();

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	} else if (strcmp(argv[1], "xics") = 0) {
+

Superfluous empty line?

powerpc/rtas.c int main(int argc, char **argv) · line 285

Quoted 2 lines
powerpc/rtas.c +2 -0
+		check_xics();
+

This is a standard pattern in kvm-unit-tests:

...

        } else if (strcmp(argv[1], "XXXX") = 0) {

                function(...);

        } else if (strcmp(argv[1], "YYY") = 0) {

...

Laurent

#6 lore raw
Quoted 31 lines · Laurent Vivier
Quoted 20 lines · Thomas Huth
Quoted 11 lines · Laurent Vivier

Check if we can set the xive server and priority, and check we get values that have been set.
Check we disable/enable interrupts.

This patch also increases NR_CPUS from 8 to 16
(maximum for KVM on POWER9, POWER8 allows 96)

---
Note: I send this as an RFC, because even if this test works well with TCG and POWER8 KVM hosts, it detects some problems with POWER9 KVM hosts

What kind of errors does it detect? Are they expected due to the different interrupt controllers?

Quoted 4 lines

main(int argc, char **argv)

check_set_time_of_day();

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	} else if (strcmp(argv[1], "xics") = 0) {
+

Superfluous empty line?

powerpc/rtas.c int main(int argc, char **argv) · line 285

Quoted 2 lines
powerpc/rtas.c +2 -0
+		check_xics();
+

This is a standard pattern in kvm-unit-tests:

Quoted 8 lines

...

        } else if (strcmp(argv[1], "XXXX") = 0) {

                function(...);

        } else if (strcmp(argv[1], "YYY") = 0) {

...

I think that pattern is primarily used in arm/selftest.c and powerpc/selftest.c, which I'm to blame for it. I found it easier to read that way, but do agree it's not a typical use of whitespace. Anyway, to me, it's not a big deal either way. I wouldn't post a patch removing those blank lines, but I also wouldn't request them to be added to patches that don't have them...

Thanks,
drew