AUXV Fixes for PowerPC Linux User Mode
cover AUXV Fixes for PowerPC Linux User Mode
These patches improve the fidelity of the AUXV for the Power PC user mode targets. Specifically, the cache line sizes and hardware capabilities are improved so that they more closely match what would be seen on an actual system.
Tom Musta (4):
linux-user: Correct AUXV Cache Line Sizes for PowerPC
target-ppc: Add DFP to Emulated Instructions Flag
linux-user: Identify Addition Hardware Capabilities for PowerPC
linux-user: Support HWCAP2 in PowerPC
linux-user/elfload.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- target-ppc/cpu.h | 2 +- 2 files changed, 43 insertions(+), 3 deletions(-)
PATCH 1/4 linux-user: Correct AUXV Cache Line Sizes for PowerPC
Set the AT_ICACHEBSIZE and AT_DCACHEBSIZE entries of the AUXV to match the CPU model's cache line sizes. This fixes memory clobbering problems on more recent Book 3s implementations; memset(p, 0, N) will use the dcbz instruction when N is sufficiently large and many of the newer server CPUs have cache lines sizes of 128 bytes.
--- linux-user/elfload.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
linux-user/elfload.c +3 -2
@@ -767,8 +767,9 @@ static uint32_t get_elf_hwcap(void)#define DLINFO_ARCH_ITEMS 5#define ARCH_DLINFO \ do { \ - NEW_AUX_ENT(AT_DCACHEBSIZE, 0x20); \ - NEW_AUX_ENT(AT_ICACHEBSIZE, 0x20); \ + PowerPCCPU *cpu = POWERPC_CPU(thread_cpu); \ + NEW_AUX_ENT(AT_DCACHEBSIZE, cpu->env.dcache_line_size); \ + NEW_AUX_ENT(AT_ICACHEBSIZE, cpu->env.icache_line_size); \ NEW_AUX_ENT(AT_UCACHEBSIZE, 0); \/* \ * Now handle glibc compatibility. \
Signature · 1 line
1.7.1
PATCH 2/4 target-ppc: Add DFP to Emulated Instructions Flag
In reply to Tom MustaDecimal Floating Point is emulated, so add it the mask. This will fix the erroneous message:
Warning: Disabling some instructions which are not emulated by TCG (0x0, 0x4)
--- target-ppc/cpu.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-ppc/cpu.h +1 -1
@@ -2012,7 +2012,7 @@ enum {PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 | \PPC2_BCTAR_ISA207 |PPC2_LSQ_ISA207 | \ - PPC2_ALTIVEC_207 | PPC2_ISA207S) + PPC2_ALTIVEC_207 | PPC2_ISA207S | PPC2_DFP) };/*****************************************************************************/
Signature · 1 line
1.7.1
PATCH 3/4 linux-user: Identify Addition Hardware Capabilities for PowerPC
In reply to Tom MustaAdd VSX, DFP and ISA 2.06 to the bits identified in the AT_HWCAP entry of the AUXV.
--- linux-user/elfload.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
linux-user/elfload.c +8 -0
@@ -742,6 +742,8 @@ static uint32_t get_elf_hwcap(void)Altivec/FP/SPE support. Anything else is just a bonus. */ #define GET_FEATURE (flag, feature) \ do { if (cpu->env.insns_flags & flag) { features |= feature; } } while (0) +#define GET_FEATURE2 (flag, feature) \ + do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)GET_FEATURE (PPC_64B ,QEMU_PPC_FEATURE_64 );GET_FEATURE (PPC_FLOAT ,QEMU_PPC_FEATURE_HAS_FPU );GET_FEATURE (PPC_ALTIVEC ,QEMU_PPC_FEATURE_HAS_ALTIVEC );
@@ -750,7 +752,13 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE (PPC_SPE_DOUBLE ,QEMU_PPC_FEATURE_HAS_EFP_DOUBLE );GET_FEATURE (PPC_BOOKE ,QEMU_PPC_FEATURE_BOOKE );GET_FEATURE (PPC_405_MAC , QEMU_PPC_FEATURE_HAS_4xxMAC); +GET_FEATURE2 (PPC2_DFP ,QEMU_PPC_FEATURE_HAS_DFP ); +GET_FEATURE2 (PPC2_VSX ,QEMU_PPC_FEATURE_HAS_VSX ); +GET_FEATURE2 ((PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | +PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 ), +QEMU_PPC_FEATURE_ARCH_2_06 );#undef GET_FEATURE +#undef GET_FEATURE2return features; }
Signature · 1 line
1.7.1
PATCH 4/4 linux-user: Support HWCAP2 in PowerPC
In reply to Tom MustaSet bits in the AT_HWCAP2 entry of the AUXV. Specifically, detect and set bits for bctar, ISEL and ISA 2.07.
--- linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
linux-user/elfload.c +31 -0
@@ -729,6 +729,14 @@ enum {QEMU_PPC_FEATURE_TRUE_LE =0x00000002 ,QEMU_PPC_FEATURE_PPC_LE =0x00000001 , + +/* Feature definitions in AT_HWCAP2. */ +QEMU_PPC_FEATURE2_ARCH_2_07 =0x80000000 ,/* ISA 2.07 */ +QEMU_PPC_FEATURE2_HAS_HTM =0x40000000 ,/* Hardware Transactional Memory */ +QEMU_PPC_FEATURE2_HAS_DSCR =0x20000000 ,/* Data Stream Control Register */ +QEMU_PPC_FEATURE2_HAS_EBB =0x10000000 ,/* Event Base Branching */ +QEMU_PPC_FEATURE2_HAS_ISEL =0x08000000 ,/* Integer Select */ + QEMU_PPC_FEATURE2_HAS_TAR = 0x04000000, /* Target Address Register */ };#define ELF_HWCAP get_elf_hwcap()
@@ -763,6 +771,29 @@ static uint32_t get_elf_hwcap(void)return features; } +#define ELF_HWCAP2 get_elf_hwcap2() + +static uint32_t get_elf_hwcap2 (void ) +{ +PowerPCCPU *cpu =POWERPC_CPU (thread_cpu); +uint32_t features =0 ; + +#define GET_FEATURE (flag, feature) \ + do { if (cpu->env.insns_flags & flag) { features |= feature; } } while (0) +#define GET_FEATURE2 (flag, feature) \ + 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 ); + +#undef GET_FEATURE +#undef GET_FEATURE2 + +return features; +} +/* * The requirements here are: * - keep the final alignment of sp (sp & 0xf)
Signature · 1 line
1.7.1
Alexander Graf
AppliedQuoted 3 lines · Tom Musta
These patches improve the fidelity of the AUXV for the Power PC user mode targets. Specifically, the cache line sizes and hardware capabilities are improved so that they more closely match what would be seen on an actual system.
Thanks, applied all to ppc-next. Next time please CC Riku for linux-user related patches :).
Alex