Skip to contentSkip to conversation

ppc-for-11.2 queue

GIT PULL Applied Harsh Prateek Bora 2 participants 43 messages Aug 28 RISC-V

lore
Share & tools
lore
#1 lore raw

[PULL 01/41] linux-headers: Update to include KVM_CAP_PPC_COMPAT_CAPS

In reply to Harsh Prateek Bora

From: Amit Machhiwal <[email protected]>

Sync linux headers from Linux kernel commit 1200d84f4c0a
("Merge tag 'powerpc-7.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux").

This picks up the new KVM_CAP_PPC_COMPAT_CAPS capability for powerpc, which introduces:
- struct kvm_ppc_compat_caps: reports processor compatibility modes supported by the host (POWER9, POWER10, POWER11)
- KVM_PPC_GET_COMPAT_CAPS ioctl (KVMIO 0xb8)
- KVM_CAP_PPC_COMPAT_CAPS (cap #250) in linux/kvm.h

The sync is needed to get the corresponding Qemu series[1] merged.

[1]: https://lore.kernel.org/all/[email protected]/

---
 include/standard-headers/linux/const.h  |  4 ++--
 linux-headers/asm-arm64/unistd_64.h     |  1 +
 linux-headers/asm-generic/unistd.h      |  6 +++++-
 linux-headers/asm-loongarch/unistd_64.h |  1 +
 linux-headers/asm-mips/unistd_n32.h     |  1 +
 linux-headers/asm-mips/unistd_n64.h     |  1 +
 linux-headers/asm-mips/unistd_o32.h     |  1 +
 linux-headers/asm-powerpc/kvm.h         | 18 ++++++++++++++++++
 linux-headers/asm-powerpc/unistd_32.h   |  1 +
 linux-headers/asm-powerpc/unistd_64.h   |  1 +
 linux-headers/asm-riscv/unistd_32.h     |  1 +
 linux-headers/asm-riscv/unistd_64.h     |  1 +
 linux-headers/asm-s390/unistd_64.h      |  1 +
 linux-headers/asm-x86/unistd_32.h       |  1 +
 linux-headers/asm-x86/unistd_64.h       |  1 +
 linux-headers/asm-x86/unistd_x32.h      |  1 +
 linux-headers/linux/const.h             |  4 ++--
 linux-headers/linux/kvm.h               |  3 +++
 18 files changed, 43 insertions(+), 5 deletions(-)
include/standard-headers/linux/const.h +2 -2
index c6a9d0c983..92635cec4a 100644
@@ -13,7 +13,7 @@
  * leave it unchanged in asm.
  */
 
-#ifdef __ASSEMBLY__
+#ifdef __ASSEMBLER__
 #define _AC(X,Y)	X
 #define _AT(T,X)	X
 #else
@@ -28,7 +28,7 @@
 #define _BITUL(x)	(_UL(1) << (x))
 #define _BITULL(x)	(_ULL(1) << (x))
 
-#if !defined(__ASSEMBLY__)
+#if !defined(__ASSEMBLER__)
 /*
  * Missing __asm__ support
  *
linux-headers/asm-arm64/unistd_64.h +1 -0
index 70b3754a42..4329a2ad54 100644
@@ -328,6 +328,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_64_H */
linux-headers/asm-generic/unistd.h +5 -1
index a627acc8fb..5b7e77a7c7 100644
@@ -863,8 +863,12 @@ __SYSCALL(__NR_listns, sys_listns)
 #define __NR_rseq_slice_yield 471
 __SYSCALL(__NR_rseq_slice_yield, sys_rseq_slice_yield)
 
+/* fs/open.c */
+#define __NR_fchroot 472
+__SYSCALL(__NR_fchroot, sys_fchroot)
+
 #undef __NR_syscalls
-#define __NR_syscalls 472
+#define __NR_syscalls 473
 
 /*
  * 32 bit systems traditionally used different
linux-headers/asm-loongarch/unistd_64.h +1 -0
index 3a29d86e1d..b525f2d7b8 100644
@@ -325,6 +325,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_64_H */
linux-headers/asm-mips/unistd_n32.h +1 -0
index 5fa1ee0cb4..f883da76c9 100644
@@ -400,5 +400,6 @@
 #define __NR_file_setattr (__NR_Linux + 469)
 #define __NR_listns (__NR_Linux + 470)
 #define __NR_rseq_slice_yield (__NR_Linux + 471)
+#define __NR_fchroot (__NR_Linux + 472)
 
 #endif /* _ASM_UNISTD_N32_H */
linux-headers/asm-mips/unistd_n64.h +1 -0
index e1f873d83a..59837eb866 100644
@@ -376,5 +376,6 @@
 #define __NR_file_setattr (__NR_Linux + 469)
 #define __NR_listns (__NR_Linux + 470)
 #define __NR_rseq_slice_yield (__NR_Linux + 471)
+#define __NR_fchroot (__NR_Linux + 472)
 
 #endif /* _ASM_UNISTD_N64_H */
linux-headers/asm-mips/unistd_o32.h +1 -0
index 8207e9ca4f..485872076e 100644
@@ -446,5 +446,6 @@
 #define __NR_file_setattr (__NR_Linux + 469)
 #define __NR_listns (__NR_Linux + 470)
 #define __NR_rseq_slice_yield (__NR_Linux + 471)
+#define __NR_fchroot (__NR_Linux + 472)
 
 #endif /* _ASM_UNISTD_O32_H */
linux-headers/asm-powerpc/kvm.h +18 -0
index 077c5437f5..913a64b901 100644
@@ -437,6 +437,24 @@ struct kvm_ppc_cpu_char {
 	__u64	behaviour_mask;		/* valid bits in behaviour */
 };
 
+/* For KVM_PPC_GET_COMPAT_CAPS */
+struct kvm_ppc_compat_caps {
+	__u64	size;			/* Size of this structure */
+	__u64	flags;			/* Reserved for future use */
+	__u64	compat_capabilities;	/* Capabilities supported by the host */
+};
+#define KVM_PPC_COMPAT_CAPS_SIZE_VER0	24 /* sizeof first published struct */
+
+/*
+ * Capability bits for compat_capabilities field in kvm_ppc_compat_caps.
+ * These bits indicate which processor compatibility modes are supported.
+ */
+#define KVM_PPC_COMPAT_CAP_POWER9	(1ULL << 62)
+#define KVM_PPC_COMPAT_CAP_POWER10	(1ULL << 61)
+#define KVM_PPC_COMPAT_CAP_POWER11	(1ULL << 60)
+#define KVM_PPC_COMPAT_BITMASK		(KVM_PPC_COMPAT_CAP_POWER9 | \
+					 KVM_PPC_COMPAT_CAP_POWER10 | \
+					 KVM_PPC_COMPAT_CAP_POWER11)
 /*
  * Values for character and character_mask.
  * These are identical to the values used by H_GET_CPU_CHARACTERISTICS.
linux-headers/asm-powerpc/unistd_32.h +1 -0
index 1f63360120..2677c54903 100644
@@ -453,6 +453,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_32_H */
linux-headers/asm-powerpc/unistd_64.h +1 -0
index 87439c53c1..6fc19ccccd 100644
@@ -425,6 +425,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_64_H */
linux-headers/asm-riscv/unistd_32.h +1 -0
index 828f3c2b9d..1039bdc6cf 100644
@@ -319,6 +319,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_32_H */
linux-headers/asm-riscv/unistd_64.h +1 -0
index 8fa59835a3..72040a5498 100644
@@ -329,6 +329,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_64_H */
linux-headers/asm-s390/unistd_64.h +1 -0
index 01f674c1bc..3d3747e3ca 100644
@@ -391,6 +391,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_64_H */
linux-headers/asm-x86/unistd_32.h +1 -0
index e945468829..7f298247f8 100644
@@ -462,6 +462,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_32_H */
linux-headers/asm-x86/unistd_64.h +1 -0
index 3c49b00ed1..fbddeb4bc3 100644
@@ -386,6 +386,7 @@
 #define __NR_file_setattr 469
 #define __NR_listns 470
 #define __NR_rseq_slice_yield 471
+#define __NR_fchroot 472
 
 
 #endif /* _ASM_UNISTD_64_H */
linux-headers/asm-x86/unistd_x32.h +1 -0
index bd2af9ad08..629770ed4b 100644
@@ -339,6 +339,7 @@
 #define __NR_file_setattr (__X32_SYSCALL_BIT + 469)
 #define __NR_listns (__X32_SYSCALL_BIT + 470)
 #define __NR_rseq_slice_yield (__X32_SYSCALL_BIT + 471)
+#define __NR_fchroot (__X32_SYSCALL_BIT + 472)
 #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
 #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
 #define __NR_ioctl (__X32_SYSCALL_BIT + 514)
linux-headers/linux/const.h +2 -2
index c6a9d0c983..92635cec4a 100644
@@ -13,7 +13,7 @@
  * leave it unchanged in asm.
  */
 
-#ifdef __ASSEMBLY__
+#ifdef __ASSEMBLER__
 #define _AC(X,Y)	X
 #define _AT(T,X)	X
 #else
@@ -28,7 +28,7 @@
 #define _BITUL(x)	(_UL(1) << (x))
 #define _BITULL(x)	(_ULL(1) << (x))
 
-#if !defined(__ASSEMBLY__)
+#if !defined(__ASSEMBLER__)
 /*
  * Missing __asm__ support
  *
linux-headers/linux/kvm.h +3 -0
index dd52e2a65b..aea4ab5c69 100644
@@ -986,6 +986,7 @@ struct kvm_enable_cap {
 #define KVM_CAP_S390_KEYOP 247
 #define KVM_CAP_S390_VSIE_ESAMODE 248
 #define KVM_CAP_S390_HPAGE_2G 249
+#define KVM_CAP_PPC_COMPAT_CAPS 250
 
 struct kvm_irq_routing_irqchip {
 	__u32 irqchip;
@@ -1330,6 +1331,8 @@ struct kvm_s390_keyop {
 /* Available with KVM_CAP_COUNTER_OFFSET */
 #define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset)
 #define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO,  0xb6, struct reg_mask_range)
+/* Available with KVM_CAP_PPC_COMPAT_CAPS */
+#define KVM_PPC_GET_COMPAT_CAPS	_IO(KVMIO,  0xb8)
 
 /* ioctl for vm fd */
 #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device)
Signature · 1 line
2.52.0
#0 lore raw

The following changes since commit 0a1ebd448b38afaa118597cbb633dbec24ef74d3:

tcg/loongarch64: Fix compile issue LoongArch host (2026-08-27 11:04:01 -0700)

are available in the Git repository at:

https://gitlab.com/harshpb/qemu.git tags/pull-ppc-for-11.2-20260828

for you to fetch changes up to fe511b25417e01f1fdb50dc8ce158db0b7522705:

target/ppc: Add self as maintainer for PowerPC TCG CPUs (2026-08-28 11:09:28 +0530)

----------------------------------------------------------------
PPC patches for 2026-08-28
* TCG Improvements (decodetree migrations and ISA 2.07 flag updates)
* Compat mode fixes for nested guests
* XIVE fix for pending interrupts post migration
* MAINTAINERS: Chinmay transitioning as PPC TCG maintainer

Checkpatch errors can be ignored as suggested here:
https://lore.kernel.org/qemu-devel/[email protected]/

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEa4EM1tK+EPOIPSFCRUTplPnWj7sFAmqRIDkACgkQRUTplPnW j7srSQ/+Ob7CDbz5tK0D7jOdNMxdSIKjNaGgWWXtUsbEJcX59rCy3qwrvPMU6Hk7 MBPwIw7+d+IlxPeDeriQjI20JFt2h7QkdjJZBdNgt4zC7YtQxD/g2JCErsI3R1hu /MC20tvIf9Yj7FywSJ52m1PZU1wWzP0ogGJvMzJtk6aFoe8CPhhNm5yomJnIW0BL GrZxLIUzOwE/bV/e739Uge3bEXHzQaxmUi+U+PUnfnDm9XB4EZqxhh3Tf5NsqFQV +xNIOdJCrc0Yz9wRXWiCz0osgRO5yl4c2CmUsUBOOoKo66KbbZ0LwrFoFV2gknuU hYkuPeUHdQQfrUmYEGC8pYP0DHxwHBpbBYrSwtksaVGsg0zFcL2scQZFB2jzkXPO 37tVobFmpj6ABO7wFxKLwMd2YenZPTu9eN3A8GVbFzvizZxlEXfJ2CMU85jriFYf gIx15ZBh2RICVK0spAbT3w9ABrLO0u3bb9RqSID2EGJIatxDwO8PlT02766VRDbS dqoU0YuNGRxDdRzVDI036nQc4ige2xFR5rogEJcrK84P2UsdcMSEx+27VxXTQ5xk HUMtybfONMqYptfnXZB1SRST+NVaS40ddlmyj5Kop64l/YdEno5IdcVdG5QtCIIE 14LXZd30f3kdt7b53VFyiI7bB305Ts9zQsglMmLoYhVqtgTq4o8= =Vp0X
-----END PGP SIGNATURE-----

----------------------------------------------------------------
Aboorva Devarajan (3):
target/ppc: Move vector merge instructions to decodetree target/ppc: Move vector pack instructions to decodetree target/ppc: Move GPR atomic load/store instructions to decodetree

Amit Machhiwal (5):
linux-headers: Update to include KVM_CAP_PPC_COMPAT_CAPS target/ppc/kvm: Add support for querying host compatibility mode target/ppc/kvm: Use host compatibility mode for nested guests target/ppc: Move fixed-point Shift insns to decodetree target/ppc: Move fixed-point byte-reversal store insns to decodetree

Chinmay Rath (9):
target/ppc: make do_ea_calc_ra available for 32 bit builds target/ppc: Replace PPC2_VSX207 flag with PPC2_ISA207 target/ppc: Use PPC2_ISA207 instead of PPC2_BCTAR_ISA207 target/ppc: Use PPC2_ISA207 instead of PPC2_LSQ_ISA207 target/ppc: Use PPC2_ISA207 instead of PPC2_ALTIVEC_207 target/ppc: Use PPC2_ISA207 instead of PPC2_ISA207S target/ppc: Reorder PPC2 flags
target/ppc: Add ICBT support for ISA version 2.07 target/ppc: Add self as maintainer for PowerPC TCG CPUs

Gautam Menghani (1):
ppc/xive: Trigger the pending interrupt for a guest after migration

Mukesh Kumar Chaurasiya (IBM) (2):
target/ppc: convert slw, srw instruction via decode spec target/ppc: convert sraw[i] instruction via decode spec

Nikhil Kumar Singh (3):
target/ppc: Migrate extswsli to decodetree target/ppc: Migrate atomic loads to decodetree target/ppc: Convert cache instructions to decodetree

Ojaswin Mujoo (7):
target/ppc: Move isync instruction to decodetree target/ppc: Convert b{a, l, la} to decode tree target/ppc: move various conditional branch insns to decodetree target/ppc: Fix TRANS* macro variadic arguments handling target/ppc: Move wait instruction to decodetree target/ppc: Move sleep & friends to decodetree target/ppc: Refactor sleep and its variants to use a common helper

Shivang Upadhyay (4):
target/ppc: Move Condition Register access instructions to decodetree. target/ppc: Move Condition Register logical instructions to decodetree. target/ppc: Move Fixed-Point Load/Store String instructions to decodetree. target/ppc: Move VMX integer arithmetic and BCD instructions to decodetree.

Shivani Nittor (1):
target/ppc: Convert mcrf to decode tree

Tanushree Shah (2):
target/ppc: Move rlwimi, rlwinm instructions to decodetree target/ppc: Move lmw, stmw instructions to decodetree

Utkarsh Verma (1):
target/ppc: Move st{b, h, w, d, q}cx instructions to decodetree

Vishal Chourasia (3):
target/ppc: Move mfmsr, mtmsr[d] instructions to decodetree target/ppc: Move byte-reverse instructions to decodetree target/ppc: Move system call and rfi instructions to decodetree

 MAINTAINERS                                    |    2 +-
 include/standard-headers/linux/const.h         |    4 +-
 linux-headers/asm-arm64/unistd_64.h            |    1 +
 linux-headers/asm-generic/unistd.h             |    6 +-
 linux-headers/asm-loongarch/unistd_64.h        |    1 +
 linux-headers/asm-mips/unistd_n32.h            |    1 +
 linux-headers/asm-mips/unistd_n64.h            |    1 +
 linux-headers/asm-mips/unistd_o32.h            |    1 +
 linux-headers/asm-powerpc/kvm.h                |   18 +
 linux-headers/asm-powerpc/unistd_32.h          |    1 +
 linux-headers/asm-powerpc/unistd_64.h          |    1 +
 linux-headers/asm-riscv/unistd_32.h            |    1 +
 linux-headers/asm-riscv/unistd_64.h            |    1 +
 linux-headers/asm-s390/unistd_64.h             |    1 +
 linux-headers/asm-x86/unistd_32.h              |    1 +
 linux-headers/asm-x86/unistd_64.h              |    1 +
 linux-headers/asm-x86/unistd_x32.h             |    1 +
 linux-headers/linux/const.h                    |    4 +-
 linux-headers/linux/kvm.h                      |    3 +
 target/ppc/cpu.h                               |   38 +-
 target/ppc/cpu_init.h                          |    7 +-
 target/ppc/helper.h                            |   96 +-
 target/ppc/internal.h                          |    7 -
 target/ppc/kvm_ppc.h                           |    7 +
 target/ppc/insn32.decode                       |  252 +++
 hw/intc/xive.c                                 |    3 +
 hw/ppc/spapr_caps.c                            |    2 +-
 hw/ppc/spapr_hcall.c                           |   14 +
 linux-user/ppc/elfload.c                       |    6 +-
 target/ppc/cpu_init.c                          |    6 +-
 target/ppc/int_helper.c                        |   76 +-
 target/ppc/kvm.c                               |   84 +
 target/ppc/mem_helper.c                        |   14 +-
 target/ppc/tcg-excp_helper.c                   |   18 +-
 target/ppc/translate.c                         | 2258 ++++--------------------
 target/ppc/translate/bhrb-impl.c.inc           |    4 +-
 target/ppc/translate/branch-impl.c.inc         |  182 +-
 target/ppc/translate/fixedpoint-impl.c.inc     |  947 +++++++++-
 target/ppc/translate/fp-impl.c.inc             |    4 +-
 target/ppc/translate/misc-impl.c.inc           |  172 ++
 target/ppc/translate/processor-ctrl-impl.c.inc |   39 +-
 target/ppc/translate/storage-ctrl-impl.c.inc   |  116 ++
 target/ppc/translate/vmx-impl.c.inc            |  457 +++--
 target/ppc/translate/vmx-ops.c.inc             |   59 +-
 target/ppc/translate/vsx-impl.c.inc            |   56 +-
 target/ppc/translate/vsx-ops.c.inc             |   24 +-
 46 files changed, 2624 insertions(+), 2374 deletions(-)
#2 lore raw

[PULL 07/41] target/ppc: Convert cache instructions to decodetree

From: Nikhil Kumar Singh <[email protected]>

Convert cache management instructions to decodetree using custom X-form layouts (@X_ea, @X_l, @X_th) and dedicated translation functions. This ensures reserved bits are accurately represented and ignored by the decoder (using '-' in the patterns), rather than being erroneously parsed into instruction fields.

Legacy GEN_HANDLER-based implementations are removed.

The implementation preserves legacy semantics, including:
- MMU-visible accesses for instructions treated as loads (e.g. dcbt, dcbtst, dcbtep, dcbtstep)
- Supervisor and BookE-specific constraints
- Effective address computation via do_ea_calc()

Instructions that were defined as no-ops in the legacy implementation remain no-ops here.

Note on intentional behavior changes:
- dcbf now validates the L field against the Power ISA v3.1 set of

    legal values (0, 1, 3, 4, 6).

- Reserved bits that were previously encoded as part of the opcode mask (and trapped if set) are now properly decoded as "don't care" ('-' in the pattern).

Testing:
- Verified TCG equivalence for all cache operations

---
 target/ppc/helper.h      |   4 +-
 target/ppc/insn32.decode |  33 ++++
 target/ppc/mem_helper.c  |   4 +-
 target/ppc/translate.c   | 409 ++++++++++++++++++++-------------------
 4 files changed, 249 insertions(+), 201 deletions(-)
target/ppc/helper.h +2 -2
index 6b2d19a3ad..82ec3a471b 100644
@@ -52,8 +52,8 @@ DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, int)
 #ifdef TARGET_PPC64
 DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl)
 #endif
-DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl)
-DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl)
+DEF_HELPER_FLAGS_2(ICBI, TCG_CALL_NO_WG, void, env, tl)
+DEF_HELPER_FLAGS_2(ICBIEP, TCG_CALL_NO_WG, void, env, tl)
 
 #if defined(TARGET_PPC64)
 DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32)
target/ppc/insn32.decode +33 -0
index 26948e08a7..92706e2097 100644
@@ -1306,6 +1306,39 @@ XVF64GERPN      111011 ... -- .... 0 ..... 10111010 ..-  @XX3_at xa=%xx_xa_pair
 XVF64GERNP      111011 ... -- .... 0 ..... 01111010 ..-  @XX3_at xa=%xx_xa_pair
 XVF64GERNN      111011 ... -- .... 0 ..... 11111010 ..-  @XX3_at xa=%xx_xa_pair
 
