From: Rusty Russell <rusty@rustcorp.com.au>
To: "lkml" <linux-kernel@vger.kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Subject: [PATCH 04/29] lguest: add infrastructure for userspace to deliver a trap to the guest.
Date: Fri, 6 Feb 2015 15:51:47 +1030 [thread overview]
Message-ID: <1423200112-5354-5-git-send-email-rusty@rustcorp.com.au> (raw)
In-Reply-To: <1423200112-5354-1-git-send-email-rusty@rustcorp.com.au>
This is required for instruction emulation to move to userspace.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/lguest/lguest_user.c | 19 +++++++++++++++++++
include/linux/lguest_launcher.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index dcf9efd94cf4..be996d173615 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -243,6 +243,23 @@ static int user_send_irq(struct lg_cpu *cpu, const unsigned long __user *input)
return 0;
}
+/*L:053
+ * Deliver a trap: this is used by the Launcher if it can't emulate
+ * an instruction.
+ */
+static int trap(struct lg_cpu *cpu, const unsigned long __user *input)
+{
+ unsigned long trapnum;
+
+ if (get_user(trapnum, input) != 0)
+ return -EFAULT;
+
+ if (!deliver_trap(cpu, trapnum))
+ return -EINVAL;
+
+ return 0;
+}
+
/*L:040
* Once our Guest is initialized, the Launcher makes it run by reading
* from /dev/lguest.
@@ -487,6 +504,8 @@ static ssize_t write(struct file *file, const char __user *in,
return getreg_setup(cpu, input);
case LHREQ_SETREG:
return setreg(cpu, input);
+ case LHREQ_TRAP:
+ return trap(cpu, input);
default:
return -EINVAL;
}
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
index c4451ebece47..3c402b843e03 100644
--- a/include/linux/lguest_launcher.h
+++ b/include/linux/lguest_launcher.h
@@ -65,6 +65,7 @@ enum lguest_req
LHREQ_EVENTFD, /* + address, fd. */
LHREQ_GETREG, /* + offset within struct pt_regs (then read value). */
LHREQ_SETREG, /* + offset within struct pt_regs, value. */
+ LHREQ_TRAP, /* + trap number to deliver to guest. */
};
/*
--
2.1.0
next prev parent reply other threads:[~2015-02-06 5:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-06 5:21 [PATCH 00/29] lguest virtio PCI 1.0 adaptation Rusty Russell
2015-02-06 5:21 ` [PATCH 01/29] lguest: have --rng read from /dev/urandom not /dev/random Rusty Russell
2015-02-06 5:21 ` [PATCH 02/29] lguest: add operations to get/set a register from the Launcher Rusty Russell
2015-02-06 5:21 ` [PATCH 03/29] lguest: write more information to userspace about pending traps Rusty Russell
2015-02-06 5:21 ` Rusty Russell [this message]
2015-02-06 5:21 ` [PATCH 05/29] lguest: add infrastructure to check mappings Rusty Russell
2015-02-06 5:21 ` [PATCH 06/29] lguest: send trap 13 through to userspace Rusty Russell
2015-02-06 5:21 ` [PATCH 07/29] lguest: suppress PS/2 keyboard polling Rusty Russell
2015-02-06 5:21 ` [PATCH 08/29] lguest: don't disable iospace Rusty Russell
2015-02-06 5:21 ` [PATCH 09/29] lguest: add iomem region, where guest page faults get sent to userspace Rusty Russell
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=1423200112-5354-5-git-send-email-rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=linux-kernel@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
Powered by JetHome