I am using `sgdt' instruction in my user space application and can't really
understand the results. The point is when I run application more time `sgdt'
doesn't return the same result every time. I am talking about returned base
address of GDT which is not same every time I run the instruction. See my code
below.
So my questions are:
Is that ok (I guess not)?
Might it be that linux changes GDTR content somehow?
Is the GDTR content constant all the time the linux is running?
Regards,
devel.
Code: Select all
#include <stdio.h>
typedef struct {
unsigned short limit;
unsigned int base __attribute__((packed));
} gdt_t;
static inline gdt_t* inl_sgdt(gdt_t* m)
{
__asm__ __volatile__("sgdt %0":"=m"(*m)::"memory");
return m;
}
int main(void)
{
gdt_t gdt;
printf("--- Checking `inl_sgdt' ---\n");
inl_sgdt((gdt_t*)&gdt);
printf("base: 0x%X limit: 0x%X sizeof: %d\n", gdt.base, gdt.limit, sizeof(gdt));
return 0;
}