All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Alexander Graf <graf@amazon.com>,
	Christoffer Dall <christoffer.dall@arm.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"lkml - Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	kvmarm@lists.cs.columbia.edu,
	arm-mail-list <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/1] KVM: inject data abort if instruction cannot be decoded
Date: Fri, 6 Sep 2019 13:34:48 +0100	[thread overview]
Message-ID: <0a99ce2b-7700-2a2f-eb3a-4922631cbe02@kernel.org> (raw)
In-Reply-To: <a58c5f76-641a-8381-2cf3-e52d139c4236@amazon.com>

On 06/09/2019 13:08, Alexander Graf wrote:
> 
> 
> On 06.09.19 10:00, Christoffer Dall wrote:
>> On Thu, Sep 05, 2019 at 02:09:18PM +0100, Marc Zyngier wrote:

[...]

>>>> @@ -673,6 +694,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
>>>>   		ret = kvm_handle_mmio_return(vcpu, vcpu->run);
>>>>   		if (ret)
>>>>   			return ret;
>>>> +	} else if (run->exit_reason == KVM_EXIT_ARM_NISV) {
>>>> +		kvm_inject_undefined(vcpu);
>>>
>>> Just to make sure I understand: Is the expectation here that userspace
>>> could clear the exit reason if it managed to handle the exit? And
>>> otherwise we'd inject an UNDEF on reentry?
>>>
>>
>> Yes, but I think we should change that to an external abort.  I'll test
>> something and send a proper patch with more clear documentation.
> 
> Why not leave the injection to user space in any case? API wise there is 
> no need to be backwards compatible, as we require the CAP to be enabled, 
> right?
> 
> IMHO it should be 100% a policy decision in user space whether to 
> emulate and what type of exception to inject, if anything.

The exception has to be something that the trapped instruction can
actually generate. An UNDEF is definitely wrong, as the guest would have
otherwise UNDEF'd at EL1, and KVM would have never seen it. You cannot
deviate from the rule of architecture, and userspace feels like the
wrong place to enforce it.

	M.
-- 
Jazz is not dead, it just smells funny...

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Alexander Graf <graf@amazon.com>,
	Christoffer Dall <christoffer.dall@arm.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"lkml - Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	kvmarm@lists.cs.columbia.edu,
	arm-mail-list <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/1] KVM: inject data abort if instruction cannot be decoded
Date: Fri, 6 Sep 2019 13:34:48 +0100	[thread overview]
Message-ID: <0a99ce2b-7700-2a2f-eb3a-4922631cbe02@kernel.org> (raw)
In-Reply-To: <a58c5f76-641a-8381-2cf3-e52d139c4236@amazon.com>

On 06/09/2019 13:08, Alexander Graf wrote:
> 
> 
> On 06.09.19 10:00, Christoffer Dall wrote:
>> On Thu, Sep 05, 2019 at 02:09:18PM +0100, Marc Zyngier wrote:

[...]

>>>> @@ -673,6 +694,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
>>>>   		ret = kvm_handle_mmio_return(vcpu, vcpu->run);
>>>>   		if (ret)
>>>>   			return ret;
>>>> +	} else if (run->exit_reason == KVM_EXIT_ARM_NISV) {
>>>> +		kvm_inject_undefined(vcpu);
>>>
>>> Just to make sure I understand: Is the expectation here that userspace
>>> could clear the exit reason if it managed to handle the exit? And
>>> otherwise we'd inject an UNDEF on reentry?
>>>
>>
>> Yes, but I think we should change that to an external abort.  I'll test
>> something and send a proper patch with more clear documentation.
> 
> Why not leave the injection to user space in any case? API wise there is 
> no need to be backwards compatible, as we require the CAP to be enabled, 
> right?
> 
> IMHO it should be 100% a policy decision in user space whether to 
> emulate and what type of exception to inject, if anything.

The exception has to be something that the trapped instruction can
actually generate. An UNDEF is definitely wrong, as the guest would have
otherwise UNDEF'd at EL1, and KVM would have never seen it. You cannot
deviate from the rule of architecture, and userspace feels like the
wrong place to enforce it.

	M.
-- 
Jazz is not dead, it just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Alexander Graf <graf@amazon.com>,
	Christoffer Dall <christoffer.dall@arm.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"lkml - Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	kvmarm@lists.cs.columbia.edu,
	arm-mail-list <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/1] KVM: inject data abort if instruction cannot be decoded
