From: James Hogan <james.hogan@imgtec.com>
To: Nicholas Mc Guire <hofrat@osadl.org>, Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Ralf Baechle <ralf@linux-mips.org>, <kvm@vger.kernel.org>,
<linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC] MIPS: KVM: role back pc in case of EMULATE_FAIL
Date: Fri, 8 May 2015 15:42:03 +0100 [thread overview]
Message-ID: <554CCB3B.90504@imgtec.com> (raw)
In-Reply-To: <1431003091-30161-1-git-send-email-hofrat@osadl.org>
[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]
On 07/05/15 13:51, Nicholas Mc Guire wrote:
> Currently if kvm_mips_complete_mmio_load() fails with EMULATE_FAIL it will
> not role back the pc nor will the caller handle this failure.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
> arch/mips/kvm/emulate.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> kvm_mips_complete_mmio_load is called only in arch/mips/kvm/mips.c without
> checking the return value to signal EMULATE_FAIL:
> 383 if (vcpu->mmio_needed) {
> 384 if (!vcpu->mmio_is_write)
> 385 kvm_mips_complete_mmio_load(vcpu, run);
> 386 vcpu->mmio_needed = 0;
> 387 }
>
> so maybe kvm_mips_complete_mmio_load should role back in case of failure
> at arch/mips/kvm/emuilate.c:kvm_mips_complete_mmio_load()
> 2406 if (er == EMULATE_FAIL) {
> 2408 return er;
>
> something like the below patch - only based no looking at how EMULATE_FAIL
> is handled at other locations - not sure if this is appropriate here.
>
> Patch was only compile tested msp71xx_defconfig + CONFIG_KVM=m
>
> Patch is against 4.1-rc2 (localversion-next is -next-20150506)
>
> diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
> index 2f0fc60..b58596b 100644
> --- a/arch/mips/kvm/emulate.c
> +++ b/arch/mips/kvm/emulate.c
> @@ -2403,8 +2403,10 @@ enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu,
> */
> curr_pc = vcpu->arch.pc;
> er = update_pc(vcpu, vcpu->arch.pending_load_cause);
> - if (er == EMULATE_FAIL)
> + if (er == EMULATE_FAIL) {
> + vcpu->arch.pc = curr_pc;
If update_pc returns EMULATE_FAIL then vcpu->arch.pc won't have been
modified, so putting it back to the old value is redundant.
Actually, curr_pc can be dropped from this function since nothing else
can go wrong that would cause the PC to need rolling back. Effectively
kvm_mips_emulate_load() has omitted to update the PC since it'll only
return to userland to handle the MMIO and get the load data, so by the
time it gets back to kvm_mips_complete_mmio_load(), it already has
everything it needs to guarantee success.
Cheers
James
> return er;
> + }
>
> switch (run->mmio.len) {
> case 4:
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-05-08 14:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 12:51 [PATCH RFC] MIPS: KVM: role back pc in case of EMULATE_FAIL Nicholas Mc Guire
2015-05-08 14:42 ` James Hogan [this message]
2015-05-08 15:39 ` Nicholas Mc Guire
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=554CCB3B.90504@imgtec.com \
--to=james.hogan@imgtec.com \
--cc=gleb@kernel.org \
--cc=hofrat@osadl.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=pbonzini@redhat.com \
--cc=ralf@linux-mips.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