[PATCH v2 2/2] uefi: fix fwts_uefi_rt_support_status_get()

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Jan 6 07:59:08 UTC 2021


On 06.01.21 07:23, ivanhu wrote:
>
>
> On 12/29/20 2:57 AM, Heinrich Schuchardt wrote:
>> The UEFI 2.8 Errata A specification has clarified that
>> RuntimeServicesSupported is not a UEFI variable but a value in the
>> EFI_RT_PROPERTIES_TABLE configuration table. Since Linux 5.11 the value can
>> be retrieved via an IOCTL call.
>>
>> Replace the code trying to read the non-existent RuntimeServicesSupported
>> variable by the IOCTL call.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
>> ---
>>  src/lib/include/fwts_uefi.h              |  4 +-
>>  src/lib/src/fwts_uefi.c                  | 49 +++++-----------
>>  src/uefi/uefirtmisc/uefirtmisc.c         | 27 ++++-----
>>  src/uefi/uefirttime/uefirttime.c         | 72 ++++++++++--------------
>>  src/uefi/uefirtvariable/uefirtvariable.c | 72 ++++++++++--------------
>>  5 files changed, 87 insertions(+), 137 deletions(-)
>>
>> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
>> index 36cd5824..24e2962e 100644
>> --- a/src/lib/include/fwts_uefi.h
>> +++ b/src/lib/include/fwts_uefi.h
>> @@ -137,6 +137,8 @@ enum {
>>  #define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES	0x1000
>>  #define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO		0x2000
>>
>> +#define EFI_RT_SUPPORTED_ALL				0x3fff
>> +
>>  #define EFI_CERT_SHA256_GUID \
>>  { 0xc1c41626, 0x504c, 0x4092, { 0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28 }}
>>
>> @@ -680,7 +682,7 @@ char *fwts_uefi_attribute_info(uint32_t attr);
>>
>>  bool fwts_uefi_efivars_iface_exist(void);
>>
>> -void fwts_uefi_rt_support_status_get(int fd, bool *getvar_supported, uint32_t *var_rtsupported);
>> +void fwts_uefi_rt_support_status_get(int fd, bool *have_rtsupported, uint32_t *var_rtsupported);
>>
>>  PRAGMA_POP
>>
>> diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
>> index 0fb6b799..131e187b 100644
>> --- a/src/lib/src/fwts_uefi.c
>> +++ b/src/lib/src/fwts_uefi.c
>> @@ -541,45 +541,26 @@ bool fwts_uefi_efivars_iface_exist(void)
>>
>>  /*
>>   *  fwts_uefi_rt_support_status_get()
>> - *	get the status of runtime service support and the value of
>> - *	the RuntimeServicesSupported variable
>> + *	get the status of runtime service support.
>> + *
>> + *	Since UEFI 2.8 Errata A the EFI_RT_PROPERTIES_TABLE configuration table
>> + *	can be used to indicate which UEFI runtime services are not implemented
>> + *	via the bitmask RuntimeServicesSupported. If the table is not present,
>> + *	all runtime services are to be considered available. Since Linux 5.11
>> + *	this bitmask can be read via an IOCTL call. Before Linux 5.11 the value
>> + *	cannot be determined.
>>   */
>> -void fwts_uefi_rt_support_status_get(int fd, bool *getvar_supported, uint32_t *var_rtsupported)
>> +void fwts_uefi_rt_support_status_get(int fd, bool *have_rtsupported, uint32_t *var_rtsupported)
>>  {
>>  	long ioret;
>> -	struct efi_getvariable getvariable;
>> -	uint64_t status = ~0ULL;
>> -	uint8_t data[512];
>> -	uint64_t getdatasize = sizeof(data);
>> -	*var_rtsupported = 0xFFFF;
>> -
>> -	uint32_t attributes = FWTS_UEFI_VAR_NON_VOLATILE |
>> -				FWTS_UEFI_VAR_BOOTSERVICE_ACCESS |
>> -				FWTS_UEFI_VAR_RUNTIME_ACCESS;
>> -	static uint16_t varname[] = {'R', 'u', 'n', 't', 'i', 'm', 'e', 'S', 'e',
>> -				'r', 'v', 'i', 'c', 'e', 's', 'S', 'u', 'p',
>> -				'p', 'o', 'r', 't', 'e', 'd', '\0'};
>> -	EFI_GUID global_var_guid = EFI_GLOBAL_VARIABLE;
>> -	getvariable.VariableName = varname;
>> -	getvariable.VendorGuid = &global_var_guid;
>> -	getvariable.Attributes = &attributes;
>> -	getvariable.DataSize = &getdatasize;
>> -	getvariable.Data = data;
>> -	getvariable.status = &status;
>> -
>> -	ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, &getvariable);
>> +
>> +	ioret = ioctl(fd, EFI_RUNTIME_GET_SUPPORTED_MASK, var_rtsupported);
>>  	if (ioret == -1) {
>> -		if (status == EFI_NOT_FOUND) {
>> -			*getvar_supported = true;
>> -		} else {
>> -			*getvar_supported = false;
>> -		}
>> -		return;
>> +		*have_rtsupported = false;
>> +		*var_rtsupported = EFI_RT_SUPPORTED_ALL;
>> +	} else {
>> +		*have_rtsupported = true;
>>  	}
>>
>> -	*getvar_supported = true;
>> -	*var_rtsupported = data[0] | data[1] << 8;
>> -
>>  	return;
>> -
>>  }
>> diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c
>> index a2dc6967..c0d3835a 100644
>> --- a/src/uefi/uefirtmisc/uefirtmisc.c
>> +++ b/src/uefi/uefirtmisc/uefirtmisc.c
>> @@ -245,20 +245,18 @@ static int uefirtmisc_test4(fwts_framework *fw)
>>  {
>>  	long ioret;
>>  	uint64_t status;
>> -	bool getvar_supported;
>> +	bool have_rtsupported;
>>  	uint32_t var_runtimeservicessupported;
>>
>>  	struct efi_getnexthighmonotoniccount getnexthighmonotoniccount;
>>  	uint32_t highcount;
>>
>> -	fwts_uefi_rt_support_status_get(fd, &getvar_supported,
>> +	fwts_uefi_rt_support_status_get(fd, &have_rtsupported,
>>  			&var_runtimeservicessupported);
>> -	if (!getvar_supported || (var_runtimeservicessupported == 0xFFFF)) {
>> +	if (!have_rtsupported) {
>>  		fwts_skipped(fw, "Cannot get the RuntimeServicesSupported "
>> -				"variable, maybe the runtime service "
>> -				"GetVariable is not supported or "
>> -				"RuntimeServicesSupported not provided by "
>> -				"firmware.");
>> +				 "mask from the kernel. This IOCTL was "
>> +				 "introduced in Linux v5.11.");
>
> Not only kernel need to support this IOCTL, but Bios need to support the
> RuntimeServicesSupported from system config table. Please also add some
> description for the skip reasons that maybe from the Bios not support
> RuntimeServicesSupported(UEFI 2.8a).

Hello Ivan,

thanks for reviewing.

I do not understand what you mean by "but Bios need to support the
RuntimeServicesSupported from system config table".

UEFI firmware will only expose an EFI_RT_PROPERTIES_TABLE if a runtime
service is *not* implemented. If EFI_RT_PROPERTIES_TABLE is not exposed,
this signals all runtime services are implemented.

For UEFI <= 2.7 EFI_RT_PROPERTIES_TABLE does not exist but the firmware
is obliged to implement all runtime services.

For UEFI >= 2.8A EFI_RT_PROPERTIES_TABLE is only required if any of the
runtime services is *not* implemented.

Linux will correctly consider all runtime services as available if
EFI_RT_PROPERTIES_TABLE does not exist in the firmware.

See drivers/firmware/efi/efi.c. Here runtime_supported_mask defaults to
EFI_RT_SUPPORTED_ALL (0x3fff). Only if the firmware exposes an
EFI_RT_PROPERTIES_TABLE Linux sets runtime_supported_mask to the actual
value of RuntimeServicesSupported in function efi_config_parse_tables().

The only reason for skipping here is a Linux version below 5.11.

Best regards

Heinrich

>
>>  		return FWTS_SKIP;
>>  	}
>>
>> @@ -268,13 +266,12 @@ static int uefirtmisc_test4(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT, &getnexthighmonotoniccount);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH,
>>  					"UEFIRuntimeGetNextHighMonotonicCount",
>>  					"Get the GetNextHighMonotonicCount runtime "
>>  					"service supported via RuntimeServicesSupported "
>> -					"variable. But actually is not supported by "
>> +					"mask. But actually is not supported by "
>>  					"firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI GetNextHighMonotonicCount runtime "
>> @@ -285,8 +282,7 @@ static int uefirtmisc_test4(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) {
>>  				fwts_passed(fw, "UEFI GetNextHighMonotonicCount runtime "
>>  					"service supported status test passed.");
>>  			} else {
>> @@ -294,7 +290,7 @@ static int uefirtmisc_test4(fwts_framework *fw)
>>  					"UEFIRuntimeGetNextHighMonotonicCount",
>>  					"Get the GetNextHighMonotonicCount runtime "
>>  					"service unsupported via RuntimeServicesSupported "
>> -					"variable. But actually is supported by firmware.");
>> +					"mask. But actually is supported by firmware.");
>>  			}
>>  		}
>>  	} else {
>> @@ -302,8 +298,7 @@ static int uefirtmisc_test4(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) {
>>  			fwts_passed(fw, "UEFI GetNextHighMonotonicCount runtime "
>>  				"service supported status test passed.");
>>  		} else {
>> @@ -311,7 +306,7 @@ static int uefirtmisc_test4(fwts_framework *fw)
>>  				"UEFIRuntimeGetNextHighMonotonicCount",
>>  				"Get the GetNextHighMonotonicCount runtime "
>>  				"service unsupported via RuntimeServicesSupported "
>> -				"variable. But actually is supported by firmware.");
>> +				"mask. But actually is supported by firmware.");
>>  		}
>>  	}
>>
>> diff --git a/src/uefi/uefirttime/uefirttime.c b/src/uefi/uefirttime/uefirttime.c
>> index e0aa7071..3bbac718 100644
>> --- a/src/uefi/uefirttime/uefirttime.c
>> +++ b/src/uefi/uefirttime/uefirttime.c
>> @@ -1142,7 +1142,7 @@ static int uefirttime_test37(fwts_framework *fw)
>>  static int uefirttime_test38(fwts_framework *fw)
>>  {
>>  	long ioret;
>> -	bool getvar_supported;
>> +	bool have_rtsupported;
>>  	uint32_t var_runtimeservicessupported;
>>
>>  	struct efi_settime settime;
>> @@ -1155,15 +1155,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  	EFI_TIME efi_time;
>>  	EFI_TIME_CAPABILITIES efi_time_cap;
>>
>> -	fwts_uefi_rt_support_status_get(fd, &getvar_supported,
>> +	fwts_uefi_rt_support_status_get(fd, &have_rtsupported,
>>  			&var_runtimeservicessupported);
>>
>> -	if (!getvar_supported || (var_runtimeservicessupported == 0xFFFF)) {
>> +	if (!have_rtsupported) {
>>  		fwts_skipped(fw, "Cannot get the RuntimeServicesSupported "
>> -				"variable, maybe the runtime service "
>> -				"GetVariable is not supported or "
>> -				"RuntimeServicesSupported not provided by "
>> -				"firmware.");
>> +				 "mask from the kernel. This IOCTL was "
>> +				 "introduced in Linux v5.11.");
>
> same here.
>
>>  		return FWTS_SKIP;
>>  	}
>>
>> @@ -1173,11 +1171,10 @@ static int uefirttime_test38(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_GET_TIME, &gettime);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetTime",
>>  					"Get the GetTime runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI GetTime runtime service "
>> @@ -1188,14 +1185,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME) {
>>  				fwts_passed(fw, "UEFI GetTime runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetTime",
>>  					"Get the GetTime runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -1204,14 +1200,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME) {
>>  			fwts_passed(fw, "UEFI GetTime runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetTime",
>>  				"Get the GetTime runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> @@ -1223,11 +1218,10 @@ static int uefirttime_test38(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_SET_TIME, &settime);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetTime",
>>  					"Get the SetTime runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI SetTime runtime service "
>> @@ -1238,14 +1232,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME) {
>>  				fwts_passed(fw, "UEFI SetTime runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetTime",
>>  					"Get the SetTime runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -1254,14 +1247,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME) {
>>  			fwts_passed(fw, "UEFI SetTime runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetTime",
>>  				"Get the SetTime runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> @@ -1274,11 +1266,10 @@ static int uefirttime_test38(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_SET_WAKETIME, &setwakeuptime);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetWakeupTime",
>>  					"Get the SetWakeupTime runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware");
>>
>>  			} else {
>> @@ -1290,14 +1281,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME) {
>>  				fwts_passed(fw, "UEFI SetWakeupTime runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetWakeupTime",
>>  					"Get the SetWakeupTime runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -1306,14 +1296,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME) {
>>  			fwts_passed(fw, "UEFI SetWakeupTime runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetWakeupTime",
>>  				"Get the SetWakeupTime runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> @@ -1326,11 +1315,10 @@ static int uefirttime_test38(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_GET_WAKETIME, &getwakeuptime);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetWakeupTime",
>>  					"Get the GetWakeupTime runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware");
>>  			} else {
>>  				fwts_passed(fw, "UEFI GetWakeupTime runtime service "
>> @@ -1341,14 +1329,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME) {
>>  				fwts_passed(fw, "UEFI GetWakeupTime runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetWakeupTime",
>>  					"Get the GetWakeupTime runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware");
>>  			}
>>  		}
>> @@ -1357,14 +1344,13 @@ static int uefirttime_test38(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknow error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME) {
>>  			fwts_passed(fw, "UEFI GetWakeupTime runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetWakeupTime",
>>  				"Get the GetWakeupTime runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware");
>>  		}
>>  	}
>> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
>> index 713803dc..1fcde5e4 100644
>> --- a/src/uefi/uefirtvariable/uefirtvariable.c
>> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
>> @@ -2020,7 +2020,7 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  {
>>  	long ioret;
>>
>> -	bool getvar_supported;
>> +	bool have_rtsupported;
>>  	uint32_t var_runtimeservicessupported;
>>
>>  	struct efi_getvariable getvariable;
>> @@ -2041,15 +2041,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  	uint64_t getdatasize = sizeof(testdata);
>>  	uint32_t attr;
>>
>> -	fwts_uefi_rt_support_status_get(fd, &getvar_supported,
>> +	fwts_uefi_rt_support_status_get(fd, &have_rtsupported,
>>  			&var_runtimeservicessupported);
>>
>> -	if (!getvar_supported || (var_runtimeservicessupported == 0xFFFF)) {
>> +	if (!have_rtsupported) {
>>  		fwts_skipped(fw, "Cannot get the RuntimeServicesSupported "
>> -				"variable, maybe the runtime service "
>> -				"GetVariable is not supported or "
>> -				"RuntimeServicesSupported not provided by "
>> -				"firmware.");
>> +				 "mask from the kernel. This IOCTL was "
>> +				 "introduced in Linux v5.11.");
>
> same here.
>
> Cheers,
> Ivan
>
>>  		return FWTS_SKIP;
>>  	}
>>
>> @@ -2063,11 +2061,10 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
>>  					"Get the Setvariable runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI SetVariable runtime service "
>> @@ -2078,14 +2075,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE) ||
>> -				(var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE) {
>>  				fwts_passed(fw, "UEFI SetVariable runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
>>  					"Get the SetVariable runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -2094,14 +2090,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE) ||
>> -			(var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE) {
>>  			fwts_passed(fw, "UEFI SetVariable runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
>>  				"Get the SetVariable runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> @@ -2116,11 +2111,10 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, &getvariable);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable",
>>  					"Get the GetVariable runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI GetVariable runtime service "
>> @@ -2131,14 +2125,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE) ||
>> -				(var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE) {
>>  				fwts_passed(fw, "UEFI GetVariable runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable",
>>  					"Get the GetVariable runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -2147,14 +2140,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE) ||
>> -			(var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE) {
>>  			fwts_passed(fw, "UEFI GetVariable runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable",
>>  				"Get the GetVariable runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> @@ -2179,11 +2171,10 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTVARIABLENAME, &getnextvariablename);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextVarName",
>>  					"Get the GetNextVarName runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI GetNextVarName runtime service "
>> @@ -2194,14 +2185,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME) {
>>  				fwts_passed(fw, "UEFI GetNextVarName runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextVarName",
>>  					"Get the GetNextVarName runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -2210,14 +2200,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME) {
>>  			fwts_passed(fw, "UEFI GetNextVarName runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextVarName",
>>  				"Get the GetNextVarName runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> @@ -2232,11 +2221,10 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  	ioret = ioctl(fd, EFI_RUNTIME_QUERY_VARIABLEINFO, &queryvariableinfo);
>>  	if (ioret == -1) {
>>  		if (status == EFI_UNSUPPORTED) {
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO) {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeQueryVarInfo",
>>  					"Get the QueryVarInfo runtime service supported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is not supported by firmware.");
>>  			} else {
>>  				fwts_passed(fw, "UEFI QueryVarInfo runtime service "
>> @@ -2247,14 +2235,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  				fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  				return FWTS_SKIP;
>>  			}
>> -			if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)
>> -				|| (var_runtimeservicessupported == 0)) {
>> +			if (var_runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO) {
>>  				fwts_passed(fw, "UEFI QueryVarInfo runtime service "
>>  					"supported status test passed.");
>>  			} else {
>>  				fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeQueryVarInfo",
>>  					"Get the QueryVarInfo runtime service unsupported "
>> -					"via RuntimeServicesSupported variable. "
>> +					"via RuntimeServicesSupported mask. "
>>  					"But actually is supported by firmware.");
>>  			}
>>  		}
>> @@ -2263,14 +2250,13 @@ static int uefirtvariable_test9(fwts_framework *fw)
>>  			fwts_skipped(fw, "Unknown error occurred, skip test.");
>>  			return FWTS_SKIP;
>>  		}
>> -		if ((var_runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)
>> -			|| (var_runtimeservicessupported == 0)) {
>> +		if (var_runtimeservicessupported & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO) {
>>  			fwts_passed(fw, "UEFI QueryVarInfo runtime service "
>>  				"supported status test passed.");
>>  		} else {
>>  			fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeQueryVarInfo",
>>  				"Get the QueryVarInfo runtime service unsupported "
>> -				"via RuntimeServicesSupported variable. "
>> +				"via RuntimeServicesSupported mask. "
>>  				"But actually is supported by firmware.");
>>  		}
>>  	}
>> --
>> 2.29.2
>>




More information about the fwts-devel mailing list