[kvm-unit-tests PATCH v10 08/15] powerpc: add pmu tests
Thomas Huth
thuth at redhat.com
Wed Jun 19 04:39:40 AEST 2024
On 12/06/2024 07.23, Nicholas Piggin wrote:
> Add some initial PMU testing.
>
> - PMC5/6 tests
> - PMAE / PMI test
> - BHRB basic tests
>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
> ---
...
> diff --git a/powerpc/pmu.c b/powerpc/pmu.c
> new file mode 100644
> index 000000000..bdc45e167
> --- /dev/null
> +++ b/powerpc/pmu.c
> @@ -0,0 +1,562 @@
...
> +static void test_pmc5_with_ldat(void)
> +{
> + unsigned long pmc5_1, pmc5_2;
> + register unsigned long r4 asm("r4");
> + register unsigned long r5 asm("r5");
> + register unsigned long r6 asm("r6");
> + uint64_t val;
> +
> + reset_mmcr0();
> + mtspr(SPR_PMC5, 0);
> + mtspr(SPR_MMCR0, mfspr(SPR_MMCR0) & ~(MMCR0_FC | MMCR0_FC56));
> + asm volatile(".rep 20 ; nop ; .endr" ::: "memory");
> + mtspr(SPR_MMCR0, mfspr(SPR_MMCR0) | (MMCR0_FC | MMCR0_FC56));
> + pmc5_1 = mfspr(SPR_PMC5);
> +
> + val = 0xdeadbeef;
> + r4 = 0;
> + r5 = 0xdeadbeef;
> + r6 = 100;
> + reset_mmcr0();
> + mtspr(SPR_PMC5, 0);
> + mtspr(SPR_MMCR0, mfspr(SPR_MMCR0) & ~(MMCR0_FC | MMCR0_FC56));
> + asm volatile(".rep 10 ; nop ; .endr ; ldat %0,%3,0x10 ; .rep 10 ; nop ; .endr" : "=r"(r4), "+r"(r5), "+r"(r6) : "r"(&val) :"memory");
Looks like older versions of Clang do not like this instruction:
/tmp/pmu-4fda98.s: Assembler messages:
/tmp/pmu-4fda98.s:1685: Error: unrecognized opcode: `ldat'
clang-13: error: assembler command failed with exit code 1 (use -v to see
invocation)
Could you please work-around that issue?
Also, please break the very long line here. Thanks!
> + mtspr(SPR_MMCR0, mfspr(SPR_MMCR0) | (MMCR0_FC | MMCR0_FC56));
> + pmc5_2 = mfspr(SPR_PMC5);
> + assert(r4 == 0xdeadbeef);
> + assert(val == 0xdeadbeef);
> +
> + /* TCG does not count instructions around syscalls correctly */
> + report_kfail(host_is_tcg, pmc5_1 != pmc5_2 + 1,
> + "PMC5 counts instructions with ldat");
> +}
Thomas
More information about the Linuxppc-dev
mailing list