Why was Intel a no-show on No Execute?

P

Peter \Firefly\ Lund

I'm not going to get into C compiler design issues, if C requires that the
stack and data segments be combined, then let them be combined. That's also

It does not.

You can have one segment per object, if you like.

-Peter
 
Y

Yousuf Khan

Robert Wessel said:
No. It's quite common to pass a pointer to a piece of automatic (on
stack) storage to a function accepting pointers to that type of data.
Or a pointer to global, or allocated storage. Unless you pass some
additional data (in x86, a selector, for example), the called routine
has no way to tell which segment to look in. Consider:

Well, as I said in another message, if stack and data need to share the same
segment, then you can share the same segment for them. You still don't have
to combine them into the same segment as the code segment.

Yousuf Khan
 
J

Jerry Peters

In comp.sys.ibm.pc.hardware.chips Yousuf Khan said:
True, but we're not talking about a pure segments-only arrangement. We're
talking about a segmented/paged arrangement. Each segment could could have
its own separate page entries in the page directory. Meaning that with
demand-paging only the sections of a segment required to be in memory could
be in memory while the rest remains marked virtual on disk.

Yousuf Khan
No, that still doesn't get you an address space > 4GB.

"Each segment could could have its own separate page entries in the
page directory." What the heck does this mean? A segment doesn't "have"
any entries in the page directory, the linear address which results
from segmentation gets translated to a physical address using the
page directory & page table entries. A linear address is 32 bits,
that's 4GB of address space.

Jerry
 
J

Jerry Peters

In comp.sys.ibm.pc.hardware.chips Yousuf Khan said:
Well, I'm sure the C compiler implementation would know when it's accessing
a stack element or a data element, and use the appropriate pointers (i.e.
stack or data). When are the only times you'd be pointing to an element on
the stack? It's usually only done when accessing a passed argument. You
should know which arguments are passed into a function, and which ones are
local to the function.

In a function, automatic local variables are on the stack. I can pass
the address of one of these to any function which is expecting a
pointer of that type, I could also pass an address of a global or an
address returned by malloc, all in the same function call; think
printf and friends and character string arguments. In fact, with a
literal format string and using gcc defaults, I'd also be passing a
pointer in the text area of the program since gcc defaults to putting
ro strings in the code area.

Jerry


---snip-----
 
P

Peter \Firefly\ Lund

Well, as I said in another message, if stack and data need to share the same
segment, then you can share the same segment for them. You still don't have
to combine them into the same segment as the code segment.

What on Earth has that got to do with anything? You still need long
pointers -- if your compiler is heroic, it can optimize some of the
pointer operations into short pointers (i.e. 4-byte pointers).

-Peter
 
R

Robin KAY

Peter said:
What on Earth has that got to do with anything? You still need long
pointers

What for? If 'DS == SS' then a pointer dereferenced through either
segment will refer to the same memory location. All that's necessary is
to restrict the size of the code segment so that it doesn't include
memory used for the heap or stack.
 
A

Alexander Grigoriev

You then can only have only one code segment and only one data segment,
which at the same time should be stack segment.

You then have to reserve a whole area for code only, and load all code
segments of all dynamic libraries there, and reserve the rest for data. You
won't be able to arbitrarily mix data and code areas - it would require
'far' pointers, which are a pain.
 
Y

Yousuf Khan

Jerry Peters said:
No, that still doesn't get you an address space > 4GB.

"Each segment could could have its own separate page entries in the
page directory." What the heck does this mean? A segment doesn't
"have" any entries in the page directory, the linear address which
results from segmentation gets translated to a physical address
using the page directory & page table entries. A linear address is
32 bits, that's 4GB of address space.

Well, when you're using a task gate to switch between programs, you can set
each task to have its own unique page table base address (loaded into CR3).
Each task could have its own page table. You can map all programs to have
their own unique pages, including unique virtual pages.

Yousuf Khan
 
Y

Yousuf Khan

Jerry Peters said:
No, that still doesn't get you an address space > 4GB.

"Each segment could could have its own separate page entries in the
page directory." What the heck does this mean? A segment doesn't
"have" any entries in the page directory, the linear address which
results from segmentation gets translated to a physical address
using the page directory & page table entries. A linear address is
32 bits, that's 4GB of address space.

Well, when you're using a task gate to switch between programs, you can set
each task to have its own unique page table base address (loaded into CR3).
Each task could have its own page table. You can map all programs to have
their own unique pages, including unique virtual pages.

