Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi/efi_test: read RuntimeServicesSupported

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>

authored by

Heinrich Schuchardt and committed by
Ard Biesheuvel
ff20661b c0249238

+19
+16
drivers/firmware/efi/test/efi_test.c
··· 663 663 return rv; 664 664 } 665 665 666 + static long efi_runtime_get_supported_mask(unsigned long arg) 667 + { 668 + unsigned int __user *supported_mask; 669 + int rv = 0; 670 + 671 + supported_mask = (unsigned int *)arg; 672 + 673 + if (put_user(efi.runtime_supported_mask, supported_mask)) 674 + rv = -EFAULT; 675 + 676 + return rv; 677 + } 678 + 666 679 static long efi_test_ioctl(struct file *file, unsigned int cmd, 667 680 unsigned long arg) 668 681 { ··· 712 699 713 700 case EFI_RUNTIME_RESET_SYSTEM: 714 701 return efi_runtime_reset_system(arg); 702 + 703 + case EFI_RUNTIME_GET_SUPPORTED_MASK: 704 + return efi_runtime_get_supported_mask(arg); 715 705 } 716 706 717 707 return -ENOTTY;
+3
drivers/firmware/efi/test/efi_test.h
··· 118 118 #define EFI_RUNTIME_RESET_SYSTEM \ 119 119 _IOW('p', 0x0B, struct efi_resetsystem) 120 120 121 + #define EFI_RUNTIME_GET_SUPPORTED_MASK \ 122 + _IOR('p', 0x0C, unsigned int) 123 + 121 124 #endif /* _DRIVERS_FIRMWARE_EFI_TEST_H_ */