+## Cache Management Instructions
+
+&X_ea           ra rb
+@X_ea           ...... ..... ra:5 rb:5 .......... .     &X_ea
+
+&X_l            l ra rb
+@X_l            ...... .. l:3 ra:5 rb:5 .......... .    &X_l
+
+&X_th           th ra rb
+@X_th           ...... th:5 ra:5 rb:5 .......... .      &X_th
+
+DCBF            011111 -- ... ..... ..... 0001010110 -   @X_l
+DCBFEP          011111 ----- ..... ..... 0001111111 -   @X_ea
+DCBI            011111 ----- ..... ..... 0111010110 -   @X_ea
+DCBST           011111 ----- ..... ..... 0000110110 -   @X_ea
+DCBSTEP         011111 ----- ..... ..... 0000111111 -   @X_ea
+DCBA            011111 ----- ..... ..... 1011110110 -   @X_ea
+
+DCBT            011111 ..... ..... ..... 0100010110 -   @X_th
+DCBTEP          011111 ----- ..... ..... 0100111111 -   @X_ea
+DCBTST          011111 ..... ..... ..... 0011110110 -   @X_th
+DCBTSTEP        011111 ----- ..... ..... 0011111111 -   @X_ea
+
+DCBTLS          011111 ..... ..... ..... 0010100110 -   @X_th
+DCBLC           011111 ..... ..... ..... 0110000110 -   @X_th
+
+ICBI            011111 ----- ..... ..... 1111010110 -   @X_ea
+ICBIEP          011111 ----- ..... ..... 1111011111 -   @X_ea
+
+DST             011111 ----- ..... ..... 0101010110 -   @X_ea
+DSTST           011111 ----- ..... ..... 0101110110 -   @X_ea
+DSS             011111 ----- ..... ..... 1100110110 -   @X_ea
+
 ##Extend Sign Word and Shift Left Immediate XS-form
 EXTSWSLI         011111 ..... ..... ..... 110111101 . .         @XS
 
target/ppc/mem_helper.c +2 -2
index 787ba2cdec..8ad6945590 100644
@@ -341,7 +341,7 @@ void helper_dcbzl(CPUPPCState *env, target_ulong addr)
 }
 #endif
 
-void helper_icbi(CPUPPCState *env, target_ulong addr)
+void helper_ICBI(CPUPPCState *env, target_ulong addr)
 {
     unsigned mmu_idx = cpu_mmu_index(env_cpu(env), false);
     MemOpIdx oi = make_memop_idx(MO_UL | MO_UNALN, mmu_idx);
@@ -357,7 +357,7 @@ void helper_icbi(CPUPPCState *env, target_ulong addr)
     cpu_ldl_mmu(env, addr, oi, GETPC());
 }
 
-void helper_icbiep(CPUPPCState *env, target_ulong addr)
+void helper_ICBIEP(CPUPPCState *env, target_ulong addr)
 {
 #if !defined(CONFIG_USER_ONLY)
     MemOpIdx oi = make_memop_idx(MO_UL | MO_UNALN, PPC_TLB_EPID_LOAD);
target/ppc/translate.c +212 -197

435 lines not on this page · raw message

Signature · 1 line
2.52.0
#3 lore raw

[PULL 13/41] target/ppc: Convert mcrf to decode tree

In reply to Harsh Prateek Bora

From: Shivani Nittor <[email protected]>

Convert mcrf to decode tree specification. The functionality was tested by comparing the qemu -D log -d op,in_asm output as well as single stepping gdb.

---
 target/ppc/insn32.decode             | 6 ++++++
 target/ppc/translate.c               | 7 -------
 target/ppc/translate/misc-impl.c.inc | 6 ++++++
 3 files changed, 12 insertions(+), 7 deletions(-)
target/ppc/insn32.decode +6 -0
index ef0fe12959..f928cd6602 100644
@@ -1452,6 +1452,12 @@ MSGSYNC         011111 ----- ----- ----- 1101110110 -
 SYNC            011111 -- ... --- ..   ----- 1001010110 -           @X_sync
 EIEIO           011111 ----- ----- ----- 1101010110 -
 
+# Condition Register Field Instruction
+
+&XL_bfa         bf bfa
+@XL_bfa         ...... bf:3 .. bfa:3 .. ..... ..... ..... .
+MCRF            010011 ... -- ... -- ----- 00000 00000 -       @XL_bfa
+
 # Branch History Rolling Buffer (BHRB) Instructions
 
 &XFX_bhrbe      rt bhrbe
target/ppc/translate.c +0 -7
index 53acd54ad4..7e7ef4e32d 100644
@@ -3642,12 +3642,6 @@ GEN_CRLOGIC(crorc, tcg_gen_orc_i32, 0x0D);
 /* crxor */
 GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06);
 
-/* mcrf */
-static void gen_mcrf(DisasContext *ctx)
-{
-    tcg_gen_mov_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfS(ctx->opcode)]);
-}
-
 /***                           System linkage                              ***/
 
 /* rfi (supervisor only) */
@@ -5709,7 +5703,6 @@ GEN_HANDLER(bc, 0x10, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bcctr, 0x13, 0x10, 0x10, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bclr, 0x13, 0x10, 0x00, 0x00000000, PPC_FLOW),
 GEN_HANDLER_E(bctar, 0x13, 0x10, 0x11, 0x0000E000, PPC_NONE, PPC2_BCTAR_ISA207),
-GEN_HANDLER(mcrf, 0x13, 0x00, 0xFF, 0x00000001, PPC_INTEGER),
 GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
 #if defined(TARGET_PPC64)
 GEN_HANDLER(rfid, 0x13, 0x12, 0x00, 0x03FF8001, PPC_64B),
target/ppc/translate/misc-impl.c.inc +6 -0
index cbf82b1ea0..890fbb209e 100644
@@ -155,3 +155,9 @@ static bool trans_ATTN(DisasContext *ctx, arg_ATTN *a)
     return false;
 #endif
 }
+
+static bool trans_MCRF(DisasContext *ctx, arg_MCRF *a)
+{
+    tcg_gen_mov_i32(cpu_crf[a->bf], cpu_crf[a->bfa]);
+    return true;
+}
Signature · 1 line
2.52.0
#4 lore raw

[PULL 06/41] target/ppc: Migrate atomic loads to decodetree

In reply to Harsh Prateek Bora

From: Nikhil Kumar Singh <[email protected]>

Migrate load-and-reserve instructions (lbarx, lharx, lwarx, ldarx, lqarx) to decodetree using the X-form layout.

A shared helper (do_load_locked) is introduced for standard-width variants, while LQARX is handled separately due to its 128-bit semantics and register pairing constraints.

The implementation preserves legacy behavior, including:
- Reservation granularity and overwrite semantics
- Alignment requirements
- Invalid instruction cases for LQARX

Testing:
- Verified TCG equivalence with legacy implementation

---
 target/ppc/insn32.decode |   7 +++
 target/ppc/translate.c   | 118 +++++++++++++++++++--------------------
 2 files changed, 63 insertions(+), 62 deletions(-)
target/ppc/insn32.decode +7 -0
index 342e65dadf..26948e08a7 100644
@@ -1309,6 +1309,13 @@ XVF64GERNN      111011 ... -- .... 0 ..... 11111010 ..-  @XX3_at xa=%xx_xa_pair
 ##Extend Sign Word and Shift Left Immediate XS-form
 EXTSWSLI         011111 ..... ..... ..... 110111101 . .         @XS
 
+## Load and Reserve Instructions
+LBARX           011111 ..... ..... ..... 0000110100 .   @X_rc
+LHARX           011111 ..... ..... ..... 0001110100 .   @X_rc
+LWARX           011111 ..... ..... ..... 0000010100 .   @X_rc
+LDARX           011111 ..... ..... ..... 0001010100 .   @X_rc
+LQARX           011111 ..... ..... ..... 0100010100 .   @X_rc
+
 ## Vector Division Instructions
 
 VDIVSW          000100 ..... ..... ..... 00110001011    @VX
target/ppc/translate.c +56 -62

151 lines not on this page · raw message

Signature · 1 line
2.52.0
#5 lore raw

[PULL 04/41] ppc/xive: Trigger the pending interrupt for a guest after migration

In reply to Harsh Prateek Bora

From: Gautam Menghani <[email protected]>

When a KVM guest is migrated to another LPAR while a stress-ng workload is running, lockups are seen when the guest resumes on the destination LPAR. This root cause is that if there was a pending interrupt for a cpu on the source machine but it was not presented yet when the migration started, the interrupt is not retriggered on the destination LPAR. This is evident when running 'info pic' on the destination LPAR:

$ virsh qemu-monitor-command --hmp migrate 'info pic' | grep -e OS -e MSI
CPU[0000]:   OS    00   ff  00    ff   ff  00  ff   ff  80000400
CPU[0001]:   OS    00   ff  00    ff   ff  00  ff   ff  80000401
CPU[0002]:   OS    00   ff  00    ff   ff  00  ff   ff  80000402
CPU[0003]:   OS    00   ff  00    ff   ff  00  ff   ff  80000403
CPU[0004]:   OS    00   ff  00    ff   ff  00  ff   ff  80000404
CPU[0005]:   OS    00   ff  00    ff   ff  00  ff   ff  80000405
CPU[0006]:   OS    80   ff  02    ff   ff  00  ff   06  80000406
CPU[0007]:   OS    00   ff  00    ff   ff  00  ff   ff  80000407
  00000000 MSI --    00000010   0/6   3071/16384 @3710000 ^1 [ 80000010 80000010 80000010 80000010 80000010 ^00000000 ]
  00000001 MSI --    00000010   1/6   1852/16384 @3980000 ^1 [ 80000010 80000033 80000033 80000033 80000033 ^00000000 ]
  00000002 MSI --    00000010   2/6   4424/16384 @40c0000 ^1 [ 80000020 80000020 80000020 80000010 80000010 ^00000000 ]
  00000003 MSI --    00000010   3/6   1913/16384 @4220000 ^1 [ 80000010 80000032 80000010 80000010 80000010 ^00000000 ]
  00000004 MSI --    00000010   4/6   2946/16384 @4360000 ^1 [ 80000010 80000010 80000010 80000010 80000010 ^00000000 ]
  00000005 MSI --    00000010   5/6   2313/16384 @44a0000 ^1 [ 80000010 80000010 80000010 80000010 80000010 ^00000000 ]
  00000006 MSI P-    00000010   6/6   5825/16384 @45f0000 ^1 [ 80000024 80000024 80000024 80000010 80000016 ^00000000 ]
  00000007 MSI --    00000010   7/6   2346/16384 @4760000 ^1 [ 80000032 80000032 80000010 80000032 80000032 ^00000000 ]

Fix this by calling xive_tctx_pipr_set() in vmstate_xive_tctx_post_load(), which ends up calling qemu_irq_raise() to present the interrupt. This fix is relevant only for setups where KVM guests rely on emulated XIVE provided by QEMU, since the native XIVE case is already handled.

---
 hw/intc/xive.c | 3 +++
 1 file changed, 3 insertions(+)
hw/intc/xive.c +3 -0
index f473e6ac77..712498d4af 100644
@@ -1080,6 +1080,9 @@ static int vmstate_xive_tctx_post_load(void *opaque, int version_id)
             error_report_err(local_err);
             return ret;
         }
+    } else {
+        uint8_t pipr = tctx->regs[TM_QW1_OS + TM_PIPR];
+        xive_tctx_pipr_set(tctx, TM_QW1_OS, pipr, 0);
     }
 
     return 0;
Signature · 1 line
2.52.0
#6 lore raw

[PULL 02/41] target/ppc/kvm: Add support for querying host compatibility mode

In reply to Harsh Prateek Bora

From: Amit Machhiwal <[email protected]>

Add infrastructure to query the host CPU compatibility mode via the KVM_PPC_GET_COMPAT_CAPS ioctl. This allows QEMU to determine if the host is running in a compatibility mode (e.g., a Power11 processor operating in Power10 compatibility mode).

The kvmppc_get_compat_caps() function issues the ioctl and returns the compat_capabilities bitmap. The kvm_ppc_host_compat_pvr() function derives the effective PVR from the bitmap using ctz64() to find the lowest set bit (highest supported compat level in IBM MSB-0 numbering).

The struct kvm_ppc_compat_caps places 'size' first and userspace sets it to sizeof(struct kvm_ppc_compat_caps) before calling the ioctl. The kernel uses copy_struct_from/to_user() to handle forward and backward ABI
compatibility: an older userspace with a smaller struct gets trailing fields zero-padded. When newer userspace passes a larger struct to an older kernel (usize > ksize), the kernel unconditionally returns -E2BIG and writes its own ksize back into host_compat.size. QEMU detects this, validates the returned size against KVM_PPC_COMPAT_CAPS_SIZE_VER0, and retries with that size.

Additionally, cas_check_pvr() in hw/ppc/spapr_hcall.c is updated to prevent fallback to raw mode when the host is running in compatibility mode. This ensures that nested guests cannot exceed the host's compatibility level. The call is guarded with kvm_enabled() since kvm_ppc_host_compat_pvr() invokes kvm_vm_ioctl() which dereferences kvm_state; without the guard, a TCG guest on a CONFIG_KVM=y binary would segfault.

If the capability is not supported or the query fails, the functions return 0, allowing fallback to existing behavior.

---
 target/ppc/kvm_ppc.h |  7 +++++
 hw/ppc/spapr_hcall.c | 14 +++++++++
 target/ppc/kvm.c     | 75 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)
target/ppc/kvm_ppc.h +7 -0
index 742881231e..195dbaac5e 100644
@@ -81,6 +81,8 @@ bool kvmppc_supports_ail_3(void);
 int kvmppc_enable_hwrng(void);
 int kvmppc_put_books_sregs(PowerPCCPU *cpu);
 PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void);
+
+uint32_t kvm_ppc_host_compat_pvr(void);
 void kvmppc_check_papr_resize_hpt(Error **errp);
 int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift);
 int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift);
@@ -440,6 +442,11 @@ static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
     return NULL;
 }
 
+static inline uint32_t kvm_ppc_host_compat_pvr(void)
+{
+    return 0;
+}
+
 static inline void kvmppc_check_papr_resize_hpt(Error **errp)
 {
 }
hw/ppc/spapr_hcall.c +14 -0
index 23bcd788da..708902934c 100644
@@ -1136,6 +1136,7 @@ static uint32_t cas_check_pvr(PowerPCCPU *cpu, uint32_t max_compat,
 {
     bool explicit_match = false; /* Matched the CPU's real PVR */
     uint32_t best_compat = 0;
+    uint32_t compat_host_pvr = 0;
     int i;
 
     /*
@@ -1163,6 +1164,19 @@ static uint32_t cas_check_pvr(PowerPCCPU *cpu, uint32_t max_compat,
         }
     }
 
+    if (explicit_match && kvm_enabled()) {
+        compat_host_pvr = kvm_ppc_host_compat_pvr();
+        /*
+         * If the host is booted in a compatibility mode, do not try booting in
+         * the raw mode as it may allow KVM guests to boot with a higher CPU
+         * version compared to what host was booted with; which should not be
+         * allowed.
+         */
+        if (compat_host_pvr) {
+            explicit_match = false;
+        }
+    }
+
     *raw_mode_supported = explicit_match;
 
     /* Parsing finished */
target/ppc/kvm.c +75 -0

81 lines not on this page · raw message

Signature · 1 line
2.52.0
#7 lore raw

[PULL 17/41] target/ppc: Move isync instruction to decodetree

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

Moving the following instructions to decodetree specification :
isync

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.

---
 target/ppc/insn32.decode                     |  1 +
 target/ppc/translate.c                       | 15 ---------------
 target/ppc/translate/storage-ctrl-impl.c.inc | 17 +++++++++++++++++
 3 files changed, 18 insertions(+), 15 deletions(-)
target/ppc/insn32.decode +1 -0
index e8326a9d0b..6fb7754566 100644
@@ -1470,6 +1470,7 @@ MSGSYNC         011111 ----- ----- ----- 1101110110 -
 @X_sync         ...... .. l:3 ... sc:2 ..... .......... .           &X_sync
 SYNC            011111 -- ... --- ..   ----- 1001010110 -           @X_sync
 EIEIO           011111 ----- ----- ----- 1101010110 -
+ISYNC           010011 ----- ----- ----- 0010010110 -
 
 # Condition Register Field Instruction
 
target/ppc/translate.c +0 -15
index c44cffb5e8..84589716b3 100644
@@ -2727,20 +2727,6 @@ static inline void gen_check_tlb_flush(DisasContext *ctx, bool global)
 static inline void gen_check_tlb_flush(DisasContext *ctx, bool global) { }
 #endif
 
-/* isync */
-static void gen_isync(DisasContext *ctx)
-{
-    /*
-     * We need to check for a pending TLB flush. This can only happen in
-     * kernel mode however so check MSR_PR
-     */
-    if (!ctx->pr) {
-        gen_check_tlb_flush(ctx, false);
-    }
-    tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
-    ctx->base.is_jmp = DISAS_EXIT_UPDATE;
-}
-
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
@@ -5364,7 +5350,6 @@ GEN_HANDLER(lswi, 0x1F, 0x15, 0x12, 0x00000001, PPC_STRING),
 GEN_HANDLER(lswx, 0x1F, 0x15, 0x10, 0x00000001, PPC_STRING),
 GEN_HANDLER(stswi, 0x1F, 0x15, 0x16, 0x00000001, PPC_STRING),
 GEN_HANDLER(stswx, 0x1F, 0x15, 0x14, 0x00000001, PPC_STRING),
-GEN_HANDLER(isync, 0x13, 0x16, 0x04, 0x03FFF801, PPC_MEM),
 /* ISA v3.0 changed the extended opcode from 62 to 30 */
 GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x039FF801, PPC_WAIT),
 GEN_HANDLER_E(wait, 0x1F, 0x1E, 0x00, 0x039CF801, PPC_NONE, PPC2_ISA300),
target/ppc/translate/storage-ctrl-impl.c.inc +17 -0
index b8b4454663..943229c438 100644
@@ -155,6 +155,23 @@ static bool trans_SLBFEE(DisasContext *ctx, arg_SLBFEE *a)
     return true;
 }
 
+static bool trans_ISYNC(DisasContext *ctx, arg_ISYNC *a)
+{
+    REQUIRE_INSNS_FLAGS(ctx, MEM);
+
+    /*
+     * We need to check for a pending TLB flush. This can only happen in
+     * kernel mode however so check MSR_PR
+     */
+    if (!ctx->pr) {
+        gen_check_tlb_flush(ctx, false);
+    }
+    tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
+    ctx->base.is_jmp = DISAS_EXIT_UPDATE;
+
+    return true;
+}
+
 static bool trans_SLBSYNC(DisasContext *ctx, arg_SLBSYNC *a)
 {
     REQUIRE_64BIT(ctx);
Signature · 1 line
2.52.0
#8 lore raw

[PULL 18/41] target/ppc: Convert b{a, l, la} to decode tree

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

Convert b, ba, bl and bla to decode tree specification. The functionality was tested by comparing the qemu -D log -d op,in_asm output as well as single stepping gdb to confirm LR was correctly populated only when LK is set.

---
 target/ppc/internal.h                  |  7 -------
 target/ppc/insn32.decode               |  7 +++++++
 target/ppc/translate.c                 | 24 ------------------------
 target/ppc/translate/branch-impl.c.inc | 24 ++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 31 deletions(-)
target/ppc/internal.h +0 -7
index a3bb12afd9..a20a0f9f7e 100644
@@ -197,13 +197,6 @@ EXTRACT_HELPER(L, 16, 2);
 EXTRACT_HELPER(WC, 21, 2);
 EXTRACT_HELPER(PL, 16, 2);
 
-/***                            Jump target decoding                       ***/
-/* Immediate address */
-static inline target_ulong LI(uint32_t opcode)
-{
-    return (opcode >> 0) & 0x03FFFFFC;
-}
-
 static inline uint32_t BD(uint32_t opcode)
 {
     return (opcode >> 0) & 0xFFFC;
target/ppc/insn32.decode +7 -0
index 6fb7754566..0c58899429 100644
@@ -1486,6 +1486,13 @@ MCRF            010011 ... -- ... -- ----- 00000 00000 -       @XL_bfa
 MFBHRBE         011111 ..... ..... ..... 0100101110 -   @XFX_bhrbe
 CLRBHRB         011111 ----- ----- ----- 0110101110 -
 
+# Branch Instructions
+%li             2:24 !function=times_4
+&I_b            li aa:bool lk:bool
+@I_b            ...... ........................ aa:1 lk:1 &I_b li=%li
+
+B               010010 ........................ . .  @I_b
+
 ## Misc POWER instructions
 
 ATTN            000000 00000 00000 00000 0100000000 0
target/ppc/translate.c +0 -24
index 84589716b3..3c6e2da8ce 100644
@@ -3089,29 +3089,6 @@ static inline void gen_setlr(DisasContext *ctx, target_ulong nip)
     tcg_gen_movi_tl(cpu_lr, nip);
 }
 
-/* b ba bl bla */
-static void gen_b(DisasContext *ctx)
-{
-    target_ulong li, target;
-
-    /* sign extend LI */
-    li = LI(ctx->opcode);
-    li = (li ^ 0x02000000) - 0x02000000;
-    if (likely(AA(ctx->opcode) == 0)) {
-        target = ctx->cia + li;
-    } else {
-        target = li;
-    }
-    if (LK(ctx->opcode)) {
-        gen_setlr(ctx, ctx->base.pc_next);
-        gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_CALL);
-    } else {
-        gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_OTHER);
-    }
-    gen_goto_tb(ctx, 0, target);
-    ctx->base.is_jmp = DISAS_NORETURN;
-}
-
 #define BCOND_IM  0
 #define BCOND_LR  1
 #define BCOND_CTR 2
@@ -5353,7 +5330,6 @@ GEN_HANDLER(stswx, 0x1F, 0x15, 0x14, 0x00000001, PPC_STRING),
 /* ISA v3.0 changed the extended opcode from 62 to 30 */
 GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x039FF801, PPC_WAIT),
 GEN_HANDLER_E(wait, 0x1F, 0x1E, 0x00, 0x039CF801, PPC_NONE, PPC2_ISA300),
-GEN_HANDLER(b, 0x12, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bc, 0x10, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bcctr, 0x13, 0x10, 0x10, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bclr, 0x13, 0x10, 0x00, 0x00000000, PPC_FLOW),
target/ppc/translate/branch-impl.c.inc +24 -0
index 9ade0c659a..745f71afd1 100644
@@ -31,3 +31,27 @@ static bool trans_RFEBB(DisasContext *ctx, arg_XL_s *arg)
     return true;
 }
 #endif
