Accessing Memory Page 0 while in unprivileged mode.

111 views
Skip to first unread message

alan jojo

unread,
Sep 26, 2020, 4:58:52 AM9/26/20
to XOS Users
During Stage 6, I had to read the following documentation (image attached):

I understand that while the machine is in unprivileged mode, and INT n instruction is called, the machine needs to push the contents of IP register to user stack and then make IP to point to the starting address of the physical memory page corresponding to the particular interrupt handler, so that after the machine switches to privileged mode, the correct instruction(that is stored in the physical memory page corresponding to interrupt n) is executed by the machine.

To do this, the machine will access the IVT(Interrupt Vector Table) even before the INT instruction switches the machine to privileged mode (As reading from the IVT is given as the 2nd thing INT instruction will do and switching is given as the 3rd thing INT instruction will do [The part where this is explained is attached below]).

As far as I understand, only the logical memory pages can be accessed in unprivileged mode. Right? So, I can't understand how the INT instruction manages to read from the physical memory page 0 for accessing the IVT even before it lets the machine to switch to privileged mode. How does INT instruction do this? Can someone explain this to me?

Unprivileged_tutorial.jpg

Murali Krishnan

unread,
Sep 26, 2020, 8:05:57 AM9/26/20
to xos-...@googlegroups.com
You are right.  This is a mistake in the documentation.  The switch to privileged mode happens before the vector table is accessed , as you correctly pointed out.  
Thanks for pointing this out.  Hope Farzeen/Ishan will volunteer to make a correction in the documentation.  

--
You received this message because you are subscribed to the Google Groups "XOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xos-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/xos-users/f293614d-f879-488d-9f2f-192cc9f3a919n%40googlegroups.com.

Farseen Abdul Salam

unread,
Sep 26, 2020, 10:30:24 AM9/26/20
to XOS Users
Sure sir.
I will fix it by tomorrow.

Regards,
Farseen

Murali Krishnan

unread,
Sep 26, 2020, 10:36:20 AM9/26/20
to xos-...@googlegroups.com
Thanks Farseen
Murali

Message has been deleted

Farseen Abdul Salam

unread,
Sep 28, 2020, 10:23:31 AM9/28/20
to XOS Users
Hi Sir,
Hi Alan,

While I was updating the doc I thought more about this.
Does it matter that machine switches to privileged mode before or after accessing the IVT?
The only thing matters is that before unprivileged code cannot read or modify protected memory right?
Which is guaranteed in either case.

For reference, I'm attaching the relevant code from the simulator, It accesses IVT before switching mode.



Regards,
Farseen

Farseen Abdul Salam

unread,
Sep 28, 2020, 10:25:26 AM9/28/20
to XOS Users

2020-09-28_19-54.png
(Attachment disappeared from previous message. Trying to attach again)

Murali Krishnan

unread,
Sep 28, 2020, 11:29:44 AM9/28/20
to xos-...@googlegroups.com
I think Alan's point is that unless the machine has switched to unprivileged code, how is there an access to something outside it's address space (IVT).

Technically speaking, what Farzeen told is right  Afterall, during the execution of an un-privileged instruction like MOV or PUSH, there is implicit access to page table in memory as well as registers like PTLR and PTBR which are not accessible to user programs directly.  So, what is wrong with implicit access to memory (vector table)?   

Nevertheless, it is convenient to say that after saving the return address to stack,  the machine switches to privileged mode before accessing IVT.  This can avoid the confusion which Alan had (and some others might also have).  Moreover, after the transfer of IP to stack, there is not much gained by delaying the announcement about entering protected mode.    
 

On Mon, Sep 28, 2020 at 7:51 PM Farseen Abdul Salam <farseena...@gmail.com> wrote:
Hi Sir,
Hi Alan,

While I was updating the doc I thought more about this.
Does it matter that machine switches to privileged mode before or after accessing the IVT?
The only thing matters is that before unprivileged code cannot read or modify protected memory right?
Which is guaranteed in either case.

For reference, I'm attaching the relevant code from the simulator:
It accesses IVT before switching mode.

Regards,
Farseen

Farseen Abdul Salam

unread,
Sep 28, 2020, 11:41:44 AM9/28/20
to XOS Users
Okay sir.
I will update the docs then.

Regards,
Farseen
Reply all
Reply to author
Forward
0 new messages