<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: question about sgdt in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911129#M11909</link>
    <description>Please got to &lt;FONT color="navy" face="Arial" size="2"&gt;&lt;SPAN&gt;Intel Customer Support email form, &lt;A title="http://supportmail.intel.com/scripts-emf/welcome.aspx" href="http://supportmail.intel.com/scripts-emf/welcome.aspx"&gt;http://supportmail.intel.com/scripts-emf/welcome.aspx&lt;/A&gt;&lt;BR /&gt;for further information on your question&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;</description>
    <pubDate>Mon, 31 Mar 2008 17:08:42 GMT</pubDate>
    <dc:creator>Steven_T_Intel</dc:creator>
    <dc:date>2008-03-31T17:08:42Z</dc:date>
    <item>
      <title>question about sgdt</title>
      <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911127#M11907</link>
      <description>&lt;SPAN class="postbody"&gt;Hi there,
&lt;BR /&gt;
I am  using `sgdt' instruction in my user space application and don't really 
&lt;BR /&gt;
understand the results. The point is when I run application more time `sgdt' 
&lt;BR /&gt;
doesn't return the same result every time. I am talking about returned base 
address of GDT which is seems to be not same every time I run the instruction. See my code
below.
&lt;BR /&gt;

&lt;BR /&gt;
So my question is:
&lt;BR /&gt;Is the GDTR content constant all the time the linux is running?
&lt;BR /&gt;
 
&lt;BR /&gt;
Regards,
&lt;BR /&gt;pocdevel.
&lt;BR /&gt;

&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include &lt;STDIO.H&gt;
&lt;/STDIO.H&gt;&lt;/SPAN&gt;&lt;BR /&gt;

&lt;BR /&gt;&lt;SPAN&gt;
typedef struct {
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
  unsigned short limit;
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
  unsigned int base __attribute__((packed));
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
} gdt_t;
&lt;/SPAN&gt;&lt;BR /&gt;

&lt;BR /&gt;&lt;SPAN&gt;
static inline gdt_t* inl_sgdt(gdt_t* m)
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
{
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
  __asm__ __volatile__("sgdt %0":"=m"(*m)::"memory");
&lt;/SPAN&gt;&lt;BR /&gt;

&lt;BR /&gt;&lt;SPAN&gt;
  return m;
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
}
&lt;/SPAN&gt;&lt;BR /&gt;

&lt;BR /&gt;&lt;SPAN&gt;
int main(void)
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
{
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
  gdt_t gdt;
&lt;/SPAN&gt;&lt;BR /&gt;

&lt;BR /&gt;&lt;SPAN&gt;
  printf("--- Checking `inl_sgdt' ---
");
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
  inl_sgdt((gdt_t*)&amp;amp;gdt);
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
  printf("base: 0x%X limit: 0x%X sizeof: %d
", gdt.base, gdt.limit, sizeof(gdt));
&lt;/SPAN&gt;&lt;BR /&gt;

&lt;BR /&gt;&lt;SPAN&gt;
  return 0;
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;
}
&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="postbody"&gt;&lt;/SPAN&gt;&lt;SPAN class="postbody"&gt;&lt;BR /&gt;
Now if you run the code more times you should get different values for base address (gdt.base). I my case are:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="postbody"&gt;base: &lt;SPAN&gt;0xC1813000&lt;/SPAN&gt; limit: 0xFF sizeof: 6
&lt;BR /&gt;
...
&lt;BR /&gt;
base: &lt;SPAN&gt;0xC1809000&lt;/SPAN&gt; limit: 0xFF sizeof: 6
&lt;BR /&gt;

&lt;BR /&gt;
If I understand well `sgdt' instruction should store 6 bytes content of GDTR at given 
address (in my case &amp;amp;gdt). I don't understand why I get two different&lt;BR /&gt;values for gdt.base.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;</description>
      <pubDate>Tue, 25 Mar 2008 13:16:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911127#M11907</guid>
      <dc:creator>pocdev</dc:creator>
      <dc:date>2008-03-25T13:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: question about sgdt</title>
      <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911128#M11908</link>
      <description>The same question is appearing in the thread:&lt;BR /&gt;&lt;A href="http://www.osdev.org/phpBB2/viewtopic.php?p=122469&amp;amp;sid=22578b099869ee17b931ea9946e1c848" target="_blank"&gt;http://www.osdev.org/phpBB2/viewtopic.php?p=122469&amp;amp;sid=22578b099869ee17b931ea9946e1c848&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Another question to follow is; which distro are you running?&lt;BR /&gt;&lt;BR /&gt;To Mis-quote Obi-Wan Kenobi, "Use the source Luke"! Look at the source code for the system you are running to see where a sgdt instruction is being used. &lt;BR /&gt;&lt;BR /&gt;Also, it is somewhat confusing to understand why this question arrives in a forum about Virtualization.&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Mar 2008 16:44:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911128#M11908</guid>
      <dc:creator>Steven_T_Intel</dc:creator>
      <dc:date>2008-03-25T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: question about sgdt</title>
      <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911129#M11909</link>
      <description>Please got to &lt;FONT color="navy" face="Arial" size="2"&gt;&lt;SPAN&gt;Intel Customer Support email form, &lt;A title="http://supportmail.intel.com/scripts-emf/welcome.aspx" href="http://supportmail.intel.com/scripts-emf/welcome.aspx"&gt;http://supportmail.intel.com/scripts-emf/welcome.aspx&lt;/A&gt;&lt;BR /&gt;for further information on your question&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;</description>
      <pubDate>Mon, 31 Mar 2008 17:08:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911129#M11909</guid>
      <dc:creator>Steven_T_Intel</dc:creator>
      <dc:date>2008-03-31T17:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: question about sgdt</title>
      <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911130#M11910</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
I realize this thread is very old, but I was interested too and the post on osdev didn't satisfy me. I suspected the behavior you saw was due to your code running on multiple CPUs.&lt;BR /&gt;&lt;BR /&gt;I wrote a kernel module (attached tarball) to test this by running a function on each CPU to dump the GDT. The results (reproduced here for convenience) were consistent with my theory:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[plain]CPU 1: Storing GDT...
CPU 1:     GDT base  = 0xc211e000
CPU 1:     GDT limit = 0x      ff
CPU 0: Storing GDT...
CPU 0:     GDT base  = 0xc2018000
CPU 0:     GDT limit = 0x      ff
[/plain]&lt;/PRE&gt;
&lt;BR /&gt;CPU #1 and CPU #0 on my system invariably report these two GDT base addresses, respectively. At least in my case, that seems to explain the matter--one GDT per CPU.&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Jan 2010 18:16:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911130#M11910</guid>
      <dc:creator>strictlymike</dc:creator>
      <dc:date>2010-01-06T18:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: question about sgdt</title>
      <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911131#M11911</link>
      <description>&lt;P&gt;Thank you for the information. It is very helpful for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2010 21:44:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911131#M11911</guid>
      <dc:creator>duzyatko2yahoo_com</dc:creator>
      <dc:date>2010-01-15T21:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: question about sgdt</title>
      <link>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911132#M11912</link>
      <description>Glad to hear it! Do feel free to rate my answer if you found it to be helpful ;-)</description>
      <pubDate>Tue, 16 Feb 2010 04:28:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/question-about-sgdt/m-p/911132#M11912</guid>
      <dc:creator>strictlymike</dc:creator>
      <dc:date>2010-02-16T04:28:34Z</dc:date>
    </item>
  </channel>
</rss>