+
+static bool trans_B(DisasContext *ctx, arg_I_b *a)
+{
+    target_ulong target, li;
+
+    /* sign extend LI */
+    li = (a->li ^ 0x02000000) - 0x02000000;
+
+    if (likely(a->aa == 0)) {
+        target = ctx->cia + li;
+    } else {
+        target = li;
+    }
+    if (a->lk) {
+        gen_setlr(ctx, ctx->base.pc_next);
+        gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_CALL);
+    } else {
+        gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_OTHER);
+    }
+    gen_goto_tb(ctx, 0, target);
+    ctx->base.is_jmp = DISAS_NORETURN;
+
+    return true;
+}
Signature · 1 line
2.52.0
#9 lore raw

[PULL 33/41] target/ppc: Move system call and rfi instructions to decodetree

In reply to Harsh Prateek Bora

From: Vishal Chourasia <[email protected]>

Moving the following instructions to decodetree specification:
sc, scv : SC-form
rfi, rfid, rfscv, hrfid : XL-form

This builds upon the previous work that moved mfmsr and mtmsr[d] instructions to decodetree.

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the -d in_asm,op flag, and also by booting a pseries qemu guest.

This also includes improvements from review feedback:
- Rename helpers to uppercase (RFI/RFID/RFSCV/HRFID) to match ISA mnemonics
- Add TRANS64_FLAGS() macro variants
- Add REQUIRE_INSNS_FLAGS_NOT() check for flag exclusion
- Specify lev field as uint8_t in SC instruction format
- Remove redundant masking in SCV since lev is already 7-bit
- Replace TARGET_PPC64 ifdefs with REQUIRE_64BIT() macro
- Gate SC, SCV, RFI, RFID, RFSCV, and HRFID with appropriate flags
- Consolidate CONFIG_USER_ONLY guards into single block

---
 target/ppc/helper.h                  |   8 +-
 target/ppc/insn32.decode             |  11 +++
 target/ppc/tcg-excp_helper.c         |   8 +-
 target/ppc/translate.c               | 126 ++-------------------------
 target/ppc/translate/misc-impl.c.inc | 102 ++++++++++++++++++++++
 5 files changed, 128 insertions(+), 127 deletions(-)
target/ppc/helper.h +4 -4
index ec3350fee8..80d6616bab 100644
@@ -11,7 +11,7 @@ DEF_HELPER_4(HASHCHKP, void, env, tl, tl, tl)
 #if !defined(CONFIG_USER_ONLY)
 DEF_HELPER_2(store_msr, void, env, tl)
 DEF_HELPER_1(ppc_maybe_interrupt, void, env)
-DEF_HELPER_1(rfi, void, env)
+DEF_HELPER_1(RFI, void, env)
 DEF_HELPER_1(40x_rfci, void, env)
 DEF_HELPER_1(rfci, void, env)
 DEF_HELPER_1(rfdi, void, env)
@@ -19,9 +19,9 @@ DEF_HELPER_1(rfmci, void, env)
 #if defined(TARGET_PPC64)
 DEF_HELPER_2(scv, noreturn, env, i32)
 DEF_HELPER_2(PMINSN, void, env, i32)
-DEF_HELPER_1(rfid, void, env)
-DEF_HELPER_1(rfscv, void, env)
-DEF_HELPER_1(hrfid, void, env)
+DEF_HELPER_1(RFID, void, env)
+DEF_HELPER_1(RFSCV, void, env)
+DEF_HELPER_1(HRFID, void, env)
 DEF_HELPER_2(rfebb, void, env, tl)
 DEF_HELPER_2(store_lpcr, void, env, tl)
 DEF_HELPER_2(store_pcr, void, env, tl)
target/ppc/insn32.decode +11 -0
index 7bbe1f8838..6563dc4f64 100644
@@ -199,6 +199,9 @@
 &X_rs_l         rs l:bool
 @X_rs_l         ...... rs:5 .... l:1 ..... .......... .         &X_rs_l
 
+&SC             lev:uint8_t
+@SC             ...... ..... ..... .... lev:7 ... . .           &SC
+
 &X_uim5         xt uim:uint8_t
 @X_uim5         ...... ..... ..... uim:5 .......... .           &X_uim5 xt=%x_xt
 
@@ -320,6 +323,14 @@ MFMSR           011111 ..... ----- ----- 0001010011 -   @X_t
 MTMSR           011111 ..... ---- . ----- 0010010010 -  @X_rs_l
 MTMSRD          011111 ..... ---- . ----- 0010110010 -  @X_rs_l
 
+### System Call and Return from Interrupt
+SC              010001 ----- ----- ---- ....... --- 1 -         @SC
+SCV             010001 ----- ----- ---- ....... --- 0 1         @SC
+RFI             010011 ----- ----- ----- 0000110010 -
+RFID            010011 ----- ----- ----- 0000010010 -
+RFSCV           010011 ----- ----- ----- 0001010010 -
+HRFID           010011 ----- ----- ----- 0100010010 -
+
 ### Fixed-Point Byte-Reverse Instructions
 BRW             011111 ..... ..... ----- 0010011011 -   @X_sa
 BRD             011111 ..... ..... ----- 0010111011 -   @X_sa
target/ppc/tcg-excp_helper.c +4 -4
index c4ffa2dfbb..d06d3f8642 100644
@@ -528,13 +528,13 @@ static void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr)
     check_tlb_flush(env, false);
 }
 
-void helper_rfi(CPUPPCState *env)
+void helper_RFI(CPUPPCState *env)
 {
     do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1] & 0xfffffffful);
 }
 
 #ifdef TARGET_PPC64
-void helper_rfid(CPUPPCState *env)
+void helper_RFID(CPUPPCState *env)
 {
     /*
      * The architecture defines a number of rules for which bits can
@@ -545,12 +545,12 @@ void helper_rfid(CPUPPCState *env)
     do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1]);
 }
 
-void helper_rfscv(CPUPPCState *env)
+void helper_RFSCV(CPUPPCState *env)
 {
     do_rfi(env, env->lr, env->ctr);
 }
 
-void helper_hrfid(CPUPPCState *env)
+void helper_HRFID(CPUPPCState *env)
 {
     do_rfi(env, env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]);
 }
target/ppc/translate.c +7 -119

144 lines not on this page · raw message

target/ppc/translate/misc-impl.c.inc +102 -0

105 lines not on this page · raw message

Signature · 1 line
2.52.0
#10 lore raw

[PULL 08/41] target/ppc: Move vector merge instructions to decodetree

In reply to Harsh Prateek Bora

From: Aboorva Devarajan <[email protected]>

Move below instructions to decodetree specification:

vmrg{hb, hh, hw, lb, lh, lw} : VX-form

The individual gen_vmrg* functions generated by GEN_VXFORM are replaced by a shared do_vmrg() helper dispatching to the existing gen_helper_VMRG* TCG helpers via the TRANS_FLAGS() macro, which also handles the ALTIVEC facility check.

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.

---
 target/ppc/helper.h                 | 12 ++++++------
 target/ppc/insn32.decode            |  9 +++++++++
 target/ppc/int_helper.c             | 12 ++++++------
 target/ppc/translate/vmx-impl.c.inc | 25 +++++++++++++++++++------
 target/ppc/translate/vmx-ops.c.inc  |  6 ------
 5 files changed, 40 insertions(+), 24 deletions(-)
target/ppc/helper.h +6 -6
index 82ec3a471b..5517d2950f 100644
@@ -173,12 +173,12 @@ DEF_HELPER_4(vcmpeqfp_dot, void, env, avr, avr, avr)
 DEF_HELPER_4(vcmpgefp_dot, void, env, avr, avr, avr)
 DEF_HELPER_4(vcmpgtfp_dot, void, env, avr, avr, avr)
 DEF_HELPER_4(vcmpbfp_dot, void, env, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vmrglb, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vmrglh, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vmrglw, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vmrghb, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vmrghh, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vmrghw, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VMRGLB, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VMRGLH, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VMRGLW, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VMRGHB, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VMRGHH, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VMRGHW, TCG_CALL_NO_RWG, void, avr, avr, avr)
 DEF_HELPER_FLAGS_3(VMULESB, TCG_CALL_NO_RWG, void, avr, avr, avr)
 DEF_HELPER_FLAGS_3(VMULESH, TCG_CALL_NO_RWG, void, avr, avr, avr)
 DEF_HELPER_FLAGS_3(VMULESW, TCG_CALL_NO_RWG, void, avr, avr, avr)
target/ppc/insn32.decode +9 -0
index 92706e2097..99f7421e77 100644
@@ -795,6 +795,15 @@ VNOR            000100 ..... ..... ..... 10100000100    @VX
 VXOR            000100 ..... ..... ..... 10011000100    @VX
 VEQV            000100 ..... ..... ..... 11010000100    @VX
 
+## Vector Merge Instructions
+
+VMRGHB          000100 ..... ..... ..... 00000001100    @VX
+VMRGHH          000100 ..... ..... ..... 00001001100    @VX
+VMRGHW          000100 ..... ..... ..... 00010001100    @VX
+VMRGLB          000100 ..... ..... ..... 00100001100    @VX
+VMRGLH          000100 ..... ..... ..... 00101001100    @VX
+VMRGLW          000100 ..... ..... ..... 00110001100    @VX
+
 ## Vector Integer Average Instructions
 
 VAVGSB          000100 ..... ..... ..... 10100000010    @VX
target/ppc/int_helper.c +6 -6
index ef4b2e75d6..a3adf746bd 100644
@@ -950,7 +950,7 @@ void helper_VMLADDUHM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c,
 }
 
 #define VMRG_DO(name, element, access, ofs)                                  \
-    void helper_v##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)            \
+    void helper_V##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)            \
     {                                                                        \
         ppc_avr_t result;                                                    \
         int i, half = ARRAY_SIZE(r->element) / 2;                            \
@@ -963,11 +963,11 @@ void helper_VMLADDUHM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c,
     }
 
 #define VMRG(suffix, element, access)          \
-    VMRG_DO(mrgl##suffix, element, access, half)   \
-    VMRG_DO(mrgh##suffix, element, access, 0)
-VMRG(b, u8, VsrB)
-VMRG(h, u16, VsrH)
-VMRG(w, u32, VsrW)
+    VMRG_DO(MRGL##suffix, element, access, half)   \
+    VMRG_DO(MRGH##suffix, element, access, 0)
+VMRG(B, u8, VsrB)
+VMRG(H, u16, VsrH)
+VMRG(W, u32, VsrW)
 #undef VMRG_DO
 #undef VMRG
 
target/ppc/translate/vmx-impl.c.inc +19 -6
index 92d6e8c603..00b359f031 100644
@@ -350,12 +350,25 @@ GEN_VXFORM_V(vsububm, MO_8, tcg_gen_gvec_sub, 0, 16);
 GEN_VXFORM_V(vsubuhm, MO_16, tcg_gen_gvec_sub, 0, 17);
 GEN_VXFORM_V(vsubuwm, MO_32, tcg_gen_gvec_sub, 0, 18);
 GEN_VXFORM_V(vsubudm, MO_64, tcg_gen_gvec_sub, 0, 19);
-GEN_VXFORM(vmrghb, 6, 0);
-GEN_VXFORM(vmrghh, 6, 1);
-GEN_VXFORM(vmrghw, 6, 2);
-GEN_VXFORM(vmrglb, 6, 4);
-GEN_VXFORM(vmrglh, 6, 5);
-GEN_VXFORM(vmrglw, 6, 6);
+
+static bool do_vmrg(DisasContext *ctx, arg_VX *a,
+                    void (*helper)(TCGv_ptr, TCGv_ptr, TCGv_ptr))
+{
+    TCGv_ptr ra, rb, rd;
+    REQUIRE_VECTOR(ctx);
+    ra = gen_avr_ptr(a->vra);
+    rb = gen_avr_ptr(a->vrb);
+    rd = gen_avr_ptr(a->vrt);
+    helper(rd, ra, rb);
+    return true;
+}
+
+TRANS_FLAGS(ALTIVEC, VMRGHB, do_vmrg, gen_helper_VMRGHB);
+TRANS_FLAGS(ALTIVEC, VMRGHH, do_vmrg, gen_helper_VMRGHH);
+TRANS_FLAGS(ALTIVEC, VMRGHW, do_vmrg, gen_helper_VMRGHW);
+TRANS_FLAGS(ALTIVEC, VMRGLB, do_vmrg, gen_helper_VMRGLB);
+TRANS_FLAGS(ALTIVEC, VMRGLH, do_vmrg, gen_helper_VMRGLH);
+TRANS_FLAGS(ALTIVEC, VMRGLW, do_vmrg, gen_helper_VMRGLW);
 
 static void trans_vmrgew(DisasContext *ctx)
 {
target/ppc/translate/vmx-ops.c.inc +0 -6
index e28958a126..b8f77d3d2c 100644
@@ -33,12 +33,6 @@ GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE),
 GEN_VXFORM_DUAL(vsubuwm, bcdus, 0, 18, PPC_ALTIVEC, PPC2_ISA300),
 GEN_VXFORM_DUAL(vsubudm, bcds, 0, 19, PPC2_ALTIVEC_207, PPC2_ISA300),
 GEN_VXFORM_300(bcds, 0, 27),
-GEN_VXFORM(vmrghb, 6, 0),
-GEN_VXFORM(vmrghh, 6, 1),
-GEN_VXFORM(vmrghw, 6, 2),
-GEN_VXFORM(vmrglb, 6, 4),
-GEN_VXFORM(vmrglh, 6, 5),
-GEN_VXFORM(vmrglw, 6, 6),
 GEN_VXFORM_300(vextublx, 6, 24),
 GEN_VXFORM_300(vextuhlx, 6, 25),
 GEN_VXFORM_DUAL(vmrgow, vextuwlx, 6, 26, PPC_NONE, PPC2_ALTIVEC_207),
Signature · 1 line
2.52.0
#11 lore raw

[PULL 16/41] target/ppc: Move GPR atomic load/store instructions to decodetree

In reply to Harsh Prateek Bora

From: Aboorva Devarajan <[email protected]>

Move below instructions to decodetree specification:

lwat, stwat : X-form (word atomic, ISA 3.0)
ldat, stdat : X-form (doubleword atomic, ISA 3.0)

The legacy gen_ld_atomic()/gen_st_atomic() functions that read register fields and the function code from ctx->opcode are replaced by new do_ld_atomic()/do_st_atomic() helpers in fixedpoint-impl.c.inc that use the pre-extracted decodetree argument fields (a->rt, a->ra, a->rb) directly. The RB field carries the Function Code (FC) selecting the atomic operation.

gen_fetch_inc_conditional() is similarly moved and refactored to accept the destination register number as an explicit parameter instead of extracting it from ctx->opcode.

Checked with '-d in_asm,op'. The printed TCG ops may differ from the pre-refactor log because EA now uses do_ea_calc(ctx, ra, 0), which lowers as GPR[ra] + 0 (then narrow in 32-bit mode) instead of mov/ext32u from ra alone.

---
 target/ppc/insn32.decode                   |   7 +
 target/ppc/translate.c                     | 212 --------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 214 +++++++++++++++++++++
 3 files changed, 221 insertions(+), 212 deletions(-)
target/ppc/insn32.decode +7 -0
index 37f508a5c2..e8326a9d0b 100644
@@ -343,6 +343,13 @@ LSKU            111010 ..... ..... ............. 0 11   @DD
 LCXU            111010 ..... ..... ............. 1 11   @DD
 
 
+### Fixed-Point Atomic Load/Store Instructions
+
+LWAT            011111 ..... ..... ..... 1001000110 -   @X
+STWAT           011111 ..... ..... ..... 1011000110 -   @X
+LDAT            011111 ..... ..... ..... 1001100110 -   @X
+STDAT           011111 ..... ..... ..... 1011100110 -   @X
+
 ### Fixed-Point Store Instructions
 
 STB             100110 ..... ..... ................     @D
target/ppc/translate.c +0 -212

224 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +214 -0

217 lines not on this page · raw message

Signature · 1 line
2.52.0
#12 lore raw

[PULL 30/41] target/ppc: Move lmw, stmw instructions to decodetree

In reply to Harsh Prateek Bora

From: Tanushree Shah <[email protected]>

Moving the following instructions to decodetree specification:
lmw : D-form
stmw : D-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the "-d in_asm,op" flag.

Additionally, validated using small assembly tests confirming the the correct register store/load behavior. Also, confirmed the register values are same before and after the change.

---
 target/ppc/helper.h                        |  4 +--
 target/ppc/insn32.decode                   |  3 ++
 target/ppc/mem_helper.c                    |  4 +--
 target/ppc/translate.c                     | 39 ----------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 32 ++++++++++++++++++
 5 files changed, 39 insertions(+), 43 deletions(-)
target/ppc/helper.h +2 -2
index 7da752c69b..ec3350fee8 100644
@@ -43,8 +43,8 @@ DEF_HELPER_1(check_tlb_flush_local, void, env)
 DEF_HELPER_1(check_tlb_flush_global, void, env)
 #endif
 
-DEF_HELPER_3(lmw, void, env, tl, i32)
-DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32)
+DEF_HELPER_3(LMW, void, env, tl, i32)
+DEF_HELPER_FLAGS_3(STMW, TCG_CALL_NO_WG, void, env, tl, i32)
 DEF_HELPER_4(LSW, void, env, tl, i32, i32)
 DEF_HELPER_5(LSWX, void, env, tl, i32, i32, i32)
 DEF_HELPER_FLAGS_4(STSW, TCG_CALL_NO_WG, void, env, tl, i32, i32)
target/ppc/insn32.decode +3 -0
index 92ee278f63..ef128f63c1 100644
@@ -354,6 +354,7 @@ LVDX            011111 ..... ..... ..... 0000010001 -   @X
 LSKU            111010 ..... ..... ............. 0 11   @DD
 LCXU            111010 ..... ..... ............. 1 11   @DD
 
+LMW             101110 ..... ..... ................     @D
 
 ### Fixed-Point Atomic Load/Store Instructions
 
@@ -399,6 +400,8 @@ STBCIX          011111 ..... ..... ..... 1111010101 -   @X
 STHBRX          011111 ..... ..... ..... 1110010110 -   @X
 STWBRX          011111 ..... ..... ..... 1010010110 -   @X
 
+STMW            101111 ..... ..... ................     @D
+
 ### Fixed-Point Compare Instructions
 
 CMP             011111 ... - . ..... ..... 0000000000 - @X_bfl
target/ppc/mem_helper.c +2 -2
index 10c648cf06..dc5eab8c76 100644
@@ -73,7 +73,7 @@ static void *probe_contiguous(CPUPPCState *env, target_ulong addr, uint32_t nb,
     return NULL;
 }
 
-void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
+void helper_LMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
 {
     uintptr_t raddr = GETPC();
     int mmu_idx = ppc_env_mmu_index(env, false);
@@ -98,7 +98,7 @@ void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
     }
 }
 
-void helper_stmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
+void helper_STMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
 {
     uintptr_t raddr = GETPC();
     int mmu_idx = ppc_env_mmu_index(env, false);
target/ppc/translate.c +0 -39
index ce94f9e4e6..880915f3da 100644
@@ -2455,43 +2455,6 @@ GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER);
 GEN_LDX_E(ldbr, ld64ur_i64, 0x14, 0x10, PPC_NONE, PPC2_DBRX, CHK_NONE);
 #endif  /* TARGET_PPC64 */
 
-/***                    Integer load and store multiple                    ***/
-
-/* lmw */
-static void gen_lmw(DisasContext *ctx)
-{
-    TCGv t0;
-    TCGv_i32 t1;
-
-    if (ctx->le_mode) {
-        gen_align_no_le(ctx);
-        return;
-    }
-    gen_set_access_type(ctx, ACCESS_INT);
-    t0 = tcg_temp_new();
-    t1 = tcg_constant_i32(rD(ctx->opcode));
-    gen_addr_imm_index(ctx, t0, 0);
-    gen_helper_lmw(tcg_env, t0, t1);
-}
-
-/* stmw */
-static void gen_stmw(DisasContext *ctx)
-{
-    TCGv t0;
-    TCGv_i32 t1;
-
-    if (ctx->le_mode) {
-        gen_align_no_le(ctx);
-        return;
-    }
-    gen_set_access_type(ctx, ACCESS_INT);
-    t0 = tcg_temp_new();
-    t1 = tcg_constant_i32(rS(ctx->opcode));
-    gen_addr_imm_index(ctx, t0, 0);
-    gen_helper_stmw(tcg_env, t0, t1);
-}
-
-
 #if !defined(CONFIG_USER_ONLY)
 static inline void gen_check_tlb_flush(DisasContext *ctx, bool global)
 {
@@ -4695,8 +4658,6 @@ GEN_HANDLER(rlwnm, 0x17, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
 GEN_HANDLER_E(dform39, 0x39, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
 /* handles stfdp, stxsd, stxssp */
 GEN_HANDLER_E(dform3D, 0x3D, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
-GEN_HANDLER(lmw, 0x2E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
-GEN_HANDLER(stmw, 0x2F, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
 /* ISA v3.0 changed the extended opcode from 62 to 30 */
 GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
 #if defined(TARGET_PPC64)
target/ppc/translate/fixedpoint-impl.c.inc +32 -0
index efef56a119..8475205f14 100644
@@ -288,6 +288,38 @@ static bool trans_STQCX(DisasContext *ctx, arg_STQCX *a)
     return true;
 }
 
+/* Load/Store Multiple Word */
+static bool do_ldst_multiple(DisasContext *ctx, arg_D *a, bool store)
+{
+    TCGv ea;
+    TCGv_i32 reg;
+
+    REQUIRE_INSNS_FLAGS(ctx, INTEGER);
+
+    /* Little-endian mode is not supported for multiple word operations */
+    if (ctx->le_mode) {
+        gen_align_no_le(ctx);
+        return true;
+    }
+
+    gen_set_access_type(ctx, ACCESS_INT);
+
+    reg = tcg_constant_i32(a->rt);
+    ea = do_ea_calc(ctx, a->ra, tcg_constant_tl(a->si));
+
+    /* Call the appropriate helper function */
+    if (store) {
+        gen_helper_STMW(tcg_env, ea, reg);
+    } else {
+        gen_helper_LMW(tcg_env, ea, reg);
+    }
+
+    return true;
+}
+
+TRANS(LMW, do_ldst_multiple, false)
+TRANS(STMW, do_ldst_multiple, true)
+
 /*
  * Fixed-Point Compare Instructions
  */
Signature · 1 line
2.52.0
#13 lore raw

[PULL 19/41] target/ppc: move various conditional branch insns to decodetree

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

Convert the following instructions to decodetree specification:

bc
bca
bcl
bcla

bclr
bclrl

bcctr
bcctrl

bctar
bctarl

The branch was tested by comparing the qemu -D log -d op,in_asm output for each instruction and also for the various combinations of branch option (BO) bits for the conditional branch instructions. Additionally, gdb was used to confirm the LR and other register's behavior is consistent to legacy behavior.

Further, the changes also pass a boot test into Fedora distro.

---
 target/ppc/insn32.decode               |  13 +++
 target/ppc/translate.c                 | 148 -----------------------
 target/ppc/translate/branch-impl.c.inc | 156 +++++++++++++++++++++++++
 3 files changed, 169 insertions(+), 148 deletions(-)
target/ppc/insn32.decode +13 -0
index 0c58899429..e7cc36bd6c 100644
@@ -1493,6 +1493,19 @@ CLRBHRB         011111 ----- ----- ----- 0110101110 -
 
 B               010010 ........................ . .  @I_b
 
+%bd             2:14 !function=times_4
+&bcond          bo:uint32_t bi bd aa:bool lk:bool
+@B_bcond        ...... bo:5 bi:5 .............. aa:1 lk:1 &bcond bd=%bd
+
+BC              010000 ..... ..... .............. . .  @B_bcond
+
+&bclr          bo bi bh lk:bool
+@XL_bclr       ...... bo:5 bi:5 --- bh:2 .......... lk:1 &bclr
+
+BCLR            010011 ..... ..... ---.. 0000010000 . @XL_bclr
+BCCTR           010011 ..... ..... ---.. 1000010000 . @XL_bclr
+BCTAR           010011 ..... ..... ---.. 1000110000 . @XL_bclr
+
 ## Misc POWER instructions
 
 ATTN            000000 00000 00000 00000 0100000000 0
target/ppc/translate.c +0 -148

160 lines not on this page · raw message

target/ppc/translate/branch-impl.c.inc +156 -0

159 lines not on this page · raw message

Signature · 1 line
2.52.0
#14 lore raw

[PULL 21/41] target/ppc: Move wait instruction to decodetree

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

Implement wait instruction using decodetree with proper handling of WC and PL fields across different ISA versions. Since the opcode changed between ISA 2.x and 3.x we have defined 2 different decodetree instructions that are handled by the same helper.

The changes have been tested by comparing the tcg generated before and after the change for wait instruction. The test was repeated for 2 types of machines:

Power10 - which should use the newer wait implementation e500mc - which should use older PPC_WAIT implementation

Both generated the same tcg ops with and without the change. Further, with the changes we were able to boot into Fedora distro as well.

---
 target/ppc/insn32.decode                     | 15 +++
 target/ppc/translate.c                       | 91 ------------------
 target/ppc/translate/storage-ctrl-impl.c.inc | 99 ++++++++++++++++++++
 3 files changed, 114 insertions(+), 91 deletions(-)
target/ppc/insn32.decode +15 -0
index e7cc36bd6c..da32ac1d28 100644
@@ -1478,6 +1478,21 @@ ISYNC           010011 ----- ----- ----- 0010010110 -
 @XL_bfa         ...... bf:3 .. bfa:3 .. ..... ..... ..... .
 MCRF            010011 ... -- ... -- ----- 00000 00000 -       @XL_bfa
 
+# Wait Instructions
+
+# We can use the same X_wait argument set for both WAIT and older ISA2.x
+# compliant WAIT_2_x. Depending on the version, we may or may not use the
+# arguments. For more information, check do_wait() helper.
+
+&X_wait         wc pl
+@X_wait         ...... ..- wc:2 --- pl:2 ----- .......... -  &X_wait
+
+# According to ISA v3.1, bit 6 and 7 are implementation dependent and "unless
+# the intention is to use the implementation-dependent field, these bits must be
+# coded zero". Hence, we code them to 0.
+WAIT            011111 00-.. ---.. ----- 0000011110 -  @X_wait
+WAIT_ISA_2_X    011111 ---.. ---.. ----- 0000111110 -  @X_wait
+
 # Branch History Rolling Buffer (BHRB) Instructions
 
 &XFX_bhrbe      rt bhrbe
target/ppc/translate.c +0 -91

103 lines not on this page · raw message

target/ppc/translate/storage-ctrl-impl.c.inc +99 -0

102 lines not on this page · raw message

Signature · 1 line
2.52.0
#15 lore raw

[PULL 15/41] target/ppc: Move fixed-point byte-reversal store insns to decodetree

In reply to Harsh Prateek Bora

From: Amit Machhiwal <[email protected]>

Move the below PPC instructions to decodetree specification:

st{d,h,w}brx, st{d,w,h,b}cix : X-form

The changes were verified by validating that the TCG micro-ops generated by those insns remain the same. These TCG micro-ops were captured with the -d op,in_asm QEMU flag.

Additionally, remove GEN_STX and GEN_STX_E macros as they are no longer used anywhere else.

---
 target/ppc/insn32.decode                   |  8 +++
 target/ppc/translate.c                     | 52 +++-----------
 target/ppc/translate/fixedpoint-impl.c.inc | 79 ++++++++++++++++++++++
 3 files changed, 95 insertions(+), 44 deletions(-)
target/ppc/insn32.decode +8 -0
index 12fb4974e4..37f508a5c2 100644
@@ -372,6 +372,14 @@ STVDX           011111 ..... ..... ..... 0010010001 -   @X
 STSKU           111110 ..... ..... ............. 0 11   @DD
 STCXU           111110 ..... ..... ............. 1 11   @DD
 
+STDBRX          011111 ..... ..... ..... 1010010100 -   @X
+STDCIX          011111 ..... ..... ..... 1111110101 -   @X
+STWCIX          011111 ..... ..... ..... 1110010101 -   @X
+STHCIX          011111 ..... ..... ..... 1110110101 -   @X
+STBCIX          011111 ..... ..... ..... 1111010101 -   @X
+STHBRX          011111 ..... ..... ..... 1110010110 -   @X
+STWBRX          011111 ..... ..... ..... 1010010110 -   @X
+
 ### Fixed-Point Compare Instructions
 
 CMP             011111 ... - . ..... ..... 0000000000 - @X_bfl
target/ppc/translate.c +8 -44

87 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +79 -0

85 lines not on this page · raw message

Signature · 1 line
2.52.0
#16 lore raw

[PULL 27/41] target/ppc: Move Fixed-Point Load/Store String instructions to decodetree.

In reply to Harsh Prateek Bora

From: Shivang Upadhyay <[email protected]>

Move below instructions to decodetree specification :

lsw{i, x},
stsw{i, x} : X-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.

---
 target/ppc/helper.h                        |   6 +-
 target/ppc/insn32.decode                   |   7 ++
 target/ppc/mem_helper.c                    |   6 +-
 target/ppc/translate.c                     | 102 ---------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 102 +++++++++++++++++++++
 5 files changed, 115 insertions(+), 108 deletions(-)
target/ppc/helper.h +3 -3
index 6e14f02598..18ef7786a4 100644
@@ -45,9 +45,9 @@ DEF_HELPER_1(check_tlb_flush_global, void, env)
 
 DEF_HELPER_3(lmw, void, env, tl, i32)
 DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32)
-DEF_HELPER_4(lsw, void, env, tl, i32, i32)
-DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32)
-DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32)
+DEF_HELPER_4(LSW, void, env, tl, i32, i32)
+DEF_HELPER_5(LSWX, void, env, tl, i32, i32, i32)
+DEF_HELPER_FLAGS_4(STSW, TCG_CALL_NO_WG, void, env, tl, i32, i32)
 DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, int)
 #ifdef TARGET_PPC64
 DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl)
target/ppc/insn32.decode +7 -0
index 5e5490b169..a88ba1fce1 100644
@@ -527,6 +527,13 @@ CREQV           010011 ..... ..... ..... 0100100001 -  @X
 CRANDC          010011 ..... ..... ..... 0010000001 -  @X
 CRORC           010011 ..... ..... ..... 0110100001 -  @X
 
+# Fixed Point Move Assist Instructions
+
+LSWI            011111 ..... ..... ..... 1 001010101 -  @X
+LSWX            011111 ..... ..... ..... 1 000010101 -  @X
+STSWI           011111 ..... ..... ..... 1 011010101 -  @X
+STSWX           011111 ..... ..... ..... 1 010010101 -  @X
+
 # Fixed-Point Hash Instructions
 
 HASHST          011111 ..... ..... ..... 1011010010 .   @X_DW
target/ppc/mem_helper.c +3 -3
index 8ad6945590..10c648cf06 100644
@@ -190,7 +190,7 @@ static void do_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb,
     env->gpr[reg] = val;
 }
 
