-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcause_smi.c
56 lines (39 loc) · 1.21 KB
/
cause_smi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <sound/initval.h>
#include <asm/io.h>
#define MSR_SMI_COUNT 0x00000034
static int my_init(void)
{
uint8_t smm_response = 0x0;
uint32_t smi_count = 0x0;
printk(KERN_INFO "Hello world.\n");
// check smi count
rdmsrl(MSR_SMI_COUNT, smi_count);
printk(KERN_INFO "SMI count earlier is %x.\n", smi_count);
//check the initial value recieve from 0xB2 port
smm_response = inb(0xb2);
printk(KERN_INFO "data recieved from port 0xb2 is %x.\n", smm_response);
//write data to 0xB2 port to cause SMI
outb(0x80, 0xb2);
// Check the respose in port 0xB2
smm_response = inb(0xb2);
printk(KERN_INFO "data recieved after is %x.\n", smm_response);
rdmsrl(MSR_SMI_COUNT, smi_count);
printk(KERN_INFO "SMI count later is %x.\n", smi_count);
return 0;
}
static void my_exit(void)
{
printk(KERN_INFO "Goodbye world.\n");
return;
}
module_init(my_init);
module_exit(my_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Shubham Dubey <shubham0d@protonmail.coms>");
MODULE_DESCRIPTION("Cause SMI and verify SMI count");