kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Marc Zyngier <maz@kernel.org>, Andrew Scull <ascull@google.com>
Cc: kernel-team@android.com, kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH] arm64: kvm: Stop clobbering x0 for HVC_SOFT_RESTART
Date: Wed, 8 Jul 2020 17:22:28 +0100	[thread overview]
Message-ID: <83615788-3efd-3b97-d95a-a71fb748766c@arm.com> (raw)
In-Reply-To: <a765085746f61ed8deff396fae1d89a1@kernel.org>

Hi Marc, Andrew,

On 06/07/2020 11:11, Marc Zyngier wrote:
> On 2020-07-06 10:52, Andrew Scull wrote:
>> HVC_SOFT_RESTART is given values for x0-2 that it should installed
>> before exiting to the new address so should not set x0 to stub HVC
>> success or failure code.

>> diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S
>> index 6e6ed5581eed..e76c0e89d48e 100644
>> --- a/arch/arm64/kvm/hyp-init.S
>> +++ b/arch/arm64/kvm/hyp-init.S
>> @@ -136,11 +136,15 @@ SYM_CODE_START(__kvm_handle_stub_hvc)
>>
>>  1:    cmp    x0, #HVC_RESET_VECTORS
>>      b.ne    1f
>> -reset:
>> +
>>      /*
>> -     * Reset kvm back to the hyp stub. Do not clobber x0-x4 in
>> -     * case we coming via HVC_SOFT_RESTART.
>> +     * Set the HVC_RESET_VECTORS return code before entering the common
>> +     * path so that we do not clobber x0-x2 in case we are coming via
>> +     * HVC_SOFT_RESTART.
>>       */
>> +    mov    x0, xzr
>> +reset:
>> +    /* Reset kvm back to the hyp stub. */
>>      mrs    x5, sctlr_el2
>>      mov_q    x6, SCTLR_ELx_FLAGS
>>      bic    x5, x5, x6        // Clear SCTL_M and etc
>> @@ -151,7 +155,6 @@ reset:
>>      /* Install stub vectors */
>>      adr_l    x5, __hyp_stub_vectors
>>      msr    vbar_el2, x5
>> -    mov    x0, xzr
>>      eret
>>
>>  1:    /* Bad stub call */

> Huh, nice catch. I wonder what the fuss is about kexec, really,
> given that it is *that* broken.

This would only bite kdump on a v8.0 machine was also running a KVM guest.

Regular kexec would happen after KVM's kvm_reboot_notifier() has called
hardware_disable_nolock() which unloads KVM and restores the hyp-stub.

I'm glad its been caught and fixed!


Thanks,

James
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  reply	other threads:[~2020-07-08 16:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  9:52 [PATCH] arm64: kvm: Stop clobbering x0 for HVC_SOFT_RESTART Andrew Scull
2020-07-06 10:11 ` Marc Zyngier
2020-07-08 16:22   ` James Morse [this message]
2020-07-06 10:29 ` Marc Zyngier

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=83615788-3efd-3b97-d95a-a71fb748766c@arm.com \
    --to=james.morse@arm.com \
    --cc=ascull@google.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=maz@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;
as well as URLs for NNTP newsgroup(s).