[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: [LI] user space, kernel space and .........



Hi

 Two paisa from me too. -:)

On Wed, 12 Jan 2000, Nick Hill wrote:

> Hi ppl. Here is a few paise of muh mind...
> 
> 
> I think U're confused here. The levels here being
> referred to are levels of hardware, mainly memory
> access and CPU registers. I dont think the super user
> and normal user talk comes in here. The 3 levels, that
> Khader is talking about are better known in hardware
> terms as "rings". On Intel processors, there are 4
> rings in which a process in protected mode can run.
> ring 0 to ring 3. The kernel, be it doze or Linux, or
> any protected mode OS (NOT DOS), runs in ring 0. And
> is responsible for assigning virtualized registers for
> various other processors. Since the days of the 386,
> there is a special mode on the CPU, which is called
> the V86 Mode or Virtual 86 mode, which can emulate a
> no. of virtual processes, though the control of
> execution of the independant processes is given by the
> app. running on a higher ring of the protected mode.
> Khader, as u are learning about Device Drivers, U must
> understand that direct access to memory is NOT allowed
> in a protected environment. It was allowed under DOS,
> but NEVER under DPMI or VCPI modes, which are the only

Direct access *is* allowed otherwise it will be overhead for the hardware.
But there is a difference. When you access a memory address, memory
translation(This is hardware translation)  using GDT/LDT takes place. This
operation *can* check
permissions and deny access if you are trying to access memory that is not
yours. That generatea an interrupt and OS is notifies for the action.
Result, you see segmentation fault and core dump under Unix/linux(and
viruses under doze -:) )

 > way to put the machine into ProtectedMode and thereby
 > allow access to the extended memory, for normal
> program relocation. BC 3.1+ provided some functions to
> access the mem > 1MB by using EMS or XMS, but the
> space could be only used for storage of data, but
> NEVER a CS:IP would fall in that area. So,

This all EMS/XMS funda is a waste of time and effort from 386 onwards.
What you see is 32 bit i.e. 4GB address space. Plain and simple. All
locations are same in all manners as others. Your CS:IP can be anywhere.
Only thing is that your OS need to be capable of handling that. Windows ke
bas ke baat nahee hai.
Furthermore original EMS/XMS ws designed by Intel+Lotus+IBM(correct me if
I am wrong). Those were memory cards like other cards because motherboards
were designed to host 640KB of memory only. It's not the case with 386
onward motherboards. Whatever memory available *can* be seen as homogenous
and continous on those machines. I don't know why Microsoft continued with
old funda.

 > Technically, u could never overwritedata with u're
 > code, as the 16 bit regs. of CS and IP didn't allow
> for accessing more than that. However, in protected
> mode, this is possible, and to prevent other apps,

In protected mode CS:IP stands for code selector:IP offsset. CS points to
code selector that in turn points to actual segment address in which the
offset is added. The length of segment can be checked. And walking into
other segment by incrementing offset is not possible. You will get a
segmentation fault.

 > from writing into u're addressspace, or storage
 > location, The Memory Protection offered by The 386+
> PM, increases the need for ring based heirarchy in
> processors. Since all of the Device memory, be it
> Network card buffers, RAM, ROM, Sound Card, Video
> cards, etc. ,all of their mem, is mapped on to a
> particular loacation in RAM, whose current limit is
> 4GB. So u have to "REQUEST" the kernel to provide u
> access to a specified segment of memory, before
> performing I/O ops on it. But, handling PCI devices is
> pretty easy, atleast Linux makes it easy.. :) Its got
> a cute data structure of pci_dev which can represent
> any PCI device, and allows to fiddle with the memory
> on the device, w/o bothering about remapping it to
> linear address space. See
> /usr/src/linux/Documentation/IO-mapping.txt for more
> info on IO-remapping on different CPU archs... I think
> I've overshooted the topic... I think I'll end it
> here... ;-)
> 
> 
> ya... ring 0 to ring 3. I dunno if it exists on other
> processors. MacOS didn't have multitasking ability,
> which NEEDS a mode similar to Intel's V86 mode. So i
> doubt if the 68000 had any PM. The PowerPC has it. I
> dunno 'bout the Alpha. As far as i know, it must be
> having...
> 
> Nikhil.


 Bye
  Shridhar


--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.