From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 2/8] test: add pagefault exception handler
Date: Wed, 24 Mar 2010 18:24:10 -0300 [thread overview]
Message-ID: <20100324212725.719993098@amt.cnet> (raw)
In-Reply-To: 20100324212408.790319364@amt.cnet
[-- Attachment #1: pf-vector --]
[-- Type: text/plain, Size: 2018 bytes --]
Which print cr2 and exits.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
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)
next prev parent reply other threads:[~2010-03-24 21:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-24 21:24 [patch 0/8] add slot deletion, rmap chain tests Marcelo Tosatti
2010-03-24 21:24 ` [patch 1/8] test: allow functions to execute on non-irq context remotely Marcelo Tosatti
2010-03-25 16:25 ` Avi Kivity
2010-03-25 18:07 ` Marcelo Tosatti
2010-03-28 6:32 ` Avi Kivity
2010-03-24 21:24 ` Marcelo Tosatti [this message]
2010-03-24 21:24 ` [patch 3/8] test: protect fwcfg accesses with lock Marcelo Tosatti
2010-03-24 21:24 ` [patch 4/8] test: export vm helpers Marcelo Tosatti
2010-03-24 21:24 ` [patch 5/8] testdev: add port to create/delete memslots Marcelo Tosatti
2010-03-25 16:27 ` Avi Kivity
2010-03-24 21:24 ` [patch 6/8] test: parallel faults vs slot deletion Marcelo Tosatti
2010-03-24 21:24 ` [patch 7/8] test: bump max vcpus to 64 Marcelo Tosatti
2010-03-24 21:24 ` [patch 8/8] test: long rmap chains Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100324212725.719993098@amt.cnet \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox