Skip to contentSkip to conversation

syscall work

hppa-linux Bjorn Helgaas 6 participants 12 messages Mar 25, 1999 – Mar 29, 1999

lore
Share & tools
lore
#0 lore raw

Cary Coutant wrote

Quoted 4 lines

I'd suggest *not* using the same gateway page address as HP-UX. If you do, you won't be able to develop a later kernel extension to support HP-UX binaries, unless you allocate syscall numbers carefully.

If Linux uses a different gateway page address than HP-UX (which I think is a good idea), why not use a strategy like that used for 64-bit HP-UX apps, where the kernel supplies the address in a register at application startup?

#1 lore raw
Quoted 4 lines · Bjorn Helgaas

If Linux uses a different gateway page address than HP-UX (which I think is a good idea), why not use a strategy like that used for 64-bit HP-UX apps, where the kernel supplies the address in a register at application startup?

OK, I'm convinced. I've changed unistd.h to use 0xC0000404 (on the next page) for the syscall gateway, although we can easily change it back.

The ``Assembly Language Reference Manual'' I have says:
Refer to the /HP-UX Reference/ manual for more information on HP-UX
system
calls.

Anyone know what manual they're talking about? I'd like to find out what to do for syscalls that take more than 4 arguments, like mmap and recvfrom and sendto.

Mike

Signature · 1 line
81996.85 73813.97
#2 lore raw
Quoted 3 lines · Mike

Anyone know what manual they're talking about? I'd like to find out what to do for syscalls that take more than 4 arguments, like mmap and recvfrom and sendto.

Sounds like the HP-UX Application Binary Interface (or
was it the Application Programming Interface...two different manuals) from the Precision RISC Organization (or, more exactly,
from HP...but developed for PRO) would be quite useful. It (the one that discusses system calls) may provide some
info about where parameters go.

Unfortunately, I'm miles away from my copy. Maybe someone from HP can comment on the manual?

BTW, I like the different gateway address better than the different range.

Signature · 2 lines
Stan Sieler                                          [email protected]
                                     http://www.allegro.com/sieler.html
#3 lore raw
In reply to Mike Shaver
Quoted 2 lines

OK, I'm convinced. I've changed unistd.h to use 0xC0000404 (on the next page) for the syscall gateway, although we can easily change it back.

Isn't the next page at 0xc0001000? Or does linux have some concept of 1k "pages" even though pages in the TLB are 4k?

-Bob

#4 lore raw
Quoted 6 lines · Bob Pflederer
Quoted 3 lines

OK, I'm convinced. I've changed unistd.h to use 0xC0000404 (on the next page) for the syscall gateway, although we can easily change it back.

Isn't the next page at 0xc0001000? Or does linux have some concept of 1k "pages" even though pages in the TLB are 4k?

Brain-o. 0xC0001004 it is.

While we're on the topic, though: why 0xC0000004 and not 0xC0000000 as the target address? (Although there are other bugs, like ``ldo 5,%r22'' instead of ``ldi 5,%r22'' in the Assembler Ref as well, so maybe this is another?)

Mike

Signature · 1 line
92501.80 83731.86
#5 lore raw
Quoted 4 lines · Mike Shaver

While we're on the topic, though: why 0xC0000004 and not 0xC0000000 as the target address? (Although there are other bugs, like ``ldo 5,%r22'' instead of ``ldi 5,%r22'' in the Assembler Ref as well, so maybe this is another?)

It does not matter as long as the gateway instruction is on the "special" page. Probably one wants to put a nop before the gateway instruction.

-pkd

#6 lore raw

Hi,

There may be a reason to avoid the GATE instruction...I've seen some HP PA-RISC systems where GATE has given way to simply marking the "gateway" page as non-executable, and relying on a trap handler to detect the gateway access. The final result is the same... an architected method of doing a system call. (I can only conjecture that there is a reason for this...but I don't know what it is.)

Perhaps we can get an HP person to comment?

Quoted 2 lines

It does not matter as long as the gateway instruction is on the "special" page. Probably one wants to put a nop before the gateway instruction.

Signature · 2 lines
Stan Sieler                                          [email protected]
                                     http://www.allegro.com/sieler.html
#7 lore raw
In reply to Mike Shaver

Making, drinking tea and reading an opus magnum from Mike Shaver:

Quoted 11 lines
Quoted 6 lines · Bob Pflederer
Quoted 3 lines

OK, I'm convinced. I've changed unistd.h to use 0xC0000404 (on the next page) for the syscall gateway, although we can easily change it back.

Isn't the next page at 0xc0001000? Or does linux have some concept of 1k "pages" even though pages in the TLB are 4k?

Brain-o. 0xC0001004 it is.

While we're on the topic, though: why 0xC0000004 and not 0xC0000000 as

