I'm trying to use float and double data types inside the kernel module. As part of satisfying my curiosity, I have written simple LKM. Here it is,
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int __init hello_start(void)
{
float x,y,z;
x = 22.27;
y = 7.25;
z = x/y;
unsigned int *u;
u = (unsigned int *)&z;
printk(KERN_INFO "0x%x\n", *u);
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Unload...\n");
}
module_init(hello_start);
module_exit(hello_end);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("XYZ");
As float will store a value into memory/register by IEEE754 format so I can assign it into 32-bit wide data types like unsigned int. And inside code same things I did and I got perfect HEX values of IEEE754 spec. In this case 22.27/7.25 = 3.071724138 and 3.071724138 normalize IEEE754 value in hex is 0x40449721. The dmesg shows me 0x40449721 while loading module.
So now questions are,
1) How can a see disassembly of my kernel module? so I can verify for float data store and division which instruction is used. (my platform is x86_64).
2) If I can able to see perfect hex value of division, then what is the role of API like kernel_fpu_begin()/kernel_fpu_end() because without using it I can perform float division? the division is performed by which hardware? what about hardware FPU?
3) This division is performed by SSE2 instructions or something else (that why I need assembly file of LKM)