stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Zenghui Yu <yuzenghui@huawei.com>
Cc: <stable@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<gregkh@linuxfoundation.org>, <sashal@kernel.org>,
	<alexandru.elisei@arm.com>, <wanghaibin.wang@huawei.com>
Subject: Re: [PATCH stable-5.12.y backport 1/2] KVM: arm64: Commit pending PC adjustemnts before returning to userspace
Date: Tue, 01 Jun 2021 12:44:28 +0100	[thread overview]
Message-ID: <87v96x24ir.wl-maz@kernel.org> (raw)
In-Reply-To: <20210601111238.1059-2-yuzenghui@huawei.com>

Hi Zenghui,

Thanks for having a go at the backport.

On Tue, 01 Jun 2021 12:12:37 +0100,
Zenghui Yu <yuzenghui@huawei.com> wrote:
> 
> From: Marc Zyngier <maz@kernel.org>
> 
> commit 26778aaa134a9aefdf5dbaad904054d7be9d656d upstream.
> 
> KVM currently updates PC (and the corresponding exception state)
> using a two phase approach: first by setting a set of flags,
> then by converting these flags into a state update when the vcpu
> is about to enter the guest.
> 
> However, this creates a disconnect with userspace if the vcpu thread
> returns there with any exception/PC flag set. In this case, the exposed
> context is wrong, as userspace doesn't have access to these flags
> (they aren't architectural). It also means that these flags are
> preserved across a reset, which isn't expected.
> 
> To solve this problem, force an explicit synchronisation of the
> exception state on vcpu exit to userspace. As an optimisation
> for nVHE systems, only perform this when there is something pending.
> 
> Reported-by: Zenghui Yu <yuzenghui@huawei.com>
> Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
> Tested-by: Zenghui Yu <yuzenghui@huawei.com>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Cc: stable@vger.kernel.org # 5.11
> [yuz: stable-5.12.y backport: add __KVM_HOST_SMCCC_FUNC___kvm_adjust_pc
>  macro manually and keep it consistent with mainline]

I'd rather you allocated a new number here, irrespective of what
mainline has (rational below).

> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
> ---
>  arch/arm64/include/asm/kvm_asm.h   |  1 +
>  arch/arm64/kvm/arm.c               | 11 +++++++++++
>  arch/arm64/kvm/hyp/exception.c     |  4 ++--
>  arch/arm64/kvm/hyp/nvhe/hyp-main.c |  8 ++++++++
>  4 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> index a8578d650bb6..d7f769bb6c9c 100644
> --- a/arch/arm64/include/asm/kvm_asm.h
> +++ b/arch/arm64/include/asm/kvm_asm.h
> @@ -57,6 +57,7 @@
>  #define __KVM_HOST_SMCCC_FUNC___kvm_get_mdcr_el2		12
>  #define __KVM_HOST_SMCCC_FUNC___vgic_v3_save_aprs		13
>  #define __KVM_HOST_SMCCC_FUNC___vgic_v3_restore_aprs		14
> +#define __KVM_HOST_SMCCC_FUNC___kvm_adjust_pc			21

This is going to generate a larger than necessary host_hcall array in
hyp/nvhe/hyp-main.c, which we're trying to keep tightly packed for
obvious reasons.

With this nit fixed:

Reviewed-by: Marc Zyngier <maz@kernel.org>

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2021-06-01 11:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 11:12 [PATCH stable-5.12.y backport 0/2] KVM: arm64: Commit exception state on exit to userspace Zenghui Yu
2021-06-01 11:12 ` [PATCH stable-5.12.y backport 1/2] KVM: arm64: Commit pending PC adjustemnts before returning " Zenghui Yu
2021-06-01 11:44   ` Marc Zyngier [this message]
2021-06-01 13:47     ` Zenghui Yu
2021-06-01 11:12 ` [PATCH stable-5.12.y backport 2/2] KVM: arm64: Resolve all pending PC updates before immediate exit Zenghui Yu
2021-06-01 11:44   ` 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=87v96x24ir.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wanghaibin.wang@huawei.com \
    --cc=yuzenghui@huawei.com \
    /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).