Received: from eggs.gnu.org ([2001:4830:134:3::10]:36127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQAhO-0000U7-Ca for qemu-devel@nongnu.org; Tue, 05 Jun 2018 08:04:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQAhJ-0005tA-Ec for qemu-devel@nongnu.org; Tue, 05 Jun 2018 08:04:26 -0400 References: <1527671818-23809-1-git-send-email-thuth@redhat.com> <1527671818-23809-4-git-send-email-thuth@redhat.com> <20180604113619.0ef8ccbd.cohuck@redhat.com> From: Thomas Huth Message-ID: Date: Tue, 5 Jun 2018 14:04:18 +0200 MIME-Version: 1.0 In-Reply-To: <20180604113619.0ef8ccbd.cohuck@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUID List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: qemu-s390x@nongnu.org, Viktor Mihajlovski , Christian Borntraeger , qemu-devel@nongnu.org, Collin Walling , Farhan Ali On 04.06.2018 11:36, Cornelia Huck wrote: > On Wed, 30 May 2018 11:16:58 +0200 > Thomas Huth wrote: >=20 >> With the STSI instruction, we can get the UUID of the current VM insta= nce, >> so we can support loading pxelinux config files via UUID in the file n= ame, >> too. >> >> Signed-off-by: Thomas Huth >> --- >> pc-bios/s390-ccw/netmain.c | 46 +++++++++++++++++++++++++++++++++++++= ++++++++- >> 1 file changed, 45 insertions(+), 1 deletion(-) >> >> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c >> index e84bb2b..7ece302 100644 >> --- a/pc-bios/s390-ccw/netmain.c >> +++ b/pc-bios/s390-ccw/netmain.c >> @@ -235,6 +235,49 @@ static void net_release(filename_ip_t *fn_ip) >> } >> =20 >> /** >> + * Retrieve the Universally Unique Identifier of the VM. >> + * @return UUID string, or NULL in case of errors >> + */ >> +static const char *get_uuid(void) >> +{ >> + register int r0 asm("0"); >> + register int r1 asm("1"); >> + uint8_t *mem, *buf, uuid[16]; >> + int i, chk =3D 0; >> + static char uuid_str[37]; >> + >> + mem =3D malloc(2 * PAGE_SIZE); >> + if (!mem) { >> + puts("Out of memory ... can not get UUID."); >> + return NULL; >> + } >> + buf =3D (uint8_t *)(((uint64_t)mem + PAGE_SIZE - 1) & ~(PAGE_SIZE= - 1)); >> + memset(buf, 0, PAGE_SIZE); >> + >> + /* Get SYSIB 3.2.2 */ >> + r0 =3D (3 << 28) | 2; >> + r1 =3D 2; >> + asm volatile(" stsi 0(%2)\n" : : "d" (r0), "d" (r1), "a" (buf) >> + : "cc", "memory"); >=20 > Maybe check for cc =3D=3D 3 here, just to be safe? (We can probably ass= ume > a dbct >=3D 1 if it is successful, I think.) Sure, I can add that check. In case it's not available, this should have been catched by the "if (!chk)" below, but let's better be safe than sorry here. >> + >> + for (i =3D 0; i < 16; i++) { >> + uuid[i] =3D buf[8 * 4 + 12 * 4 + i]; >=20 > Is there some way to make this offset less magic (offset of first vmdb > + offset of uuid inside vmdb)? Would a comment be sufficient? Or shall I copy the SysIB_322 structure from target/s390x/cpu.h over to the s390-ccw bios? Thomas