Number of times that xen added hypercall to retrieve page_fault

Source: Internet
Author: User

 

1. Register a hypercall call number first.
Xen/include/public/xen. h
# DEFINE _ hypervisor_kexec_op 37
+ # DEFINE _ hypervisor_print 38

2. Update the system call table
/Xen/ARCH/x86/x86_32/entry. s
Entry (hypercall_table)

. Long do_kexec_op
+. Long do_print_string

Entry (hypercall_args_table)

. Byte 2/* do_kexec_op */
+. Byte 1

3. Define the function header file
/Xen/include/asm-x86/hypercall. h

Extern int
Do_kexec (
Unsigned long op, unsigned arg1, xen_guest_handle (void) UARG );

+ Extern int
+ Do_print (void );

4. In/xen/ARCH/x86/traps. c
Add a global variable
Long mynr_page_fault = 0;

Count the number of times in the do_page_fault () function. After each execution, add 1 to mynr_page_fault.

Custom Functions
Int do_print (void)

{

Printk ("#################### test begin/N ");

Printk ("nr_page_fault: % LD/N", mynr_page_fault );

Return 1;

}
Then make DIST and make install to create the initialization boot disk.

 

5. edit a print. c file for testing in the user space.

 

# Include <stdio. h>
# Include <stdlib. h>
# Include <errno. h>
# Include <sys/IOCTL. h>
# Include <sys/types. h>
# Include <fcntl. h>
# Include <string. h>
# Include <xenctrl. h>
# Include <xen/sys/privcmd. h>
Int main ()
{
Int FD, RET;
Private_hypercall_t hcall = {
_ Hypervisor_print_string,
{0, 0, 0, 0}
};
FD = open ("/proc/xen/privcmd", o_rdwr );
If (FD <0)
{
Perror ("open ");
Exit (1 );
} Else
Printf ("FD = % d/N", FD );
Ret = IOCTL (FD, ioctl_private_hypercall, & hcall );
Printf ("ret = % d/N", RET );
}

 

6. Test
[Root @ locahost ~] Gcc-o a print. c

[Root @ locahost ~] ./

[Root @ locahost ~] Xm dm | tail-N 1

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.