All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@keyaccess.nl>
To: mohanlal jangir <mohanlal@samsung.com>
Cc: Rajat Jain <rajat.noida.india@gmail.com>,
	Linux Newbie <linux-newbie@vger.kernel.org>,
	kernelnewbies <kernelnewbies@nl.linux.org>
Subject: Re: Reading the GDT in kernel space?
Date: Mon, 28 Aug 2006 02:47:23 +0200	[thread overview]
Message-ID: <44F23D1B.4020605@keyaccess.nl> (raw)
In-Reply-To: <003001c6c758$e88c8310$26526c6b@sisodomain.com>

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

      reply	other threads:[~2006-08-28  0:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44F23D1B.4020605@keyaccess.nl \
    --to=rene.herman@keyaccess.nl \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-newbie@vger.kernel.org \
    --cc=mohanlal@samsung.com \
    --cc=rajat.noida.india@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.