-void helper_lsw(CPUPPCState *env, target_ulong addr,
+void helper_LSW(CPUPPCState *env, target_ulong addr,
                 uint32_t nb, uint32_t reg)
 {
     do_lsw(env, addr, nb, reg, GETPC());
@@ -202,7 +202,7 @@ void helper_lsw(CPUPPCState *env, target_ulong addr,
  * this is valid, but rA won't be loaded.  For now, I'll follow the
  * spec...
  */
-void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg,
+void helper_LSWX(CPUPPCState *env, target_ulong addr, uint32_t reg,
                  uint32_t ra, uint32_t rb)
 {
     if (likely(xer_bc != 0)) {
@@ -218,7 +218,7 @@ void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg,
     }
 }
 
-void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb,
+void helper_STSW(CPUPPCState *env, target_ulong addr, uint32_t nb,
                  uint32_t reg)
 {
     uintptr_t raddr = GETPC();
target/ppc/translate.c +0 -102

114 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +102 -0

108 lines not on this page · raw message

Signature · 1 line
2.52.0
#17 lore raw

[PULL 38/41] target/ppc: Use PPC2_ISA207 instead of PPC2_ISA207S

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

PPC2_ISA207S is only ever set in the CPUPPCState's insns_flags2 alongside PPC2_ISA207. Checks made by PPC2_ISA207S could be replaced with PPC2_ISA207, hence rendering it useless and apt for removal. This patch does the same.

---
 target/ppc/cpu.h                               | 5 +----
 target/ppc/cpu_init.h                          | 2 +-
 hw/ppc/spapr_caps.c                            | 2 +-
 linux-user/ppc/elfload.c                       | 2 +-
 target/ppc/cpu_init.c                          | 3 +--
 target/ppc/tcg-excp_helper.c                   | 8 ++++----
 target/ppc/translate.c                         | 6 +++---
 target/ppc/translate/bhrb-impl.c.inc           | 4 ++--
 target/ppc/translate/branch-impl.c.inc         | 2 +-
 target/ppc/translate/processor-ctrl-impl.c.inc | 8 ++++----
 10 files changed, 19 insertions(+), 23 deletions(-)
target/ppc/cpu.h +1 -4
index 00676cea2b..4a77607f80 100644
@@ -2577,8 +2577,6 @@ enum {
     PPC2_FP_CVT_ISA206 = 0x0000000000000400ULL,
     /* ISA 2.06B floating point test instructions                            */
     PPC2_FP_TST_ISA206 = 0x0000000000000800ULL,
-    /* PowerISA 2.07 Book3s specification                                    */
-    PPC2_ISA207S       = 0x0000000000008000ULL,
     /* Double precision floating point conversion for signed integer 64      */
     PPC2_FP_CVT_S64    = 0x0000000000010000ULL,
     /* Transactional Memory (ISA 2.07, Book II)                              */
@@ -2603,8 +2601,7 @@ enum {
 #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \
                         PPC2_ISA205 | PPC2_ISA207 | PPC2_PERM_ISA206 | \
                         PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
-                        PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
-                        PPC2_ISA207S | PPC2_DFP | \
+                        PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_DFP | \
                         PPC2_FP_CVT_S64 | PPC2_TM | PPC2_PM_ISA206 | \
                         PPC2_ISA300 | PPC2_ISA310 | PPC2_MEM_LWSYNC | \
                         PPC2_BCDA_ISA206 | PPC2_PPE42 | PPC2_PPE42X | \
target/ppc/cpu_init.h +1 -1
index 73f014c82a..4ba559d8af 100644
@@ -18,7 +18,7 @@
     (PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |                 \
      PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 |      \
      PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_ISA205 |         \
-     PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_ISA300 | PPC2_PRCNTL |    \
+     PPC2_FP_CVT_S64 | PPC2_ISA300 | PPC2_PRCNTL |                   \
      PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206)
 
 #define PPC_INSNS_FLAGS2_POWER9                                      \
hw/ppc/spapr_caps.c +1 -1
index f4a26a85b5..0d659e9b02 100644
@@ -676,7 +676,7 @@ static void cap_ail_mode_3_apply(SpaprMachineState *spapr,
 
     if (tcg_enabled()) {
         /* AIL-3 is only supported on POWER8 and above CPUs. */
-        if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
+        if (!(pcc->insns_flags2 & PPC2_ISA207)) {
             error_setg(errp, "TCG only supports cap-ail-mode-3 on POWER8 and later CPUs");
             error_append_hint(errp, "Try appending -machine cap-ail-mode-3=off\n");
             return;
linux-user/ppc/elfload.c +1 -1
index 8c40f1a663..7bf49e7c0b 100644
@@ -116,7 +116,7 @@ abi_ulong get_elf_hwcap2(CPUState *cs)
     do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)
 
     GET_FEATURE(PPC_ISEL, QEMU_PPC_FEATURE2_HAS_ISEL);
-    GET_FEATURE2((PPC2_ISA207 | PPC2_ISA207S), (QEMU_PPC_FEATURE2_ARCH_2_07 |
+    GET_FEATURE2(PPC2_ISA207, (QEMU_PPC_FEATURE2_ARCH_2_07 |
                   QEMU_PPC_FEATURE2_VEC_CRYPTO | QEMU_PPC_FEATURE2_HAS_TAR));
     GET_FEATURE2(PPC2_ISA300, QEMU_PPC_FEATURE2_ARCH_3_00 |
                  QEMU_PPC_FEATURE2_DARN | QEMU_PPC_FEATURE2_HAS_IEEE128);
target/ppc/cpu_init.c +1 -2
index c251426b2e..6c626843c9 100644
@@ -6349,8 +6349,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, const void *data)
     pcc->insns_flags2 = PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |
                         PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
                         PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
-                        PPC2_FP_TST_ISA206 |
-                        PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |
+                        PPC2_FP_TST_ISA206 | PPC2_ISA205 | PPC2_FP_CVT_S64 |
                         PPC2_TM | PPC2_PM_ISA206 | PPC2_MEM_LWSYNC |
                         PPC2_BCDA_ISA206;
     pcc->msr_mask = (1ull << MSR_SF) |
target/ppc/tcg-excp_helper.c +4 -4
index d06d3f8642..93aedb0c8e 100644
@@ -314,7 +314,7 @@ void ppc_cpu_debug_excp_handler(CPUState *cs)
 #if defined(TARGET_PPC64)
     CPUPPCState *env = cpu_env(cs);
 
-    if (env->insns_flags2 & PPC2_ISA207S) {
+    if (env->insns_flags2 & PPC2_ISA207) {
         if (cs->watchpoint_hit) {
             if (cs->watchpoint_hit->flags & BP_CPU) {
                 env->spr[SPR_DAR] = cs->watchpoint_hit->hitaddr;
@@ -336,7 +336,7 @@ bool ppc_cpu_debug_check_breakpoint(CPUState *cs)
 #if defined(TARGET_PPC64)
     CPUPPCState *env = cpu_env(cs);
 
-    if (env->insns_flags2 & PPC2_ISA207S) {
+    if (env->insns_flags2 & PPC2_ISA207) {
         target_ulong priv;
 
         priv = env->spr[SPR_CIABR] & PPC_BITMASK(62, 63);
@@ -365,7 +365,7 @@ bool ppc_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
     bool wt, wti, hv, sv, pr;
     uint32_t dawrx;
 
-    if ((env->insns_flags2 & PPC2_ISA207S) &&
+    if ((env->insns_flags2 & PPC2_ISA207) &&
         (wp == env->dawr_watchpoint[0])) {
         dawrx = env->spr[SPR_DAWRX0];
     } else if ((env->insns_flags2 & PPC2_ISA310) &&
@@ -849,7 +849,7 @@ void helper_book3s_msgsndp(CPUPPCState *env, target_ulong rb)
 void helper_book3s_trace(CPUPPCState *env, target_ulong prev_ip)
 {
     uint32_t error_code = 0;
-    if (env->insns_flags2 & PPC2_ISA207S) {
+    if (env->insns_flags2 & PPC2_ISA207) {
         /* Load/store reporting, SRR1[35, 36] and SDAR, are not implemented. */
         env->spr[SPR_POWER_SIAR] = prev_ip;
         error_code = PPC_BIT(33);
target/ppc/translate.c +3 -3
index f93af662f3..023935c10e 100644
@@ -2775,7 +2775,7 @@ static inline void gen_op_mfspr(DisasContext *ctx)
         }
     } else {
         /* ISA 2.07 defines these as no-ops */
-        if ((ctx->insns_flags2 & PPC2_ISA207S) &&
+        if ((ctx->insns_flags2 & PPC2_ISA207) &&
             (sprn >= 808 && sprn <= 811)) {
             /* This is a nop */
             return;
@@ -2841,7 +2841,7 @@ static void gen_mtspr(DisasContext *ctx)
         }
     } else {
         /* ISA 2.07 defines these as no-ops */
-        if ((ctx->insns_flags2 & PPC2_ISA207S) &&
+        if ((ctx->insns_flags2 & PPC2_ISA207) &&
             (sprn >= 808 && sprn <= 811)) {
             /* This is a nop */
             return;
@@ -4135,7 +4135,7 @@ TRANS64(LDARX, do_load_locked, DEF_MEMOP(MO_UQ))
 static bool trans_LQARX(DisasContext *ctx, arg_LQARX *a)
 {
     REQUIRE_64BIT(ctx);
-    REQUIRE_INSNS_FLAGS2(ctx, ISA207S);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
 #if defined(TARGET_PPC64)
     TCGv EA;
     TCGv_i128 t16;
target/ppc/translate/bhrb-impl.c.inc +2 -2
index 3a19bc4555..4b3914a1f6 100644
@@ -14,7 +14,7 @@
 
 static bool trans_MFBHRBE(DisasContext *ctx, arg_XFX_bhrbe *arg)
 {
-    REQUIRE_INSNS_FLAGS2(ctx, ISA207S);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
     TCGv_i32 bhrbe = tcg_constant_i32(arg->bhrbe);
     gen_helper_mfbhrbe(cpu_gpr[arg->rt], tcg_env, bhrbe);
     return true;
@@ -22,7 +22,7 @@ static bool trans_MFBHRBE(DisasContext *ctx, arg_XFX_bhrbe *arg)
 
 static bool trans_CLRBHRB(DisasContext *ctx, arg_CLRBHRB *arg)
 {
-    REQUIRE_INSNS_FLAGS2(ctx, ISA207S);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
     gen_helper_clrbhrb(tcg_env);
     return true;
 }
target/ppc/translate/branch-impl.c.inc +1 -1
index e5b64ca84e..51fcabff63 100644
@@ -14,7 +14,7 @@
 
 static bool trans_RFEBB(DisasContext *ctx, arg_XL_s *arg)
 {
-    REQUIRE_INSNS_FLAGS2(ctx, ISA207S);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
 
     translator_io_start(&ctx->base);
     gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_NORECORD);
target/ppc/translate/processor-ctrl-impl.c.inc +4 -4
index cfcca28267..cb125cfa72 100644
@@ -23,7 +23,7 @@
 
 static bool trans_MSGCLR(DisasContext *ctx, arg_X_rb *a)
 {
-    if (!(ctx->insns_flags2 & PPC2_ISA207S)) {
+    if (!(ctx->insns_flags2 & PPC2_ISA207)) {
         /*
          * Before Power ISA 2.07, processor control instructions were only
          * implemented in the "Embedded.Processor Control" category.
@@ -47,7 +47,7 @@ static bool trans_MSGCLR(DisasContext *ctx, arg_X_rb *a)
 
 static bool trans_MSGSND(DisasContext *ctx, arg_X_rb *a)
 {
-    if (!(ctx->insns_flags2 & PPC2_ISA207S)) {
+    if (!(ctx->insns_flags2 & PPC2_ISA207)) {
         /*
          * Before Power ISA 2.07, processor control instructions were only
          * implemented in the "Embedded.Processor Control" category.
@@ -72,7 +72,7 @@ static bool trans_MSGSND(DisasContext *ctx, arg_X_rb *a)
 static bool trans_MSGCLRP(DisasContext *ctx, arg_X_rb *a)
 {
     REQUIRE_64BIT(ctx);
-    REQUIRE_INSNS_FLAGS2(ctx, ISA207S);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
     REQUIRE_SV(ctx);
 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_PPC64)
     gen_helper_book3s_msgclrp(tcg_env, cpu_gpr[a->rb]);
@@ -85,7 +85,7 @@ static bool trans_MSGCLRP(DisasContext *ctx, arg_X_rb *a)
 static bool trans_MSGSNDP(DisasContext *ctx, arg_X_rb *a)
 {
     REQUIRE_64BIT(ctx);
-    REQUIRE_INSNS_FLAGS2(ctx, ISA207S);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
     REQUIRE_SV(ctx);
 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_PPC64)
     gen_helper_book3s_msgsndp(tcg_env, cpu_gpr[a->rb]);
Signature · 1 line
2.52.0
#18 lore raw

[PULL 32/41] target/ppc: Move byte-reverse instructions to decodetree

In reply to Harsh Prateek Bora

From: Vishal Chourasia <[email protected]>

Moving the following instructions to decodetree specification:
brd, brw, brh : X-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the -d in_asm,op flag.

This also includes improvements from review feedback:
- Add TARGET_PPC64 guards with qemu_build_not_reached() for 32-bit builds

---
 target/ppc/insn32.decode                   |  5 +++
 target/ppc/translate.c                     | 35 ----------------
 target/ppc/translate/fixedpoint-impl.c.inc | 48 ++++++++++++++++++++++
 3 files changed, 53 insertions(+), 35 deletions(-)
target/ppc/insn32.decode +5 -0
index 1e263449a5..7bbe1f8838 100644
@@ -320,6 +320,11 @@ MFMSR           011111 ..... ----- ----- 0001010011 -   @X_t
 MTMSR           011111 ..... ---- . ----- 0010010010 -  @X_rs_l
 MTMSRD          011111 ..... ---- . ----- 0010110010 -  @X_rs_l
 
+### Fixed-Point Byte-Reverse Instructions
+BRW             011111 ..... ..... ----- 0010011011 -   @X_sa
+BRD             011111 ..... ..... ----- 0010111011 -   @X_sa
+BRH             011111 ..... ..... ----- 0011011011 -   @X_sa
+
 ### Fixed-Point Load Instructions
 
 LBZ             100010 ..... ..... ................     @D
target/ppc/translate.c +0 -35
index 1d069c5250..20d3e7c1ab 100644
@@ -4519,42 +4519,7 @@ static void gen_dform3D(DisasContext *ctx)
     return gen_invalid(ctx);
 }
 
-#if defined(TARGET_PPC64)
-/* brd */
-static void gen_brd(DisasContext *ctx)
-{
-    tcg_gen_bswap64_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
-}
-
-/* brw */
-static void gen_brw(DisasContext *ctx)
-{
-    tcg_gen_bswap64_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
-    tcg_gen_rotli_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 32);
-
-}
-
-/* brh */
-static void gen_brh(DisasContext *ctx)
-{
-    TCGv_i64 mask = tcg_constant_i64(0x00ff00ff00ff00ffull);
-    TCGv_i64 t1 = tcg_temp_new_i64();
-    TCGv_i64 t2 = tcg_temp_new_i64();
-
-    tcg_gen_shri_i64(t1, cpu_gpr[rS(ctx->opcode)], 8);
-    tcg_gen_and_i64(t2, t1, mask);
-    tcg_gen_and_i64(t1, cpu_gpr[rS(ctx->opcode)], mask);
-    tcg_gen_shli_i64(t1, t1, 8);
-    tcg_gen_or_i64(cpu_gpr[rA(ctx->opcode)], t1, t2);
-}
-#endif
-
 static opcode_t opcodes[] = {
-#if defined(TARGET_PPC64)
-GEN_HANDLER_E(brd, 0x1F, 0x1B, 0x05, 0x0000F801, PPC_NONE, PPC2_ISA310),
-GEN_HANDLER_E(brw, 0x1F, 0x1B, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA310),
-GEN_HANDLER_E(brh, 0x1F, 0x1B, 0x06, 0x0000F801, PPC_NONE, PPC2_ISA310),
-#endif
 GEN_HANDLER(invalid, 0x00, 0x00, 0x00, 0xFFFFFFFF, PPC_NONE),
 GEN_HANDLER_E(copy, 0x1F, 0x06, 0x18, 0x03C00001, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(cp_abort, 0x1F, 0x06, 0x1A, 0x03FFF801, PPC_NONE, PPC2_ISA300),
target/ppc/translate/fixedpoint-impl.c.inc +48 -0

54 lines not on this page · raw message

Signature · 1 line
2.52.0
#19 lore raw

[PULL 39/41] target/ppc: Reorder PPC2 flags

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

Consolidation of different variations of Power ISA 2.07 flags into the PPC2_ISA207 flag has left gaps in the flag encoding. This patch reorders them, restoring the expected incremental order without any gaps, freeing up bits for future use.

---
 target/ppc/cpu.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
target/ppc/cpu.h +10 -10
index 4a77607f80..3fb51bbeb8 100644
@@ -2578,25 +2578,25 @@ enum {
     /* ISA 2.06B floating point test instructions                            */
     PPC2_FP_TST_ISA206 = 0x0000000000000800ULL,
     /* Double precision floating point conversion for signed integer 64      */
-    PPC2_FP_CVT_S64    = 0x0000000000010000ULL,
+    PPC2_FP_CVT_S64    = 0x0000000000001000ULL,
     /* Transactional Memory (ISA 2.07, Book II)                              */
-    PPC2_TM            = 0x0000000000020000ULL,
+    PPC2_TM            = 0x0000000000002000ULL,
     /* Server PM instructgions (ISA 2.06, Book III)                          */
-    PPC2_PM_ISA206     = 0x0000000000040000ULL,
+    PPC2_PM_ISA206     = 0x0000000000004000ULL,
     /* POWER ISA 3.0                                                         */
-    PPC2_ISA300        = 0x0000000000080000ULL,
+    PPC2_ISA300        = 0x0000000000008000ULL,
     /* POWER ISA 3.1                                                         */
-    PPC2_ISA310        = 0x0000000000100000ULL,
+    PPC2_ISA310        = 0x0000000000010000ULL,
     /*   lwsync instruction                                                  */
-    PPC2_MEM_LWSYNC    = 0x0000000000200000ULL,
+    PPC2_MEM_LWSYNC    = 0x0000000000020000ULL,
     /* ISA 2.06 BCD assist instructions                                      */
-    PPC2_BCDA_ISA206   = 0x0000000000400000ULL,
+    PPC2_BCDA_ISA206   = 0x0000000000040000ULL,
     /* PPE42 instructions                                                    */
-    PPC2_PPE42         = 0x0000000000800000ULL,
+    PPC2_PPE42         = 0x0000000000080000ULL,
     /* PPE42X instructions                                                   */
-    PPC2_PPE42X        = 0x0000000001000000ULL,
+    PPC2_PPE42X        = 0x0000000000100000ULL,
     /* PPE42XM instructions                                                  */
-    PPC2_PPE42XM       = 0x0000000002000000ULL,
+    PPC2_PPE42XM       = 0x0000000000200000ULL,
 
 #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \
                         PPC2_ISA205 | PPC2_ISA207 | PPC2_PERM_ISA206 | \
Signature · 1 line
2.52.0
#20 lore raw

[PULL 22/41] target/ppc: Move sleep & friends to decodetree

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

Convert the following instructions to decode tree specification:

doze
nap
sleep
rvwinkle
stop

The functionality was tested by comparing the qemu -D log -d op,in_asm output as well as single stepping gdb to confirm behavior was not changed for ISA3.x (stop) as well as ISA206 (doze, nap, sleep, rvwinkle).

---
 target/ppc/insn32.decode                      |   8 ++
 target/ppc/translate.c                        |  85 ---------------
 .../ppc/translate/processor-ctrl-impl.c.inc   | 100 ++++++++++++++++++
 3 files changed, 108 insertions(+), 85 deletions(-)
target/ppc/insn32.decode +8 -0
index da32ac1d28..b833244932 100644
@@ -913,6 +913,14 @@ VPERMR          000100 ..... ..... ..... ..... 111011   @VA
 
 VSEL            000100 ..... ..... ..... ..... 101010   @VA
 
+## Power Management Instructions
+
+DOZE            010011 ----- ----- ----- 0110010010 -
+NAP             010011 ----- ----- ----- 0110110010 -
+SLEEP           010011 ----- ----- ----- 0111010010 -
+RVWINKLE        010011 ----- ----- ----- 0111110010 -
+STOP            010011 ----- ----- ----- 0101110010 -
+
 ## Vector Integer Shift Instruction
 
 VSLB            000100 ..... ..... ..... 00100000100    @VX
target/ppc/translate.c +0 -85

97 lines not on this page · raw message

target/ppc/translate/processor-ctrl-impl.c.inc +100 -0

103 lines not on this page · raw message

Signature · 1 line
2.52.0
#21 lore raw

[PULL 35/41] target/ppc: Use PPC2_ISA207 instead of PPC2_BCTAR_ISA207

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

PPC2_BCTAR_ISA207 is only ever set in the CPUPPCState's insns_flags2 alongside PPC2_ISA207. Checks made by PPC2_BCTAR_ISA207 could be replaced with PPC2_ISA207, hence rendering it useless and apt for removal. This patch does the same.

---
 target/ppc/cpu.h                       | 4 +---
 target/ppc/cpu_init.h                  | 2 +-
 linux-user/ppc/elfload.c               | 7 +++----
 target/ppc/cpu_init.c                  | 2 +-
 target/ppc/translate/branch-impl.c.inc | 2 +-
 5 files changed, 7 insertions(+), 10 deletions(-)
target/ppc/cpu.h +1 -3
index 91ef34cb21..df1e943d8d 100644
@@ -2577,8 +2577,6 @@ enum {
     PPC2_FP_CVT_ISA206 = 0x0000000000000400ULL,
     /* ISA 2.06B floating point test instructions                            */
     PPC2_FP_TST_ISA206 = 0x0000000000000800ULL,
-    /* ISA 2.07 bctar instruction                                            */
-    PPC2_BCTAR_ISA207  = 0x0000000000001000ULL,
     /* ISA 2.07 load/store quadword                                          */
     PPC2_LSQ_ISA207    = 0x0000000000002000ULL,
     /* ISA 2.07 Altivec                                                      */
@@ -2610,7 +2608,7 @@ enum {
                         PPC2_ISA205 | PPC2_ISA207 | PPC2_PERM_ISA206 | \
                         PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
                         PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
-                        PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | \
+                        PPC2_LSQ_ISA207 | \
                         PPC2_ALTIVEC_207 | PPC2_ISA207S | PPC2_DFP | \
                         PPC2_FP_CVT_S64 | PPC2_TM | PPC2_PM_ISA206 | \
                         PPC2_ISA300 | PPC2_ISA310 | PPC2_MEM_LWSYNC | \
target/ppc/cpu_init.h +1 -1
index 1c41c0d349..7dd587908e 100644
@@ -17,7 +17,7 @@
 #define PPC_INSNS_FLAGS2_POWER_COMMON                                \
     (PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |                 \
      PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 |      \
-     PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |   \
+     PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 |                       \
      PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 |              \
      PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_ISA300 | PPC2_PRCNTL |    \
      PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206)
linux-user/ppc/elfload.c +3 -4
index 0d54da9803..5c6065e08a 100644
@@ -116,10 +116,9 @@ abi_ulong get_elf_hwcap2(CPUState *cs)
     do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)
 
     GET_FEATURE(PPC_ISEL, QEMU_PPC_FEATURE2_HAS_ISEL);
-    GET_FEATURE2(PPC2_BCTAR_ISA207, QEMU_PPC_FEATURE2_HAS_TAR);
-    GET_FEATURE2((PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
-                  PPC2_ISA207S), QEMU_PPC_FEATURE2_ARCH_2_07 |
-                  QEMU_PPC_FEATURE2_VEC_CRYPTO);
+    GET_FEATURE2((PPC2_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
+                  PPC2_ISA207S), (QEMU_PPC_FEATURE2_ARCH_2_07 |
+                  QEMU_PPC_FEATURE2_VEC_CRYPTO | QEMU_PPC_FEATURE2_HAS_TAR));
     GET_FEATURE2(PPC2_ISA300, QEMU_PPC_FEATURE2_ARCH_3_00 |
                  QEMU_PPC_FEATURE2_DARN | QEMU_PPC_FEATURE2_HAS_IEEE128);
     GET_FEATURE2(PPC2_ISA310, QEMU_PPC_FEATURE2_ARCH_3_1 |
target/ppc/cpu_init.c +1 -1
index b913edd243..c250f805a7 100644
@@ -6349,7 +6349,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, const void *data)
     pcc->insns_flags2 = PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |
                         PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
                         PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
-                        PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |
+                        PPC2_FP_TST_ISA206 |
                         PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
                         PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |
                         PPC2_TM | PPC2_PM_ISA206 | PPC2_MEM_LWSYNC |
target/ppc/translate/branch-impl.c.inc +1 -1
index c51fd9b13e..e5b64ca84e 100644
@@ -210,4 +210,4 @@ static bool bclr_helper(DisasContext *ctx, arg_bclr *a, int type)
 
 TRANS(BCLR, bclr_helper, BCOND_LR)
 TRANS(BCCTR, bclr_helper, BCOND_CTR)
-TRANS_FLAGS2(BCTAR_ISA207, BCTAR, bclr_helper, BCOND_TAR)
+TRANS_FLAGS2(ISA207, BCTAR, bclr_helper, BCOND_TAR)
Signature · 1 line
2.52.0
#22 lore raw

[PULL 09/41] target/ppc: Move vector pack instructions to decodetree

In reply to Harsh Prateek Bora

From: Aboorva Devarajan <[email protected]>

Move below instructions to decodetree specification:

vpkuhum, vpkuwum, vpkuhus, vpkuwus : VX-form (PPC_ALTIVEC) vpkshus, vpkswus, vpkshss, vpkswss : VX-form (PPC_ALTIVEC)
vpkpx : VX-form (PPC_ALTIVEC)
vpkudum, vpkudus, vpksdus, vpksdss : VX-form (PPC2_ALTIVEC_207)

The legacy GEN_VXFORM_ENV/GEN_VXFORM macros that generated gen_vpk*() functions reading register fields from ctx->opcode are replaced by new do_vpk_env()/do_vpk() helpers in vmx-impl.c.inc that use the pre-extracted decodetree argument fields (a->vrt, a->vra, a->vrb) directly. The existing gen_helper_vpk*() implementations in int_helper.c are reused without changes.

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' option before and after the patch.

---
 target/ppc/helper.h                 | 26 +++++++--------
 target/ppc/insn32.decode            | 16 +++++++++
 target/ppc/int_helper.c             | 28 ++++++++--------
 target/ppc/translate/vmx-impl.c.inc | 51 +++++++++++++++++++++--------
 target/ppc/translate/vmx-ops.c.inc  | 13 --------
 5 files changed, 81 insertions(+), 53 deletions(-)
target/ppc/helper.h +13 -13
index 5517d2950f..a0d08d6192 100644
@@ -249,19 +249,19 @@ DEF_HELPER_FLAGS_4(VMSUMUBM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
 DEF_HELPER_FLAGS_4(VMSUMMBM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
 DEF_HELPER_FLAGS_4(VPERM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
 DEF_HELPER_FLAGS_4(VPERMR, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
-DEF_HELPER_4(vpkshss, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkshus, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkswss, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkswus, void, env, avr, avr, avr)
-DEF_HELPER_4(vpksdss, void, env, avr, avr, avr)
-DEF_HELPER_4(vpksdus, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkuhus, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkuwus, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkudus, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkuhum, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkuwum, void, env, avr, avr, avr)
-DEF_HELPER_4(vpkudum, void, env, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vpkpx, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_4(VPKSHSS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKSHUS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKSWSS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKSWUS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKSDSS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKSDUS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKUHUS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKUWUS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKUDUS, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKUHUM, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKUWUM, void, env, avr, avr, avr)
+DEF_HELPER_4(VPKUDUM, void, env, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VPKPX, TCG_CALL_NO_RWG, void, avr, avr, avr)
 DEF_HELPER_5(VMHADDSHS, void, env, avr, avr, avr, avr)
 DEF_HELPER_5(VMHRADDSHS, void, env, avr, avr, avr, avr)
 DEF_HELPER_FLAGS_4(VMSUMUHM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
target/ppc/insn32.decode +16 -0
index 99f7421e77..d6f1875532 100644
@@ -1054,6 +1054,22 @@ VSTRIHR         000100 ..... 00011 ..... . 0000001101   @VX_tb_rc
 VCLRLB          000100 ..... ..... ..... 00110001101    @VX
 VCLRRB          000100 ..... ..... ..... 00111001101    @VX
 
+## Vector Pack Instructions
+
+VPKUHUM         000100 ..... ..... ..... 0000000111 0    @VX
+VPKUWUM         000100 ..... ..... ..... 0000100111 0    @VX
+VPKUDUM         000100 ..... ..... ..... 1000100111 0    @VX
+VPKUHUS         000100 ..... ..... ..... 0001000111 0    @VX
+VPKUWUS         000100 ..... ..... ..... 0001100111 0    @VX
+VPKUDUS         000100 ..... ..... ..... 1001100111 0    @VX
+VPKSHUS         000100 ..... ..... ..... 0010000111 0    @VX
+VPKSWUS         000100 ..... ..... ..... 0010100111 0    @VX
+VPKSDUS         000100 ..... ..... ..... 1010100111 0    @VX
+VPKSHSS         000100 ..... ..... ..... 0011000111 0    @VX
+VPKSWSS         000100 ..... ..... ..... 0011100111 0    @VX
+VPKSDSS         000100 ..... ..... ..... 1011100111 0    @VX
+VPKPX           000100 ..... ..... ..... 0110000111 0    @VX
+
 # VSX Load/Store Instructions
 
 LXSD            111001 ..... ..... .............. 10    @DS
target/ppc/int_helper.c +14 -14
index a3adf746bd..dc55ccadf7 100644
@@ -1465,7 +1465,7 @@ void helper_VPMSUMD(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
 #else
 #define PKBIG 0
 #endif
-void helper_vpkpx(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
+void helper_VPKPX(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
 {
     int i, j;
     ppc_avr_t result;
@@ -1488,7 +1488,7 @@ void helper_vpkpx(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
 }
 
 #define VPK(suffix, from, to, cvt, dosat)                               \
-    void helper_vpk##suffix(CPUPPCState *env, ppc_avr_t *r,             \
+    void helper_VPK##suffix(CPUPPCState *env, ppc_avr_t *r,             \
                             ppc_avr_t *a, ppc_avr_t *b)                 \
     {                                                                   \
         int i;                                                          \
@@ -1507,18 +1507,18 @@ void helper_vpkpx(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
         }                                                               \
     }
 #define I(x, y) (x)
-VPK(shss, s16, s8, cvtshsb, 1)
-VPK(shus, s16, u8, cvtshub, 1)
-VPK(swss, s32, s16, cvtswsh, 1)
-VPK(swus, s32, u16, cvtswuh, 1)
-VPK(sdss, s64, s32, cvtsdsw, 1)
-VPK(sdus, s64, u32, cvtsduw, 1)
-VPK(uhus, u16, u8, cvtuhub, 1)
-VPK(uwus, u32, u16, cvtuwuh, 1)
-VPK(udus, u64, u32, cvtuduw, 1)
-VPK(uhum, u16, u8, I, 0)
-VPK(uwum, u32, u16, I, 0)
-VPK(udum, u64, u32, I, 0)
+VPK(SHSS, s16, s8, cvtshsb, 1)
+VPK(SHUS, s16, u8, cvtshub, 1)
+VPK(SWSS, s32, s16, cvtswsh, 1)
+VPK(SWUS, s32, u16, cvtswuh, 1)
+VPK(SDSS, s64, s32, cvtsdsw, 1)
+VPK(SDUS, s64, u32, cvtsduw, 1)
+VPK(UHUS, u16, u8, cvtuhub, 1)
+VPK(UWUS, u32, u16, cvtuwuh, 1)
+VPK(UDUS, u64, u32, cvtuduw, 1)
+VPK(UHUM, u16, u8, I, 0)
+VPK(UWUM, u32, u16, I, 0)
+VPK(UDUM, u64, u32, I, 0)
 #undef I
 #undef VPK
 #undef PKBIG
target/ppc/translate/vmx-impl.c.inc +38 -13

57 lines not on this page · raw message

target/ppc/translate/vmx-ops.c.inc +0 -13
index b8f77d3d2c..2820976c0f 100644
@@ -59,19 +59,6 @@ GEN_VXFORM_300(bcdtrunc, 0, 20),
 GEN_VXFORM_300(bcdutrunc, 0, 21),
 GEN_VXFORM(vsl, 2, 7),
 GEN_VXFORM(vsr, 2, 11),
-GEN_VXFORM(vpkuhum, 7, 0),
-GEN_VXFORM(vpkuwum, 7, 1),
-GEN_VXFORM_207(vpkudum, 7, 17),
-GEN_VXFORM(vpkuhus, 7, 2),
-GEN_VXFORM(vpkuwus, 7, 3),
-GEN_VXFORM_207(vpkudus, 7, 19),
-GEN_VXFORM(vpkshus, 7, 4),
-GEN_VXFORM(vpkswus, 7, 5),
-GEN_VXFORM_207(vpksdus, 7, 21),
-GEN_VXFORM(vpkshss, 7, 6),
-GEN_VXFORM(vpkswss, 7, 7),
-GEN_VXFORM_207(vpksdss, 7, 23),
-GEN_VXFORM(vpkpx, 7, 12),
 GEN_VXFORM(vsum4ubs, 4, 24),
 GEN_VXFORM(vsum4sbs, 4, 28),
 GEN_VXFORM(vsum4shs, 4, 25),
Signature · 1 line
2.52.0
#23 lore raw

[PULL 28/41] target/ppc: Move VMX integer arithmetic and BCD instructions to decodetree.

In reply to Harsh Prateek Bora

From: Shivang Upadhyay <[email protected]>

Move below instructions to decodetree specification :

        vadd{u, s}{b, h, w, d}m[.],
        vsub{u, s}{b, h, w, d}m[.],
        vmuluwm[.],
        vmul10{u, eu, ecu, cu}q[.]       : VX-form

        bcd{add, sub}[.],
        bcd{s, us}[.],
        bcdcpsgn[.],
        bcdct{sq, n}[.],
        bcdcf{sq, z, n}[.],
        bcdctz[.],
        bcdsetsgn[.],
        bcdsr[.],
        bcd{u,}trunc[.]                  : VX-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.

---
 target/ppc/helper.h                 |  30 +--
 target/ppc/insn32.decode            |  39 ++++
 target/ppc/int_helper.c             |  32 +--
 target/ppc/translate/vmx-impl.c.inc | 299 ++++++++++++----------------
 target/ppc/translate/vmx-ops.c.inc  |  22 --
 5 files changed, 199 insertions(+), 223 deletions(-)
target/ppc/helper.h +15 -15
index 18ef7786a4..7da752c69b 100644
@@ -349,21 +349,21 @@ DEF_HELPER_FLAGS_3(vshasigmaw, TCG_CALL_NO_RWG, void, avr, avr, i32)
 DEF_HELPER_FLAGS_3(vshasigmad, TCG_CALL_NO_RWG, void, avr, avr, i32)
 DEF_HELPER_FLAGS_4(vpermxor, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
 
-DEF_HELPER_FLAGS_4(bcdadd, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcdsub, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdcfn, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdctn, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdcfz, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdctz, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdcfsq, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdctsq, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcdcpsgn, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_3(bcdsetsgn, TCG_CALL_NO_RWG, i32, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcds, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcdus, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcdsr, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcdtrunc, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_4(bcdutrunc, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDADD, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDSUB, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDCFN, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDCTN, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDCFZ, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDCTZ, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDCFSQ, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDCTSQ, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDCPSGN, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_3(BCDSETSGN, TCG_CALL_NO_RWG, i32, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDS, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDUS, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDSR, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDTRUNC, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
+DEF_HELPER_FLAGS_4(BCDUTRUNC, TCG_CALL_NO_RWG, i32, avr, avr, avr, i32)
 
 DEF_HELPER_4(XSADDDP, void, env, vsr, vsr, vsr)
 DEF_HELPER_5(xsaddqp, void, env, i32, vsr, vsr, vsr)
target/ppc/insn32.decode +39 -0
index a88ba1fce1..69d60605bd 100644
@@ -90,6 +90,9 @@
 &VX             vrt vra vrb
 @VX             ...... vrt:5 vra:5 vrb:5 .......... .           &VX
 
+&VX_ps          vrt vra vrb ps
+@VX_ps          ...... vrt:5 vra:5 vrb:5 . ps:1 ........ .           &VX_ps
+
 &VX_bf          bf vra vrb
 @VX_bf          ...... bf:3 .. vra:5 vrb:5 ...........          &VX_bf
 
@@ -108,6 +111,9 @@
 &VX_tb          vrt vrb
 @VX_tb          ...... vrt:5 ..... vrb:5 ...........            &VX_tb
 
+&VX_tb_ps       vrt vrb ps
+@VX_tb_ps       ...... vrt:5 ..... vrb:5 . ps:1 .........            &VX_tb_ps
+
 &X              rt ra rb
 @X              ...... rt:5 ra:5 rb:5 .......... .              &X
 
@@ -991,6 +997,10 @@ VADDSBS         000100 ..... ..... ..... 01100000000    @VX
 VADDSHS         000100 ..... ..... ..... 01101000000    @VX
 VADDSWS         000100 ..... ..... ..... 01110000000    @VX
 
+VADDUBM         000100 ..... ..... ..... 00000000000    @VX
+VADDUHM         000100 ..... ..... ..... 00001000000    @VX
+VADDUWM         000100 ..... ..... ..... 00010000000    @VX
+VADDUDM         000100 ..... ..... ..... 00011000000    @VX
 VADDUBS         000100 ..... ..... ..... 01000000000    @VX
 VADDUHS         000100 ..... ..... ..... 01001000000    @VX
 VADDUWS         000100 ..... ..... ..... 01010000000    @VX
@@ -1006,6 +1016,10 @@ VSUBSBS         000100 ..... ..... ..... 11100000000    @VX
 VSUBSHS         000100 ..... ..... ..... 11101000000    @VX
 VSUBSWS         000100 ..... ..... ..... 11110000000    @VX
 
+VSUBUBM         000100 ..... ..... ..... 10000000000    @VX
+VSUBUHM         000100 ..... ..... ..... 10001000000    @VX
+VSUBUWM         000100 ..... ..... ..... 10010000000    @VX
+VSUBUDM         000100 ..... ..... ..... 10011000000    @VX
 VSUBUBS         000100 ..... ..... ..... 11000000000    @VX
 VSUBUHS         000100 ..... ..... ..... 11001000000    @VX
 VSUBUWS         000100 ..... ..... ..... 11010000000    @VX
@@ -1099,6 +1113,13 @@ VMULHSD         000100 ..... ..... ..... 01111001001    @VX
 VMULHUD         000100 ..... ..... ..... 01011001001    @VX
 VMULLD          000100 ..... ..... ..... 00111001001    @VX
 
+VMULUWM         000100 ..... ..... ..... 00010001001    @VX
+
+VMUL10UQ        000100 ..... ..... ..... 01000000001    @VX
+VMUL10EUQ       000100 ..... ..... ..... 01001000001    @VX
+VMUL10ECUQ      000100 ..... ..... ..... 00001000001    @VX
+VMUL10CUQ       000100 ..... ..... ..... 00000000001    @VX
+
 ## Vector Multiply-Sum Instructions
 
 VMSUMUBM        000100 ..... ..... ..... ..... 100100   @VA
@@ -1141,6 +1162,24 @@ VPKSWSS         000100 ..... ..... ..... 0011100111 0    @VX
 VPKSDSS         000100 ..... ..... ..... 1011100111 0    @VX
 VPKPX           000100 ..... ..... ..... 0110000111 0    @VX
 
+## Decimal Integer Arithmetic Instructions
+
+BCDADD          000100 ..... ..... ..... 1.000000001    @VX_ps
+BCDSUB          000100 ..... ..... ..... 1.001000001    @VX_ps
+BCDUS           000100 ..... ..... ..... 10010000001    @VX
+BCDS            000100 ..... ..... ..... 1.011000001    @VX_ps
+BCDCTSQ         000100 ..... 00000 ..... 10110000001    @VX_tb
+BCDCTN          000100 ..... 00101 ..... 10110000001    @VX_tb
+BCDCFSQ         000100 ..... 00010 ..... 1.110000001    @VX_tb_ps
+BCDCTZ          000100 ..... 00100 ..... 1.110000001    @VX_tb_ps
+BCDCFZ          000100 ..... 00110 ..... 1.110000001    @VX_tb_ps
+BCDCFN          000100 ..... 00111 ..... 1.110000001    @VX_tb_ps
+BCDSETSGN       000100 ..... 11111 ..... 1.110000001    @VX_tb_ps
+BCDCPSGN        000100 ..... ..... ..... 01101000001    @VX
+BCDSR           000100 ..... ..... ..... 1.111000001    @VX_ps
+BCDTRUNC        000100 ..... ..... ..... 1.100000001    @VX_ps
+BCDUTRUNC       000100 ..... ..... ..... 10101000001    @VX
+
 # VSX Load/Store Instructions
 
 LXSD            111001 ..... ..... .............. 10    @DS
target/ppc/int_helper.c +16 -16
index 8e8076a92c..86346f5b9a 100644
@@ -2348,7 +2348,7 @@ static void bcd_sub_mag(ppc_avr_t *t, ppc_avr_t *a, ppc_avr_t *b, int *invalid,
     *overflow = carry;
 }
 
-uint32_t helper_bcdadd(ppc_avr_t *r,  ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDADD(ppc_avr_t *r,  ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
 
     int sgna = bcd_get_sgn(a);
@@ -2395,7 +2395,7 @@ uint32_t helper_bcdadd(ppc_avr_t *r,  ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdsub(ppc_avr_t *r,  ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDSUB(ppc_avr_t *r,  ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     ppc_avr_t bcopy = *b;
     int sgnb = bcd_get_sgn(b);
@@ -2406,10 +2406,10 @@ uint32_t helper_bcdsub(ppc_avr_t *r,  ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     }
     /* else invalid ... defer to bcdadd code for proper handling */
 
-    return helper_bcdadd(r, a, &bcopy, ps);
+    return helper_BCDADD(r, a, &bcopy, ps);
 }
 
-uint32_t helper_bcdcfn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCFN(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     int cr = 0;
@@ -2445,7 +2445,7 @@ uint32_t helper_bcdcfn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdctn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCTN(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     int cr = 0;
@@ -2479,7 +2479,7 @@ uint32_t helper_bcdctn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdcfz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCFZ(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     int cr = 0;
@@ -2523,7 +2523,7 @@ uint32_t helper_bcdcfz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCTZ(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     int cr = 0;
@@ -2582,7 +2582,7 @@ static inline int ucmp128(uint64_t alo, uint64_t ahi,
         (ahi > bhi ? 1 : -1);
 }
 
-uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCFSQ(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     int cr;
@@ -2640,7 +2640,7 @@ uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdctsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCTSQ(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     uint8_t i;
     int cr;
@@ -2680,7 +2680,7 @@ uint32_t helper_bcdctsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdcpsgn(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDCPSGN(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     int invalid = 0;
@@ -2703,7 +2703,7 @@ uint32_t helper_bcdcpsgn(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     return bcd_cmp_zero(r);
 }
 
-uint32_t helper_bcdsetsgn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDSETSGN(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
 {
     int sgnb = bcd_get_sgn(b);
 
@@ -2717,7 +2717,7 @@ uint32_t helper_bcdsetsgn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
     return bcd_cmp_zero(r);
 }
 
-uint32_t helper_bcds(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDS(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     int cr;
     int i = a->VsrSB(7);
@@ -2753,7 +2753,7 @@ uint32_t helper_bcds(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdus(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDUS(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     int cr;
     int i;
@@ -2790,7 +2790,7 @@ uint32_t helper_bcdus(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdsr(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDSR(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     int cr;
     int unused = 0;
@@ -2836,7 +2836,7 @@ uint32_t helper_bcdsr(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     return cr;
 }
 
-uint32_t helper_bcdtrunc(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDTRUNC(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     uint64_t mask;
     uint32_t ox_flag = 0;
@@ -2869,7 +2869,7 @@ uint32_t helper_bcdtrunc(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
     return bcd_cmp_zero(&ret) | ox_flag;
 }
 
-uint32_t helper_bcdutrunc(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+uint32_t helper_BCDUTRUNC(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
 {
     int i;
     uint64_t mask;
target/ppc/translate/vmx-impl.c.inc +129 -170

363 lines not on this page · raw message

target/ppc/translate/vmx-ops.c.inc +0 -22
index 2820976c0f..c1951c6975 100644
@@ -24,39 +24,17 @@ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1)
 GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, tp0, tp1), \
 GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1),
 
-GEN_VXFORM_DUAL(vaddubm, vmul10cuq, 0, 0, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM_DUAL(vadduhm, vmul10ecuq, 0, 1, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM(vadduwm, 0, 2),
-GEN_VXFORM_207(vaddudm, 0, 3),
-GEN_VXFORM_DUAL(vsububm, bcdadd, 0, 16, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM_DUAL(vsubuwm, bcdus, 0, 18, PPC_ALTIVEC, PPC2_ISA300),
-GEN_VXFORM_DUAL(vsubudm, bcds, 0, 19, PPC2_ALTIVEC_207, PPC2_ISA300),
-GEN_VXFORM_300(bcds, 0, 27),
 GEN_VXFORM_300(vextublx, 6, 24),
 GEN_VXFORM_300(vextuhlx, 6, 25),
 GEN_VXFORM_DUAL(vmrgow, vextuwlx, 6, 26, PPC_NONE, PPC2_ALTIVEC_207),
 GEN_VXFORM_300(vextubrx, 6, 28),
 GEN_VXFORM_300(vextuhrx, 6, 29),
 GEN_VXFORM_DUAL(vmrgew, vextuwrx, 6, 30, PPC_NONE, PPC2_ALTIVEC_207),
-GEN_VXFORM_207(vmuluwm, 4, 2),
 GEN_VXFORM_300(vsrv, 2, 28),
 GEN_VXFORM_300(vslv, 2, 29),
 GEN_VXFORM(vslo, 6, 16),
 GEN_VXFORM(vsro, 6, 17),
 
-GEN_VXFORM(xpnd04_1, 0, 22),
-GEN_VXFORM_300(bcdsr, 0, 23),
-GEN_VXFORM_300(bcdsr, 0, 31),
-GEN_VXFORM_300_EXT(vmul10uq, 0, 8, 0x0000F800),
-GEN_VXFORM_300(vmul10euq, 0, 9),
-GEN_VXFORM_300(bcdcpsgn, 0, 13),
-GEN_VXFORM_207(bcdadd, 0, 24),
-GEN_VXFORM_207(bcdsub, 0, 25),
-GEN_VXFORM_300(bcdtrunc, 0, 28),
-GEN_VXFORM_300(xpnd04_2, 0, 30),
-GEN_VXFORM_300(bcdtrunc, 0, 20),
-GEN_VXFORM_300(bcdutrunc, 0, 21),
 GEN_VXFORM(vsl, 2, 7),
 GEN_VXFORM(vsr, 2, 11),
 GEN_VXFORM(vsum4ubs, 4, 24),
Signature · 1 line
2.52.0
#24 lore raw

[PULL 11/41] target/ppc: convert slw, srw instruction via decode spec

In reply to Harsh Prateek Bora

From: "Mukesh Kumar Chaurasiya (IBM)" <[email protected]>

Move slw and srw to decodetree specification using the @X_rc format. The existing shift-masking logic from gen_slw/gen_srw is preserved verbatim in the new trans_SLW/trans_SRW handlers.

---
 target/ppc/insn32.decode                   |  5 +++
 target/ppc/translate.c                     | 49 ----------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 48 +++++++++++++++++++++
 3 files changed, 53 insertions(+), 49 deletions(-)
target/ppc/insn32.decode +5 -0
index 824181eb4e..189f9c6fe7 100644
@@ -505,6 +505,11 @@ HASHCHK         011111 ..... ..... ..... 1011110010 .   @X_DW
 HASHSTP         011111 ..... ..... ..... 1010010010 .   @X_DW
 HASHCHKP        011111 ..... ..... ..... 1010110010 .   @X_DW
 
+# Fixed-Point Shift Instructions
+
+SLW             011111 ..... ..... ..... 0000011000 .   @X_rc
+SRW             011111 ..... ..... ..... 1000011000 .   @X_rc
+
 ## BCD Assist
 
 ADDG6S          011111 ..... ..... ..... - 001001010 -  @X
target/ppc/translate.c +0 -49

69 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +48 -0

51 lines not on this page · raw message

Signature · 1 line
2.52.0
#25 lore raw

[PULL 03/41] target/ppc/kvm: Use host compatibility mode for nested guests

In reply to Harsh Prateek Bora

From: Amit Machhiwal <[email protected]>

On POWER systems, the host CPU may run in a compatibility mode (e.g., a Power11 processor operating in Power10 compatibility mode). When running nested KVM guests, QEMU currently derives the host CPU type using mfpvr(), which reflects the physical processor version. This can result in a mismatch between the CPU model used by QEMU and the compatibility mode enforced by the host, leading to guest boot failures such as "KVM-NESTEDv2: couldn't set guest wide elements".

Update kvm_ppc_get_host_cpu_class() to check if the host is running in a compatibility mode using kvm_ppc_host_compat_pvr(). When available, use the compatibility PVR instead of the raw hardware PVR when selecting the CPU model. This ensures that QEMU selects a CPU model consistent with the host compatibility mode, allowing nested guests to boot correctly.

The guard uses #if defined(TARGET_PPC64) to prevent build breakage on ppc32 targets where the POWER9/10/11 PVR constants are not defined.

---
 target/ppc/kvm.c | 9 +++++++++
 1 file changed, 9 insertions(+)
target/ppc/kvm.c +9 -0
index d4c5601a00..8e89a6c665 100644
@@ -2682,6 +2682,15 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
     uint32_t host_pvr = mfpvr();
     PowerPCCPUClass *pvr_pcc;
 
+#if defined(TARGET_PPC64)
+    uint32_t compat_host_pvr;
+
+    compat_host_pvr = kvm_ppc_host_compat_pvr();
+    if (compat_host_pvr) {
+        host_pvr = compat_host_pvr;
+    }
+#endif /* TARGET_PPC64 */
+
     pvr_pcc = ppc_cpu_class_by_pvr(host_pvr);
     if (pvr_pcc == NULL) {
         pvr_pcc = ppc_cpu_class_by_pvr_mask(host_pvr);
Signature · 1 line
2.52.0
#26 lore raw

[PULL 36/41] target/ppc: Use PPC2_ISA207 instead of PPC2_LSQ_ISA207

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

PPC2_LSQ_ISA207 is only ever set in the CPUPPCState's insns_flags2 alongside PPC2_ISA207. Checks made by PPC2_LSQ_ISA207 could be replaced with PPC2_ISA207, hence rendering it useless and apt for removal. This patch does the same.

---
 target/ppc/cpu.h                           | 3 ---
 target/ppc/cpu_init.h                      | 2 +-
 linux-user/ppc/elfload.c                   | 2 +-
 target/ppc/cpu_init.c                      | 3 +--
 target/ppc/translate/fixedpoint-impl.c.inc | 4 ++--
 5 files changed, 5 insertions(+), 9 deletions(-)
target/ppc/cpu.h +0 -3
index df1e943d8d..b3cd8d85df 100644
@@ -2577,8 +2577,6 @@ enum {
     PPC2_FP_CVT_ISA206 = 0x0000000000000400ULL,
     /* ISA 2.06B floating point test instructions                            */
     PPC2_FP_TST_ISA206 = 0x0000000000000800ULL,
-    /* ISA 2.07 load/store quadword                                          */
-    PPC2_LSQ_ISA207    = 0x0000000000002000ULL,
     /* ISA 2.07 Altivec                                                      */
     PPC2_ALTIVEC_207   = 0x0000000000004000ULL,
     /* PowerISA 2.07 Book3s specification                                    */
@@ -2608,7 +2606,6 @@ enum {
                         PPC2_ISA205 | PPC2_ISA207 | PPC2_PERM_ISA206 | \
                         PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
                         PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
-                        PPC2_LSQ_ISA207 | \
                         PPC2_ALTIVEC_207 | PPC2_ISA207S | PPC2_DFP | \
                         PPC2_FP_CVT_S64 | PPC2_TM | PPC2_PM_ISA206 | \
                         PPC2_ISA300 | PPC2_ISA310 | PPC2_MEM_LWSYNC | \
target/ppc/cpu_init.h +1 -1
index 7dd587908e..6961007926 100644
@@ -18,7 +18,7 @@
     (PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |                 \
      PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 |      \
      PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 |                       \
-     PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 |              \
+     PPC2_ALTIVEC_207 | PPC2_ISA205 |                                \
      PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_ISA300 | PPC2_PRCNTL |    \
      PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206)
 
linux-user/ppc/elfload.c +1 -1
index 5c6065e08a..76ab9f43de 100644
@@ -116,7 +116,7 @@ abi_ulong get_elf_hwcap2(CPUState *cs)
     do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)
 
     GET_FEATURE(PPC_ISEL, QEMU_PPC_FEATURE2_HAS_ISEL);
-    GET_FEATURE2((PPC2_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
+    GET_FEATURE2((PPC2_ISA207 | PPC2_ALTIVEC_207 |
                   PPC2_ISA207S), (QEMU_PPC_FEATURE2_ARCH_2_07 |
                   QEMU_PPC_FEATURE2_VEC_CRYPTO | QEMU_PPC_FEATURE2_HAS_TAR));
     GET_FEATURE2(PPC2_ISA300, QEMU_PPC_FEATURE2_ARCH_3_00 |
target/ppc/cpu_init.c +1 -2
index c250f805a7..4cc8b93dca 100644
@@ -6349,8 +6349,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, const void *data)
     pcc->insns_flags2 = PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |
                         PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
                         PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
-                        PPC2_FP_TST_ISA206 |
-                        PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
+                        PPC2_FP_TST_ISA206 | PPC2_ALTIVEC_207 |
                         PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |
                         PPC2_TM | PPC2_PM_ISA206 | PPC2_MEM_LWSYNC |
                         PPC2_BCDA_ISA206;
target/ppc/translate/fixedpoint-impl.c.inc +2 -2
index 0e1960a272..c3d8bbf267 100644
@@ -124,7 +124,7 @@ static bool do_ldst_quad(DisasContext *ctx, arg_D *a, bool store, bool prefixed)
 
     REQUIRE_INSNS_FLAGS(ctx, 64BX);
 
-    if (!prefixed && !(ctx->insns_flags2 & PPC2_LSQ_ISA207)) {
+    if (!prefixed && !(ctx->insns_flags2 & PPC2_ISA207)) {
         /* lq and stq were privileged prior to V. 2.07 */
         REQUIRE_SV(ctx);
 
@@ -288,7 +288,7 @@ TRANS64(STDCX, do_store_cond, MO_UQ);
 static bool trans_STQCX(DisasContext *ctx, arg_STQCX *a)
 {
     REQUIRE_64BIT(ctx);
-    REQUIRE_INSNS_FLAGS2(ctx, LSQ_ISA207);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
 #if defined(TARGET_PPC64)
     TCGLabel *lfail = gen_new_label();
     TCGv ea = do_ea_calc(ctx, a->ra, cpu_gpr[a->rb]);
Signature · 1 line
2.52.0
#27 lore raw

[PULL 40/41] target/ppc: Add ICBT support for ISA version 2.07

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

The summary of changes in Power ISA version 2.07B mentions :
"ICBT instruction has been moved from the Embedded category to the Base category".
Updating ICBT flag for the same.

While we are at it, correct the invalid mask as per the ISA as well.

---
 target/ppc/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate.c +2 -2
index 023935c10e..467b8f3d4e 100644
@@ -4498,8 +4498,8 @@ GEN_HANDLER2_E(tlbilx_booke206, "tlbilx", 0x1F, 0x12, 0x00, 0x03800001,
 GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE),
 GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000E7C01, PPC_WRTEE),
 GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC),
-GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001,
-               PPC_BOOKE, PPC2_BOOKE206),
+GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x02000001,
+               PPC_BOOKE, (PPC2_BOOKE206 | PPC2_ISA207)),
 GEN_HANDLER2(icbt_440, "icbt", 0x1F, 0x06, 0x08, 0x03E00001,
              PPC_440_SPEC),
 GEN_HANDLER(mfvscr, 0x04, 0x2, 0x18, 0x001ff800, PPC_ALTIVEC),
Signature · 1 line
2.52.0
#28 lore raw

[PULL 41/41] target/ppc: Add self as maintainer for PowerPC TCG CPUs

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

I have been contributing and reviewing code in the PowerPC TCG CPUs module for a long time now. Stepping up as an active maintainer to better reflect the current status.

---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
index 6c18b8a419..4a49a40294 100644
@@ -337,8 +337,8 @@ F: tests/functional/or1k/meson.build
 F: tests/tcg/or1k/
 
 PowerPC TCG CPUs
+M: Chinmay Rath <[email protected]>
 M: Nicholas Piggin <[email protected]>
-R: Chinmay Rath <[email protected]>
 R: Glenn Miles <[email protected]>
 R: Harsh Prateek Bora <[email protected]>
 L: [email protected]
Signature · 1 line
2.52.0
#29 lore raw

[PULL 10/41] target/ppc: Move st{b, h, w, d, q}cx instructions to decodetree

In reply to Harsh Prateek Bora

From: Utkarsh Verma <[email protected]>

Move the following store conditional instructions to decodetree specification:

stbcx. : X-form
sthcx. : X-form
stwcx. : X-form
stdcx. : X-form
stqcx. : X-form

The changes were verified by checking that the generated TCG ops remain semantically identical to the legacy translation, using logs captured with the -d in_asm,op flag.

---
 target/ppc/insn32.decode                   |   8 ++
 target/ppc/translate.c                     | 103 ---------------------
 target/ppc/translate/fixedpoint-impl.c.inc |  84 +++++++++++++++++
 3 files changed, 92 insertions(+), 103 deletions(-)
target/ppc/insn32.decode +8 -0
index d6f1875532..824181eb4e 100644
@@ -732,6 +732,14 @@ DSCLIQ          111111 ..... ..... ...... 001000010 .   @Z22_tap_sh_rc
 DSCRI           111011 ..... ..... ...... 001100010 .   @Z22_ta_sh_rc
 DSCRIQ          111111 ..... ..... ...... 001100010 .   @Z22_tap_sh_rc
 
+### Store Conditional Instructions
+
+STBCX           011111 ..... ..... ..... 1010110110 1   @X
+STHCX           011111 ..... ..... ..... 1011010110 1   @X
+STWCX           011111 ..... ..... ..... 0010010110 1   @X
+STDCX           011111 ..... ..... ..... 0011010110 1   @X
+STQCX           011111 ..... ..... ..... 0010110110 1   @X
+
 ## Vector Exclusive-OR-based Instructions
 
 VPMSUMD         000100 ..... ..... ..... 10011001000    @VX
target/ppc/translate.c +0 -103

118 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +84 -0

90 lines not on this page · raw message

Signature · 1 line
2.52.0
#30 lore raw

[PULL 29/41] target/ppc: Move rlwimi, rlwinm instructions to decodetree

In reply to Harsh Prateek Bora

From: Tanushree Shah <[email protected]>

-Moving the following instructions to decodetree specification:

            rlwimi                           : M-form
            rlwimi.                          : M-form
            rlwinm                           : M-form
            rlwinm.                          : M-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the "-d in_asm,op" flag.

Additionally, validated using small assembly tests confirming the destination register is correctly updated based on rotated and masked source values and confirmed that the value was same before and after the change

---
 target/ppc/insn32.decode                   |   6 ++
 target/ppc/translate.c                     | 106 ---------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 102 ++++++++++++++++++++
 3 files changed, 108 insertions(+), 106 deletions(-)
target/ppc/insn32.decode +6 -0
index 69d60605bd..92ee278f63 100644
@@ -312,6 +312,9 @@
 
 @Z23_te_tbp     ...... ....0 te:5 ....0 rmc:2 ........ rc:1     &Z23_te_tb frt=%z23_frtp frb=%z23_frbp
 
+&M              ra rs sh mb me rc:bool
+@M              ...... rs:5 ra:5 sh:5 mb:5 me:5 rc:1 &M
+
 ### Fixed-Point Load Instructions
 
 LBZ             100010 ..... ..... ................     @D
@@ -561,6 +564,9 @@ SRADI           011111 ..... ..... ..... 110011101 . .  @XS
 
 EXTSWSLI        011111 ..... ..... ..... 110111101 . .  @XS
 
+RLWIMI          010100 ..... ..... ..... ..... ......   @M
+RLWINM          010101 ..... ..... ..... ..... ......   @M
+
 ## BCD Assist
 
 ADDG6S          011111 ..... ..... ..... - 001001010 -  @X
target/ppc/translate.c +0 -106

118 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +102 -0

108 lines not on this page · raw message

Signature · 1 line
2.52.0
#31 lore raw

[PULL 26/41] target/ppc: make do_ea_calc_ra available for 32 bit builds

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

There is no reason to keep do_ea_calc_ra exclusive to TARGET_PPC64. Make it available for PPC32 builds.

---
 target/ppc/translate.c | 2 --
 1 file changed, 2 deletions(-)
target/ppc/translate.c +0 -2
index c5361d8db5..c45883ac30 100644
@@ -2397,7 +2397,6 @@ static TCGv do_ea_calc(DisasContext *ctx, int ra, TCGv displ)
     return ea;
 }
 
-#if defined(TARGET_PPC64)
 /* EA <- (ra == 0) ? 0 : GPR[ra] */
 static TCGv do_ea_calc_ra(DisasContext *ctx, int ra)
 {
@@ -2411,7 +2410,6 @@ static TCGv do_ea_calc_ra(DisasContext *ctx, int ra)
     }
     return EA;
 }
-#endif
 
 /***                             Integer load                              ***/
 #define DEF_MEMOP(op) ((op) | ctx->default_tcg_memop_mask)
Signature · 1 line
2.52.0
#32 lore raw

[PULL 31/41] target/ppc: Move mfmsr, mtmsr[d] instructions to decodetree

In reply to Harsh Prateek Bora

From: Vishal Chourasia <[email protected]>

Moving the following instructions to decodetree specification:
mfmsr : X-form
mtmsr[d] : X-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the -d in_asm,op flag.

This also includes improvements from review feedback:
- Gate MFMSR/MTMSR on PPC_MISC via TRANS_FLAGS()
- Use UINT32_MAX instead of 0xFFFFFFFF for clarity

---
 target/ppc/insn32.decode             |  5 ++
 target/ppc/translate.c               | 97 ----------------------------
 target/ppc/translate/misc-impl.c.inc | 64 ++++++++++++++++++
 3 files changed, 69 insertions(+), 97 deletions(-)
target/ppc/insn32.decode +5 -0
index ef128f63c1..1e263449a5 100644
@@ -315,6 +315,11 @@
 &M              ra rs sh mb me rc:bool
 @M              ...... rs:5 ra:5 sh:5 mb:5 me:5 rc:1 &M
 
+### MSR
+MFMSR           011111 ..... ----- ----- 0001010011 -   @X_t
+MTMSR           011111 ..... ---- . ----- 0010010010 -  @X_rs_l
+MTMSRD          011111 ..... ---- . ----- 0010110010 -  @X_rs_l
+
 ### Fixed-Point Load Instructions
 
 LBZ             100010 ..... ..... ................     @D
target/ppc/translate.c +0 -97

121 lines not on this page · raw message

target/ppc/translate/misc-impl.c.inc +64 -0

67 lines not on this page · raw message

Signature · 1 line
2.52.0
#33 lore raw

[PULL 14/41] target/ppc: Move fixed-point Shift insns to decodetree

In reply to Harsh Prateek Bora

From: Amit Machhiwal <[email protected]>

Move the below instructions to decodetree specification:

s{r,l}d, and srad[i] : X-form

The changes were verified by validating that the TCG ops generated by these instructions remain the same after these changes. The TCG micro-ops were captured with the '-d op,in_asm' QEMU flag.

Move all shift insntructions to one place in insn32.decode

---
 target/ppc/helper.h                        |  2 +-
 target/ppc/insn32.decode                   | 12 ++-
 target/ppc/int_helper.c                    |  2 +-
 target/ppc/translate.c                     | 96 ----------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 72 ++++++++++++++++
 5 files changed, 82 insertions(+), 102 deletions(-)
target/ppc/helper.h +1 -1
index d4a9334ce8..e7bf43bf4b 100644
@@ -74,7 +74,7 @@ DEF_HELPER_FLAGS_1(CBCDTD, TCG_CALL_NO_RWG_SE, tl, tl)
 DEF_HELPER_FLAGS_2(CMPEQB, TCG_CALL_NO_RWG_SE, i32, tl, tl)
 DEF_HELPER_FLAGS_1(POPCNTW, TCG_CALL_NO_RWG_SE, tl, tl)
 DEF_HELPER_FLAGS_2(BPERMD, TCG_CALL_NO_RWG_SE, i64, i64, i64)
-DEF_HELPER_3(srad, tl, env, tl, tl)
+DEF_HELPER_3(SRAD, tl, env, tl, tl)
 DEF_HELPER_FLAGS_0(DARN32, TCG_CALL_NO_RWG, tl)
 DEF_HELPER_FLAGS_0(DARN64, TCG_CALL_NO_RWG, tl)
 #endif
target/ppc/insn32.decode +8 -4
index f928cd6602..12fb4974e4 100644
@@ -119,7 +119,7 @@
 
 # XS-form with fractured shift amount
 %xs_sh           1:1 11:5
-&XS              rs ra sh rc
+&XS              rs ra sh rc:bool
 @XS              ...... rs:5 ra:5 ..... ......... . rc:1        &XS sh=%xs_sh
 
 %x_frtp         22:4 !function=times_2
@@ -512,6 +512,13 @@ SRW             011111 ..... ..... ..... 1000011000 .   @X_rc
 SRAW            011111 ..... ..... ..... 1100011000 .   @X_rc
 SRAWI           011111 ..... ..... ..... 1100111000 .   @X_rc
 
+SLD             011111 ..... ..... ..... 0000011011 .   @X_rc
+SRD             011111 ..... ..... ..... 1000011011 .   @X_rc
+SRAD            011111 ..... ..... ..... 1100011010 .   @X_rc
+SRADI           011111 ..... ..... ..... 110011101 . .  @XS
+
+EXTSWSLI        011111 ..... ..... ..... 110111101 . .  @XS
+
 ## BCD Assist
 
 ADDG6S          011111 ..... ..... ..... - 001001010 -  @X
@@ -1379,9 +1386,6 @@ DST             011111 ----- ..... ..... 0101010110 -   @X_ea
 DSTST           011111 ----- ..... ..... 0101110110 -   @X_ea
 DSS             011111 ----- ..... ..... 1100110110 -   @X_ea
 
-##Extend Sign Word and Shift Left Immediate XS-form
-EXTSWSLI         011111 ..... ..... ..... 110111101 . .         @XS
-
 ## Load and Reserve Instructions
 LBARX           011111 ..... ..... ..... 0000110100 .   @X_rc
 LHARX           011111 ..... ..... ..... 0001110100 .   @X_rc
target/ppc/int_helper.c +1 -1
index b161f930ec..8e8076a92c 100644
@@ -261,7 +261,7 @@ target_ulong helper_SRAW(CPUPPCState *env, target_ulong value,
 }
 
 #if defined(TARGET_PPC64)
-target_ulong helper_srad(CPUPPCState *env, target_ulong value,
+target_ulong helper_SRAD(CPUPPCState *env, target_ulong value,
                          target_ulong shift)
 {
     int64_t ret;
target/ppc/translate.c +0 -96

108 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +72 -0

84 lines not on this page · raw message

Signature · 1 line
2.52.0
#34 lore raw

[PULL 34/41] target/ppc: Replace PPC2_VSX207 flag with PPC2_ISA207

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

There are several flags for Power ISA 2.07 currently in use, namely :
PPC2_VSX207, PPC2_BCTAR_ISA207, PPC2_LSQ_ISA207, etc, but most of them are used together without any individual use.

Create a generic ISA 2.07 flag and switch usage of PPC2_VSX207 to it instead. Next commits would consolidate the remaining flags.

---
 target/ppc/cpu.h                    |  6 ++--
 target/ppc/cpu_init.h               |  2 +-
 target/ppc/cpu_init.c               |  2 +-
 target/ppc/translate/fp-impl.c.inc  |  4 +--
 target/ppc/translate/vsx-impl.c.inc | 56 ++++++++++++++---------------
 target/ppc/translate/vsx-ops.c.inc  | 24 ++++++-------
 6 files changed, 47 insertions(+), 47 deletions(-)
target/ppc/cpu.h +3 -3
index cbd5964b1a..91ef34cb21 100644
@@ -2565,8 +2565,8 @@ enum {
     PPC2_DBRX          = 0x0000000000000010ULL,
     /* Book I 2.05 PowerPC specification                                     */
     PPC2_ISA205        = 0x0000000000000020ULL,
-    /* VSX additions in ISA 2.07                                             */
-    PPC2_VSX207        = 0x0000000000000040ULL,
+    /* POWER ISA 2.07                                                        */
+    PPC2_ISA207        = 0x0000000000000040ULL,
     /* ISA 2.06B bpermd                                                      */
     PPC2_PERM_ISA206   = 0x0000000000000080ULL,
     /* ISA 2.06B divide extended variants                                    */
@@ -2607,7 +2607,7 @@ enum {
     PPC2_PPE42XM       = 0x0000000002000000ULL,
 
 #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \
-                        PPC2_ISA205 | PPC2_VSX207 | PPC2_PERM_ISA206 | \
+                        PPC2_ISA205 | PPC2_ISA207 | PPC2_PERM_ISA206 | \
                         PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
                         PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
                         PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | \
target/ppc/cpu_init.h +1 -1
index f8fd6ff5cd..1c41c0d349 100644
@@ -15,7 +15,7 @@
 #define PPC_INSNS_FLAGS_POWER11 PPC_INSNS_FLAGS_POWER10
 
 #define PPC_INSNS_FLAGS2_POWER_COMMON                                \
-    (PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |                 \
+    (PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |                 \
      PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 |      \
      PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |   \
      PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 |              \
target/ppc/cpu_init.c +1 -1
index e2533481d8..b913edd243 100644
@@ -6346,7 +6346,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, const void *data)
                        PPC_SEGMENT_64B | PPC_SLBI |
                        PPC_POPCNTB | PPC_POPCNTWD |
                        PPC_CILDST;
-    pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |
+    pcc->insns_flags2 = PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |
                         PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
                         PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
                         PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |
target/ppc/translate/fp-impl.c.inc +2 -2
index 464fb1d90f..e0d9fa2e24 100644
@@ -342,7 +342,7 @@ static bool trans_FCPSGN(DisasContext *ctx, arg_FCPSGN *a)
 static bool trans_FMRGEW(DisasContext *ctx, arg_FMRGEW *a)
 {
     TCGv_i64 t0, t1, t2;
-    REQUIRE_INSNS_FLAGS2(ctx, VSX207);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
     REQUIRE_FPU(ctx);
     t0 = tcg_temp_new_i64();
     t1 = tcg_temp_new_i64();
@@ -358,7 +358,7 @@ static bool trans_FMRGEW(DisasContext *ctx, arg_FMRGEW *a)
 static bool trans_FMRGOW(DisasContext *ctx, arg_FMRGOW *a)
 {
     TCGv_i64 t0, t1, t2;
-    REQUIRE_INSNS_FLAGS2(ctx, VSX207);
+    REQUIRE_INSNS_FLAGS2(ctx, ISA207);
     REQUIRE_FPU(ctx);
     t0 = tcg_temp_new_i64();
     t1 = tcg_temp_new_i64();
target/ppc/translate/vsx-impl.c.inc +28 -28

110 lines not on this page · raw message

target/ppc/translate/vsx-ops.c.inc +12 -12
index e553b5b8fa..ae3df2c13d 100644
@@ -1,9 +1,9 @@
-GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0x0000F800, PPC_NONE, PPC2_VSX207),
-GEN_HANDLER_E(mtvsrwa, 0x1F, 0x13, 0x06, 0x0000F800, PPC_NONE, PPC2_VSX207),
-GEN_HANDLER_E(mtvsrwz, 0x1F, 0x13, 0x07, 0x0000F800, PPC_NONE, PPC2_VSX207),
+GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0x0000F800, PPC_NONE, PPC2_ISA207),
+GEN_HANDLER_E(mtvsrwa, 0x1F, 0x13, 0x06, 0x0000F800, PPC_NONE, PPC2_ISA207),
+GEN_HANDLER_E(mtvsrwz, 0x1F, 0x13, 0x07, 0x0000F800, PPC_NONE, PPC2_ISA207),
 #if defined(TARGET_PPC64)
-GEN_HANDLER_E(mfvsrd, 0x1F, 0x13, 0x01, 0x0000F800, PPC_NONE, PPC2_VSX207),
-GEN_HANDLER_E(mtvsrd, 0x1F, 0x13, 0x05, 0x0000F800, PPC_NONE, PPC2_VSX207),
+GEN_HANDLER_E(mfvsrd, 0x1F, 0x13, 0x01, 0x0000F800, PPC_NONE, PPC2_ISA207),
+GEN_HANDLER_E(mtvsrd, 0x1F, 0x13, 0x05, 0x0000F800, PPC_NONE, PPC2_ISA207),
 GEN_HANDLER_E(mfvsrld, 0X1F, 0x13, 0x09, 0x0000F800, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(mtvsrdd, 0X1F, 0x13, 0x0D, 0x0, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(mtvsrws, 0x1F, 0x13, 0x0C, 0x0000F800, PPC_NONE, PPC2_ISA300),
@@ -127,7 +127,7 @@ GEN_VSX_XFORM_300(xscmpoqp, 0x04, 0x04, 0x00600001),
 GEN_VSX_XFORM_300(xscmpuqp, 0x04, 0x14, 0x00600001),
 GEN_XX2FORM_EO(xscvdphp, 0x16, 0x15, 0x11, PPC2_ISA300),
 GEN_XX2FORM(xscvdpsp, 0x12, 0x10, PPC2_VSX),
-GEN_XX2FORM(xscvdpspn, 0x16, 0x10, PPC2_VSX207),
+GEN_XX2FORM(xscvdpspn, 0x16, 0x10, PPC2_ISA207),
 GEN_XX2FORM_EO(xscvhpdp, 0x16, 0x15, 0x10, PPC2_ISA300),
 GEN_VSX_XFORM_300_EO(xscvsdqp, 0x04, 0x1A, 0x0A, 0x00000001),
 GEN_XX2FORM(xscvspdp, 0x12, 0x14, PPC2_VSX),
@@ -145,12 +145,12 @@ GEN_XX2FORM(xsrdpip, 0x12, 0x06, PPC2_VSX),
 GEN_XX2FORM(xsrdpiz, 0x12, 0x05, PPC2_VSX),
 
 GEN_VSX_XFORM_300(xsdivqp, 0x04, 0x11, 0x0),
-GEN_XX2FORM(xsresp,  0x14, 0x01, PPC2_VSX207),
-GEN_XX2FORM(xsrsp, 0x12, 0x11, PPC2_VSX207),
-GEN_XX2FORM(xssqrtsp,  0x16, 0x00, PPC2_VSX207),
-GEN_XX2FORM(xsrsqrtesp,  0x14, 0x00, PPC2_VSX207),
-GEN_XX2FORM(xscvsxdsp, 0x10, 0x13, PPC2_VSX207),
-GEN_XX2FORM(xscvuxdsp, 0x10, 0x12, PPC2_VSX207),
+GEN_XX2FORM(xsresp,  0x14, 0x01, PPC2_ISA207),
+GEN_XX2FORM(xsrsp, 0x12, 0x11, PPC2_ISA207),
+GEN_XX2FORM(xssqrtsp,  0x16, 0x00, PPC2_ISA207),
+GEN_XX2FORM(xsrsqrtesp,  0x14, 0x00, PPC2_ISA207),
+GEN_XX2FORM(xscvsxdsp, 0x10, 0x13, PPC2_ISA207),
+GEN_XX2FORM(xscvuxdsp, 0x10, 0x12, PPC2_ISA207),
 
 GEN_XX2FORM(xvredp,  0x14, 0x0D, PPC2_VSX),
 GEN_XX2FORM(xvsqrtdp,  0x16, 0x0C, PPC2_VSX),
Signature · 1 line
2.52.0
#35 lore raw

[PULL 05/41] target/ppc: Migrate extswsli to decodetree

In reply to Harsh Prateek Bora

From: Nikhil Kumar Singh <[email protected]>

Move EXTSWSLI to decodetree using the XS-form layout with a custom %xs_sh field to represent the fractured shift encoding.

This replaces legacy GEN_HANDLER-based implementations with a single trans_EXTSWSLI() handler.

The implementation intentionally operates directly on the destination GPR to preserve exact TCG output and avoid introducing temporary variables, matching legacy behavior.

Testing:
- Verified TCG equivalence with legacy implementation.

---
 target/ppc/insn32.decode |  8 ++++++++
 target/ppc/translate.c   | 43 ++++++++++++++--------------------------
 2 files changed, 23 insertions(+), 28 deletions(-)
target/ppc/insn32.decode +8 -0
index 0e9c68f2fb..342e65dadf 100644
@@ -117,6 +117,11 @@
 &X_sa_rc        rs ra rc
 @X_sa_rc        ...... rs:5 ra:5 ..... .......... rc:1          &X_sa_rc
 
+# XS-form with fractured shift amount
+%xs_sh           1:1 11:5
+&XS              rs ra sh rc
+@XS              ...... rs:5 ra:5 ..... ......... . rc:1        &XS sh=%xs_sh
+
 %x_frtp         22:4 !function=times_2
 %x_frap         17:4 !function=times_2
 %x_frbp         12:4 !function=times_2
@@ -1301,6 +1306,9 @@ XVF64GERPN      111011 ... -- .... 0 ..... 10111010 ..-  @XX3_at xa=%xx_xa_pair
 XVF64GERNP      111011 ... -- .... 0 ..... 01111010 ..-  @XX3_at xa=%xx_xa_pair
 XVF64GERNN      111011 ... -- .... 0 ..... 11111010 ..-  @XX3_at xa=%xx_xa_pair
 
+##Extend Sign Word and Shift Left Immediate XS-form
+EXTSWSLI         011111 ..... ..... ..... 110111101 . .         @XS
+
 ## Vector Division Instructions
 
 VDIVSW          000100 ..... ..... ..... 00110001011    @VX
target/ppc/translate.c +15 -28

61 lines not on this page · raw message

Signature · 1 line
2.52.0
#36 lore raw

[PULL 25/41] target/ppc: Move Condition Register logical instructions to decodetree.

In reply to Harsh Prateek Bora

From: Shivang Upadhyay <[email protected]>

Move below instructions to decodetree specification :

cr{and, or, xor, nand, nor, eqv, andc, orc} : XL-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.

---
 target/ppc/insn32.decode                   | 11 ++++
 target/ppc/translate.c                     | 59 ----------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 45 +++++++++++++++++
 3 files changed, 56 insertions(+), 59 deletions(-)
target/ppc/insn32.decode +11 -0
index 137432ed96..5e5490b169 100644
@@ -516,6 +516,17 @@ CFUGED          011111 ..... ..... ..... 0011011100 -   @X
 PDEPD           011111 ..... ..... ..... 0010011100 -   @X
 PEXTD           011111 ..... ..... ..... 0010111100 -   @X
 
+## Condition Register Instructions
+
+CRAND           010011 ..... ..... ..... 0100000001 -  @X
+CROR            010011 ..... ..... ..... 0111000001 -  @X
+CRNAND          010011 ..... ..... ..... 0011100001 -  @X
+CRXOR           010011 ..... ..... ..... 0011000001 -  @X
+CRNOR           010011 ..... ..... ..... 0000100001 -  @X
+CREQV           010011 ..... ..... ..... 0100100001 -  @X
+CRANDC          010011 ..... ..... ..... 0010000001 -  @X
+CRORC           010011 ..... ..... ..... 0110100001 -  @X
+
 # Fixed-Point Hash Instructions
 
 HASHST          011111 ..... ..... ..... 1011010010 .   @X_DW
target/ppc/translate.c +0 -59

71 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +45 -0

51 lines not on this page · raw message

Signature · 1 line
2.52.0
#37 lore raw

[PULL 12/41] target/ppc: convert sraw[i] instruction via decode spec

In reply to Harsh Prateek Bora

From: "Mukesh Kumar Chaurasiya (IBM)" <[email protected]>

Move sraw and srawi to decodetree specification using the @X_rc format. The existing shift-masking logic from gen_sraw/gen_srawi is preserved verbatim in the new trans_SRAW/trans_SRAWI handlers.

---
 target/ppc/helper.h                        |  2 +-
 target/ppc/insn32.decode                   |  2 ++
 target/ppc/int_helper.c                    |  2 +-
 target/ppc/translate.c                     | 42 ----------------------
 target/ppc/translate/fixedpoint-impl.c.inc | 41 +++++++++++++++++++++
 5 files changed, 45 insertions(+), 44 deletions(-)
target/ppc/helper.h +1 -1
index a0d08d6192..d4a9334ce8 100644
@@ -64,7 +64,7 @@ DEF_HELPER_4(DIVWE, tl, env, tl, tl, i32)
 
 DEF_HELPER_FLAGS_1(POPCNTB, TCG_CALL_NO_RWG_SE, tl, tl)
 DEF_HELPER_FLAGS_2(CMPB, TCG_CALL_NO_RWG_SE, tl, tl, tl)
-DEF_HELPER_3(sraw, tl, env, tl, tl)
+DEF_HELPER_3(SRAW, tl, env, tl, tl)
 DEF_HELPER_FLAGS_2(CFUGED, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(PDEPD, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(PEXTD, TCG_CALL_NO_RWG_SE, i64, i64, i64)
target/ppc/insn32.decode +2 -0
index 189f9c6fe7..ef0fe12959 100644
@@ -509,6 +509,8 @@ HASHCHKP        011111 ..... ..... ..... 1010110010 .   @X_DW
 
 SLW             011111 ..... ..... ..... 0000011000 .   @X_rc
 SRW             011111 ..... ..... ..... 1000011000 .   @X_rc
+SRAW            011111 ..... ..... ..... 1100011000 .   @X_rc
+SRAWI           011111 ..... ..... ..... 1100111000 .   @X_rc
 
 ## BCD Assist
 
target/ppc/int_helper.c +1 -1
index dc55ccadf7..b161f930ec 100644
@@ -235,7 +235,7 @@ target_ulong helper_CMPB(target_ulong rs, target_ulong rb)
 }
 
 /* shift right arithmetic helper */
-target_ulong helper_sraw(CPUPPCState *env, target_ulong value,
+target_ulong helper_SRAW(CPUPPCState *env, target_ulong value,
                          target_ulong shift)
 {
     int32_t ret;
target/ppc/translate.c +0 -42

54 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +41 -0

44 lines not on this page · raw message

Signature · 1 line
2.52.0
#38 lore raw

[PULL 24/41] target/ppc: Move Condition Register access instructions to decodetree.

In reply to Harsh Prateek Bora

From: Shivang Upadhyay <[email protected]>

Move below instructions to decodetree specification :

mfcr, mfocr,
mtcrf, mtocrf : XFX-form

The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.

---
 target/ppc/insn32.decode                   |  8 +++
 target/ppc/translate.c                     | 62 -----------------
 target/ppc/translate/fixedpoint-impl.c.inc | 78 ++++++++++++++++++++++
 3 files changed, 86 insertions(+), 62 deletions(-)
target/ppc/insn32.decode +8 -0
index b833244932..137432ed96 100644
@@ -70,6 +70,9 @@
 %dx_d           6:s10 16:5 0:1
 @DX             ...... rt:5  ..... .......... ..... .           &DX d=%dx_d
 
+&XFX            rt fxm
+@XFX            ...... rt:5  . fxm:8 ...... ..... .             &XFX
+
 %md_sh          1:1 11:5
 %md_mb          5:1 6:5
 &MD             rs ra sh mb rc
@@ -648,6 +651,11 @@ FSEL            111111 ..... ..... ..... ..... 10111 .  @A
 
 ### Move To/From System Register Instructions
 
+MFCR            011111 ..... 0.... ....- 0000010011 -   @XFX
+MFOCR           011111 ..... 1.... ....- 0000010011 -   @XFX
+MTCRF           011111 ..... 0.... ....- 0010010000 -   @XFX
+MTOCRF          011111 ..... 1.... ....- 0010010000 -   @XFX
+
 SETBC           011111 ..... ..... ----- 0110000000 -   @X_bi
 SETBCR          011111 ..... ..... ----- 0110100000 -   @X_bi
 SETNBC          011111 ..... ..... ----- 0111000000 -   @X_bi
target/ppc/translate.c +0 -62

83 lines not on this page · raw message

target/ppc/translate/fixedpoint-impl.c.inc +78 -0

84 lines not on this page · raw message

Signature · 1 line
2.52.0
#39 lore raw

[PULL 23/41] target/ppc: Refactor sleep and its variants to use a common helper

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

With sleep, doze, nap, rvwinkle and stop instructions moved to decodetree, the helper these instructions used : gen_helper_pminsn, should now be renamed to gen_helper_PMINSN, abiding by the decodetree standards. Do the same.
Also refactor their translation routine to use a common do_sleep routine since they share majority of the code.

---
 target/ppc/helper.h                           |  2 +-
 target/ppc/tcg-excp_helper.c                  |  2 +-
 .../ppc/translate/processor-ctrl-impl.c.inc   | 99 +++----------------
 3 files changed, 17 insertions(+), 86 deletions(-)
target/ppc/helper.h +1 -1
index e7bf43bf4b..6e14f02598 100644
@@ -18,7 +18,7 @@ DEF_HELPER_1(rfdi, void, env)
 DEF_HELPER_1(rfmci, void, env)
 #if defined(TARGET_PPC64)
 DEF_HELPER_2(scv, noreturn, env, i32)
-DEF_HELPER_2(pminsn, void, env, i32)
+DEF_HELPER_2(PMINSN, void, env, i32)
 DEF_HELPER_1(rfid, void, env)
 DEF_HELPER_1(rfscv, void, env)
 DEF_HELPER_1(hrfid, void, env)
target/ppc/tcg-excp_helper.c +1 -1
index b04f07a637..c4ffa2dfbb 100644
@@ -459,7 +459,7 @@ void helper_scv(CPUPPCState *env, uint32_t lev)
     }
 }
 
-void helper_pminsn(CPUPPCState *env, uint32_t insn)
+void helper_PMINSN(CPUPPCState *env, uint32_t insn)
 {
     CPUState *cs = env_cpu(env);
 
target/ppc/translate/processor-ctrl-impl.c.inc +15 -84

117 lines not on this page · raw message

Signature · 1 line
2.52.0
#40 lore raw

[PULL 37/41] target/ppc: Use PPC2_ISA207 instead of PPC2_ALTIVEC_207

In reply to Harsh Prateek Bora

From: Chinmay Rath <[email protected]>

PPC2_ALTIVEC_207 is only ever set in the CPUPPCState's insns_flags2 alongside PPC2_ISA207. Checks made by PPC2_ALTIVEC_207 could be replaced with PPC2_ISA207, hence rendering it useless and apt for removal. This patch does the same.

---
 target/ppc/cpu.h                    |   4 +-
 target/ppc/cpu_init.h               |   3 +-
 linux-user/ppc/elfload.c            |   3 +-
 target/ppc/cpu_init.c               |   2 +-
 target/ppc/translate/vmx-impl.c.inc | 102 ++++++++++++++--------------
 target/ppc/translate/vmx-ops.c.inc  |  18 ++---
 6 files changed, 64 insertions(+), 68 deletions(-)
target/ppc/cpu.h +1 -3
index b3cd8d85df..00676cea2b 100644
@@ -2577,8 +2577,6 @@ enum {
     PPC2_FP_CVT_ISA206 = 0x0000000000000400ULL,
     /* ISA 2.06B floating point test instructions                            */
     PPC2_FP_TST_ISA206 = 0x0000000000000800ULL,
-    /* ISA 2.07 Altivec                                                      */
-    PPC2_ALTIVEC_207   = 0x0000000000004000ULL,
     /* PowerISA 2.07 Book3s specification                                    */
     PPC2_ISA207S       = 0x0000000000008000ULL,
     /* Double precision floating point conversion for signed integer 64      */
@@ -2606,7 +2604,7 @@ enum {
                         PPC2_ISA205 | PPC2_ISA207 | PPC2_PERM_ISA206 | \
                         PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
                         PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
-                        PPC2_ALTIVEC_207 | PPC2_ISA207S | PPC2_DFP | \
+                        PPC2_ISA207S | PPC2_DFP | \
                         PPC2_FP_CVT_S64 | PPC2_TM | PPC2_PM_ISA206 | \
                         PPC2_ISA300 | PPC2_ISA310 | PPC2_MEM_LWSYNC | \
                         PPC2_BCDA_ISA206 | PPC2_PPE42 | PPC2_PPE42X | \
target/ppc/cpu_init.h +1 -2
index 6961007926..73f014c82a 100644
@@ -17,8 +17,7 @@
 #define PPC_INSNS_FLAGS2_POWER_COMMON                                \
     (PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |                 \
      PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 |      \
-     PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 |                       \
-     PPC2_ALTIVEC_207 | PPC2_ISA205 |                                \
+     PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_ISA205 |         \
      PPC2_ISA207S | PPC2_FP_CVT_S64 | PPC2_ISA300 | PPC2_PRCNTL |    \
      PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206)
 
linux-user/ppc/elfload.c +1 -2
index 76ab9f43de..8c40f1a663 100644
@@ -116,8 +116,7 @@ abi_ulong get_elf_hwcap2(CPUState *cs)
     do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)
 
     GET_FEATURE(PPC_ISEL, QEMU_PPC_FEATURE2_HAS_ISEL);
-    GET_FEATURE2((PPC2_ISA207 | PPC2_ALTIVEC_207 |
-                  PPC2_ISA207S), (QEMU_PPC_FEATURE2_ARCH_2_07 |
+    GET_FEATURE2((PPC2_ISA207 | PPC2_ISA207S), (QEMU_PPC_FEATURE2_ARCH_2_07 |
                   QEMU_PPC_FEATURE2_VEC_CRYPTO | QEMU_PPC_FEATURE2_HAS_TAR));
     GET_FEATURE2(PPC2_ISA300, QEMU_PPC_FEATURE2_ARCH_3_00 |
                  QEMU_PPC_FEATURE2_DARN | QEMU_PPC_FEATURE2_HAS_IEEE128);
target/ppc/cpu_init.c +1 -1
index 4cc8b93dca..c251426b2e 100644
@@ -6349,7 +6349,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, const void *data)
     pcc->insns_flags2 = PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX |
                         PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
                         PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
-                        PPC2_FP_TST_ISA206 | PPC2_ALTIVEC_207 |
+                        PPC2_FP_TST_ISA206 |
                         PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |
                         PPC2_TM | PPC2_PM_ISA206 | PPC2_MEM_LWSYNC |
                         PPC2_BCDA_ISA206;
target/ppc/translate/vmx-impl.c.inc +51 -51

234 lines not on this page · raw message

target/ppc/translate/vmx-ops.c.inc +9 -9
index c1951c6975..2facbc7cb4 100644
@@ -2,7 +2,7 @@
 GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
 
 #define GEN_VXFORM_207(name, opc2, opc3) \
-GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)
+GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA207)
 
 #define GEN_VXFORM_300(name, opc2, opc3)                                \
 GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA300)
@@ -26,10 +26,10 @@ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1),
 
 GEN_VXFORM_300(vextublx, 6, 24),
 GEN_VXFORM_300(vextuhlx, 6, 25),
-GEN_VXFORM_DUAL(vmrgow, vextuwlx, 6, 26, PPC_NONE, PPC2_ALTIVEC_207),
+GEN_VXFORM_DUAL(vmrgow, vextuwlx, 6, 26, PPC_NONE, PPC2_ISA207),
 GEN_VXFORM_300(vextubrx, 6, 28),
 GEN_VXFORM_300(vextuhrx, 6, 29),
-GEN_VXFORM_DUAL(vmrgew, vextuwrx, 6, 30, PPC_NONE, PPC2_ALTIVEC_207),
+GEN_VXFORM_DUAL(vmrgew, vextuwrx, 6, 30, PPC_NONE, PPC2_ISA207),
 GEN_VXFORM_300(vsrv, 2, 28),
 GEN_VXFORM_300(vslv, 2, 29),
 GEN_VXFORM(vslo, 6, 16),
@@ -113,10 +113,10 @@ GEN_VXFORM_UIMM(vctsxs, 5, 15),
     GEN_HANDLER(name0##_##name1, 0x04, opc2, 0xFF, 0x00000000, PPC_ALTIVEC)
 GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23),
 
-GEN_VXFORM_DUAL(vclzb, vpopcntb, 1, 28, PPC_NONE, PPC2_ALTIVEC_207),
-GEN_VXFORM_DUAL(vclzh, vpopcnth, 1, 29, PPC_NONE, PPC2_ALTIVEC_207),
-GEN_VXFORM_DUAL(vclzw, vpopcntw, 1, 30, PPC_NONE, PPC2_ALTIVEC_207),
-GEN_VXFORM_DUAL(vclzd, vpopcntd, 1, 31, PPC_NONE, PPC2_ALTIVEC_207),
+GEN_VXFORM_DUAL(vclzb, vpopcntb, 1, 28, PPC_NONE, PPC2_ISA207),
+GEN_VXFORM_DUAL(vclzh, vpopcnth, 1, 29, PPC_NONE, PPC2_ISA207),
+GEN_VXFORM_DUAL(vclzw, vpopcntw, 1, 30, PPC_NONE, PPC2_ISA207),
+GEN_VXFORM_DUAL(vclzd, vpopcntd, 1, 31, PPC_NONE, PPC2_ISA207),
 
 GEN_VXFORM_300(vbpermd, 6, 23),
 GEN_VXFORM_207(vbpermq, 6, 21),
@@ -127,8 +127,8 @@ GEN_VXFORM_207(vpmsumw, 4, 18),
 
 GEN_VXFORM_207(vsbox, 4, 23),
 
-GEN_VXFORM_DUAL(vcipher, vcipherlast, 4, 20, PPC_NONE, PPC2_ALTIVEC_207),
-GEN_VXFORM_DUAL(vncipher, vncipherlast, 4, 21, PPC_NONE, PPC2_ALTIVEC_207),
+GEN_VXFORM_DUAL(vcipher, vcipherlast, 4, 20, PPC_NONE, PPC2_ISA207),
+GEN_VXFORM_DUAL(vncipher, vncipherlast, 4, 21, PPC_NONE, PPC2_ISA207),
 
 GEN_VXFORM_207(vshasigmaw, 1, 26),
 GEN_VXFORM_207(vshasigmad, 1, 27),
Signature · 1 line
2.52.0
#41 lore raw

[PULL 20/41] target/ppc: Fix TRANS* macro variadic arguments handling

In reply to Harsh Prateek Bora

From: Ojaswin Mujoo <[email protected]>

Use ##__VA_ARGS__ in TRANS* macros to allow variadic arguments to be optional instead of mandatory. "##" removes the preceding comma when __VA_ARGS__ is empty, enabling macros to work with functions that don't need extra parameters.

This avoid compilation errors when using a pattern like below:

static bool do_wait(DisasContext *ctx, arg_X_wait *a) {...}

TRANS_FLAGS(WAIT, WAIT_ISA_2_X, do_wait)

Compilation Error:
../target/ppc/translate.c:5526:40: error: expected expression before ‘)’ token
5526 | return FUNC(ctx, a, __VA_ARGS__); \
| ^
../target/ppc/translate/storage-ctrl-impl.c.inc:368:1: note: in expansion of macro ‘TRANS_FLAGS’
368 | TRANS_FLAGS(WAIT, WAIT_ISA_2_X, do_wait)

---
 target/ppc/translate.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
target/ppc/translate.c +5 -5
index f5b1446d7a..322870dc0d 100644
@@ -4749,29 +4749,29 @@ static int64_t dw_compose_ea(DisasContext *ctx, int x)
  */
 #define TRANS(NAME, FUNC, ...) \
     static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
-    { return FUNC(ctx, a, __VA_ARGS__); }
+    { return FUNC(ctx, a, ##__VA_ARGS__); }
 #define TRANS_FLAGS(FLAGS, NAME, FUNC, ...) \
     static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
     {                                                          \
         REQUIRE_INSNS_FLAGS(ctx, FLAGS);                       \
-        return FUNC(ctx, a, __VA_ARGS__);                      \
+        return FUNC(ctx, a, ##__VA_ARGS__);                    \
     }
 #define TRANS_FLAGS2(FLAGS2, NAME, FUNC, ...) \
     static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
     {                                                          \
         REQUIRE_INSNS_FLAGS2(ctx, FLAGS2);                     \
-        return FUNC(ctx, a, __VA_ARGS__);                      \
+        return FUNC(ctx, a, ##__VA_ARGS__);                    \
     }
 
 #define TRANS64(NAME, FUNC, ...) \
     static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
-    { REQUIRE_64BIT(ctx); return FUNC(ctx, a, __VA_ARGS__); }
+    { REQUIRE_64BIT(ctx); return FUNC(ctx, a, ##__VA_ARGS__); }
 #define TRANS64_FLAGS2(FLAGS2, NAME, FUNC, ...) \
     static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
     {                                                          \
         REQUIRE_64BIT(ctx);                                    \
         REQUIRE_INSNS_FLAGS2(ctx, FLAGS2);                     \
-        return FUNC(ctx, a, __VA_ARGS__);                      \
+        return FUNC(ctx, a, ##__VA_ARGS__);                    \
     }
 
 /* TODO: More TRANS* helpers for extra insn_flags checks. */
Signature · 1 line
2.52.0
#42 lore raw
In reply to Harsh Prateek Bora
Quoted 19 lines · Harsh Prateek Bora

The following changes since commit 0a1ebd448b38afaa118597cbb633dbec24ef74d3:

   tcg/loongarch64: Fix compile issue LoongArch host (2026-08-27 11:04:01 -0700)

are available in the Git repository at:

   https://gitlab.com/harshpb/qemu.git tags/pull-ppc-for-11.2-20260828

for you to fetch changes up to fe511b25417e01f1fdb50dc8ce158db0b7522705:

target/ppc: Add self as maintainer for PowerPC TCG CPUs (2026-08-28 11:09:28 +0530)

----------------------------------------------------------------
PPC patches for 2026-08-28
* TCG Improvements (decodetree migrations and ISA 2.07 flag updates)
* Compat mode fixes for nested guests
* XIVE fix for pending interrupts post migration
* MAINTAINERS: Chinmay transitioning as PPC TCG maintainer

Quoted 2 lines

Checkpatch errors can be ignored as suggested here:
https://lore.kernel.org/qemu- devel/[email protected]/

Applied, thanks.

r~