rtc: efi: Add runtime check for the wakeup service capability

The kernel selftest of rtc reported a error on an ARM server which
use rtc-efi device:

	RUN           rtc.alarm_alm_set ...
	rtctest.c:262:alarm_alm_set:Alarm time now set to 17:31:36.
	rtctest.c:267:alarm_alm_set:Expected -1 (-1) != rc (-1)
	alarm_alm_set: Test terminated by assertion
		 FAIL  rtc.alarm_alm_set
	not ok 5 rtc.alarm_alm_set

The root cause is, the underlying EFI firmware doesn't support wakeup
service (get/set alarm), while it doesn't have the EFI RT_PROP table
either. As Ard Biesheuvel clarified [1], this violates the UEFI spec,
which requires EFI firmware to provide a 'RT_PROP' table if it doesn't
support all runtime services (Section 4.6.2, UEFI spec 2.10).

This issue was also reproduced on ARM server from another vendor, which
doesn't have RT_PROP table either. This means, in real world, there are
quite some platforms having this issue, that it doesn't support wakeup
service while not providing a correct RT_PROP table, which makes it
wrongly claimed to support it.

Add a runtime check for the wakeup service to detect and correct this
kind of cases.

[1]. https://lore.kernel.org/lkml/CAMj1kXEkzXsjm0dPhzxB+KdtzqADd4NmafKmw2rKw7mAPBrgdA@mail.gmail.com/

Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 file changed