Date: Fri, 6 Sep 2019 13:34:48 +0100	[thread overview]
Message-ID: <0a99ce2b-7700-2a2f-eb3a-4922631cbe02@kernel.org> (raw)
In-Reply-To: <a58c5f76-641a-8381-2cf3-e52d139c4236@amazon.com>

On 06/09/2019 13:08, Alexander Graf wrote:
> 
> 
> On 06.09.19 10:00, Christoffer Dall wrote:
>> On Thu, Sep 05, 2019 at 02:09:18PM +0100, Marc Zyngier wrote:

[...]

>>>> @@ -673,6 +694,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
>>>>   		ret = kvm_handle_mmio_return(vcpu, vcpu->run);
>>>>   		if (ret)
>>>>   			return ret;
>>>> +	} else if (run->exit_reason == KVM_EXIT_ARM_NISV) {
>>>> +		kvm_inject_undefined(vcpu);
>>>
>>> Just to make sure I understand: Is the expectation here that userspace
>>> could clear the exit reason if it managed to handle the exit? And
>>> otherwise we'd inject an UNDEF on reentry?
>>>
>>
>> Yes, but I think we should change that to an external abort.  I'll test
>> something and send a proper patch with more clear documentation.
> 
> Why not leave the injection to user space in any case? API wise there is 
> no need to be backwards compatible, as we require the CAP to be enabled, 
> right?
> 
> IMHO it should be 100% a policy decision in user space whether to 
> emulate and what type of exception to inject, if anything.

The exception has to be something that the trapped instruction can
actually generate. An UNDEF is definitely wrong, as the guest would have
otherwise UNDEF'd at EL1, and KVM would have never seen it. You cannot
deviate from the rule of architecture, and userspace feels like the
wrong place to enforce it.

	M.
-- 
Jazz is not dead, it just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-09-06 12:34 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 18:07 [PATCH 1/1] KVM: inject data abort if instruction cannot be decoded Heinrich Schuchardt
2019-09-04 18:07 ` Heinrich Schuchardt
2019-09-04 18:07 ` Heinrich Schuchardt
2019-09-05  1:35 ` Guoheyi
2019-09-05  1:35   ` Guoheyi
2019-09-05  8:03 ` Marc Zyngier
2019-09-05  8:03   ` Marc Zyngier
2019-09-05  8:03   ` Marc Zyngier
2019-09-05  8:16   ` Peter Maydell
2019-09-05  8:16     ` Peter Maydell
2019-09-05  8:16     ` Peter Maydell
2019-09-05  8:25     ` Christoffer Dall
2019-09-05  8:25       ` Christoffer Dall
2019-09-05  8:25       ` Christoffer Dall
2019-09-05  8:32       ` Peter Maydell
2019-09-05  8:32         ` Peter Maydell
2019-09-05  8:32         ` Peter Maydell
2019-09-05  8:48     ` Heinrich Schuchardt
2019-09-05  8:48       ` Heinrich Schuchardt
2019-09-05  8:48       ` Heinrich Schuchardt
2019-09-05  8:52     ` Marc Zyngier
2019-09-05  8:52       ` Marc Zyngier
2019-09-05  8:52       ` Marc Zyngier
2019-09-05  8:56       ` Peter Maydell
2019-09-05  8:56         ` Peter Maydell
2019-09-05  8:56         ` Peter Maydell
2019-09-05  9:15         ` Marc Zyngier
2019-09-05  9:15           ` Marc Zyngier
2019-09-05  9:15           ` Marc Zyngier
2019-09-05  9:22         ` Christoffer Dall
2019-09-05  9:22           ` Christoffer Dall
2019-09-05  9:22           ` Christoffer Dall
2019-09-05 13:09           ` Marc Zyngier
2019-09-05 13:09             ` Marc Zyngier
2019-09-05 13:09             ` Marc Zyngier
2019-09-06  8:00             ` Christoffer Dall
2019-09-06  8:00               ` Christoffer Dall
2019-09-06  8:00               ` Christoffer Dall
2019-09-06 12:08               ` Alexander Graf
2019-09-06 12:08                 ` Alexander Graf
2019-09-06 12:08                 ` Alexander Graf
2019-09-06 12:34                 ` Marc Zyngier [this message]
2019-09-06 12:34                   ` Marc Zyngier
2019-09-06 12:34                   ` Marc Zyngier
2019-09-06 13:02                   ` [UNVERIFIED SENDER] " Alexander Graf
2019-09-06 13:02                     ` Alexander Graf
2019-09-06 13:02                     ` Alexander Graf
2019-09-06 13:12                 ` Christoffer Dall
2019-09-06 13:12                   ` Christoffer Dall
2019-09-06 13:12                   ` Christoffer Dall
2019-09-06 13:16                   ` Alexander Graf
2019-09-06 13:16                     ` Alexander Graf
2019-09-06 13:16                     ` Alexander Graf
2019-09-06 13:31                   ` Peter Maydell
2019-09-06 13:31                     ` Peter Maydell
2019-09-06 13:31                     ` Peter Maydell
2019-09-06 13:41                     ` Alexander Graf
2019-09-06 13:41                       ` Alexander Graf
2019-09-06 13:41                       ` Alexander Graf
2019-09-06 13:50                       ` Peter Maydell
2019-09-06 13:50                         ` Peter Maydell
2019-09-06 13:50                         ` Peter Maydell
2019-09-06 14:12                         ` Alexander Graf
2019-09-06 14:12                           ` Alexander Graf
2019-09-06 14:12                           ` Alexander Graf
2019-09-06 13:44                     ` Christoffer Dall
2019-09-06 13:44                       ` Christoffer Dall
2019-09-06 13:44                       ` Christoffer Dall
2019-09-05 13:25           ` Heinrich Schuchardt
2019-09-05 13:25             ` Heinrich Schuchardt
2019-09-05 13:25             ` Heinrich Schuchardt
2019-09-06  7:58             ` Christoffer Dall
2019-09-06  7:58               ` Christoffer Dall
2019-09-06  7:58               ` Christoffer Dall
2019-09-05  8:28   ` Heinrich Schuchardt
2019-09-05  8:28     ` Heinrich Schuchardt
2019-09-05  8:28     ` Heinrich Schuchardt
2019-09-05  9:11     ` Marc Zyngier
2019-09-05  9:11       ` Marc Zyngier
2019-09-05  9:11       ` Marc Zyngier
2019-09-05  9:20 ` Stefan Hajnoczi
2019-09-05  9:20   ` Stefan Hajnoczi
2019-09-05  9:20   ` Stefan Hajnoczi
2019-09-05  9:23   ` Daniel P. Berrangé
2019-09-05  9:23     ` Daniel P. Berrangé
2019-09-05  9:23     ` Daniel P. Berrangé
2019-09-05 12:01   ` Heinrich Schuchardt
2019-09-05 12:01     ` Heinrich Schuchardt
2019-09-05 12:01     ` Heinrich Schuchardt
2019-09-05 12:16     ` Christoffer Dall
2019-09-05 12:16       ` Christoffer Dall
2019-09-05 12:16       ` Christoffer Dall

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=0a99ce2b-7700-2a2f-eb3a-4922631cbe02@kernel.org \
    --to=maz@kernel.org \
    --cc=berrange@redhat.com \
    --cc=christoffer.dall@arm.com \
    --cc=graf@amazon.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefanha@redhat.com \
    --cc=xypron.glpk@gmx.de \
    /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.