2012/10/28 Fan Yang <[email protected]> > > > 2012/10/27 Jun Hu <[email protected]> > >> Can you post out your codes ? >> >> *From:* Fan Yang <[email protected]> >> *Sent:* Wednesday, October 24, 2012 8:04 PM >> *To:* [email protected] >> *Subject:* linux segment >> >> Hi all: >> I print the cs ds and ss register in the user space, and it is same >> as the __USER_CS and __USER_DS which defined in kernel as 73 and 7b. In the >> kernel __KERNEL_CS and __KERNEL_DS defined as 60 and 68, but when I print >> this two value in my kernel module, I get 60 and 7b. Why ? It should be 60 >> and 68, shouldn't it? >> >> >> >> ------------------------------ >> _______________________________________________ >> Kernelnewbies mailing list >> [email protected] >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> >> Hi Jun Hu > There is my code which run at the user space: > > 1 #include<stdio.h> > 2 main() > 3 { > 4 unsigned long cs, ds, ss, es, fs, gs; > 5 asm volatile("movl %%CS,%0\n\t":"=r"(cs)); > 6 asm volatile("movl %%DS,%0\n\t":"=r"(ds)); > 7 asm volatile("movl %%SS,%0\n\t":"=r"(ss)); > 8 asm volatile("movl %%ES,%0\n\t":"=r"(es)); > > 9 asm volatile("movl %%FS,%0\n\t":"=r"(fs)); > 10 asm volatile("movl %%GS,%0\n\t":"=r"(gs)); > 11 printf ("**********************************\n"); > 12 printf ("cs %lx\t%ld\n", cs, cs); > 13 printf ("ds %lx\t%ld\n", ds, ds); > 14 printf ("ss %lx\t%ld\n", ss, ss); > 15 printf ("es %lx\t%ld\n", es, es); > 16 printf ("fs %lx\t%ld\n", fs, fs); > 17 printf ("gs %lx\t%ld\n", gs, gs); > 18 printf ("**********************************\n"); > 19 } > > > > and the result of the progress in my machine is > > > ********************************** > cs 73 115 > ds 7b 123 > ss 7b 123 > es 7b 123 > fs 0 0 > gs 33 51 > ********************************** > > > so, you can see the cs and ds register is 73 and 7b which are same as the > kernel defined. And the code of the kernel module is > > > 1 #include<linux/init.h> > > 2 #include<linux/kernel.h> > 3 #include<linux/module.h> > 4 > 5 static void __init print_init (void) > 6 { > 7 unsigned long cs, ds, ss, es, fs, gs,currenttime; > 8 asm volatile("movl %%CS,%0\n\t":"=r"(cs)); > 9 asm volatile("movl %%DS,%0\n\t":"=r"(ds)); > 10 asm volatile("movl %%SS,%0\n\t":"=r"(ss)); > 11 asm volatile("movl %%ES,%0\n\t":"=r"(es)); > 12 asm volatile("movl %%FS,%0\n\t":"=r"(fs)); > 13 asm volatile("movl %%GS,%0\n\t":"=r"(gs)); > 14 printk ("**********************************\n"); > 15 printk ("cs %lx\t%ld\n", cs, cs); > 16 printk ("ds %lx\t%ld\n", ds, ds); > 17 printk ("ss %lx\t%ld\n", ss, ss); > 18 printk ("es %lx\t%ld\n", es, es); > 19 printk ("fs %lx\t%ld\n", fs, fs); > 20 printk ("gs %lx\t%ld\n", gs, gs); > 21 printk ("**********************************\n"); > 22 > 23 } > 24 > 25 static void __exit print_exit (void) > 26 { > 27 unsigned long cs, ds, ss; > 28 asm volatile("movl %%cs,%0\n\t":"=r"(cs)); > 29 asm volatile("movl %%ds,%0\n\t":"=r"(ds)); > 30 asm volatile("movl %%ss,%0\n\t":"=r"(ss)); > 31 > 32 printk ("**********************************\n"); > 33 printk ("cs %lx\t%ld\n", cs, cs); > 34 printk ("ds %lx\t%ld\n", ds, ds); > 35 printk ("ss %lx\t%ld\n", ss, ss); > 36 printk ("**********************************\n"); > 37 printk ("*****************bye***************\n"); > 38 } > 39 > 40 module_init (print_init); > 41 module_exit (print_exit); > > 42 MODULE_LICENSE ("GPL"); > > > the result of the running this module is > > [root@shell--box kernel_mod]# dmesg -c > ********************************** > cs 60 96 > ds 7b 123 > ss 68 104 > es 7b 123 > fs d8 216 > gs e0 224 > ********************************** > > The cs and ds in the kernel space is 60 and 7b. But the kernel define the > KERNEL_CS as 60 and the KERNEL_DS as 7b. Where am I wrong? > > > Thanks > Fan >
sorry, the kernel define the KERNEL_DS as 68, but I get 7b in my machine.
_______________________________________________ Kernelnewbies mailing list [email protected] http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
