bad news, good news, unkown (Temp CR used as permanent storage)
Philipp kindly documented the Control Register usage a while ago...
Quoted 10 lines
register today soon CR24 unused what CR26 is today (I thought CR2[45] were readable CR25 unused what CR25 is today from userspace. stupid prumpf) CR26 used in head.S unused CR27 used in head.S unused CR28 temporary usage in interruption handlers [GR1 saved here] CR29 temporary usage in interruption handlers [arg0 (for the interruptionhandler, NOT GR26) saved here]
CR30 current, 0 if in kernel mode (this might not work for syscalls yet)
CR31 temporary usage in interruption handlers [GR29 saved here]
THE BAD NEWS
The bad news is that the PA-RISC architecture allows PDC to modify the contents of the "Temporary" Control Registers, CR 24 - 31 (see "PA-RISC 1.1 Firmware Architecture Reference Specification: Processor Dependent Code (PDC) Procedures" at
http://thepuffingroup.com/parisc/documentation.html, the table and Note 5 on page 1-4). If PDC does change the contents of these registers then they cannot be used for permanent storage by the kernel unless the kernel saves the registers before calling PDC and restores them after the return from PDC.
THE GOOD NEWS
I have started the process of changing the architecture to require PDC to preserve the state of the "Temporary" Control Registers. So far, there have been no objections to the change, but there is still some time left for HP engineers to object (like if a current PDC implementation violates the new architecture). This means that implementations of PDC for *future* machines should preserve the state of the Temporary Control Registers.
THE UNKNOWN
Even if no one in HP objects to the new constraint on PDC, there is no guarantee that existing PDC doesn't modify the Temporary Control Registers. No one is checking all the PDC implementations that have ever shipped to ensure that they meet the new restriction.
However, there is a chance that existing PDC does not modify the Temporary Control Registers, based on conversations with some relevent engineers, and some theorizing.
(Of course, the obvious exception is that the Temporary Control Registers are undefined when the kernel's HPMC handler is called.)
HP-UX does use some Temporary Control Registers for permanent storage. It saves the values of these registers before calling PDC, and restores them when PDC returns. I would recommend that Linux follow this practice.
-Frank
On the subject of things possibly getting clobbered in PDC/IODC calls, I think the variable real_routine can get clobbered since it is used for more than one type of call.
The good news is that I have made some improvement to the PDC/IODC console. I have eliminated the double lines, and when the IODC console is configured, the system can now successfully print all stored messages and open /dev/console. However, in making changes to iodccon.c, I realized that the IODC console is a really bad video console since you can't do cursor addressing. I think it would better to use the serial driver.
Thoughts?
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
Quoted 3 lines
On the subject of things possibly getting clobbered in PDC/IODC calls, I think the variable
real_routinecan get clobbered since it is used for more than one type of call.
Fixed by now.
Quoted 2 lines
The good news is that I have made some improvement to the PDC/IODC console. I have eliminated the double lines,
How ? There are quite a lot of ways to solve the two-consoles-which-are- really-the-same problem, some of them just aren't very clean. (Probably the cleanest is to merge arch/parisc/kernel/pdc_cons.c and drivers/video/ iodccon.c into one file).
Quoted 2 lines
and when the IODC console is configured, the system can now successfully print all stored messages and open
/dev/console.
This was there before, wasn't it ?
Quoted 4 lines
However, in making changes to
iodccon.c, I realized that the IODC console is a really bad video console since you can't do cursor addressing. I think it would better to use the serial
driver.
Sure it would, and I encourage everyone with a box using serial console to clean up drivers/char/serial.c (it already should do everything you want, it's just not clean) and use that. The problem is there are boxes with graphical consoles as well.
Quoted 1 line
Thoughts?
Where's the patch ;) ?
Philipp Rumpf
Quoted 9 lines
The bad news is that the PA-RISC architecture allows PDC to modify the contents of the "Temporary" Control Registers, CR 24 - 31 (see "PA-RISC 1.1 Firmware Architecture Reference Specification: Processor Dependent Code (PDC) Procedures" at
http://thepuffingroup.com/parisc/documentation.html, the table and Note 5 on page 1-4). If PDC does change the contents of these registers then they cannot be used for permanent storage by the kernel unless the kernel saves the registers before calling PDC and restores them after the return from PDC.
Right, we should save/restore them.
Quoted 9 lines
THE GOOD NEWS
I have started the process of changing the architecture to require PDC to preserve the state of the "Temporary" Control Registers. So far, there have been no objections to the change, but there is still some time left for HP engineers to object (like if a current PDC implementation violates the new architecture). This means that implementations of PDC for *future* machines should preserve the state of the Temporary Control Registers.
How much of the PDC code actually uses interruptions ?
Quoted 7 lines
THE UNKNOWN
Even if no one in HP objects to the new constraint on PDC, there is no guarantee that existing PDC doesn't modify the Temporary Control Registers. No one is checking all the PDC implementations that have ever shipped to ensure that they meet the new restriction.
Quoted 6 lines
However, there is a chance that existing PDC does not modify the Temporary Control Registers, based on conversations with some relevent engineers, and some theorizing.
(Of course, the obvious exception is that the Temporary Control Registers are undefined when the kernel's HPMC handler is called.)
How is that obvious ? I would have expected the firmware HPMC handler to use some sort of temporary storage in the 0xffffe000 - 0xffffffff range (which can be accessed using an immediate offset and GR0), in the debug registers or something similar (probably it could even use undefined spots in page zero).
Quoted 4 lines
HP-UX does use some Temporary Control Registers for permanent storage. It saves the values of these registers before calling PDC, and restores them when PDC returns. I would recommend that Linux follow this practice.
Agreed.
Philipp Rumpf
Philipp Rumpf wrote:
< stuff deleted >
Quoted 4 lines
Quoted 2 lines
(Of course, the obvious exception is that the Temporary Control Registers are undefined when the kernel's HPMC handler is called.)
How is that obvious ? I would have expected the firmware HPMC handler
Ahhh, obvious if one had read the comments at the beginning of the basic hpmc handler that I submitted. Or read p. 1-16 of pdce.pdf, "PA-RISC 2.0 Formware Architecture Reference Specification: Processor Dependent Code (PDC) Procedures (Part 2/2)" at
http://thepuffingroup.com/parisc/documentation.html
OK, so it's not so obvious....
-Frank
Quoted 6 lines
However, there is a chance that existing PDC does not modify the Temporary Control Registers, based on conversations with some relevent engineers, and some theorizing.
(Of course, the obvious exception is that the Temporary Control Registers are undefined when the kernel's HPMC handler is called.)
In this context I interpreted the last paragraph as saying that even if firmware is nice and doesn't modify the temporary registers during PDC calls, there is no chance whatsoever that the temporary registers contain useful values after every HPMC on a certain firmware implementation. (Now I don't see how HPMC's are an exception to the more general rule that some firmware implementations might preserve the temporary registers).
Quoted 6 lines
Ahhh, obvious if one had read the comments at the beginning of the basic hpmc handler that I submitted.
Or read p. 1-16 of pdce.pdf, "PA-RISC 2.0
Formware Architecture Reference Specification: Processor Dependent Code (PDC) Procedures (Part 2/2)" at
http://thepuffingroup.com/parisc/documentation.html
Which contradict each other wrt the PSW W and E bits (E isn't going to concern us but W might), btw.
Philipp Rumpf