From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Avi Kivity <avi@qumranet.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/7] KVM: userspace interface
Date: Thu, 19 Oct 2006 23:15:48 +0100 [thread overview]
Message-ID: <1161296148.17335.150.camel@localhost.localdomain> (raw)
In-Reply-To: <4537D298.6010105@us.ibm.com>
Ar Iau, 2006-10-19 am 14:31 -0500, ysgrifennodd Anthony Liguori:
> > My plan was to allow userspace to register certain mmio addresses for
> > cacheing, so that if the guest code had a code sequence like
Thats actually not ideal having played with this for something else. The
best results I got with real world hardware was supporting registration
of sequences and address/mask pairs. You can also pre-load answers to
avoid trapping back out to user apps. Obviously emulating virtualized
hardware with proper guest OS drivers is far better still.
What I had in the end looked something like this
Groups of addresses in a table. Each table has state bits. Each access
can be conditional on a mask of statebits being 1/0. Each access can
also either trap or not
Within each access the rule was matched by address and width then by
masks
Firstly if the bits matching a transition mask changed to the transition
state bits then we trapped
ie if ((new_value & transition_mask) == transition_bits)
so you can avoid trapping out on stuff that doesn't "fire" an event - eg
the head select on IDE.
Then the I/O was merged with a mask of fixed bits (for read only bits
without trapping in emulation) which occur a lot, and stored in an array
slot number given by the rule (with overlaps for .b/.w allowed). Finally
the statebits were updated by the rule again using a mask and bits.
Similar rules applied to reads so that values that didn't need traps
could be handled directly. Repeating I/O had a special case (thats
"hack") rule type for saying eg "512 bytes" then trap.
A trap was also allowed to load back a prediction sequence. That allowed
the user space side to "guess" the usual behaviour of the driver stuff
being emulated so if it got a given event it could feed a sequence of
address/size/value back [never did make these conditional to be
cleverer]
This means you can do stuff like IDE by trapping mostly on the final
'kick' of a command, and if its a read the predict then 512 byte insw()
from the driver and the next 5 or 6 port read accesses for each I/O.
The state stuff is very compact as its basically
while (rule) {
if (bitcompare(table->state, rule->state)) {
rule = rule->next;
continue;
}
if (bitcompare(rule->transition, value) == 0)
return TRAP;
value &= rule->value[0];
value |= rule->value[1];
table->state &= rule->newstate[0];
table->state |= rule->newstate[1];
table->cache[rule->cache] = value;
rule = rule->next;
}
and for read on a given table just a case of
if (predictor == NULL || port != predictor->port || size !=
predictor->size)
TRAP();
else {
value = table->cache[predictor->cache];
predictor = predictor->next;
}
Alan
next prev parent reply other threads:[~2006-10-19 22:13 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-19 13:45 [PATCH 0/7] KVM: Kernel-based Virtual Machine Avi Kivity
2006-10-19 13:47 ` [PATCH 1/7] KVM: userspace interface Avi Kivity
2006-10-19 14:30 ` John Stoffel
2006-10-19 14:43 ` Avi Kivity
2006-10-19 23:26 ` Greg KH
2006-10-19 14:50 ` Alan Cox
2006-10-19 14:51 ` Avi Kivity
2006-10-19 15:25 ` John Stoffel
2006-10-19 18:49 ` Anthony Liguori
2006-10-19 19:10 ` Avi Kivity
2006-10-19 19:17 ` Anthony Liguori
2006-10-20 7:36 ` Avi Kivity
2006-10-20 15:33 ` Anthony Liguori
2006-10-22 8:10 ` Avi Kivity
2006-10-19 20:36 ` Alan Cox
2006-10-19 18:46 ` Anthony Liguori
2006-10-19 19:04 ` Avi Kivity
2006-10-19 19:09 ` Anthony Liguori
2006-10-19 19:26 ` Avi Kivity
2006-10-19 19:31 ` Anthony Liguori
2006-10-19 22:15 ` Alan Cox [this message]
2006-10-20 7:42 ` Avi Kivity
2006-10-20 15:35 ` Anthony Liguori
2006-10-19 20:10 ` Andi Kleen
2006-10-19 20:14 ` Jan Engelhardt
2006-10-20 7:16 ` Avi Kivity
2006-10-21 15:50 ` Arnd Bergmann
2006-10-22 8:19 ` Avi Kivity
2006-10-21 13:37 ` Steven Rostedt
2006-10-22 8:14 ` Avi Kivity
2006-10-19 13:48 ` [PATCH 2/7] KVM: Intel virtual mode extensions definitions Avi Kivity
2006-10-19 20:19 ` Jan Engelhardt
2006-10-19 21:54 ` Alan Cox
2006-10-20 7:17 ` Avi Kivity
2006-10-21 13:48 ` Steven Rostedt
2006-10-22 8:17 ` Avi Kivity
2006-10-19 13:49 ` [PATCH 3/7] KVM: kvm data structures Avi Kivity
2006-10-19 13:53 ` [PATCH 5/7] KVM: mmu virtualization Avi Kivity
2006-10-19 20:26 ` Jan Engelhardt
2006-10-20 7:24 ` Avi Kivity
2006-10-19 13:54 ` [PATCH 6/7] KVM: x86 emulator Avi Kivity
2006-10-19 13:56 ` [PATCH 7/7] KVM: plumbing Avi Kivity
2006-10-19 13:58 ` [PATCH 0/7] KVM: Kernel-based Virtual Machine Avi Kivity
2006-10-19 16:05 ` Andi Kleen
2006-10-19 16:09 ` Avi Kivity
2006-10-19 19:02 ` Anthony Liguori
2006-10-19 19:14 ` Avi Kivity
2006-10-19 19:28 ` Anthony Liguori
2006-10-20 7:37 ` Avi Kivity
2006-10-19 17:31 ` Muli Ben-Yehuda
2006-10-19 18:00 ` Avi Kivity
2006-10-19 18:12 ` Randy Dunlap
2006-10-19 18:14 ` Avi Kivity
2006-10-19 18:30 ` Randy.Dunlap
2006-10-21 16:16 ` Arnd Bergmann
2006-10-22 8:37 ` Avi Kivity
2006-10-22 15:23 ` Arnd Bergmann
2006-10-22 16:18 ` Avi Kivity
2006-10-22 16:51 ` Arnd Bergmann
2006-10-22 17:01 ` Avi Kivity
2006-10-22 17:06 ` Arnd Bergmann
2006-10-22 17:41 ` Avi Kivity
2006-10-22 17:47 ` Arnd Bergmann
2006-10-22 17:56 ` Christoph Hellwig
2006-10-22 18:00 ` Avi Kivity
2006-10-22 18:36 ` Arnd Bergmann
2006-10-22 18:41 ` Avi Kivity
2006-10-22 18:49 ` Arnd Bergmann
2006-10-22 18:55 ` Avi Kivity
2006-10-22 22:26 ` Andi Kleen
2006-10-23 22:29 ` Jeremy Fitzhardinge
2006-10-22 20:01 ` Alan Cox
2006-10-22 20:45 ` Roland Dreier
2006-10-23 0:29 ` Anthony Liguori
2006-10-25 16:42 ` Pavel Machek
2006-10-22 19:59 ` Alan Cox
2006-10-22 22:28 ` Andi Kleen
2006-10-23 0:27 ` Roland Dreier
2006-10-23 0:39 ` Andi Kleen
2006-10-23 0:51 ` Roland Dreier
2006-10-22 17:39 ` Anthony Liguori
2006-10-22 17:53 ` Arnd Bergmann
2006-10-22 19:56 ` Alan Cox
2006-10-23 7:42 ` Avi Kivity
2006-10-24 21:38 ` kvm_create() (was Re: [PATCH 0/7] KVM: Kernel-based Virtual Machine) Andy Isaacson
2006-10-19 18:55 ` [PATCH 0/7] KVM: Kernel-based Virtual Machine Anthony Liguori
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=1161296148.17335.150.camel@localhost.localdomain \
--to=alan@lxorguk.ukuu.org.uk \
--cc=aliguori@us.ibm.com \
--cc=avi@qumranet.com \
--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