From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web08.5419.1643366187089949026 for ; Fri, 28 Jan 2022 02:36:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JJOuJ8Vd; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643366186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n6ttzICDLRkC5UuyWEYv0gOM1Ucp9Jmhso20SgMcUxg=; b=JJOuJ8VdEPRCJUGjrs1qAPofGm5A8EISsmr50nONlApJfr8Tc1ykf8A4VSuaPoxQtkYtMS csBU96fl396GPPBVbxfq6EQIO74JCS7twLZaTVzGLu7QAYya053J6Q4LQ0mLm/7l2igw5p BY1+KPMkOcghAJ9bboEEeOccK1M5o8Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-o57AX8f4PRC95S3UhqAx8w-1; Fri, 28 Jan 2022 05:36:25 -0500 X-MC-Unique: o57AX8f4PRC95S3UhqAx8w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D751280D6B1; Fri, 28 Jan 2022 10:36:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D0C87B6D5; Fri, 28 Jan 2022 10:36:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id ED071180060D; Fri, 28 Jan 2022 11:36:21 +0100 (CET) Date: Fri, 28 Jan 2022 11:36:21 +0100 From: "Gerd Hoffmann" To: Nicolas Ojeda Leon Cc: devel@edk2.groups.io, atugup@amazon.com, Alexander Graf Subject: Re: [PATCH v3 2/8] Ovmf/HardwareInfoLib: Create Pei lib to parse directly from fw-cfg Message-ID: <20220128103621.oc363pk3na2qhpkc@sirius.home.kraxel.org> References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 25, 2022 at 03:30:09PM +0100, Nicolas Ojeda Leon wrote: > Define the HardwareInfoLib API and create the PeiHardwareInfoLib > which implements it, specifically for Pei usage, supporting > only static accesses to parse data directly from a fw-cfg file. > All list-like APIs are implemented as unsupported and only a > fw-cfg wrapper to read hardware info elements is provided. > > The Hardware Info library is intended to describe non-discoverable > hardware information and share that from the host to the guest in Ovmf > platforms. The QEMU fw-cfg extension for this library provides a first > variation to parse hardware info by reading it directly from a fw-cfg > file. This library offers a wrapper function to the plain > QmeuFwCfgReadBytes which, specifically, parses header-data pairs out > of the binary values in the file. For this purpose, the approach is > incremental, reading the file block by block and outputting the values > only for a specific known hardware type (e.g. PCI host bridges). One > element is returned in each call until the end of the file is reached. > > Considering fw-cfg as the first means to transport hardware info from > the host to the guest, this wrapping library offers the possibility > to statically, and in steps, read a specific type of hardware info > elements out of the file. This method reads one hardware element of a > specific type at a time, without the need to pre-allocate memory and > read the whole file or dynamically allocate memory for each new > element found. > > As a usage example, the static approach followed by this library > enables early UEFI stages to use and read hardware information > supplied by the host. For instance, in early times of the PEI stage, > hardware information can be parsed out from a fw-cfg file prescinding > from memory services, that may not yet be available, and avoiding > dynamic memory allocations. > > Cc: Alexander Graf > Cc: Gerd Hoffmann > > Signed-off-by: Nicolas Ojeda Leon Acked-by: Gerd Hoffmann