[PATCH][V3] dmicheck: skip scanning smbios in /dev/mem on aarch64

ivanhu ivan.hu at canonical.com
Wed Mar 30 07:30:05 UTC 2022


Hi Edhay,

Thanks for the information.

I'll check on my local machine and PPA to see if I can reproduce it.


Cheers,

Ivan


On 3/29/22 19:34, G Edhaya Chandran wrote:
>
> Hi Alex,
>
>  
>
>     Apologies for following up on the below issue after so long.
>
>  
>
> /I don't observe the build errors on my local system and not on PPA./
>
> /Could you please share more about your build env? I will try to
> reproduce it and see how this can be fixed./
>
>  
>
> The build environment is a new installation of Ubuntu 20.04.
>
> The FWTS build will fail with the below error:
>
>  
>
>  
>
> The suggestion to resolve this dependency is to install the libz-dev
> package by
>
> sudo apt-get install libz-dev
>
> However this installed zlib.h in /usr/include which is not in the
> include path of FWTS compilation for fwts_ac_adapter.c
>
> (In fact this package is by default installed in default Ubuntu 20.04)
>
>  
>
> Suggestion:
>
> Including /usr/include in the -I path fwts_ac_adapter.c for may solve
> this issue.
>
>  
>
> With Warm Regards,
>
> Edhay
>
>  
>
>  
>
>  
>
> *From:* Alex Hung <alex.hung at canonical.com>
> *Sent:* 16 December 2021 21:27
> *To:* G Edhaya Chandran <Edhaya.Chandran at arm.com>
> *Cc:* Sunny Wang <Sunny.Wang at arm.com>; fwts-devel at lists.ubuntu.com
> *Subject:* Re: [PATCH][V3] dmicheck: skip scanning smbios in /dev/mem
> on aarch64
>
>  
>
>  
>
>  
>
> On Thu, Dec 16, 2021 at 1:36 AM G Edhaya Chandran
> <Edhaya.Chandran at arm.com> wrote:
>
>     Hi Alex,
>
>      
>
>         There is no dependency on ACS image, but on *ubuntu* build env.
>
>  
>
> I don't observe the build errors on my local system and not on PPA.
>
>  
>
> Could you please share more about your build env? I will try to
> reproduce it and see how this can be fixed.
>
>  
>
>  
>
>      
>
>     I already tried the solution
>      https://unix.stackexchange.com/questions/315605/unable-to-cross-compile-openssh-for-arm-zlib-missing.
>
>     The package was already installed in my env.  However the zlib.h
>     was present in /usr/include
>
>     Probably this is different in the other Linux distros.
>
>      
>
>     I am not sure of the relevance but the .Po files in the package
>     alse has this path
>
>     src/acpi/battery/.deps/fwts-battery.Po:
>     ../src/lib/include/fwts_fileio.h */usr/include/zlib.h *\
>
>     src/acpi/battery/.deps/fwts-battery.Po:/usr/include/zlib.h:
>
>     src/acpi/crsdump/.deps/fwts-prsdump.Po:
>     ../src/lib/include/fwts_fileio.h /usr/include/zlib.h \
>
>     src/acpi/crsdump/.deps/fwts-prsdump.Po:/usr/include/zlib.h:
>
>      
>
>     With Warm Regards,
>     Edhay
>
>      
>
>      
>
>     *From:* Alex Hung <alex.hung at canonical.com>
>     *Sent:* 16 December 2021 00:15
>     *To:* G Edhaya Chandran <Edhaya.Chandran at arm.com>
>     *Cc:* Sunny Wang <Sunny.Wang at arm.com>; fwts-devel at lists.ubuntu.com
>     *Subject:* Re: [PATCH][V3] dmicheck: skip scanning smbios in
>     /dev/mem on aarch64
>
>      
>
>     Hi,
>
>      
>
>     I am not familiar with your ACS image but did you try solutions
>     like
>     https://unix.stackexchange.com/questions/315605/unable-to-cross-compile-openssh-for-arm-zlib-missing?
>
>      
>
>     On Mon, Dec 13, 2021 at 12:48 AM G Edhaya Chandran
>     <Edhaya.Chandran at arm.com> wrote:
>
>         Hello Alex,
>
>          
>
>            Thank you. The solution does work on our ACS Image.
>
>         Attached are the logs.
>
>          
>
>          
>
>         However I did find a build issue for including the .h file:
>
>         #include <zlib.h>
>
>          
>
>         In the Ubuntu installation that I have this file exists in
>
>         /usr/include
>
>          
>
>         When I included this path though -I/usr/include in
>         Makefile.md, it gave redefinition errors for other symbols.
>
>         So I updated the code to
>
>         #include </usr/include/zlib.h>
>
>         to complete the build.
>
>          
>
>         With Warm Regards,
>
>         Edhay
>
>          
>
>          
>
>          
>
>         *From:* Alex Hung <alex.hung at canonical.com>
>         *Sent:* 08 December 2021 04:28
>         *To:* Sunny Wang <Sunny.Wang at arm.com>
>         *Cc:* fwts-devel at lists.ubuntu.com; G Edhaya Chandran
>         <Edhaya.Chandran at arm.com>
>         *Subject:* Re: [PATCH][V3] dmicheck: skip scanning smbios in
>         /dev/mem on aarch64
>
>          
>
>         Hi Sunny,
>
>          
>
>         The attached patch also checks /proc/config.gz.
>
>          
>
>         Please give it a try and let me know whether it works or needs
>         improvement.
>
>          
>
>         On Thu, Nov 25, 2021 at 10:39 AM Sunny Wang
>         <Sunny.Wang at arm.com> wrote:
>
>             Here you go.
>
>              
>
>             Best Regards,
>
>             Sunny
>
>              
>
>             *From:* Alex Hung <alex.hung at canonical.com>
>             *Sent:* 25 November 2021 16:39
>             *To:* Sunny Wang <Sunny.Wang at arm.com>
>             *Cc:* fwts-devel at lists.ubuntu.com; G Edhaya Chandran
>             <Edhaya.Chandran at arm.com>
>             *Subject:* Re: [PATCH][V3] dmicheck: skip scanning smbios
>             in /dev/mem on aarch64
>
>              
>
>              
>
>              
>
>             On Tue, Nov 23, 2021 at 4:18 AM Sunny Wang
>             <Sunny.Wang at arm.com> wrote:
>
>                 You’re right, Alex.
>
>                 Edhaya and I just checked this. Our kernel config is
>                 in /proc/config.gz. Could you add code to handle
>                 /proc/config.gz?
>
>              
>
>             Please share a copy of config.gz for further analysis.
>
>                 For more information, please check
>                 https://superuser.com/questions/287371/obtain-kernel-config-from-currently-running-linux-system.
>
>                  
>
>                 Best Regards,
>
>                 Sunny
>
>                 *From:* Alex Hung <alex.hung at canonical.com>
>                 *Sent:* 22 November 2021 22:59
>                 *To:* Sunny Wang <Sunny.Wang at arm.com>
>                 *Cc:* fwts-devel at lists.ubuntu.com; G Edhaya Chandran
>                 <Edhaya.Chandran at arm.com>
>                 *Subject:* Re: [PATCH][V3] dmicheck: skip scanning
>                 smbios in /dev/mem on aarch64
>
>                  
>
>                 It is also possible that your ACS uses a different
>                 approach for kernel config, i.e. not
>                 /boot/config-`uname -r` like Ubuntu and fwts-live. If
>                 that's the case, this patch can be improved to include
>                 more ways for kernel config.
>
>                  
>
>                 On Mon, Nov 22, 2021 at 3:46 PM Alex Hung
>                 <alex.hung at canonical.com> wrote:
>
>                      
>
>                      
>
>                     On Mon, Nov 22, 2021 at 2:44 PM Sunny Wang
>                     <Sunny.Wang at arm.com> wrote:
>
>                         Hi Alex,
>
>                         Edhaya and I just tested the v2 patch by
>                         cherry-picking it into our ACS FWTS, and then
>                         somehow this fix doesn’t work.
>                         Does it work on your side? Could you build the
>                         FWTS live image with this fix and offline
>                         share it with us for verification?
>
>                      
>
>                     Yes it worked on my RPI4. The attached results.log
>                     contains two runs: 1st run with patch (runs to
>                     completion) and 2nd run without the patch (stopped
>                     in test 1)
>
>                      
>
>                     The fwts-live requires released version of fwts so
>                     it's not possible without major modifications. If
>                     it doesn't work I think the patch may not fix but
>                     hide the error on my systems. We will have to
>                     revisit the bug again.
>
>                      
>
>                      
>
>
>                         Best Regards,
>                         Sunny
>                         -----Original Message-----
>                         From: fwts-devel
>                         <fwts-devel-bounces at lists.ubuntu.com> On
>                         Behalf Of Alex Hung
>                         Sent: 22 November 2021 02:15
>                         To: fwts-devel at lists.ubuntu.com
>                         Subject: [PATCH][V3] dmicheck: skip scanning
>                         smbios in /dev/mem on aarch64
>
>                         Buglink: https://bugs.launchpad.net/bugs/1947786
>
>                         Signed-off-by: Alex Hung <alex.hung at canonical.com>
>                         ---
>                          src/dmi/dmicheck/dmicheck.c   | 14 +++++++
>                          src/lib/include/fwts.h        |  1 +
>                          src/lib/include/fwts_kernel.h | 25 ++++++++++++
>                          src/lib/src/Makefile.am       |  1 +
>                          src/lib/src/fwts_kernel.c     | 74
>                         +++++++++++++++++++++++++++++++++++
>                          5 files changed, 115 insertions(+)
>                          create mode 100644 src/lib/include/fwts_kernel.h
>                          create mode 100644 src/lib/src/fwts_kernel.c
>
>                         diff --git a/src/dmi/dmicheck/dmicheck.c
>                         b/src/dmi/dmicheck/dmicheck.c
>                         index 7f6a90c4..3985b126 100644
>                         --- a/src/dmi/dmicheck/dmicheck.c
>                         +++ b/src/dmi/dmicheck/dmicheck.c
>                         @@ -381,6 +381,13 @@ static void*
>                         dmi_table_smbios(fwts_framework *fw,
>                         fwts_smbios_entry *entry)
>                                         free(table);
>                                 }
>
>                         +#ifdef FWTS_ARCH_AARCH64
>                         +       if
>                         (fwts_kernel_config_set("CONFIG_STRICT_DEVMEM")) {
>                         +               fwts_warning(fw, "Skipping
>                         scanning SMBIOS table in memory for arm64
>                         systems");
>                         +               return NULL;
>                         +       }
>                         +#endif
>                         +
>                                 mem = fwts_mmap(addr, length);
>                                 if (mem != FWTS_MAP_FAILED) {
>                                         /* Can we safely copy the
>                         table? */
>                         @@ -429,6 +436,13 @@ static void*
>                         dmi_table_smbios30(fwts_framework *fw,
>                         fwts_smbios30_entry *entry)
>                                         free(table);
>                                 }
>
>                         +#ifdef FWTS_ARCH_AARCH64
>                         +       if
>                         (fwts_kernel_config_set("CONFIG_STRICT_DEVMEM")) {
>                         +               fwts_warning(fw, "Skipping
>                         scanning SMBIOS3 table in memory for arm64
>                         systems");
>                         +               return NULL;
>                         +       }
>                         +#endif
>                         +
>                                 mem = fwts_mmap(addr, length);
>                                 if (mem != FWTS_MAP_FAILED) {
>                                         /* Can we safely copy the
>                         table? */
>                         diff --git a/src/lib/include/fwts.h
>                         b/src/lib/include/fwts.h
>                         index 551a4e09..be754a99 100644
>                         --- a/src/lib/include/fwts.h
>                         +++ b/src/lib/include/fwts.h
>                         @@ -185,6 +185,7 @@
>                          #include "fwts_iasl.h"
>                          #include "fwts_ipmi.h"
>                          #include "fwts_klog.h"
>                         +#include "fwts_kernel.h"
>                          #include "fwts_olog.h"
>                          #include "fwts_pipeio.h"
>                          #include "fwts_stringextras.h"
>                         diff --git a/src/lib/include/fwts_kernel.h
>                         b/src/lib/include/fwts_kernel.h
>                         new file mode 100644
>                         index 00000000..a89576ae
>                         --- /dev/null
>                         +++ b/src/lib/include/fwts_kernel.h
>                         @@ -0,0 +1,25 @@
>                         +/*
>                         + * Copyright (C) 2021 Canonical
>                         + *
>                         + * This program is free software; you can
>                         redistribute it and/or
>                         + * modify it under the terms of the GNU
>                         General Public License
>                         + * as published by the Free Software
>                         Foundation; either version 2
>                         + * of the License, or (at your option) any
>                         later version.
>                         + *
>                         + * This program is distributed in the hope
>                         that it will be useful,
>                         + * but WITHOUT ANY WARRANTY; without even the
>                         implied warranty of
>                         + * MERCHANTABILITY or FITNESS FOR A
>                         PARTICULAR PURPOSE.  See the
>                         + * GNU General Public License for more details.
>                         + *
>                         + * You should have received a copy of the GNU
>                         General Public License
>                         + * along with this program; if not, write to
>                         the Free Software
>                         + * Foundation, Inc., 51 Franklin Street,
>                         Fifth Floor, Boston, MA 02110-1301, USA.
>                         + *
>                         + */
>                         +
>                         +#ifndef __FWTS_KERNEL_H__
>                         +#define __FWTS_KERNEL_H__
>                         +
>                         +bool fwts_kernel_config_set(const char *config);
>                         +
>                         +#endif
>                         diff --git a/src/lib/src/Makefile.am
>                         b/src/lib/src/Makefile.am
>                         index 55c52b41..0a39882a 100644
>                         --- a/src/lib/src/Makefile.am
>                         +++ b/src/lib/src/Makefile.am
>                         @@ -83,6 +83,7 @@ libfwts_la_SOURCES =          \
>                                 fwts_ioport.c           \
>                                 fwts_ipmi.c             \
>                                 fwts_json.c             \
>                         +       fwts_kernel.c           \
>                                 fwts_keymap.c           \
>                                 fwts_klog.c             \
>                                 fwts_olog.c             \
>                         diff --git a/src/lib/src/fwts_kernel.c
>                         b/src/lib/src/fwts_kernel.c
>                         new file mode 100644
>                         index 00000000..10d11a99
>                         --- /dev/null
>                         +++ b/src/lib/src/fwts_kernel.c
>                         @@ -0,0 +1,74 @@
>                         +/*
>                         + * Copyright (C) 2021 Canonical
>                         + *
>                         + * This program is free software; you can
>                         redistribute it and/or
>                         + * modify it under the terms of the GNU
>                         General Public License
>                         + * as published by the Free Software
>                         Foundation; either version 2
>                         + * of the License, or (at your option) any
>                         later version.
>                         + *
>                         + * This program is distributed in the hope
>                         that it will be useful,
>                         + * but WITHOUT ANY WARRANTY; without even the
>                         implied warranty of
>                         + * MERCHANTABILITY or FITNESS FOR A
>                         PARTICULAR PURPOSE.  See the
>                         + * GNU General Public License for more details.
>                         + *
>                         + * You should have received a copy of the GNU
>                         General Public License
>                         + * along with this program; if not, write to
>                         the Free Software
>                         + * Foundation, Inc., 51 Franklin Street,
>                         Fifth Floor, Boston, MA 02110-1301, USA.
>                         + *
>                         + */
>                         +
>                         +#include <sys/utsname.h>
>                         +
>                         +#include "fwts.h"
>                         +#include "fwts_kernel.h"
>                         +#include <stdlib.h>
>                         +#include <stdio.h>
>                         +#include <bsd/string.h>
>                         +
>                         +#define CONFIG_FILE_PREFIX     "/boot/config-"
>                         +
>                         +/*
>                         + *  fwts_kernel_config_set
>                         + *      check whether a kernel config is set, ex.
>                         + *      true if CONFIG_XYZ=y or CONFIG_XYZ=m
>                         + */
>                         +bool fwts_kernel_config_set(const char *config)
>                         +{
>                         +       const size_t config_str_len =
>                         strlen(config) + 3;
>                         +       char config_file[PATH_MAX];
>                         +       char config_str[255];
>                         +       size_t config_file_len;
>                         +       fwts_list* config_list;
>                         +       fwts_list_link *item;
>                         +       struct utsname buf;
>                         +
>                         +       /* get path of config file, i.e.
>                         /boot/config-5.11.0-38-generic */
>                         +       uname(&buf);
>                         +       config_file_len =
>                         strlen(CONFIG_FILE_PREFIX) +
>                         strlen(buf.release) + 1;
>                         +       (void)strlcpy(config_file,
>                         CONFIG_FILE_PREFIX, config_file_len);
>                         +       (void)strlcat(config_file,
>                         buf.release, config_file_len);
>                         +
>                         +       config_list =
>                         fwts_file_open_and_read(config_file);
>                         +       if (config_list == NULL)
>                         +               return false;
>                         +
>                         +       fwts_list_foreach(item, config_list) {
>                         +               /* check built-in, i.e. =y */
>                         +               (void)strlcpy(config_str,
>                         config, config_str_len);
>                         +               (void)strlcat(config_str,
>                         "=y", config_str_len);
>                         +               if
>                         (!strncmp(fwts_text_list_text(item),
>                         config_str, strlen(config_str))) {
>                         +                     
>                          fwts_list_free(config_list, free);
>                         +                       return true;
>                         +               }
>                         +
>                         +               /* check module, i.e. =m */
>                         +               config_str[strlen(config_str)
>                         - 1] = 'm';
>                         +               if
>                         (!strncmp(fwts_text_list_text(item),
>                         config_str, strlen(config_str))) {
>                         +                     
>                          fwts_list_free(config_list, free);
>                         +                       return true;
>                         +               }
>                         +       }
>                         +
>                         +       fwts_list_free(config_list, free);
>                         +       return false;
>                         +}
>                         --
>                         2.32.0
>
>
>                         --
>                         fwts-devel mailing list
>                         fwts-devel at lists.ubuntu.com
>                         Modify settings or unsubscribe at:
>                         https://lists.ubuntu.com/mailman/listinfo/fwts-devel
>                         IMPORTANT NOTICE: The contents of this email
>                         and any attachments are confidential and may
>                         also be privileged. If you are not the
>                         intended recipient, please notify the sender
>                         immediately and do not disclose the contents
>                         to any other person, use it for any purpose,
>                         or store or copy the information in any
>                         medium. Thank you.
>
>
>
>                     -- 
>
>                     Cheers,
>                     Alex Hung
>
>
>
>                 -- 
>
>                 Cheers,
>                 Alex Hung
>
>                 IMPORTANT NOTICE: The contents of this email and any
>                 attachments are confidential and may also be
>                 privileged. If you are not the intended recipient,
>                 please notify the sender immediately and do not
>                 disclose the contents to any other person, use it for
>                 any purpose, or store or copy the information in any
>                 medium. Thank you.
>
>
>
>             -- 
>
>             Cheers,
>             Alex Hung
>
>             IMPORTANT NOTICE: The contents of this email and any
>             attachments are confidential and may also be privileged.
>             If you are not the intended recipient, please notify the
>             sender immediately and do not disclose the contents to any
>             other person, use it for any purpose, or store or copy the
>             information in any medium. Thank you.
>
>
>
>         -- 
>
>         Cheers,
>         Alex Hung
>
>         IMPORTANT NOTICE: The contents of this email and any
>         attachments are confidential and may also be privileged. If
>         you are not the intended recipient, please notify the sender
>         immediately and do not disclose the contents to any other
>         person, use it for any purpose, or store or copy the
>         information in any medium. Thank you.
>
>
>
>     -- 
>
>     Cheers,
>     Alex Hung
>
>     IMPORTANT NOTICE: The contents of this email and any attachments
>     are confidential and may also be privileged. If you are not the
>     intended recipient, please notify the sender immediately and do
>     not disclose the contents to any other person, use it for any
>     purpose, or store or copy the information in any medium. Thank you.
>
>
>
> -- 
>
> Cheers,
> Alex Hung
>
> IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose
> the contents to any other person, use it for any purpose, or store or
> copy the information in any medium. Thank you. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20220330/43d9e512/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 378574 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20220330/43d9e512/attachment-0001.png>


More information about the fwts-devel mailing list