efi/efi_test: read RuntimeServicesSupported
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 27 Nov 2020 19:20:51 +0000 (20:20 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 9 Dec 2020 07:37:27 +0000 (08:37 +0100)
Since the UEFI 2.8A specification the UEFI enabled firmware provides a
configuration table EFI_RT_PROPERTIES_TABLE which indicates which runtime
services are enabled. The EFI stub reads this table and saves the value of
the field RuntimeServicesSupported internally.

The Firmware Test Suite requires the value to determine if UEFI runtime
services are correctly implemented.

With this patch an IOCTL call is provided to read the value of the field
RuntimeServicesSupported, e.g.

    #define EFI_RUNTIME_GET_SUPPORTED_MASK \
            _IOR('p', 0x0C, unsigned int)
    unsigned int mask;
    fd = open("/dev/efi_test", O_RDWR);
    ret = ioctl(fd, EFI_RUNTIME_GET_SUPPORTED_MASK, &mask);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Link: https://lore.kernel.org/r/20201127192051.1430-1-xypron.glpk@gmx.de
Acked-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Ivan Hu <ivan.hu@canonical.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/test/efi_test.c
drivers/firmware/efi/test/efi_test.h

index ddf9eae396fe1c9f3333c0c2431ec161cb8c5767..47d67bb0a516d6b5d1864c0d80d84fb66b5e781b 100644 (file)
@@ -663,6 +663,19 @@ out:
        return rv;
 }
 
+static long efi_runtime_get_supported_mask(unsigned long arg)
+{
+       unsigned int __user *supported_mask;
+       int rv = 0;
+
+       supported_mask = (unsigned int *)arg;
+
+       if (put_user(efi.runtime_supported_mask, supported_mask))
+               rv = -EFAULT;
+
+       return rv;
+}
+
 static long efi_test_ioctl(struct file *file, unsigned int cmd,
                                                        unsigned long arg)
 {
@@ -699,6 +712,9 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd,
 
        case EFI_RUNTIME_RESET_SYSTEM:
                return efi_runtime_reset_system(arg);
+
+       case EFI_RUNTIME_GET_SUPPORTED_MASK:
+               return efi_runtime_get_supported_mask(arg);
        }
 
        return -ENOTTY;
index f2446aa1c2e3d841aacfb0adc423c1b52a695ec1..117349e579937e704e73e57488c18d282382e3ed 100644 (file)
@@ -118,4 +118,7 @@ struct efi_resetsystem {
 #define EFI_RUNTIME_RESET_SYSTEM \
        _IOW('p', 0x0B, struct efi_resetsystem)
 
+#define EFI_RUNTIME_GET_SUPPORTED_MASK \
+       _IOR('p', 0x0C, unsigned int)
+
 #endif /* _DRIVERS_FIRMWARE_EFI_TEST_H_ */