Linux syscall ABI
Quoted 4 lines
I don't think reserving 0xFXXX XXXX for I/O in userspace is a good idea. There is no problem with doing userspace I/O using the normal mmap
/dev/memapproach. (Except maybe HPUX compatibility, which doesn't concern linux- only processes).
...
Quoted 1 line
kernel
memcpy()shouldn't ever be called with either an IO or a user address
I was referring to user space memcpy, not kernel memcpy. The HP-UX user space memcpy supports use with IO mapped addresses, however it has to differentiate those addresses in order to not do optimizations that won't work with IO mapped addresses. Having a dedicated range allows for an easy test. But perhaps if this is not desirable we can just say that Linux glibc memcpy is not supported for IO mapped addresses (assuming it is optimized).
Quoted 8 lines
Quoted 5 lines
One disadvantage of this proposal is that we could not support the System V personality null pointer dereference behaviour. This maps a page of zero's at location 0 so that null pointer dereferences will return 0 for buggy software. Do we really still need to maintain this ancient hack?
No, we don't. We're talking about
PER_LINUXbinaries here, and those never expected to be able to dereference NULL pointers.
I don't know much about PER_SVR4, and why it exists. Willy pointed it out to me. I can see from the kernel source that perhaps it is only there for sparc. If it is not necessary for parisc-linux to support then there is no issue. If it is necessary then I guess I assumed that PER_SVR4 binaries would use the same gateway page as PER_LINUX binaries.
Quoted 3 lines
Of course every page in the region
0xfffc0000-0x3ffffc (it's a 17-bit signed immediate shifted left 2 bits, so that should be -2^18 - 2^18-4) can be used, so we just need a page within the first 256 KB.
This is true for user space. For kernel space, I don't think we can use anything in F space, unless we map the real IO addresses somewhere else in virtual space. I'm not sure what assumptions are being made right now regarding that mapping in the drivers.
I was also thinking that we may want to eventually map physical addresses directly (with no offset) to virtual addresses, in order to support the maximum amount of physical memory. But Perhaps we can have a 16 Mb offset instead.
Quoted 7 lines
a variety of reasons why it might not be available long term) the
Quoted 5 lines
sequence could be shortened to:
mtsp %r0,%sr0 ble <gateway offset>(%sr0,%r0) ldi <syscall #>,%r20
Quoted 6 lines
In fact, what's wrong with shortening _this_ sequence to
ble <gateway offset)(%sr2, %r0) ldi <syscall #>,%r20and teaching userspace to not modify sr2 ?
I like this idea. The only disadvantage is that if the user modifies sr2 by mistake, all of a sudden all of the syscalls stop working (for that process only). It might be hard to debug. But, as long as we make sure that gcc never touches sr2, there should be almost no legitimate reason to play with space registers in the user address space for Linux processes, since we are going to have sr4=sr5=sr6=sr7. In fact, gcc should be modified to stop using $$dyncall for indirect function pointer calls. So, a C programmer will never run into this problem by mistake. Only people doing assembly language programming could run into the error.
Now, I am assuming we would set sr2 to 0 and locate the gateway page in the kernel address space if we chose this proposal. But this idea has the flexibility of allowing us to move the gateway page into another space completely if we ever need to (would require modifications to the tlb miss handler). It also has the interesting feature that a programmer could set sr2 to point into the user address space, and if we choose an offset for the gateway page in the kernel address space and make that offset also available for mmap in the user address space, the user could place there own page at the gateway offset in user space and intercept all syscalls (there are other ways of doing this, but I just thought it was interesting).
John Marvin
[email protected]
Quoted 8 lines · John Marvin
Quoted 2 lines
No, we don't. We're talking about
PER_LINUXbinaries here, and those never expected to be able to dereference NULL pointers.I don't know much about
PER_SVR4, and why it exists. Willy pointed it out to me. I can see from the kernel source that perhaps it is only there for sparc. If it is not necessary for parisc-linux to support then there is no issue. If it is necessary then I guess I assumed thatPER_SVR4binaries would use the same gateway page asPER_LINUXbinaries.
Linux has a personality() syscall which tells the kernel what operating system this binary was compiled for. PER_SVR4 means that this binary was compiled for SVR4. We _may_ want to include a PER_HPUX at some point, but i'm not convinced we need it yet. I pointed you at that bit of code to show you that for some binaries Linux did that nasty hack, rather than to advocate we do it too.
Quoted 9 lines
Quoted 1 line
kernel
memcpy()shouldn't ever be called with either an IO or a user addressI was referring to user space memcpy, not kernel memcpy. The HP-UX user space memcpy supports use with IO mapped addresses, however it has to differentiate those addresses in order to not do optimizations that won't work with IO mapped addresses. Having a dedicated range allows for an easy test. But perhaps if this is not desirable we can just say that Linux glibc memcpy is not supported for IO mapped addresses (assuming it is optimized).
This sounds to me like a typical case of doing a static optimization (is this a memcpy() to I/O space, from I/O space, to and from I/O space) at runtime.
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines
One disadvantage of this proposal is that we could not support the System V personality null pointer dereference behaviour. This maps a page of zero's at location 0 so that null pointer dereferences will return 0 for buggy software. Do we really still need to maintain this ancient hack?
No, we don't. We're talking about
PER_LINUXbinaries here, and those never expected to be able to dereference NULL pointers.I don't know much about
PER_SVR4, and why it exists. Willy pointed it out to me. I can see from the kernel source that perhaps it is only there for sparc. If it is not necessary for parisc-linux to support then there is no issue. If it is necessary then I guess I assumed thatPER_SVR4binaries would use the same gateway page asPER_LINUXbinaries.
Quoted 7 lines
Quoted 3 lines
Of course every page in the region
0xfffc0000-0x3ffffc (it's a 17-bit signed immediate shifted left 2 bits, so that should be -2^18 - 2^18-4) can be used, so we just need a page within the first 256 KB.This is true for user space. For kernel space, I don't think we can use anything in F space, unless we map the real IO addresses somewhere else in virtual space.
That's what I meant by "within the first 256 KB". ble <offset>(srX, r0) gives us the range 0xfffc0000 - 0x3 fffc, we can't use 0xfffc0000 - 0xfffffff, so we're limited to the first 256 KB.
Quoted 2 lines
I'm not sure what assumptions are being made
right now regarding that mapping in the drivers.
Mapping the I/O space to 0xf000 0000 - 0xffff ffff would make sense, IMO, and shouldn't be a problem with our drivers.
Quoted 3 lines
I was also thinking that we may want to eventually map physical addresses directly (with no offset) to virtual addresses, in order to support the maximum amount of physical memory.
We agreed upon doing this eventually, didn't we ?
Quoted 1 line
But Perhaps we can have a 16 Mb offset instead.
I think not mapping the first 64 KB and making a copy of page 0 somewhere else would make sense. Then we could use the first 64 KB of the virtual address space to implement gateway pages.
Quoted 9 lines
Quoted 9 lines
a variety of reasons why it might not be available long term) the
Quoted 5 lines
sequence could be shortened to:
mtsp %r0,%sr0 ble <gateway offset>(%sr0,%r0) ldi <syscall #>,%r20In fact, what's wrong with shortening _this_ sequence to
Quoted 8 lines
Quoted 4 lines
ble <gateway offset)(%sr2, %r0) ldi <syscall #>,%r20and teaching userspace to not modify sr2 ?
I like this idea. The only disadvantage is that if the user modifies sr2 by mistake, all of a sudden all of the syscalls stop working (for that process only).
I don't see a real problem with that. Modifying SR2 requires either direct modification (the only code I could see doing that is HP/UX code, which isn't supposed to execute with PER_LINUX anytime soon) or executing random bytes, which will always break in unexpected ways.
Quoted 5 lines
It might be hard to debug. But, as long as we make sure that gcc never touches sr2, there should be almost no legitimate reason to play with space registers in the user address space for Linux processes, since we are going to have sr4=sr5=sr6=sr7. In fact, gcc should be modified to stop using $$dyncall for indirect function pointer calls. So,
There is an option for that. Something along the lines of "fast function calls" (I'll have a look lateron).
Quoted 11 lines
Now, I am assuming we would set sr2 to 0 and locate the gateway page in the kernel address space if we chose this proposal. But this idea has the flexibility of allowing us to move the gateway page into another space completely if we ever need to (would require modifications to the tlb miss handler). It also has the interesting feature that a programmer could set sr2 to point into the user address space, and if we choose an offset for the gateway page in the kernel address space and make that offset also available for mmap in the user address space, the user could place there own page at the gateway offset in user space and intercept all syscalls (there are other ways of doing this, but I just thought it was interesting).
I agree this would be another point in favour of using 0:0 or 0:0x1000 as default gateway page.
Philipp
John Marvin wrote:
...
Quoted 8 lines
Quoted 3 lines
Of course every page in the region
0xfffc0000-0x3ffffc (it's a 17-bit signed immediate shifted left 2 bits, so that should be -2^18 - 2^18-4) can be used, so we just need a page within the first 256 KB.This is true for user space. For kernel space, I don't think we can use anything in F space, unless we map the real IO addresses somewhere else in virtual space. I'm not sure what assumptions are being made right now regarding that mapping in the drivers.
Drivers don't map anything. The assumption for GSC/PCI drivers is the address given will work with readl/writel (or inb/outb) routines.
For GSC, the HPA is in the struct hp_device->hpa field and readl/writel are aliases for gsc_readl/gsc_writel.
For PCI devices the base address is in struct pci_device ->resources[]. The PCI drivers know to use MMIO or I/O port space for their device (often based on #define flags). And again readl/writel alias to gsc_readl/gsc_writel for MMIO. inl/outl are defined to be an indirect function call to either Dino or "lba" PCI services (similar to how pci_config_read is an indirect call).
gsc_readl/writel take a physical address as the address parameter. I would like to get away from gsc_read for one simple reason: HPMC. If a driver incorrectly accesses something which isn't supposed to we get either an HPMC or undefined behavior. Most likely the HPMC. If the read/write routines referenced a virtual address, we have much better chances of getting a data page fault and some decent debugging information to track down the problem.
This is #2 on my TODO list after reviewing the coherent DMA services recently introduced in 2.3.
grant
Grant Grundler
Unix Development Lab
+1.408.447.7253
Quoted 2 lines
Drivers don't map anything. The assumption for GSC/PCI drivers is the address given will work with readl/writel (or inb/outb) routines.
PCI drivers call ioremap(), which is free to do the mapping (but I don't think it should, for PA-RISC).
Quoted 2 lines
For GSC, the HPA is in the struct
hp_device->hpafield and readl/writel are aliases for gsc_readl/gsc_writel.
which itself will be aliased to simple volatile accesses soon.
Quoted 7 lines
gsc_readl/writel take a physical address as the address parameter. I would like to get away from
gsc_readfor one simple reason: HPMC. If a driver incorrectly accesses something which isn't supposed to we get either an HPMC or undefined behavior. Most likely the HPMC. If the read/write routines referenced a virtual address, we have much better chances of getting a data page fault and some decent debugging information to track down the problem.
HPMC is good debugging information - you've got PIM. Of course, we want an HPMC handler too, at some point. The assembly part just tries to find out if the machine is still usable, and resets it if it's not. If it is, we'd like it to be treated as normal interruption, and then have a CPU-specific fault handler that reads the interesting registers and prints a nice message.
Philipp Rumpf
Quoted 27 lines · Philipp Rumpf
Quoted 3 lines
Drivers don't map anything. The assumption for GSC/PCI drivers is the address given will work with readl/writel (or inb/outb) routines.
PCI drivers call
ioremap(), which is free to do the mapping (but I don't think it should, for PA-RISC).Quoted 2 lines
For GSC, the HPA is in the struct
hp_device->hpafield and readl/writel are aliases for gsc_readl/gsc_writel.which itself will be aliased to simple volatile accesses soon.
Quoted 7 lines
gsc_readl/writel take a physical address as the address parameter. I would like to get away from
gsc_readfor one simple reason: HPMC. If a driver incorrectly accesses something which isn't supposed to we get either an HPMC or undefined behavior. Most likely the HPMC. If the read/write routines referenced a virtual address, we have much better chances of getting a data page fault and some decent debugging information to track down the problem.HPMC is good debugging information - you've got PIM. Of course, we want an HPMC handler too, at some point. The assembly part just tries to find out if the machine is still usable, and resets it if it's not. If it is, we'd like it to be treated as normal interruption, and then have a CPU-specific fault handler that reads the interesting registers and prints a nice message.
Quoted 5 lines
Philipp Rumpf
---------------------------------------------------------------------------
To unsubscribe: send e-mail to [email protected] with `unsubscribe' as the subject.
An HPMC may be delayed, relative to the instruction that caused it. The worst case is that a context switch _could_ occur before the HPMC occurs (and yes, we did see this problem with our HP-UX and HP-RT VME systems when a VME time-out was long enough). This can make it more difficult to figure out what instruction was issued to cause the HPMC. The advantage of the page fault is that you know exactly what instruction caused the fault.
-Frank
Signature · 2 lines
MontaVista Software, Inc [email protected]
Philipp Rumpf wrote:
...
Quoted 1 line
HPMC is good debugging information - you've got PIM.
IMO, Frank didn't say this clearly:
PIM is not "good debugging information".
Given the complexity of the systems, knowing *some* (not all) of the HW state is marginally useful at best. When we get into debugging driver problems later on, this will be clearer.
Besides the asynchronous nature of HPMCs, PIMs are unique to each class of box. So decoding a PIM on a K-class is quite different from the PIM on N or L-class. Only recently have tools been made internally available to help decode each type of PIM. I wouldn't hold my breath waiting for those to get published.
Quoted 6 lines
Of course, we want
an HPMC handler too, at some point. The assembly part just tries to find out if the machine is still usable, and resets it if it's not. If it is, we'd like it to be treated as normal interruption, and then have a CPU-specific fault handler that reads the interesting registers and prints a nice message.
If linux could learn to dump host memory to disk, then HPMC's would a bit easier to debug since one could review data structures for suspect code. I think that's what the HPMC handler is intended for - not attempt to recover. Attempting to recover from an asyncronous fault doesn't sound feasible to me. But what do I know anyway....
later,
grant
Grant Grundler
Unix Development Lab
+1.408.447.7253
Grant wrote:
| | Given the complexity of the systems, knowing *some* (not all) | of the HW state is marginally useful at best. When we get | into debugging driver problems later on, this will be clearer. | | Besides the asynchronous nature of HPMCs, PIMs are unique to each | class of box. So decoding a PIM on a K-class is quite different | from the PIM on N or L-class. Only recently have tools been made | internally available to help decode each type of PIM. I wouldn't | hold my breath waiting for those to get published.
There are two key take aways from what Grant has said:
1. There are some platform specific tools which help PIM analysis. As someone who has read literally thousands of PIM dumps over 10 years worth of server platforms, and as someone who has contributed some of the analysis tools, I would say that the tools only automate the decoding of status register values (which are all implementation specific). There has never been an expert tool which pulls in a PIM dump and spits out the answer.
2. The platforms which Grant specified are server platforms, not the workstations. In my experience, you're going to find many more people familiar with server PIM dump output than workstations, simply because of the threshold of pain of the customer base. A server customer is much more concerned with getting a fully analysis of each and every failure than a workstation customer.
In general, for real hardware faults, PIM dumps are usually as good as the underlying hardware error logging registers in telling an expert what has gone wrong. But, in this case, when there is an OS or OS/hardware interaction, the PIM is usually not enough.
| | If linux could learn to dump host memory to disk, then HPMC's would | a bit easier to debug since one could review data structures for suspect | code. I think that's what the HPMC handler is intended for - not | attempt to recover. Attempting to recover from an asyncronous fault | doesn't sound feasible to me. But what do I know anyway.... |
I don't know what Grant does (n't) know :), but I second the call for a core dump. To give an example of a complex hardware/OS interaction, I was once debugging a system which was regularly getting OS panics due to data page faults. As a hardware engineer I would, as a matter of principle, blaim software and then firmware. But, the problem was actually a double bit error due to a bad SRAM in the instruction cache which was corrupting an instruction. I only found this out by comparing instructions and data in the memory dumps with the data stored in PIM dumps.
As to recovery from HMPCs, I can only speak to the hardware generated exceptions. Most of the hardware generated HPMCs are linked to events which calls into question the validity of information. Get a parity error on a private, dirty cache line? Well that means that there is no valid copy anywhere. Better to dump PIM and halt immediately rather than possibly commit bad data to permanent storage. I think that you have to be pretty confident to continue with other than a core dump or tombstone page.
KMB
--
+============================================================+ | Kirk Bresniker (916) 748-2393 | | 8000 Foothills Blvd | | Roseville, CA 95747-5649 | | [email protected] |
[parisc-linux] Location of HIL protocol docs?
In reply to Philipp RumpfA brief poking around HP's site didn't turn me up any links -- and I'd prefer to enhance the existing code if appropriate, rather than just reformat it, not to mention debugging might go faster if I actually understand what I'm doing :).
Anyone got a link to tech docs on HIL?
--
Brian S. Julin
Re: [parisc-linux] Location of HIL protocol docs?
Quoted 1 line · Brian S. Julin
Anyone got a link to tech docs on HIL?
HIL comes off the "WAX" (EISA Bus Adapter chip) on C200. I assume the same is true for any box which supports EISA. (ie 715/725, GSCtoPCI workstations).
I don't know if WAX documents will ever get published. Probably but not right away if they aren't already.
grant
Grant Grundler
Unix Development Lab
+1.408.447.7253