From: Stefan Hajnoczi <stefanha@redhat.com>
To: Riku Voipio <riku.voipio@iki.fi>,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 3/6] hypertrace: [*-user] Add QEMU-side proxy to "guest_hypertrace" event
Date: Tue, 10 Jan 2017 14:47:54 +0000 [thread overview]
Message-ID: <20170110144754.GB17540@stefanha-x1.localdomain> (raw)
In-Reply-To: <87zij0jdt4.fsf@ac.upc.edu>
[-- Attachment #1: Type: text/plain, Size: 2717 bytes --]
On Mon, Jan 09, 2017 at 07:20:07PM +0100, Lluís Vilanova wrote:
> Stefan Hajnoczi writes:
>
> > On Mon, Dec 26, 2016 at 09:34:54PM +0100, Lluís Vilanova wrote:
> >> +static void segv_handler(int signum, siginfo_t *siginfo, void *sigctxt)
> >> +{
> >> + CPUState *vcpu = current_cpu;
> >> + void *control_0 = vcpu->hypertrace_control;
> >> + void *control_1 = vcpu->hypertrace_control + config.control_size / 2;
> >> + void *control_2 = control_1 + config.control_size / 2;
> >> +
> >> + if (control_0 <= siginfo->si_addr && siginfo->si_addr < control_1) {
> >> +
> >> + /* 1st fault (guest will write cmd) */
> >> + assert(((unsigned long)siginfo->si_addr % sizeof(uint64_t)) == 0);
> >> + swap_control(control_0, control_1);
> >> +
> >> + } else if (control_1 <= siginfo->si_addr && siginfo->si_addr < control_2) {
> >> + size_t client = (siginfo->si_addr - control_1) / sizeof(uint64_t);
> >> + uint64_t vcontrol = ((uint64_t *)control_0)[client];
> >> + uint64_t *data_ptr = &qemu_data[client * config.client_data_size];
> >> +
> >> + /* 2nd fault (invoke) */
> >> + assert(((unsigned long)siginfo->si_addr % sizeof(uint64_t)) == 0);
> >> + hypertrace_emit(current_cpu, vcontrol, data_ptr);
> >> + swap_control(control_1, control_0);
>
> > A simpler and faster approach is to permanently mprotect just one region
> > and load all arguments from data[] (including the first argument). Then
> > swapping isn't necessary.
>
> I'm don't understand what you propose.
>
> With a single protected region, you don't know when to restore protection of it
> so that later accesses will be detected too. That could be solved if we used
> single-stepping (maybe that's what you meant):
>
> * trap access
> * unprotect memory region
> * single-step guest
> * read written data and emit event
> * protect memory region again
> * resume guest
>
> If the single-stepping can be done without too much complexity, that'd be a
> faster option, and that piece of code might be cleaner too.
>
> We could only avoid the protect/unprotect sequence if we added target-specific
> code to "skip" the failed instruction (assuming all useful writes go to the data
> channel), but I wanted to make all code target-agnostic.
Okay, I didn't realize the instruction would be restarted. I thought
swapping was solely to allow the guest to write vcontrol =
control_0[client].
Assuming for a second that the instruction isn't restarted, my
suggestion was to use si_addr to identify which client and then load all
args out of the (read/write) data region. This eliminates vcontrol.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2017-01-10 14:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-26 20:34 [Qemu-devel] [PATCH v4 0/6] hypertrace: Lightweight guest-to-QEMU trace channel Lluís Vilanova
2016-12-26 20:34 ` [Qemu-devel] [PATCH v4 1/6] hypertrace: Add documentation Lluís Vilanova
2016-12-26 20:34 ` [Qemu-devel] [PATCH v4 2/6] hypertrace: Add tracing event "guest_hypertrace" Lluís Vilanova
2016-12-26 20:34 ` [Qemu-devel] [PATCH v4 3/6] hypertrace: [*-user] Add QEMU-side proxy to "guest_hypertrace" event Lluís Vilanova
2017-01-09 15:44 ` Stefan Hajnoczi
2017-01-16 17:05 ` Lluís Vilanova
2017-01-17 9:46 ` Stefan Hajnoczi
2017-01-17 23:35 ` Lluís Vilanova
2017-01-16 17:10 ` Lluís Vilanova
2017-01-09 16:35 ` Stefan Hajnoczi
2017-01-09 18:20 ` Lluís Vilanova
2017-01-10 14:47 ` Stefan Hajnoczi [this message]
2016-12-26 20:34 ` [Qemu-devel] [PATCH v4 4/6] hypertrace: [softmmu] " Lluís Vilanova
2017-01-09 16:12 ` Stefan Hajnoczi
2016-12-26 20:35 ` [Qemu-devel] [PATCH v4 5/6] hypertrace: Add guest-side user-level library Lluís Vilanova
2016-12-26 20:35 ` [Qemu-devel] [PATCH v4 6/6] hypertrace: Add guest-side Linux module Lluís Vilanova
2017-01-09 16:17 ` Stefan Hajnoczi
2017-01-15 2:10 ` Lluís Vilanova
2017-01-16 10:37 ` Stefan Hajnoczi
2016-12-26 20:47 ` [Qemu-devel] [PATCH v4 0/6] hypertrace: Lightweight guest-to-QEMU trace channel no-reply
2017-01-09 16:28 ` Stefan Hajnoczi
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=20170110144754.GB17540@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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;
as well as URLs for NNTP newsgroup(s).