From patchwork Wed Oct 27 23:56:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1547220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=OXgT9FRk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hflwd5K6hz9t0Y for ; Thu, 28 Oct 2021 10:57:05 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mfsmv-00020b-Ti; Wed, 27 Oct 2021 23:56:57 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mfsmt-00020U-9u for fwts-devel@lists.ubuntu.com; Wed, 27 Oct 2021 23:56:55 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 287663F173 for ; Wed, 27 Oct 2021 23:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1635379015; bh=ZsJC2eSTmVP4cio2Fwj7OCa0U1S5sVd+7TMX3mtsiIc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OXgT9FRkZczUDY8LJC7ozDcWYmYN3gf1p/rtaRdeDqLZ0o03VGqcWREQ0x0geV4ru iWl06JJYTrkubRpriKJybZUXnedPkqlrc7UWbwLLGIBMz4MdLmKW1isO6jhwVfsO1y cLZen8zbyVl7alfsNVAoV8COpOwHC+9M0303voA8obdEYWScm/kjt858nQZb7E2n0X cXst/vkOPZ4bigQhSAApzxNsnXZ3wOQ0PJL1oo6BrKHIiE6UC22G2LiuUoNmskMV3m zvEnEgSN9GZvFnrjTeQHCkRVZXRs6n/LOKd6ipKhJOE73Q6+BxPaRJT0UevSArfu4U 99EUShLdqqNiw== Received: by mail-pg1-f199.google.com with SMTP id u5-20020a63d3450000b029023a5f6e6f9bso2310346pgi.21 for ; Wed, 27 Oct 2021 16:56:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZsJC2eSTmVP4cio2Fwj7OCa0U1S5sVd+7TMX3mtsiIc=; b=N9bDQPlKvHGr6qpfsQZ+x/Ih9p2zfKMiKaCmUGKDG8z43/TBtCvcVjHds7ZvLQg0br +cbivl/FBFRpewd5y5KkEp+ZmRWDDu2wrPU7YPf9RQ4JrKTmySKlJg1lW5Mr0sBZHAm6 C8ixIbirOsDcrpZX+OFvBzYbv4u45oWmcCVC0m+fgl/09IXvSFdMa2DdONG7mihC8i61 orh8m9c5HRLGSYrboPdzuNWQQ0aiSUqssk9seXl8Jlc5prMMbSSGP9vsu3x1f82LBZHt cbsoq9H6r6Je4y2rnt2xynzI4UjIT6zTWZAIP5nykmBjCecRMKIFkxQJ15bIJ+2eeb+c TY8g== X-Gm-Message-State: AOAM533FvyMaCcEwJRJXAwNFD7826qd2/wHt9eBDHzP/O/jMoR3GmKKd z5E8Xd+67dxiqJTwcGAN0Lxkd6v3dshAHCCA15eu1zPTh4cwUK8BRnipSZB8JRnLofqQz7Ow3i0 lUi1NP9DGJ/PkXT8xGBdKOBzmPkIKG73J9Z61FULJ X-Received: by 2002:a17:903:120c:b0:13f:d043:3477 with SMTP id l12-20020a170903120c00b0013fd0433477mr603648plh.89.1635379013329; Wed, 27 Oct 2021 16:56:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTdHh5luAILT5+WjkLjI7bLc2+wbHLBlbqnN16QW7gUxvS3/7GvOUkRnnABU6xq6Ri7isMIA== X-Received: by 2002:a17:903:120c:b0:13f:d043:3477 with SMTP id l12-20020a170903120c00b0013fd0433477mr603631plh.89.1635379012959; Wed, 27 Oct 2021 16:56:52 -0700 (PDT) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmghm.ipv6.telus.net. [2001:56a:78ed:fb00::dfa]) by smtp.gmail.com with ESMTPSA id w13sm5320650pjc.29.2021.10.27.16.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 16:56:52 -0700 (PDT) From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] dmicheck: skip scanning smbios in /dev/mem on aarch64 Date: Wed, 27 Oct 2021 17:56:50 -0600 Message-Id: <20211027235650.1272555-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edhaya.chandran@arm.com Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Buglink: https://bugs.launchpad.net/bugs/1947786 Signed-off-by: Alex Hung Signed-off-by: Alex Hung --- src/dmi/dmicheck/dmicheck.c | 5 +++ 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, 106 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..2b47a41f 100644 --- a/src/dmi/dmicheck/dmicheck.c +++ b/src/dmi/dmicheck/dmicheck.c @@ -381,6 +381,11 @@ 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")) + 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 + +#include "fwts.h" +#include "fwts_kernel.h" +#include +#include +#include + +#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; +}