Re: [kvm-unit-tests PATCH v3 4/7] s390x: Add function for checking diagnose intercepts

Nina Schoetterl-Glausch
2024-06-20T17:46:13Z

On Thu, 2024-06-20 at 18:47 +0200, Claudio Imbrenda wrote:
> On Thu, 20 Jun 2024 16:16:57 +0200
> Nina Schoetterl-Glausch <nsg@linux.ibm.com> wrote:
>
> > sie_is_diag_icpt() checks if the intercept is due to an expected
> > diagnose call and is valid.
> > It subsumes pv_icptdata_check_diag.
> >
> > Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
>
>
> [...]
>
>
> > diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c
> > index 0fa915cf..d4ba2a40 100644
> > --- a/lib/s390x/sie.c
> > +++ b/lib/s390x/sie.c
> > @@ -42,6 +42,59 @@ void sie_check_validity(struct vm *vm, uint16_t vir_exp)
> > report(vir_exp == vir, "VALIDITY: %x", vir);
> > }
> >
> > +bool sie_is_diag_icpt(struct vm *vm, unsigned int diag)
> > +{
> > + union {
> > + struct {
> > + uint64_t : 16;
> > + uint64_t ipa : 16;
> > + uint64_t ipb : 32;
> > + };
> > + struct {
> > + uint64_t : 16;
> > + uint64_t opcode : 8;
> > + uint64_t r_1 : 4;
> > + uint64_t r_2 : 4;
> > + uint64_t r_base : 4;
> > + uint64_t displace : 12;
> > + uint64_t zero : 16;
> > + };
> > + } instr = { .ipa = vm->sblk->ipa, .ipb = vm->sblk->ipb };
> > + uint8_t icptcode;
> > + uint64_t code;
> > +
> > + switch (diag) {
> > + case 0x44:
> > + case 0x9c:
> > + case 0x288:
> > + case 0x308:
> > + icptcode = ICPT_PV_NOTIFY;
> > + break;
> > + case 0x500:
> > + icptcode = ICPT_PV_INSTR;
> > + break;
> > + default:
> > + /* If a new diag is introduced add it to the cases above! */
> > + assert_msg(false, "unknown diag");
>
> just a nit, but would it be possible to also print the diag number that
> causes the error?

Yes and easy
assert_msg(false, "unknown diag 0x%x", diag);
>
>
> otherwise looks good
>
>