Yousuf Khan
 
Y

Yousuf Khan

Jerry Peters said:
No, that still doesn't get you an address space > 4GB.

"Each segment could could have its own separate page entries in the
page directory." What the heck does this mean? A segment doesn't
"have" any entries in the page directory, the linear address which
results from segmentation gets translated to a physical address
using the page directory & page table entries. A linear address is
32 bits, that's 4GB of address space.

Well, when you're using a task gate to switch between programs, you can set
each task to have its own unique page table base address (loaded into CR3).
Each task could have its own page table. You can map all programs to have
their own unique pages, including unique virtual pages.

Yousuf Khan
 
Y

Yousuf Khan

Alexander Grigoriev said:
You then can only have only one code segment and only one data
segment, which at the same time should be stack segment.

You then have to reserve a whole area for code only, and load all code
segments of all dynamic libraries there, and reserve the rest for
data. You won't be able to arbitrarily mix data and code areas - it
would require 'far' pointers, which are a pain.

You can use the page tables to map the data pages totally separately from
the code pages. In a case like that you can start your data access right
from address 0 and finish right at the 4GB address mark. There will be no
danger of it overwriting the code, because the code will have totally
different pages. The code itself could go from 0 to 4GB without ever
trampling over the data segments either. This where the paging magic comes
in.

Yousuf Khan
 
S

Stephen Sprunk

Yousuf Khan said:
You can use the page tables to map the data pages totally separately from
the code pages. In a case like that you can start your data access right
from address 0 and finish right at the 4GB address mark. There will be no
danger of it overwriting the code, because the code will have totally
different pages. The code itself could go from 0 to 4GB without ever
trampling over the data segments either. This where the paging magic comes
in.

While the physical address space can be 36-bit, isn't the linear address
space still limited to 32-bit? If that's correct, all segments must have
the same base (zero) if they're to have a 4GB limit.

S
 
P

Peter \Firefly\ Lund

What for? If 'DS == SS' then a pointer dereferenced through either
segment will refer to the same memory location. All that's necessary is
to restrict the size of the code segment so that it doesn't include
memory used for the heap or stack.

I think you misunderstood Yousuf.

-Peter
 
Y

Yousuf Khan

Stephen Sprunk said:
While the physical address space can be 36-bit, isn't the linear
address space still limited to 32-bit? If that's correct, all
segments must have the same base (zero) if they're to have a 4GB
limit.

Yes, but they can be different 4GB regions because they will have different
page mappings.

Yousuf Khan
 
S

Stephen Sprunk

Yousuf Khan said:
Yes, but they can be different 4GB regions because they will have different
page mappings.

How? LDT/GDT are used to map virtual addresses to linear addresses, and
page tables are used to map linear addresses to physical addresses. If the
linear address space is 32-bit, how can a single process address more than
4GB in unique virtual address space? My understanding is that systems over
4GB use different page directories for each process so that the linear
address space can be reused, but I don't see a similar scheme using
selectors within a single process.

S
 
P

Peter \Firefly\ Lund

How? LDT/GDT are used to map virtual addresses to linear addresses, and
page tables are used to map linear addresses to physical addresses. If the
linear address space is 32-bit, how can a single process address more than
4GB in unique virtual address space? My understanding is that systems over

It can't, really. But...
4GB use different page directories for each process so that the linear
address space can be reused, but I don't see a similar scheme using
selectors within a single process.

....if you have long pointers (with selectors), several of them, in fact,
then you can mark some of the corresponding segments as not present.
When the program tries to access it, the operating system can kick and
change the page tables (and mark the faulting segment present). You have
in effect taken the bank switching schemes from the late eighties' home
computers into the brave new modern world. Or something.

It's called pointer swizzling.

-Peter
 
J

Jerry Peters

In comp.sys.ibm.pc.hardware.chips Yousuf Khan said:
Well, when you're using a task gate to switch between programs, you can set
each task to have its own unique page table base address (loaded into CR3).
Each task could have its own page table. You can map all programs to have
their own unique pages, including unique virtual pages.

Yousuf Khan
??? You're confused. That's how Linux works now, each process has its
own page tables and hence address space. Oh, except Linux doesn't use
a task gate, since 1) it's slow, & 2) limits you to something like
4000 total processes. This still doesn't get you a _single_ AS that's
greater then 4GB. AFAIK x86 has no facilities like IBM's S3X0 has to
have access to multiple address spaces at once.

You _really_ do need to do some research on OS design and
implementation issues.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top