efivar fails to read variables

Bug #2034705 reported by Heinrich Schuchardt
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
efivar (Ubuntu)
Invalid
Undecided
Unassigned
linux-meta-riscv (Ubuntu)
In Progress
High
Unassigned

Bug Description

On riscv64 StarFive VisionFive 2 with U-Boot v2023.10-rc4 and kernel 6.5.0-2-generic we see this output:

root@ubuntu-server:/var# ls /sys/firmware/efi/efivars/
AuditMode-8be4df61-93ca-11d2-aa0d-00e098032b8c
DeployedMode-8be4df61-93ca-11d2-aa0d-00e098032b8c
OsIndicationsSupported-8be4df61-93ca-11d2-aa0d-00e098032b8c
PlatformLang-8be4df61-93ca-11d2-aa0d-00e098032b8c
PlatformLangCodes-8be4df61-93ca-11d2-aa0d-00e098032b8c
SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c
SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c
VendorKeys-8be4df61-93ca-11d2-aa0d-00e098032b8c

root@ubuntu-server:/var# efivar -l
efivar: error listing variables: Function not implemented

root@ubuntu-server:/var# efibootmgr -v
EFI variables are not supported on this system.

Expected behavior would be to display the variables.

tags: added: foundations-todo
tags: added: fr-5276
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

The problem is due to the kernel not supporting the deprecated statfs() call on the efivarfs file system.

To demonstrate this I have created the following program (statfs.c):

#include <sys/vfs.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
        struct statfs s;
        int ret;

        if (argc < 2) {
                printf("usage: %s <dirpath>\n", argv[0]);
                return 1;
        }

        ret = statfs(argv[1], &s);
        if (ret == -1) {
                perror("statfs");
                return 1;
        } else {
                printf("%s type: 0x%llx\n", argv[1],
                       (unsigned long long)s.f_type);
        }
        return 0;
}

When I run it I get the following output:

$ ./statfs /sys/firmware/efi
/sys/firmware/efi type: 0x62656572
$ ./statfs /sys/firmware/efi/efivars/
statfs: Invalid argument
$ mount | grep efivarfs
efivarfs on /sys/firmware/efi/efivars type efivarfs (ro,nosuid,nodev,noexec,relatime)

Though efivarfs is mounted on /sys/firmware/efi/efivars the statfs call fails.

Revision history for this message
Heinrich Schuchardt (xypron) wrote (last edit ):

Kernel commit d86ff3333cb1 ("efivarfs: expose used and total size") introduced an EFI runtime call QueryVariableInfo().

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

In U-Boot's EFI_RT_PROPERTIES_TABLE_VERSION the flag EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO is not set.

Revision history for this message
Heinrich Schuchardt (xypron) wrote (last edit ):

U-Boot currently does not implement QueryVariableInfo at runtime. This function is not needed for a read only efivarfs. I think it would be more appropriate to check if GetVariable is enabled in efi.runtime_supported_mask.

Changed in efivar (Ubuntu):
status: New → Invalid
Revision history for this message
Heinrich Schuchardt (xypron) wrote :
Changed in linux-meta-riscv (Ubuntu):
assignee: nobody → Heinrich Schuchardt (xypron)
importance: Undecided → High
status: New → In Progress
tags: added: patch
Revision history for this message
Heinrich Schuchardt (xypron) wrote (last edit ):

Patch sent upstream https://lore<email address hidden>/T/#u

Without this patch the Ubuntu installer on systems using U-Boot (e.g. riscv64) will fail.

Changed in linux-meta-riscv (Ubuntu):
assignee: Heinrich Schuchardt (xypron) → nobody
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

With kernel 6.5.0-6-generic #6.1-Ubuntu SMP Thu Sep 21 12:51:18 from ppa:esmil/ppa efivar works fine.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.