0xC0000004 is because hpux uses it (;
dunno about linux's binary emulation principles, but for
all bsd's the emulation parameters pointer is located in the proc structure, which allows syscall emulation to work even all the emulated os'es are using the same syscall entry point (on some architectures there might be only one possible way for syscall, 4 xampl)

Quoted 3 lines

the target address? (Although there are other bugs, like ``ldo 5,%r22'' instead of ``ldi 5,%r22'' in the Assembler Ref as well, so maybe this is another?)

there is no such pa-risc instruction like ldi, it's a pseudo-asm-insn which is actually ldo imm(0), rt
the whole pa-risc asm is full of pseudo-insns (like comb, comib, b(ranch))

cu

Signature · 1 line
    paranoic mickey       (my employers have changed but, the name has remained)
#8 lore raw
Quoted 3 lines · Michael Shalayeff

Making, drinking tea and reading an opus magnum from Mike Shaver:

Quoted 1 line

While we're on the topic, though: why 0xC0000004 and not 0xC0000000 as

0xC0000004 is because hpux uses it (;

Actually, I meant ``why does HP-UX use that address?''. =)

Quoted 5 lines

dunno about linux's binary emulation principles, but for
all bsd's the emulation parameters pointer is located in the proc structure, which allows syscall emulation to work even all the emulated os'es are using the same syscall entry point (on some architectures there might be only one possible way for syscall, 4 xampl)

Yes, we can do that too (and do on SPARC for Solaris at least, perhaps SunOS as well), but it seems less efficient than just using different syscall numbers or -- in the case of lovely hardware like PA-RISC -- using a different gateway address.

Quoted 6 lines
Quoted 3 lines

the target address? (Although there are other bugs, like ``ldo 5,%r22'' instead of ``ldi 5,%r22'' in the Assembler Ref as well, so maybe this is another?)

there is no such pa-risc instruction like ldi, it's a pseudo-asm-insn which is actually ldo imm(0), rt
the whole pa-risc asm is full of pseudo-insns (like comb, comib, b(ranch))

That I know, but ``ldo 5,%r22'' is illegal syntax (according to gas and the assembler reference, anyway), and that's what appears in the Assembler Ref.

Mike

Signature · 1 line
158640.45 72598.35
#9 lore raw

Making, drinking tea and reading an opus magnum from Mike Shaver:

Quoted 5 lines
Quoted 3 lines · Michael Shalayeff

Making, drinking tea and reading an opus magnum from Mike Shaver:

Quoted 1 line

While we're on the topic, though: why 0xC0000004 and not 0xC0000000 as

0xC0000004 is because hpux uses it (;

Actually, I meant ``why does HP-UX use that address?''. =)

my guess is NULL-challenge (:

Quoted 10 lines
Quoted 5 lines

dunno about linux's binary emulation principles, but for
all bsd's the emulation parameters pointer is located in the proc structure, which allows syscall emulation to work even all the emulated os'es are using the same syscall entry point (on some architectures there might be only one possible way for syscall, 4 xampl)

Yes, we can do that too (and do on SPARC for Solaris at least, perhaps SunOS as well), but it seems less efficient than just using different syscall numbers or -- in the case of lovely hardware like PA-RISC -- using a different gateway address.

ok, valid.
let's think what is less efficient: extra mapped page, or extra indirrect ptr reference?
my point is, why map extra page (and waiste extra page) ?
one page is 128 page dir entries, hehe (; returning to the pd discussion)

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

the target address? (Although there are other bugs, like ``ldo 5,%r22'' instead of ``ldi 5,%r22'' in the Assembler Ref as well, so maybe this is another?)

there is no such pa-risc instruction like ldi, it's a pseudo-asm-insn which is actually ldo imm(0), rt
the whole pa-risc asm is full of pseudo-insns (like comb, comib, b(ranch))

That I know, but ``ldo 5,%r22'' is illegal syntax (according to gas and the assembler reference, anyway), and that's what appears in the Assembler Ref.

ah, oh, that's too bad.
i guess i've made the typo/reado as they did in the manual (:
(btw, 'i' and 'o' are very close on the kbd ;)

cu

Signature · 1 line
    paranoic mickey       (my employers have changed but, the name has remained)
#10 lore raw

Re:

Quoted 4 lines

let's think what is less efficient: extra mapped page, or extra indirrect ptr reference?
my point is, why map extra page (and waiste extra page) ?
one page is 128 page dir entries, hehe (; returning to the pd discussion)

If you're talking about the gateway page, if you don't actually *allocate* a page, but simply rely on the trap that occurs when you try to jump to it, then there's 0 storage cost for the extra mapped page approach...no TLB entry, no entries in other data structures. The only cost is the additional CPU time in the TLB miss handler to say:

if isr.ior = 0xc0000400 (or whatever)
then handle system call attempt
else
handle TLB miss

BTW, the extra cost of doing a system call mechanism via a non-mapped gateway page vs. using a GATE instruction is about 5 microseconds on a 32MHz machine.

Signature · 2 lines
Stan Sieler                                          [email protected]
                                     http://www.allegro.com/sieler.html
#11 lore raw

re
okie, but why emulating gate instruction, when there is already such instruction exist? (;
page w/ gate instructions needed for existing (3 already) operating systems compatibility, so it's needed anyway, and btw having the gateway page mapped (and only one) could result in that it's tlb mapping would persist in the tlb improving perfomance, while doing if() would always penilize. this needs actual measurement, but i beleive certain cases w/ many syscalls being called should be very possible.
cu

Making, drinking tea and reading an opus magnum from Stan Sieler:

Quoted 26 lines

Re:

Quoted 4 lines

let's think what is less efficient: extra mapped page, or extra indirrect ptr reference?
my point is, why map extra page (and waiste extra page) ?
one page is 128 page dir entries, hehe (; returning to the pd discussion)

If you're talking about the gateway page, if you don't actually *allocate* a page, but simply rely on the trap that occurs when you try to jump to it, then there's 0 storage cost for the extra mapped page approach...no TLB entry, no entries in other data structures. The only cost is the additional CPU time in the TLB miss handler to say:

if isr.ior = 0xc0000400 (or whatever)
then handle system call attempt
else
handle TLB miss

BTW, the extra cost of doing a system call mechanism via a non-mapped gateway page vs. using a GATE instruction is about 5 microseconds on a 32MHz machine.

Signature · 2 lines
Stan Sieler                                          [email protected]
                                     http://www.allegro.com/sieler.html
Signature · 1 line
    paranoic mickey       (my employers have changed but, the name has remained)