Which print cr2 and exits. Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx> Index: qemu-kvm/kvm/user/test/lib/x86/smp.c =================================================================== --- qemu-kvm.orig/kvm/user/test/lib/x86/smp.c +++ qemu-kvm/kvm/user/test/lib/x86/smp.c @@ -5,6 +5,7 @@ #include "fwcfg.h" #define IPI_VECTOR 0x20 +#define PF_VECTOR 0xe static struct spinlock ipi_lock; static void (*ipi_function)(void *data); @@ -18,6 +19,20 @@ static __attribute__((used)) void ipi() ipi_done = 1; } +unsigned long read_cr2() +{ + unsigned long cr2; + + asm volatile ("mov %%cr2, %0" : "=r"(cr2)); + return cr2; +} + +static __attribute__((used)) void pf() +{ + printf("PF: %lx\n", read_cr2()); + asm ("call exit"); +} + asm ( "ipi_entry: \n" " call ipi \n" @@ -28,21 +43,31 @@ asm ( #endif ); +asm ( + "pf_entry: \n" + " call pf \n" +#ifndef __x86_64__ + " iret" +#else + " iretq" +#endif + ); + -static void set_ipi_descriptor(void (*ipi_entry)(void)) +static void set_exp_descriptor(void (*entry)(void), unsigned vec) { - unsigned short *desc = (void *)(IPI_VECTOR * sizeof(long) * 2); + unsigned short *desc = (void *)(vec * sizeof(long) * 2); unsigned short cs; - unsigned long ipi = (unsigned long)ipi_entry; + unsigned long fn = (unsigned long)entry; asm ("mov %%cs, %0" : "=r"(cs)); - desc[0] = ipi; + desc[0] = fn; desc[1] = cs; desc[2] = 0x8e00; - desc[3] = ipi >> 16; + desc[3] = fn >> 16; #ifdef __x86_64__ - desc[4] = ipi >> 32; - desc[5] = ipi >> 48; + desc[4] = fn >> 32; + desc[5] = fn >> 48; desc[6] = 0; desc[7] = 0; #endif @@ -118,8 +143,10 @@ void smp_init_ids(void) { int i; void ipi_entry(void); + void pf_entry(void); - set_ipi_descriptor(ipi_entry); + set_exp_descriptor(ipi_entry, IPI_VECTOR); + set_exp_descriptor(pf_entry, PF_VECTOR); setup_smp_id(0); for (i = 1; i < cpu_count(); ++i) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html