From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48160 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731964AbgGaJVm (ORCPT ); Fri, 31 Jul 2020 05:21:42 -0400 Date: Fri, 31 Jul 2020 11:21:22 +0200 From: Cornelia Huck Subject: Re: [kvm-unit-tests PATCH v2 3/3] s390x: Ultravisor guest API test Message-ID: <20200731112122.1db14419.cohuck@redhat.com> In-Reply-To: <16eee269-d773-26df-a517-08f2265318c4@linux.ibm.com> References: <20200727095415.494318-1-frankja@linux.ibm.com> <20200727095415.494318-4-frankja@linux.ibm.com> <20200730131617.7f7d5e5f.cohuck@redhat.com> <1a407971-0b43-879e-0aac-65c7f9e29606@redhat.com> <20200731104205.37add810.cohuck@redhat.com> <16eee269-d773-26df-a517-08f2265318c4@linux.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/85AWDb/urtlSoUNPc2_4Ym3"; protocol="application/pgp-signature"; micalg=pgp-sha256 Sender: linux-s390-owner@vger.kernel.org List-ID: To: Janosch Frank Cc: Thomas Huth , kvm@vger.kernel.org, linux-s390@vger.kernel.org, david@redhat.com, borntraeger@de.ibm.com, imbrenda@linux.ibm.com --Sig_/85AWDb/urtlSoUNPc2_4Ym3 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 31 Jul 2020 11:06:25 +0200 Janosch Frank wrote: > On 7/31/20 10:42 AM, Cornelia Huck wrote: > > On Fri, 31 Jul 2020 09:34:41 +0200 > > Janosch Frank wrote: > > =20 > >> On 7/30/20 5:58 PM, Thomas Huth wrote: =20 > >>> On 30/07/2020 13.16, Cornelia Huck wrote: =20 > >>>> On Mon, 27 Jul 2020 05:54:15 -0400 > >>>> Janosch Frank wrote: > >>>> =20 > >>>>> Test the error conditions of guest 2 Ultravisor calls, namely: > >>>>> * Query Ultravisor information > >>>>> * Set shared access > >>>>> * Remove shared access > >>>>> > >>>>> Signed-off-by: Janosch Frank > >>>>> Reviewed-by: Claudio Imbrenda > >>>>> --- > >>>>> lib/s390x/asm/uv.h | 68 +++++++++++++++++++ > >>>>> s390x/Makefile | 1 + > >>>>> s390x/unittests.cfg | 3 + > >>>>> s390x/uv-guest.c | 159 ++++++++++++++++++++++++++++++++++++++++= ++++ > >>>>> 4 files changed, 231 insertions(+) > >>>>> create mode 100644 lib/s390x/asm/uv.h > >>>>> create mode 100644 s390x/uv-guest.c > >>>>> =20 > >>>> > >>>> (...) > >>>> =20 > >>>>> +static inline int uv_call(unsigned long r1, unsigned long r2) > >>>>> +{ > >>>>> +=09int cc; > >>>>> + > >>>>> +=09asm volatile( > >>>>> +=09=09"0:=09.insn rrf,0xB9A40000,%[r1],%[r2],0,0\n" > >>>>> +=09=09"=09=09brc=093,0b\n" > >>>>> +=09=09"=09=09ipm=09%[cc]\n" > >>>>> +=09=09"=09=09srl=09%[cc],28\n" > >>>>> +=09=09: [cc] "=3Dd" (cc) > >>>>> +=09=09: [r1] "a" (r1), [r2] "a" (r2) > >>>>> +=09=09: "memory", "cc"); > >>>>> +=09return cc; > >>>>> +} =20 > >>>> > >>>> This returns the condition code, but no caller seems to check it > >>>> (instead, they look at header.rc, which is presumably only set if th= e > >>>> instruction executed successfully in some way?) > >>>> > >>>> Looking at the kernel, it retries for cc > 1 (presumably busy > >>>> conditions), and cc !=3D 0 seems to be considered a failure. Do we w= ant > >>>> to look at the cc here as well? =20 > >>> > >>> It's there - but here it's in the assembly code, the "brc 3,0b". = =20 > >=20 > > Ah yes, I missed that. > > =20 > >> > >> Yes, we needed to factor that out in KVM because we sometimes need to > >> schedule and then it looks nicer handling that in C code. The branch o= n > >> condition will jump back for cc 2 and 3. cc 0 and 1 are success and > >> error respectively and only then the rc and rrc in the UV header are s= et. =20 > >=20 > > Yeah, it's a bit surprising that rc/rrc are also set with cc 1. =20 >=20 > Is it? > The (r)rc *only* contain meaningful information on CC 1. > On CC 0 they will simply say everything is fine which CC 0 states > already anyway. I would consider "things worked" to actually be meaningful :) (I've seen other instructions indicating different kinds of success.) >=20 > >=20 > > (Can you add a comment? Just so that it is clear that callers never > > need to check the cc, as rc/rrc already contain more information than > > that.) =20 >=20 > I'd rather fix my test code and also check the CC. > I did check it for my other UV tests so I've no idea why I didn't do it > here... >=20 >=20 > How about adding a comment for the cc 2/3 case? > "The brc instruction will take care of the cc 2/3 case where we need to > continue the execution because we were interrupted. > The inline assembly will only return on success/error i.e. cc 0/1." Sounds good. --Sig_/85AWDb/urtlSoUNPc2_4Ym3 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAl8j4pIACgkQ3s9rk8bw L6+I0RAAmoCKVRrXzu8om3hAovHTbKnIf7+8PPW5tKHGnQZNaHVeo3jmioJBU6Ur NYuMapYIwMxiBkOXkBpm/WFhLMZunWCKMmjrwZNGZGtp/sFHFvDTUAan2A1eCfZ4 23o4wHpQnMCHR3LkRgaHOvVbKrGwDwMr4n7K0btmsOQWQHFS0Ot2xEIHVwXrJj+k xWPFVs66ylYwMPNifrtwHSejWtBvlN8QM0GvA9MDAYZCyQExRNfSyS9Ebx41+jg6 TGR3eUWrKoewmtv6JozCaCEiv3kIaRMCJkTR26FiCgUb0ZuiqtRBeMan9uxm5Yji S+5u2Gty+yJSC6bKdhvITpDQ92mjMbVApQF6Hq4FGUY0APKXQa9+TL7CDX4ySBam YNOVDn7gWnuzLE7pP+uRHWznYEj2SCvolDmU3zKSnYMVhKLvTqUdr/6/dwVCwq8A JEnc8R3sXjhA3PhYaf2i4EpfPcivEBH1yuVYHtZh4t2V1+JQ2Uz7EfpAil63ACpH dbOJj5hIYO8wBsS0e3KoNpXVPTyEmmKX1UuOqdumZzS7YUoAPZ2mGMG3Pb2ABCQW nc9hdK31I4UGG8LDYy+nkWDpqcSA/ns0W+Cf0nW1IoyPVmiBvdWSNQZPfguNZlKJ KSEhdsq1u0l8SllxLNWUYAbK0p0ws31p5+OiNa+IelnMJH2ry8I= =Ib/4 -----END PGP SIGNATURE----- --Sig_/85AWDb/urtlSoUNPc2_4Ym3--