Re: weird IDT issue

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Apr 05 2002 - 15:27:15 EST


On Fri, 5 Apr 2002, halfdead wrote:

> hey! i experience a weird IDT issue on kernels 2.4.x. what i want to do is
> finding the address of a certain IDT gate but when i try to read memory
> from ring0 at that location it segfaults. the code is in assembler.
>
> .bss
> idtr:
> .double
> .text
>
> get_gate:
> movl $0x80, %eax
> sidt idtr

# Store contents of IDT into idtr, in space you own. Okay so far even
though '.double' isn't correct. It should be:

.section .bss
idtr: .long[2]
.section .text

> movl idtr+2, %ebx

This should put the PHYSICAL address of the base into ebx.

> leal (%ebx, %eax, 8), %ebx

Now you are going to sum the physical address in ebx with 0x80 and 8
index, putting the result into ebx. Hmmm...

> movw (%ebx), %cx <- segfault
>

Now you are going to access something in some strange location that
is either not mapped or you don't own.

> i cannot find out why is this happening.. i would apreciate any help that
> i can get.
>
> - halfdead
>

In the first place, addresses in the IDT are physical. They are mapped
in an area where there is a 1:1 correspondence between virtual and
physical. You either need to set DS to that descriptor before you
access (where the page-table is, I forget its name) it or mmap that
address so you can access it.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

                 Windows-2000/Professional isn't.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 07 2002 - 22:00:17 EST