target/ppc: Implement new wait variants
commit0c9717ff35d2fe46fa9cb91566fe2afbed9f4f2a
authorNicholas Piggin <npiggin@gmail.com>
Wed, 20 Jul 2022 13:33:52 +0000 (20 23:33 +1000)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Thu, 28 Jul 2022 16:30:41 +0000 (28 13:30 -0300)
tree8862952fe3df2aff0c0a34c2b369f513cf648653
parenteda3f17bcd7b96cf43b1aead3c1c93a2dbbd21ae
target/ppc: Implement new wait variants

ISA v2.06 adds new variations of wait, specified by the WC field. These
are not all compatible with the prior wait implementation, because they
add additional conditions that cause the processor to resume, which can
cause software to hang or run very slowly.

At this moment, with the current wait implementation and a pseries guest
using mainline kernel with new wait upcodes [1], QEMU hangs during boot if
more than one CPU is present:

 qemu-system-ppc64 -M pseries,x-vof=on -cpu POWER10 -smp 2 -nographic
-kernel zImage.pseries -no-reboot

QEMU will exit (as there's no filesystem) if the test "passes", or hang
during boot if it hits the bug.

ISA v3.0 changed the wait opcode and removed the new variants (retaining
the WC field but making non-zero values reserved).

ISA v3.1 added new WC values to the new wait opcode, and added a PL
field.

This patch implements the new wait encoding and supports WC variants
with no-op implementations, which provides basic correctness as
explained in comments.

[1] https://lore.kernel.org/all/20220720132132.903462-1-npiggin@gmail.com/

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: VĂ­ctor Colombo <victor.colombo@eldorado.org.br>
Tested-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20220720133352.904263-1-npiggin@gmail.com>
[danielhb: added information about the bug being fixed]
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
target/ppc/internal.h
target/ppc/translate.c