efi: remove the rtc-wakeup capability from default value
Subsystems (2)
PATCH 1/1 efi: remove the rtc-wakeup capability from default value
The kernel selftest of rtc reported a error on an ARM server:
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 unerlying EFI firmware doesn't support wakeup service (get/set alarm), while it doesn't have the efi 'RT_PROP' table either. The current code logic will claim efi supports these runtime service capability by default, and let following 'RT_PROP' table parsing to correct it, if that table exists.
This issue was reproduced on ARM server from another verndor, and not reproudce on one x86 server (Icelake). All these 3 platforms don't have 'RT_PROP' tables, so they are all claimed to support alarm service, but x86 server uses real CMOS RTC device instead rtc-efi device, and passes the test.
So remove the wakeup/alarm capability from default value, and setup the capability bits according to the 'RT_PROP' table parsing.
--- drivers/firmware/efi/efi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/firmware/efi/efi.c +11 -0
@@ -789,6 +789,17 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables, } } +/* +* After bootup, the runtime_supported_mask was set to be capable of +* all features, which could be kind of too optimistici. In real +* world, many platforms don't support advanced RTC wakeup runtime +* service, while they don't provide RT_PROPERTY table either, which +* led to rtc-wakeup capability being worngly claimed. +* +* So remove the wakeup capbility from default value, and let the +* RT_PROPERTY do the judge. +*/ + efi.runtime_supported_mask &= ~EFI_RT_SUPPORTED_WAKEUP_SERVICES ;if (rt_prop !=EFI_INVALID_TABLE_ADDR ) {efi_rt_properties_table_t *tbl;
Signature · 1 line
2.43.5
Ard Biesheuvel
maintainerQuoted 16 lines · Feng Tang
The kernel selftest of rtc reported a error on an ARM server:
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_setThe root cause is, the unerlying EFI firmware doesn't support wakeup service (get/set alarm), while it doesn't have the efi '
RT_PROP' table either. The current code logic will claim efi supports these runtime service capability by default, and let following 'RT_PROP' table parsing to correct it, if that table exists.
Quoted 9 lines
This issue was reproduced on ARM server from another verndor, and not reproudce on one x86 server (Icelake). All these 3 platforms don't have '
RT_PROP' tables, so they are all claimed to support alarm service, but x86 server uses real CMOS RTC device instead rtc-efi device, and passes the test.So remove the wakeup/alarm capability from default value, and setup the capability bits according to the '
RT_PROP' table parsing.
What does this achieve? The test result is accurate, as the platform violates the spec by not implementing the RTC wakeup services, and not setting the RT_PROP table bits accordingly.
What do we gain by pretending that the platform is not broken, and lying about it?
Quoted 17 lines
Signed-off-by Feng Tang <[email protected]>--- drivers/firmware/efi/efi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/firmware/efi/efi.c +4
-0@@ -789,6 +789,17 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables, } } +/* +* After bootup, the runtime_supported_mask was set to be capable of +* all features, which could be kind of too optimistici. In real +* world, many platforms don't support advanced RTC wakeup runtime
drivers/firmware/efi/efi.c int __init efi_config_parse_tables(const efi_config_table_t *config_tables, · line 805
Quoted 10 lines
drivers/firmware/efi/efi.c +7
-0+* service, while they don't provide RT_PROPERTY table either, which +* led to rtc-wakeup capability being worngly claimed. +* +* So remove the wakeup capbility from default value, and let the +* RT_PROPERTY do the judge. +*/ + efi.runtime_supported_mask &= ~EFI_RT_SUPPORTED_WAKEUP_SERVICES ;if (rt_prop !=EFI_INVALID_TABLE_ADDR ) {efi_rt_properties_table_t *tbl;
Doesn't this break the RTC wakeup services on platforms that do implement them, and don't expose a RT_PROP table?
Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Feng Tang
The kernel selftest of rtc reported a error on an ARM server:
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_setThe root cause is, the unerlying EFI firmware doesn't support wakeup service (get/set alarm), while it doesn't have the efi '
RT_PROP' table either. The current code logic will claim efi supports these runtime service capability by default, and let following 'RT_PROP' table parsing to correct it, if that table exists.Quoted 9 lines
This issue was reproduced on ARM server from another verndor, and not reproudce on one x86 server (Icelake). All these 3 platforms don't have '
RT_PROP' tables, so they are all claimed to support alarm service, but x86 server uses real CMOS RTC device instead rtc-efi device, and passes the test.So remove the wakeup/alarm capability from default value, and setup the capability bits according to the '
RT_PROP' table parsing.
Quoted 6 lines
What does this achieve? The test result is accurate, as the platform violates the spec by not implementing the RTC wakeup services, and not setting the
RT_PROPtable bits accordingly.What do we gain by pretending that the platform is not broken, and lying about it?
I don't have much experience with EFI, so I might be totally wrong. I don't think not providing the RT_PROP table is 'broken', that's why I tried to borrow platforms from different vendors to do the check, which all have no this table.
For platform which have no 'RT_PROP' tables (seems to be not a rare case), claiming them support all efi runtime service may be kind of risky.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Feng Tang <[email protected]>--- drivers/firmware/efi/efi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/firmware/efi/efi.c +9
-0@@ -789,6 +789,17 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables, } } +/* +* After bootup, the runtime_supported_mask was set to be capable of +* all features, which could be kind of too optimistici. In real +* world, many platforms don't support advanced RTC wakeup runtime +* service, while they don't provide RT_PROPERTY table either, which +* led to rtc-wakeup capability being worngly claimed. +* +* So remove the wakeup capbility from default value, and let the +* RT_PROPERTY do the judge.
Quoted 8 lines
drivers/firmware/efi/efi.c int __init efi_config_parse_tables(const efi_config_table_t *config_tables, · line 805
Quoted 5 lines
drivers/firmware/efi/efi.c +2
-0+*/ + efi.runtime_supported_mask &= ~EFI_RT_SUPPORTED_WAKEUP_SERVICES ;if (rt_prop !=EFI_INVALID_TABLE_ADDR ) {efi_rt_properties_table_t *tbl;Doesn't this break the RTC wakeup services on platforms that do implement them, and don't expose a
RT_PROPtable?
You are right, there is such risk.
Thanks,
Feng
Ard Biesheuvel
maintainerQuoted 36 lines · Feng Tang
Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Feng Tang
The kernel selftest of rtc reported a error on an ARM server:
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_setThe root cause is, the unerlying EFI firmware doesn't support wakeup service (get/set alarm), while it doesn't have the efi '
RT_PROP' table either. The current code logic will claim efi supports these runtime service capability by default, and let following 'RT_PROP' table parsing to correct it, if that table exists.Quoted 9 lines
This issue was reproduced on ARM server from another verndor, and not reproudce on one x86 server (Icelake). All these 3 platforms don't have '
RT_PROP' tables, so they are all claimed to support alarm service, but x86 server uses real CMOS RTC device instead rtc-efi device, and passes the test.So remove the wakeup/alarm capability from default value, and setup the capability bits according to the '
RT_PROP' table parsing.Quoted 6 lines
What does this achieve? The test result is accurate, as the platform violates the spec by not implementing the RTC wakeup services, and not setting the
RT_PROPtable bits accordingly.What do we gain by pretending that the platform is not broken, and lying about it?
Quoted 8 lines
I don't have much experience with EFI, so I might be totally wrong. I don't think not providing the
RT_PROPtable is 'broken', that's why I tried to borrow platforms from different vendors to do the check, which all have no this table.For platform which have no '
RT_PROP' tables (seems to be not a rare case), claiming them support all efi runtime service may be kind of risky.
It is the other way around. The UEFI spec mandates that all runtime services are implemented, unless a RT_PROP table is provided.
Add Alexandre Belloni for his view on rtc-efi driver
Quoted 42 lines · Ard Biesheuvel
Quoted 41 lines · Feng Tang
Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Feng Tang
The kernel selftest of rtc reported a error on an ARM server:
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_setThe root cause is, the unerlying EFI firmware doesn't support wakeup service (get/set alarm), while it doesn't have the efi '
RT_PROP' table either. The current code logic will claim efi supports these runtime service capability by default, and let following 'RT_PROP' table parsing to correct it, if that table exists.Quoted 9 lines
This issue was reproduced on ARM server from another verndor, and not reproudce on one x86 server (Icelake). All these 3 platforms don't have '
RT_PROP' tables, so they are all claimed to support alarm service, but x86 server uses real CMOS RTC device instead rtc-efi device, and passes the test.So remove the wakeup/alarm capability from default value, and setup the capability bits according to the '
RT_PROP' table parsing.Quoted 6 lines
What does this achieve? The test result is accurate, as the platform violates the spec by not implementing the RTC wakeup services, and not setting the
RT_PROPtable bits accordingly.What do we gain by pretending that the platform is not broken, and lying about it?
I don't have much experience with EFI, so I might be totally wrong. I don't think not providing the
RT_PROPtable is 'broken', that's why I tried to borrow platforms from different vendors to do the check, which all have no this table.
Quoted 6 lines
Quoted 3 lines
For platform which have no '
RT_PROP' tables (seems to be not a rare case), claiming them support all efi runtime service may be kind of risky.It is the other way around. The UEFI spec mandates that all runtime services are implemented, unless a
RT_PROPtable is provided.
Thanks for the explaination! Yes, it's fair to claim the uefi implementation on the 2 ARM servers 'broken' :)
I talked with some firmware developers. They said the rtc-alarm service could be implemented, while the difficult part is how to notify OS. I submitted a request for a correct RT_PROP table.
Meanwhile, given there are quite some platforms (All ARM server I can access) don't have the table and not support rtc wakeup service, I'm thinking of adding some runtime check for the service in rtc-efi driver, something like:
---
drivers/rtc/rtc-efi.c +3 -1
@@ -259,6 +259,7 @@ static int __init efi_rtc_probe(struct platform_device *dev)struct rtc_device *rtc;efi_time_t eft;efi_time_cap_t cap; +efi_bool_t enabled, pending;/* First check if the RTC is usable */ if (efi.get_time (&eft, &cap) !=EFI_SUCCESS )
@@ -272,7 +273,8 @@ static int __init efi_rtc_probe(struct platform_device *dev) rtc->ops = &efi_rtc_ops;clear_bit (RTC_FEATURE_UPDATE_INTERRUPT , rtc->features); -if (efi_rt_services_supported (EFI_RT_SUPPORTED_WAKEUP_SERVICES )) +if (efi_rt_services_supported (EFI_RT_SUPPORTED_WAKEUP_SERVICES ) && + efi.get_wakeup_time (&enabled, &pending, &eft) ==EFI_SUCCESS )set_bit (RTC_FEATURE_ALARM_WAKEUP_ONLY , rtc->features);else clear_bit (RTC_FEATURE_ALARM , rtc->features);
This works on one ARM server I can test kernel with. Any suggestions?
Thanks,
Feng
Ard Biesheuvel
maintainerQuoted 88 lines · Feng Tang
Add Alexandre Belloni for his view on rtc-efi driver
Quoted 42 lines · Ard Biesheuvel
Quoted 41 lines · Feng Tang
Quoted 27 lines · Ard Biesheuvel
Quoted 16 lines · Feng Tang
The kernel selftest of rtc reported a error on an ARM server:
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_setThe root cause is, the unerlying EFI firmware doesn't support wakeup service (get/set alarm), while it doesn't have the efi '
RT_PROP' table either. The current code logic will claim efi supports these runtime service capability by default, and let following 'RT_PROP' table parsing to correct it, if that table exists.Quoted 9 lines
This issue was reproduced on ARM server from another verndor, and not reproudce on one x86 server (Icelake). All these 3 platforms don't have '
RT_PROP' tables, so they are all claimed to support alarm service, but x86 server uses real CMOS RTC device instead rtc-efi device, and passes the test.So remove the wakeup/alarm capability from default value, and setup the capability bits according to the '
RT_PROP' table parsing.Quoted 6 lines
What does this achieve? The test result is accurate, as the platform violates the spec by not implementing the RTC wakeup services, and not setting the
RT_PROPtable bits accordingly.What do we gain by pretending that the platform is not broken, and lying about it?
I don't have much experience with EFI, so I might be totally wrong. I don't think not providing the
RT_PROPtable is 'broken', that's why I tried to borrow platforms from different vendors to do the check, which all have no this table.Quoted 6 lines
Quoted 3 lines
For platform which have no '
RT_PROP' tables (seems to be not a rare case), claiming them support all efi runtime service may be kind of risky.It is the other way around. The UEFI spec mandates that all runtime services are implemented, unless a
RT_PROPtable is provided.Thanks for the explaination! Yes, it's fair to claim the uefi implementation on the 2 ARM servers 'broken' :)
I talked with some firmware developers. They said the rtc-alarm service could be implemented, while the difficult part is how to notify OS. I submitted a request for a correct
RT_PROPtable.Meanwhile, given there are quite some platforms (All ARM server I can access) don't have the table and not support rtc wakeup service, I'm thinking of adding some runtime check for the service in rtc-efi driver, something like:
---
drivers/rtc/rtc-efi.c +3
-1@@ -259,6 +259,7 @@ static int __init efi_rtc_probe(struct platform_device *dev)struct rtc_device *rtc;efi_time_t eft;efi_time_cap_t cap; +efi_bool_t enabled, pending;/* First check if the RTC is usable */ if (efi.get_time (&eft, &cap) !=EFI_SUCCESS )@@ -272,7 +273,8 @@ static int __init efi_rtc_probe(struct platform_device *dev) rtc->ops = &efi_rtc_ops;clear_bit (RTC_FEATURE_UPDATE_INTERRUPT , rtc->features); -if (efi_rt_services_supported (EFI_RT_SUPPORTED_WAKEUP_SERVICES )) +if (efi_rt_services_supported (EFI_RT_SUPPORTED_WAKEUP_SERVICES ) && + efi.get_wakeup_time (&enabled, &pending, &eft) ==EFI_SUCCESS )set_bit (RTC_FEATURE_ALARM_WAKEUP_ONLY , rtc->features);else clear_bit (RTC_FEATURE_ALARM , rtc->features);
Quoted 2 lines
This works on one ARM server I can test kernel with. Any suggestions?
I think this is fine - please send it as a proper patch with commit log etc.