Skip to content

Commit

Permalink
rtc: block registration of rtc-cmos when CMOS RTC Not Present
Browse files Browse the repository at this point in the history
We should not acess CMOS address when CMOS RTC Not Present bit set in
FADT. The ee5872b patch didn't avoid rtc-cmos driver loaded when system support
ACPI PNP PNP0B0* devices.
So this patch block the registion of rtc-cmos driver to avoid
user space access RTC through CMOS interface.

Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
  • Loading branch information
joeyli committed Aug 18, 2014
1 parent 1daaf01 commit d0cf919
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 16 additions & 4 deletions arch/x86/kernel/rtc.c
Expand Up @@ -174,16 +174,27 @@ static __init int add_rtc_cmos(void)
{ "PNP0b00", "PNP0b01", "PNP0b02", };
struct pnp_dev *dev;
struct pnp_id *id;
int i;
int i = 0;
bool found_pnp;

pnp_for_each_dev(dev) {
for (id = dev->id; id; id = id->next) {
for (i = 0; i < ARRAY_SIZE(ids); i++) {
if (compare_pnp_id(id, ids[i]) != 0)
return 0;
if (compare_pnp_id(id, ids[i]) != 0) {
found_pnp = true;
goto found_pnp;
}
}
}
}

found_pnp:
if (found_pnp) {
if (acpi_gbl_FADT.header.revision >= 5 &&
acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC)
pr_err(FW_BUG "Found %s device but CMOS RTC Not Present flag set\n", ids[i]);
return 0;
}
#endif
if (of_have_populated_dt())
return 0;
Expand All @@ -193,7 +204,8 @@ static __init int add_rtc_cmos(void)
return -ENODEV;

#ifdef CONFIG_ACPI
if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
if (acpi_gbl_FADT.header.revision >= 5 &&
acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
/* This warning can likely go away again in a year or two. */
pr_info("ACPI: not registering RTC platform device\n");
return -ENODEV;
Expand Down
9 changes: 9 additions & 0 deletions drivers/rtc/rtc-cmos.c
Expand Up @@ -28,6 +28,9 @@
* interrupts disabled, holding the global rtc_lock, to exclude those
* other drivers and utilities on correctly configured systems.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
Expand Down Expand Up @@ -1144,6 +1147,12 @@ static int __init cmos_init(void)
{
int retval = 0;

if (acpi_gbl_FADT.header.revision >= 5 &&
acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
pr_info("ACPI CMOS RTC Not Present detected - not loading\n");
return 0;
}

#ifdef CONFIG_PNP
retval = pnp_register_driver(&cmos_pnp_driver);
if (retval == 0)
Expand Down

0 comments on commit d0cf919

Please sign in to comment.