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.133.124]) by mx.groups.io with SMTP id smtpd.web10.5813.1675410884082161100 for ; Thu, 02 Feb 2023 23:54:44 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AsBZ6x/1; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675410883; 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=zyKhq978ptFI4rSL/z9PU8SCfhsXSmJCeZnYaWdL/D0=; b=AsBZ6x/164QxNAgx8PcciolJOkSlnWSVqpvLn3Wp7ycbOltRfaw+QWg3DMuWqm2toEADnH FSnLbJHGMI85Vhs7mjw9c2cLCLDT36gjlCQI/5WZGrtNfCBHX2x5KCT/VqhSTvwJ4cRbtR WSr2qP0Ox2boli/UicXS20BbB4MQOkQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-74-uKdUzRkrMdKh8F3XK4kmng-1; Fri, 03 Feb 2023 02:54:39 -0500 X-MC-Unique: uKdUzRkrMdKh8F3XK4kmng-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53F40101A55E; Fri, 3 Feb 2023 07:54:39 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 208FC400F756; Fri, 3 Feb 2023 07:54:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BB419180060E; Fri, 3 Feb 2023 08:54:37 +0100 (CET) Date: Fri, 3 Feb 2023 08:54:37 +0100 From: "Gerd Hoffmann" To: "Ni, Ray" Cc: "Johnson, Brian" , "devel@edk2.groups.io" , Laszlo Ersek , "Wu, Jiaxin" , "Dong, Eric" , "Zeng, Star" , "Kumar, Rahul R" , "Kinney, Michael D" , "Zimmer, Vincent" Subject: Re: [edk2-devel] [PATCH v3 1/5] UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data Message-ID: <20230203075437.fkp3mwri4jg7rn4q@sirius.home.kraxel.org> References: <20230118095620.9860-1-jiaxin.wu@intel.com> <20230118095620.9860-2-jiaxin.wu@intel.com> <20230118111913.xgjlxdhngzwhvf76@sirius.home.kraxel.org> <8142cc40-ca21-2748-a3de-d0432ccbdc07@redhat.com> <20230202125158.bx7amq2nfibhimvf@sirius.home.kraxel.org> <525d8100-b306-d1fb-08c4-e5e2cc6204e2@hpe.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 03, 2023 at 03:14:42AM +0000, Ni, Ray wrote: > Gerd, > Can you please explain a bit more on the chunk idea? > > > to introduce a generic and reusable concept of chunked HOBs, so you can > > > add helper functions to HobLib for splitting and reassembling, with a > > > struct along the lines of: > > > > > > typedef struct { > > > // offset and size of this particular chunk > > > UINT32 ChunkOffset; > > > UINT32 ChunkSize; > > > > > > // number of chunks and size of all chunks combined. > > > UINT32 ChunkCount; > > > UINT32 TotalSize; > > > > > > // chunk data > > > UINT8 Data[0]; > > > } EFI_HOB_CHUNK; Reassembling would work like this: // once AssembledHob = malloc(HobChunk->TotalSize); // for each chunk memcpy(AssembledHob + HobChunk->ChunkOffset, HobChunk->Data, HobChunk->ChunkSize); Possible shortcut: if (HobChunk->ChunkSize == HobChunk->TotalSize) // data is not splitted into multiple chunks AssembledHob = HobChunk->Data Advantage: you avoid the allocation in case the data fits into a single HOB. Disadvantage: you need to track whenever AssembledHob is allocated (and must eventually be freed) or not. HobChunk->ChunkCount is not really needed but might be useful for sanity checking. take care, Gerd