ACK: [PATCH 1/2][V2] lib: fwts_acpi_tables: add option for dump acpi table from sysfs

Colin Ian King colin.king at canonical.com
Mon Jun 22 14:12:00 UTC 2020


On 16/06/2020 12:20, Ivan Hu wrote:
> Currently, fwts acpi table acpidumping first read from /dev/mem/,
> it is the same as acpidump -c off, it will missing some customized tables.
> Add --dump-acpi-from-sysfs option for user to first dump acpi tables
> from sysfs, which sync up with acpidump tool and keep the flexibilty.
> 
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
>  src/lib/include/fwts_framework.h |  4 +++-
>  src/lib/src/fwts_acpi_tables.c   | 20 +++++++++++++++-----
>  src/lib/src/fwts_framework.c     |  4 ++++
>  3 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index dddc2fda..eb8278b8 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -63,7 +63,9 @@ typedef enum {
>  	FWTS_FLAG_TEST_COMPLIANCE_ACPI		= 0x00800000,
>  	FWTS_FLAG_TEST_SBBR			= 0x01000000,
>  	FWTS_FLAG_TEST_EBBR			= 0x02000000,
> -	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR
> +	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR,
> +	FWTS_FLAG_DUMP_ACPI_FROM_SYSFS		= 0x08000000,
> +
>  } fwts_framework_flags;
>  
>  #define FWTS_FLAG_TEST_MASK		\
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 3b1d7887..90d4a50d 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1214,12 +1214,22 @@ int fwts_acpi_load_tables(fwts_framework *fw)
>  		ret = fwts_acpi_load_tables_from_acpidump(fw);
>  		require_fixup = true;
>  	} else if (fwts_check_root_euid(fw, true) == FWTS_OK) {
> -		ret = fwts_acpi_load_tables_from_firmware(fw);
> -
> -		/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> -		if (ret != FWTS_OK) {
> +		if (!(fw->flags & FWTS_FLAG_DUMP_ACPI_FROM_SYSFS)) {
> +			ret = fwts_acpi_load_tables_from_firmware(fw);
> +
> +			/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> +			if (ret != FWTS_OK) {
> +				ret = fwts_acpi_load_tables_from_sysfs(fw);
> +				require_fixup = true;
> +			}			
> +		} else {
> +			/* Load from sysfs */
>  			ret = fwts_acpi_load_tables_from_sysfs(fw);
> -			require_fixup = true;
> +			if (ret != FWTS_OK) {
> +				/* Load from sysfs failed, try from mem(e.g. /dev/mem) */
> +				ret = fwts_acpi_load_tables_from_firmware(fw);
> +			} else
> +				require_fixup = true;
>  		}
>  	} else {
>  		ret = FWTS_ERROR_NO_PRIV;
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index e1e896bb..424092f1 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -139,6 +139,7 @@ static fwts_option fwts_framework_options[] = {
>  	{ "ifv",		"",   0, "Run tests in firmware-vendor modes." },
>  	{ "clog",		"",   1, "Specify a coreboot logfile dump" },
>  	{ "ebbr",		"",   0, "Run ARM EBBR tests." },
> +	{ "dump-acpi-from-sysfs","",  0, "Specify dumping acpi table log default from sysfs." },
>  	{ NULL, NULL, 0, NULL }
>  };
>  
> @@ -1347,6 +1348,9 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  		case 49: /* --ebbr */
>  			fw->flags |= FWTS_FLAG_TEST_EBBR;
>  			break;
> +		case 50: /* --dump-acpi-from-sysfs */
> +			fw->flags |= FWTS_FLAG_DUMP_ACPI_FROM_SYSFS;
> +			break;
>  		}
>  		break;
>  	case 'a': /* --all */
> 
Acked-by: Colin Ian King <colin.king at canonical.com>



More information about the fwts-devel mailing list