Re: [PATCH v12 17/17] tests/tcg/s390x: Add tests for CPACF instructions

Harald Freudenberger <[email protected]> Mon, 03 Aug 2026 18:02:14 +0200
Newsgroups org.nongnu.qemu-devel,org.kernel.vger.linux-s390
Message-ID <[email protected]>
On 2026-07-14 14:01, Ilya Leoshkevich wrote:
> On 7/10/26 17:29, Harald Freudenberger wrote:
>> Add simple tests for the CPACF instructions implemented:
>> - kdsa - minimal as only query is implemented
>> - kimd - query, sha256, sha512
>> - klmd - query, sha256, sha512
>> - km - query, aes 128, 192, 256 with clear and prot key
>> - kmac - minimal as only query is implemented
>> - kmc - query, aes 128, 192, 256 with clear and prot key
>> - kmctr - query, aes 128, 192, 256 with clear and prot key
>> - pcc - query, xts aes 128, 256 and prot key xts aes 128, 256
>> - prno - query, trng
>> No test for pckmo as this is a privileged instruction.
>> No test for kma, kmf, kmo as these instructions are currently
>> not implemented at all.
>> 
>> Signed-off-by: Harald Freudenberger <[email protected]>
>> ---
>>   target/s390x/tcg/cpacf.h        |   7 +
>>   tests/tcg/s390x/Makefile.target |   9 +
>>   tests/tcg/s390x/cpacf-kdsa.c    |  58 ++++
>>   tests/tcg/s390x/cpacf-kimd.c    | 166 +++++++++
>>   tests/tcg/s390x/cpacf-klmd.c    | 206 +++++++++++
>>   tests/tcg/s390x/cpacf-km.c      | 590 
>> ++++++++++++++++++++++++++++++++
>>   tests/tcg/s390x/cpacf-kmac.c    |  58 ++++
>>   tests/tcg/s390x/cpacf-kmc.c     | 351 +++++++++++++++++++
>>   tests/tcg/s390x/cpacf-kmctr.c   | 360 +++++++++++++++++++
>>   tests/tcg/s390x/cpacf-pcc.c     | 245 +++++++++++++
>>   tests/tcg/s390x/cpacf-prno.c    | 131 +++++++
>>   tests/tcg/s390x/cpacf.h         | 571 
>> +++++++++++++++++++++++++++++++
>>   12 files changed, 2752 insertions(+)
>>   create mode 100644 tests/tcg/s390x/cpacf-kdsa.c
>>   create mode 100644 tests/tcg/s390x/cpacf-kimd.c
>>   create mode 100644 tests/tcg/s390x/cpacf-klmd.c
>>   create mode 100644 tests/tcg/s390x/cpacf-km.c
>>   create mode 100644 tests/tcg/s390x/cpacf-kmac.c
>>   create mode 100644 tests/tcg/s390x/cpacf-kmc.c
>>   create mode 100644 tests/tcg/s390x/cpacf-kmctr.c
>>   create mode 100644 tests/tcg/s390x/cpacf-pcc.c
>>   create mode 100644 tests/tcg/s390x/cpacf-prno.c
>>   create mode 100644 tests/tcg/s390x/cpacf.h
> 
> I get failures when running these on a real z17, for example:
> 
> $ ./cpacf-kdsa
> test_kdsa_query failed
> cpacf-kdsa: 1 failures

I've reworked the testcases - see v13 coming soon.
The query function now compares against the minimal expected
subfunction set but does not fail if there are more subfunctions
available. However, the tests will still fail when run on real
hardware when it comes to protected key related operations.