From: pbonzini@redhat.com (Paolo Bonzini)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/4] ARM: KVM: on unhandled IO mem abort, route the call to the KVM MMIO bus
Date: Sat, 29 Mar 2014 18:34:52 +0100 [thread overview]
Message-ID: <5337043C.2080500@redhat.com> (raw)
In-Reply-To: <20140328190913.GJ25519@cbox>
Il 28/03/2014 20:09, Christoffer Dall ha scritto:
> On Thu, Mar 13, 2014 at 04:57:26PM +0100, Antonios Motakis wrote:
>> On an unhandled IO memory abort, use the kvm_io_bus_* API in order to
>> handle the MMIO access through any registered read/write callbacks. This
>> is a dependency for eventfd support (ioeventfd and irqfd).
>>
>> However, accesses to the VGIC are still left implemented independently,
>> since the kvm_io_bus_* API doesn't pass the VCPU pointer doing the access.
>>
>> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
>> Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
>> ---
>> arch/arm/kvm/mmio.c | 32 ++++++++++++++++++++++++++++++++
>> virt/kvm/arm/vgic.c | 5 ++++-
>> 2 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
>> index 4cb5a93..1d17831 100644
>> --- a/arch/arm/kvm/mmio.c
>> +++ b/arch/arm/kvm/mmio.c
>> @@ -162,6 +162,35 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>> return 0;
>> }
>>
>> +/**
>> + * kvm_handle_mmio - handle an in-kernel MMIO access
>> + * @vcpu: pointer to the vcpu performing the access
>> + * @run: pointer to the kvm_run structure
>> + * @mmio: pointer to the data describing the access
>> + *
>> + * returns true if the MMIO access has been performed in kernel space,
>> + * and false if it needs to be emulated in user space.
>> + */
>> +static bool handle_kernel_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> + struct kvm_exit_mmio *mmio)
>> +{
>> + int ret;
>> + if (mmio->is_write) {
>> + ret = kvm_io_bus_write(vcpu->kvm, KVM_MMIO_BUS, mmio->phys_addr,
>> + mmio->len, &mmio->data);
>> +
>> + } else {
>> + ret = kvm_io_bus_read(vcpu->kvm, KVM_MMIO_BUS, mmio->phys_addr,
>> + mmio->len, &mmio->data);
>> + }
>> + if (!ret) {
>> + kvm_prepare_mmio(run, mmio);
>> + kvm_handle_mmio_return(vcpu, run);
>> + }
>> +
>> + return !ret;
>> +}
>> +
>> int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> phys_addr_t fault_ipa)
>> {
>> @@ -200,6 +229,9 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> if (vgic_handle_mmio(vcpu, run, &mmio))
>> return 1;
>>
>> + if (handle_kernel_mmio(vcpu, run, &mmio))
>> + return 1;
>> +
>
> this special-casing of the vgic is now really terrible. Is there
> anything holding you back from doing the necessary restructure of the
> kvm_bus_io_*() API instead? That would allow us to get rid of the ugly
> Fix it! in the vgic driver as well.
It's also quite terrible in x86, for the same reason (see
vcpu_mmio_write in arch/x86/kvm/x86.c).
Though I suppose moving vgic_handle_mmio to handle_kernel_mmio would
ameliorate the situation a bit.
Paolo
> -Christoffer
>
>> kvm_prepare_mmio(run, &mmio);
>> return 0;
>> }
>> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
>> index 8ca405c..afdecc3 100644
>> --- a/virt/kvm/arm/vgic.c
>> +++ b/virt/kvm/arm/vgic.c
>> @@ -849,13 +849,16 @@ struct mmio_range *find_matching_range(const struct mmio_range *ranges,
>> }
>>
>> /**
>> - * vgic_handle_mmio - handle an in-kernel MMIO access
>> + * vgic_handle_mmio - handle an in-kernel vgic MMIO access
>> * @vcpu: pointer to the vcpu performing the access
>> * @run: pointer to the kvm_run structure
>> * @mmio: pointer to the data describing the access
>> *
>> * returns true if the MMIO access has been performed in kernel space,
>> * and false if it needs to be emulated in user space.
>> + *
>> + * This is handled outside of kvm_handle_mmio because the kvm_io_bus only
>> + * passes the VM pointer, while we need the VCPU performing the access.
>> */
>> bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> struct kvm_exit_mmio *mmio)
>> --
>> 1.8.3.2
>>
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: Christoffer Dall <christoffer.dall@linaro.org>,
Antonios Motakis <a.motakis@virtualopensystems.com>
Cc: Russell King <linux@arm.linux.org.uk>,
"open list:KERNEL VIRTUAL MA..." <kvm@vger.kernel.org>,
marc.zyngier@arm.com, agraf@suse.de,
n.nikolaev@virtualopensystems.com,
open list <linux-kernel@vger.kernel.org>,
Gleb Natapov <gleb@kernel.org>,
tech@virtualopensystems.com, kvmarm@lists.cs.columbia.edu,
ARM PORT <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 1/4] ARM: KVM: on unhandled IO mem abort, route the call to the KVM MMIO bus
Date: Sat, 29 Mar 2014 18:34:52 +0100 [thread overview]
Message-ID: <5337043C.2080500@redhat.com> (raw)
In-Reply-To: <20140328190913.GJ25519@cbox>
Il 28/03/2014 20:09, Christoffer Dall ha scritto:
> On Thu, Mar 13, 2014 at 04:57:26PM +0100, Antonios Motakis wrote:
>> On an unhandled IO memory abort, use the kvm_io_bus_* API in order to
>> handle the MMIO access through any registered read/write callbacks. This
>> is a dependency for eventfd support (ioeventfd and irqfd).
>>
>> However, accesses to the VGIC are still left implemented independently,
>> since the kvm_io_bus_* API doesn't pass the VCPU pointer doing the access.
>>
>> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
>> Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
>> ---
>> arch/arm/kvm/mmio.c | 32 ++++++++++++++++++++++++++++++++
>> virt/kvm/arm/vgic.c | 5 ++++-
>> 2 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
>> index 4cb5a93..1d17831 100644
>> --- a/arch/arm/kvm/mmio.c
>> +++ b/arch/arm/kvm/mmio.c
>> @@ -162,6 +162,35 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>> return 0;
>> }
>>
>> +/**
>> + * kvm_handle_mmio - handle an in-kernel MMIO access
>> + * @vcpu: pointer to the vcpu performing the access
>> + * @run: pointer to the kvm_run structure
>> + * @mmio: pointer to the data describing the access
>> + *
>> + * returns true if the MMIO access has been performed in kernel space,
>> + * and false if it needs to be emulated in user space.
>> + */
>> +static bool handle_kernel_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> + struct kvm_exit_mmio *mmio)
>> +{
>> + int ret;
>> + if (mmio->is_write) {
>> + ret = kvm_io_bus_write(vcpu->kvm, KVM_MMIO_BUS, mmio->phys_addr,
>> + mmio->len, &mmio->data);
>> +
>> + } else {
>> + ret = kvm_io_bus_read(vcpu->kvm, KVM_MMIO_BUS, mmio->phys_addr,
>> + mmio->len, &mmio->data);
>> + }
>> + if (!ret) {
>> + kvm_prepare_mmio(run, mmio);
>> + kvm_handle_mmio_return(vcpu, run);
>> + }
>> +
>> + return !ret;
>> +}
>> +
>> int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> phys_addr_t fault_ipa)
>> {
>> @@ -200,6 +229,9 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> if (vgic_handle_mmio(vcpu, run, &mmio))
>> return 1;
>>
>> + if (handle_kernel_mmio(vcpu, run, &mmio))
>> + return 1;
>> +
>
> this special-casing of the vgic is now really terrible. Is there
> anything holding you back from doing the necessary restructure of the
> kvm_bus_io_*() API instead? That would allow us to get rid of the ugly
> Fix it! in the vgic driver as well.
It's also quite terrible in x86, for the same reason (see
vcpu_mmio_write in arch/x86/kvm/x86.c).
Though I suppose moving vgic_handle_mmio to handle_kernel_mmio would
ameliorate the situation a bit.
Paolo
> -Christoffer
>
>> kvm_prepare_mmio(run, &mmio);
>> return 0;
>> }
>> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
>> index 8ca405c..afdecc3 100644
>> --- a/virt/kvm/arm/vgic.c
>> +++ b/virt/kvm/arm/vgic.c
>> @@ -849,13 +849,16 @@ struct mmio_range *find_matching_range(const struct mmio_range *ranges,
>> }
>>
>> /**
>> - * vgic_handle_mmio - handle an in-kernel MMIO access
>> + * vgic_handle_mmio - handle an in-kernel vgic MMIO access
>> * @vcpu: pointer to the vcpu performing the access
>> * @run: pointer to the kvm_run structure
>> * @mmio: pointer to the data describing the access
>> *
>> * returns true if the MMIO access has been performed in kernel space,
>> * and false if it needs to be emulated in user space.
>> + *
>> + * This is handled outside of kvm_handle_mmio because the kvm_io_bus only
>> + * passes the VM pointer, while we need the VCPU performing the access.
>> */
>> bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
>> struct kvm_exit_mmio *mmio)
>> --
>> 1.8.3.2
>>
next prev parent reply other threads:[~2014-03-29 17:34 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1394726249-1547-1-git-send-email-a.motakis@virtualopensystems.com>
2014-03-13 15:57 ` [RFC PATCH 1/4] ARM: KVM: on unhandled IO mem abort, route the call to the KVM MMIO bus Antonios Motakis
2014-03-13 15:57 ` Antonios Motakis
2014-03-28 19:09 ` Christoffer Dall
2014-03-28 19:09 ` Christoffer Dall
2014-03-29 17:34 ` Paolo Bonzini [this message]
2014-03-29 17:34 ` Paolo Bonzini
2014-11-10 15:09 ` Nikolay Nikolaev
2014-11-10 15:09 ` Nikolay Nikolaev
2014-11-10 16:27 ` Christoffer Dall
2014-11-10 16:27 ` Christoffer Dall
2014-11-13 10:45 ` Nikolay Nikolaev
2014-11-13 10:45 ` Nikolay Nikolaev
2014-11-13 11:20 ` Christoffer Dall
2014-11-13 11:20 ` Christoffer Dall
2014-11-13 11:20 ` Christoffer Dall
2014-11-13 11:20 ` Christoffer Dall
2014-11-13 11:37 ` Marc Zyngier
2014-11-13 11:37 ` Marc Zyngier
2014-11-13 11:52 ` Andre Przywara
2014-11-13 11:52 ` Andre Przywara
2014-11-13 12:29 ` Nikolay Nikolaev
2014-11-13 12:29 ` Nikolay Nikolaev
2014-11-13 12:52 ` Andre Przywara
2014-11-13 12:52 ` Andre Przywara
2014-11-13 14:16 ` Eric Auger
2014-11-13 14:16 ` Eric Auger
2014-11-13 14:23 ` Eric Auger
2014-11-13 14:23 ` Eric Auger
2014-11-13 15:02 ` Nikolay Nikolaev
2014-11-13 15:13 ` Christoffer Dall
2014-11-13 15:31 ` Andre Przywara
2014-11-13 16:07 ` Eric Auger
2014-03-13 15:57 ` [RFC PATCH 2/4] KVM: irqfd should depend on CONFIG_HAVE_KVM_IRQ_ROUTING Antonios Motakis
2014-03-13 15:57 ` [RFC PATCH 3/4] ARM: KVM: enable linking against eventfd Antonios Motakis
2014-03-13 15:57 ` Antonios Motakis
2014-03-13 15:57 ` [RFC PATCH 4/4] ARM: KVM: enable KVM_CAP_IOEVENTFD Antonios Motakis
2014-03-13 15:57 ` Antonios Motakis
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=5337043C.2080500@redhat.com \
--to=pbonzini@redhat.com \
--cc=linux-arm-kernel@lists.infradead.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 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.