* Reading the GDT in kernel space?
@ 2006-08-23 14:09 Rajat Jain
2006-08-23 15:29 ` Josef Sipek
2006-08-24 8:40 ` mohanlal jangir
0 siblings, 2 replies; 4+ messages in thread
From: Rajat Jain @ 2006-08-23 14:09 UTC (permalink / raw)
To: kernelnewbies, Linux Newbie
Hi,
I'm trying to read & display the GDT contents in kernel space. Is this
permissible? I used the "sgdt" assembly instruction to load the GDT
register, and found out the address & length of GDT from that (It is
"0000c248") . Is this the physical or the virtual address?
I'm now trying to print out the contents of GDT. I am able to print
this address. BUt the moment I try to deference it, the kernel OOPS. I
understand that this is because the address is not in kernel virtual
address space (3GB). I tried using "ioremap" but it always returns
NULL. Any ideas?
Thanks in Advance,
Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Reading the GDT in kernel space?
2006-08-23 14:09 Reading the GDT in kernel space? Rajat Jain
@ 2006-08-23 15:29 ` Josef Sipek
2006-08-24 8:40 ` mohanlal jangir
1 sibling, 0 replies; 4+ messages in thread
From: Josef Sipek @ 2006-08-23 15:29 UTC (permalink / raw)
To: Rajat Jain; +Cc: kernelnewbies, Linux Newbie
On Wed, Aug 23, 2006 at 07:39:22PM +0530, Rajat Jain wrote:
> Hi,
>
> I'm trying to read & display the GDT contents in kernel space. Is this
> permissible? I used the "sgdt" assembly instruction to load the GDT
> register, and found out the address & length of GDT from that (It is
> "0000c248") . Is this the physical or the virtual address?
I quickly looked at the Intel Instruction Set Reference for SGDT, and it
says that the stored value is 6 bytes long.
"The 16-bit limit field of the register is stored in the low 2 bytes of the
memory location and the 32-bit base address is stored in the high 4 bytes."
0xc248xxxx looks like a valid address, so my guess is that you are off by 2
bytes :)
Hope this helps,
Josef "Jeff" Sipek.
--
Once you have their hardware. Never give it back.
(The First Rule of Hardware Acquisition)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Reading the GDT in kernel space?
2006-08-23 14:09 Reading the GDT in kernel space? Rajat Jain
2006-08-23 15:29 ` Josef Sipek
@ 2006-08-24 8:40 ` mohanlal jangir
2006-08-28 0:47 ` Rene Herman
1 sibling, 1 reply; 4+ messages in thread
From: mohanlal jangir @ 2006-08-24 8:40 UTC (permalink / raw)
To: Rajat Jain; +Cc: Linux Newbie, kernelnewbies
> Hi,
>
> I'm trying to read & display the GDT contents in kernel space. Is this
> permissible? I used the "sgdt" assembly instruction to load the GDT
> register, and found out the address & length of GDT from that (It is
> "0000c248") . Is this the physical or the virtual address?
It's a physical address. Convert in virtual address using __va(x) before
dereferencing.
>
> I'm now trying to print out the contents of GDT. I am able to print
> this address. BUt the moment I try to deference it, the kernel OOPS. I
> understand that this is because the address is not in kernel virtual
> address space (3GB). I tried using "ioremap" but it always returns
> NULL. Any ideas?
>
> Thanks in Advance,
>
> Rajat
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Reading the GDT in kernel space?
2006-08-24 8:40 ` mohanlal jangir
@ 2006-08-28 0:47 ` Rene Herman
0 siblings, 0 replies; 4+ messages in thread
From: Rene Herman @ 2006-08-28 0:47 UTC (permalink / raw)
To: mohanlal jangir; +Cc: Rajat Jain, Linux Newbie, kernelnewbies
mohanlal jangir wrote:
>> I'm trying to read & display the GDT contents in kernel space. Is
>> this permissible?
Sure. Also note that sgdt is available from userspace even.
>> I used the "sgdt" assembly instruction to load the GDT register,
>> and found out the address & length of GDT from that (It is
>> "0000c248") . Is this the physical or the virtual address?
SGDT gets you a kernel virtual address. That 0000c248 isn't though and
it's incorrect. The problem you will be experiencing is that you haven't
told GCC to pack the struct in which you put the result. If you declare:
struct gdtr {
u16 limit;
u32 base;
};
then gcc will align the 32-bit base field on a 32-bit boundary, meaning
it will end up looking like:
struct gdtr {
u16 limit;
u16 padding
u32 base;
};
SGDT then stores into the limit and padding and only the low 16-bits of
base (your base is actually 0xc248xxxx). To avoid this, tell GCC to pack
the struct:
struct gdtr {
u16 limit;
u32 base;
} __attribute__((packed));
Rene.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-28 0:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-23 14:09 Reading the GDT in kernel space? Rajat Jain
2006-08-23 15:29 ` Josef Sipek
2006-08-24 8:40 ` mohanlal jangir
2006-08-28 0:47 ` Rene Herman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.