From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by mx.groups.io with SMTP id smtpd.web11.7142.1570781891535135382 for ; Fri, 11 Oct 2019 01:18:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=WZawosAU; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.160.193, mailfrom: mw@semihalf.com) Received: by mail-qt1-f193.google.com with SMTP id 3so12727811qta.1 for ; Fri, 11 Oct 2019 01:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VmeE1TRnHdH46vfoICP50WpzNVekXgN9EDC5UCRzmPY=; b=WZawosAU4JBketaDTKoJEShPBDQasmgFRTOFQDUH1W6R0qqGNp4+fkCEEL84DLWwvT LoNkbueM48o/pzl2socuVRHtp9u+NgnRs6JUfnbn0bYCvqGaEZGrAwbvc0tawLG8KRyW MpbGKbffWpl9RTOGjzyR1e2rPlBawLlqFNYvY+v+g+LRB8FS/PTn5SWgX5iHdoh3wTpZ StGMI0ELogzeFYAWu9SxUdRNY5PC8au2KZsCWGYCVl6VSeOEggJR1SCKKb61dlHr7w6/ C+R4Nh4hnB331vbNnoe8JZaie8Ub6/tskDxTAbbsiYbpdZjY08BSUWG1Hmx3wnM36tXh pbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VmeE1TRnHdH46vfoICP50WpzNVekXgN9EDC5UCRzmPY=; b=jittKs/FePkLMEcW11ULXRg07kqXTr9zHHTMcfaAZXEdpK3b4shw551T16RuoaMyWF P2SlYha2i9hTnZXSvmwu9vVFHaHaTHt8OS/dk5JTg+E6pvXJa36uRvPkWMOjGme/kd6N IuoTSORGRsr8q8fBL4YLan6dl3uOGjcY+S9Fvi78UAfz1pA0m2PCa2ptgPYWIe9yj4ZL I5VVNiwDaunWPEELfRiMCsCivchfEqra8/Zpunmyiny1VMXGawaMzao+ZphsS/tmBTl3 HuF0ozb9G5/1dAlemPW6lnAdfKC5JiuDsNH9i/XRCqO50FLGfzOEtbyPg6YhZr21PzHG bUTg== X-Gm-Message-State: APjAAAVrHsdx6KR8r5z9G5FFWAdcW8NW/0Qd7Dt0c70oFX5mXQL5ywTE PtZFwCy9AlJ/BkKaAIuWMf+5n5NkPk40/cGcBgdkNg== X-Google-Smtp-Source: APXvYqwwEQN5SkO/twfM76MAfxc6NwaoO7o+WybYwRGMH1CKWvkACETYk6AlzhLbKu9humydvyJp41DapBxi9aSpNDo= X-Received: by 2002:ac8:708f:: with SMTP id y15mr15242599qto.247.1570781890443; Fri, 11 Oct 2019 01:18:10 -0700 (PDT) MIME-Version: 1.0 References: <1570686139-25182-1-git-send-email-mw@semihalf.com> <1570686139-25182-9-git-send-email-mw@semihalf.com> <20191010230430.GX25504@bivouac.eciton.net> <20191010235106.GZ25504@bivouac.eciton.net> In-Reply-To: From: "Marcin Wojtas" Date: Fri, 11 Oct 2019 10:17:59 +0200 Message-ID: Subject: Re: [edk2-platforms: PATCH v3 8/9] Marvell/Drivers: SmbiosPlatformDxe: Load SMBIOS strings from PCD To: Leif Lindholm Cc: edk2-devel-groups-io , Ard Biesheuvel , "jsd@semihalf.com" , Grzegorz Jaszczyk , Kostya Porotchkin , Patryk Duda Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Leif, pt., 11 pa=C5=BA 2019 o 09:30 Marcin Wojtas napisa=C5=82(= a): > > Hi Leif, > > pt., 11 pa=C5=BA 2019 o 01:51 Leif Lindholm na= pisa=C5=82(a): > > > > On Fri, Oct 11, 2019 at 01:33:49AM +0200, Marcin Wojtas wrote: > > > Hi Leif, > > > > > > pt., 11 pa=C5=BA 2019 o 01:04 Leif Lindholm napisa=C5=82(a): > > > > > > > > On Thu, Oct 10, 2019 at 07:42:18AM +0200, Marcin Wojtas wrote: > > > > > From: Patryk Duda > > > > > > > > > > This patch implements convenient way of changing strings included > > > > > in SMBIOS Table1, Table2, Table3. > > > > > > > > > > Strings can be altered by defining following PCDs: > > > > > gMarvellTokenSpaceGuid.PcdProductManufacturer > > > > > gMarvellTokenSpaceGuid.PcdProductPlatformName > > > > > gMarvellTokenSpaceGuid.PcdProductVersion > > > > > gMarvellTokenSpaceGuid.PcdProductSerial > > > > > > > > > > This patch adds also limit for length of string which can be incr= eased > > > > > if necessary in future. > > > > > > > > > > Signed-off-by: Patryk Duda > > > > > --- > > > > > Silicon/Marvell/Marvell.dec = | 6 ++ > > > > > Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf = | 4 + > > > > > Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c = | 79 +++++++++++++++++--- > > > > > 3 files changed, 78 insertions(+), 11 deletions(-) > > > > > > > > > > diff --git a/Silicon/Marvell/Marvell.dec b/Silicon/Marvell/Marvel= l.dec > > > > > index d337d3e..a84b056 100644 > > > > > --- a/Silicon/Marvell/Marvell.dec > > > > > +++ b/Silicon/Marvell/Marvell.dec > > > > > @@ -169,6 +169,12 @@ > > > > > gMarvellTokenSpaceGuid.PcdPciEAhci|{ 0x0 }|VOID*|0x3000034 > > > > > gMarvellTokenSpaceGuid.PcdPciESdhci|{ 0x0 }|VOID*|0x3000035 > > > > > > > > > > +#Platform description > > > > > + gMarvellTokenSpaceGuid.PcdProductManufacturer|"Marvell = \0"|VOID*|0x50000100 > > > > > + gMarvellTokenSpaceGuid.PcdProductPlatformName|"Marvell Develop= ment Board \0"|VOID*|0x50000101 > > > > > + gMarvellTokenSpaceGuid.PcdProductSerial|"Serial Not Set = \0"|VOID*|0x50000103 > > > > > + gMarvellTokenSpaceGuid.PcdProductVersion|"Revision unknown = \0"|VOID*|0x50000102 > > > > > + > > > > > > > > I'm not too pleased about this random number of spaces. I'm cool wi= th > > > > the strings, but they should be treated as such, not magical data > > > > structures. > > > > > > In v4 the trailing spaces will be removed from the defaults (as well = as "\0"). > > > > > > > > +STATIC > > > > > +VOID > > > > > +MvSmbiosCopyStrings ( > > > > > + VOID > > > > > + ) > > > > > +{ > > > > > + EFI_STATUS Status; > > > > > + > > > > > + ASSERT (AsciiStrnLenS ((CHAR8 *)PcdGetPtr (PcdProductManufactu= rer), > > > > > + MV_SMBIOS_STRING_MAX_SIZE) < MV_SMBIOS_STRING_MAX_SIZE); > > > > > + ASSERT (AsciiStrnLenS ((CHAR8 *)PcdGetPtr (PcdProductPlatformN= ame), > > > > > + MV_SMBIOS_STRING_MAX_SIZE) < MV_SMBIOS_STRING_MAX_SIZE); > > > > > + ASSERT (AsciiStrnLenS ((CHAR8 *)PcdGetPtr (PcdProductVersion), > > > > > + MV_SMBIOS_STRING_MAX_SIZE) < MV_SMBIOS_STRING_MAX_SIZE); > > > > > + ASSERT (AsciiStrnLenS ((CHAR8 *)PcdGetPtr (PcdProductSerial), > > > > > + MV_SMBIOS_STRING_MAX_SIZE) < MV_SMBIOS_STRING_MAX_SIZE); > > > > > > > > Especially given the current design, these ASSERTs seem a bit > > > > ... unhelpful. In fact, this whole MAX_SIZE thing seems ... restric= ted > > > > by the implementation, not by external constraints. What is the > > > > benefit? Not having to do a bunch of pointer conversions at > > > > SetVirtualAddressMap? > > > > > > > > > > The default static tables require constant initializers and the > > > placeholders should have some predefined size in current approach. So > > > max of 32 characters was picked and with the asserts, ensuring the > > > user will not exceed it. Do you think they should be removed? > > > > Oh, you're saying this is basically "TO BE FILLED BY OEM"? > > *yurgh*. > > > > I still say it's horrible, but not more horrible than most existing > > platforms. Nevertheless, the arbitrary size should be something > > defined by the code generating the tables - it shouldn't depend on > > what's in the .dec (or more usefully, the .dsc). > > > > I also feel that if it is effectively "TO BE FILLED BY OEM", it would > > be better if it said that than something that looks like it may be > > proper names. > > > > I would also prefer a compilation failure over an ASSERT if the string > > ended up not fitting. > > > > I think I found a solution to remove any fixed size constraint and assert= s: > STATIC CHAR8 mSysInfoManufacturer[sizeof ((CHAR8 *)PcdGetPtr > (PcdProductManufacturer))]; > STATIC CHAR8 mSysInfoProductName[sizeof ((CHAR8 *)PcdGetPtr > (PcdProductPlatformName))]; > STATIC CHAR8 mSysInfoVersion[sizeof ((CHAR8 *)PcdGetPtr (PcdProductVersio= n))]; > STATIC CHAR8 mSysInfoSerial[sizeof ((CHAR8 *)PcdGetPtr (PcdProductSerial)= )]; > Compilation test was not enough, please ignore my previous email - I have to find out something better :) Best regards, Marcin > > > > > > > > > > > > > + > > > > > + Status =3D AsciiStrCpyS (mSysInfoManufacturer, > > > > > + MV_SMBIOS_STRING_MAX_SIZE, > > > > > + (CHAR8 *)PcdGetPtr (PcdProductManufacturer)); > > > > > + ASSERT_EFI_ERROR (Status); > > > > > + Status =3D AsciiStrCpyS (mSysInfoProductName, > > > > > + MV_SMBIOS_STRING_MAX_SIZE, > > > > > + (CHAR8 *)PcdGetPtr (PcdProductPlatformName)); > > > > > + ASSERT_EFI_ERROR (Status); > > > > > + Status =3D AsciiStrCpyS (mSysInfoVersion, > > > > > + MV_SMBIOS_STRING_MAX_SIZE, > > > > > + (CHAR8 *)PcdGetPtr (PcdProductVersion)); > > > > > + ASSERT_EFI_ERROR (Status); > > > > > + Status =3D AsciiStrCpyS (mSysInfoSerial, > > > > > + MV_SMBIOS_STRING_MAX_SIZE, > > > > > + (CHAR8 *)PcdGetPtr (PcdProductSerial)); > > > > > + ASSERT_EFI_ERROR (Status); > > > > > +} > > > > > + > > > > > +/** > > > > > Install all structures from the DefaultTables structure > > > > > > > > > > @param Smbios SMBIOS protocol > > > > > @@ -760,6 +815,8 @@ SmbiosInstallAllStructures ( > > > > > FirmwareMajorRevisionNumber =3D (PcdGet32 (PcdFirmwareRevision= ) >> 16) & 0xFF; > > > > > FirmwareMinorRevisionNumber =3D PcdGet32 (PcdFirmwareRevision)= & 0xFF; > > > > > > > > > > + MvSmbiosCopyStrings(); > > > > > + > > > > > // > > > > > // Update Firmware Revision, CPU and DRAM frequencies. > > > > > // > > > > > -- > > > > > 2.7.4 > > > > >