On Thu Sep 12, 2024 at 10:15 AM CEST, Claudio Imbrenda wrote:
On Mon, 2 Sep 2024 13:50:01 +0200 Christoph Schlameuss schlameuss@linux.ibm.com wrote:
Add a test case manipulating s390 storage keys from within the ucontrol VM.
Signed-off-by: Christoph Schlameuss schlameuss@linux.ibm.com
.../selftests/kvm/s390x/ucontrol_test.c | 89 ++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-)
[...]
+TEST_F(uc_kvm, uc_skey) +{
- u64 test_vaddr = VM_MEM_SIZE - (SZ_1M / 2);
 - struct kvm_sync_regs *sync_regs = &self->run->s.regs;
 - struct kvm_run *run = self->run;
 - u8 skeyvalue = 0x34;
 - /* copy test_skey_asm to code_hva / code_gpa */
 - TH_LOG("copy code %p to vm mapped memory %p / %p",
 &test_skey_asm, (void *)self->code_hva, (void *)self->code_gpa);- memcpy((void *)self->code_hva, &test_skey_asm, PAGE_SIZE);
 - /* set register content for test_skey_asm to access not mapped memory */
 - sync_regs->gprs[1] = skeyvalue;
 - sync_regs->gprs[5] = self->base_gpa;
 - sync_regs->gprs[6] = test_vaddr;
 - run->kvm_dirty_regs |= KVM_SYNC_GPRS;
 - /* DAT disabled + 64 bit mode */
 - run->psw_mask = 0x0000000180000000ULL;
 - run->psw_addr = self->code_gpa;
 - ASSERT_EQ(0, uc_run_once(self));
 - ASSERT_EQ(false, uc_handle_exit(self));
 this should be true, since KSS will be triggered
Good find. Yes, as this is the assertion does actually fail here. Will fix that in the next version.
- ASSERT_EQ(1, sync_regs->gprs[0]);
 - /* ISKE */
 - ASSERT_EQ(0, uc_run_once(self));
 - ASSERT_EQ(false, uc_handle_exit(self));
 - ASSERT_EQ(2, sync_regs->gprs[0]);
 - /* assert initial skey (ACC = 0, R & C = 1) */
 - ASSERT_EQ(0x06, sync_regs->gprs[1]);
 - uc_assert_diag44(self);
 
[...]