All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Zhi Yong Wu <zwu.kernel@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/5] backdoor: [softmmu] Add QEMU-side proxy to "libbackdoor.a"
Date: Fri, 30 Sep 2011 22:49:30 +0200	[thread overview]
Message-ID: <87ehyx3gdh.fsf@ginnungagap.bsc.es> (raw)
In-Reply-To: <CAAu8pHtn-WkmcLs-_mmf2xgzOsKZiiUDnNqR8A5kMBQwbXX4Yg@mail.gmail.com> (Blue Swirl's message of "Fri, 30 Sep 2011 20:07:54 +0000")

Blue Swirl writes:

> 2011/9/29 Lluís Vilanova <vilanova@ac.upc.edu>:
>> Blue Swirl writes:
>> 
>>> 2011/9/29 Lluís Vilanova <vilanova@ac.upc.edu>:
>>>> +static uint64_t control_io_read(void *opaque, target_phys_addr_t addr, unsigned size)
>>>> +{
>>>> +    State *s = opaque;
>>>> +
>>>> +    uint64_t res = ldq_p(&s->size);
>>>> +    uint8_t *resb = (uint8_t*)&res;
>>>> +    return resb[addr % CTRL_BYTES];
>> 
>>> I don't think these lines do what you mean, but I'm also not sure what
>>> it is supposed to mean.
>> 
>> Pre: only can read on a byte-per-byte basis (as stated in control_ops.impl),
>> just because the code looks less ugly, and host performance should not be an
>> issue here.
>> 
>> The device is treated as a circular buffer of length CTRL_BYTES
>> 
>> Reads are only used to get the size of the data channel.
>> 
>> First line should handle guest/host endianess swapping, although I'm not sure if
>> that's the API I'm supposed to use.
>> 
>> Then return the N'th byte of the uint64_t variable holding the (endianess-aware)
>> result.

> That may be the intention, but the first line will load res from guest
> memory using an address (&s->size) in host memory.

Ok, I think I found what I really wanted: tswap64


> I think the next two lines are equal to
> return res >> (addr % CTRL_BYTES);
> but with some obfuscation.

But I cannot assume any endianess on neither host or guest. The only thing I can
assume is that the generic device code handling the reads will read from lower
to higher addresses.

In any case, take me with a grain of salt, endianess often confuses me.


> It would be much clearer if the registers were byte arrays so you
> could read and write the data directly without pointer arithmetic.

Is that something present on the device API? Sorry I don't know what you mean by
byte array... for me 'resb' already is a byte array :)


> Byte accesses will be slower than larger word size accesses, I thought
> performance was one of the goals with this?

They will be slower on host time, but will not waste "guest time".

BTW, will the current scheme in KVM provoke one VM exit for each byte or only
one for the whole 64bits?

But yes, I was just too lazy to add code for all the supported sizes from 1 to
8, and let the generic device code pick the best.


Lluis

-- 
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth

  reply	other threads:[~2011-09-30 20:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 13:47 [Qemu-devel] [RFC][PATCH 0/5] backdoor: lightweight guest-to-QEMU backdoor channel Lluís Vilanova
2011-09-29 13:47 ` [Qemu-devel] [PATCH 1/5] backdoor: Add documentation Lluís Vilanova
2011-09-29 13:47 ` [Qemu-devel] [PATCH 2/5] backdoor: Add build infrastructure Lluís Vilanova
2011-09-29 13:47 ` [Qemu-devel] [PATCH 3/5] backdoor: [*-user] Add QEMU-side proxy to "libbackdoor.a" Lluís Vilanova
2011-09-29 13:47 ` [Qemu-devel] [PATCH 4/5] backdoor: [softmmu] " Lluís Vilanova
2011-09-29 20:42   ` Blue Swirl
2011-09-29 21:49     ` Lluís Vilanova
2011-09-29 22:13       ` Frans de Boer
2011-09-29 22:35       ` Frans de Boer
2011-09-30 20:29         ` Blue Swirl
2011-09-30 20:07       ` Blue Swirl
2011-09-30 20:49         ` Lluís Vilanova [this message]
2011-09-30 20:59           ` Blue Swirl
2011-09-29 13:47 ` [Qemu-devel] [PATCH 5/5] backdoor: Add guest-side library Lluís Vilanova
2011-09-29 13:52 ` [Qemu-devel] [RFC][PATCH 0/5] backdoor: lightweight guest-to-QEMU backdoor channel Anthony Liguori
2011-09-29 17:10   ` Lluís Vilanova
2011-09-29 20:55   ` Blue Swirl

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=87ehyx3gdh.fsf@ginnungagap.bsc.es \
    --to=vilanova@ac.upc.edu \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zwu.kernel@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.