Re: Kernel interrupts disable at user level - RIGHT/ WRONG - Help

From: linux-os (Dick Johnson)
Date: Mon Dec 19 2005 - 08:54:13 EST



On Mon, 19 Dec 2005, Mukund JB. wrote:

>
> Dear Kernel Developers,
>
> I have a requirement of getting the CMOS details at the user level.
> I have identified the interfaces as /dev/nvram & /dev/rtc.
> But, the complete CMOS details are available to the user Applications
> as the driver does not provide the suitable interface to get the
> complete CMOS details.
>
> I found an application that reads directly form the port 70, 71
> and gets the complete details about the CMOS. It does not use any Device
> Interface and at the same disables all the interruptson the HOST system.
>
> I would like to hear from you whether this kind of Applications can be
> used or NOT? Please see the attached source code I am planning to use to
> access the CMOS contents.
>
> Please give me ur valuable suggestions.
>
> Regards,
> Mukund Jampala
>

First, only root can disable interrupts in user-mode and read/write
to ports. One must prepare for this with iopl(3).

Second, the RTC is a shared resource. It must be protected with
a lock.

If you want to make your own rtc driver, then feel free. However,
you can't just poke at the ports from user-mode and get away with
it for any period of time. You will find that the CMOS checksum
gets screwed up and/or the time gets changed to a previous epoch.

This is because the kernel may change the index register in between
the time that you set it and when you wrote to the data register.

You need to use the provided spin-lock, rtc_lock. This needs
to be accessed from within the kernel, in your driver.

>
>
> <<dmpCmos.c>>
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.56 BogoMips).
Warning : 98.36% of all statistics are fiction.
.

****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@xxxxxxxxxxxx - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/