From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org,
Paul Mackerras <paulus@ozlabs.org>
Subject: Re: [PATCH kernel 4/4] KVM: PPC: Propagate errors to the guest when failed instead of ignoring
Date: Thu, 30 Aug 2018 14:04:13 +1000 [thread overview]
Message-ID: <20180830040413.GJ2222@umbus.fritz.box> (raw)
In-Reply-To: <20180830031647.34134-5-aik@ozlabs.ru>
[-- Attachment #1: Type: text/plain, Size: 3672 bytes --]
On Thu, Aug 30, 2018 at 01:16:47PM +1000, Alexey Kardashevskiy wrote:
> At the moment if the PUT_TCE{_INDIRECT} handlers fail to update
> the hardware tables, we print a warning once, clear the entry and
> continue. This is so as at the time the assumption was that if
> a VFIO device is hotplugged into the guest, and the userspace replays
> virtual DMA mappings (i.e. TCEs) to the hardware tables and if this fails,
> then there is nothing useful we can do about it.
>
> However the assumption is not valid as these handlers are not called for
> TCE replay (VFIO ioctl interface is used for that) and these handlers
> are for new TCEs.
>
> This returns an error to the guest if there is a request which cannot be
> processed. By now the only possible failure must be H_TOO_HARD.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> arch/powerpc/kvm/book3s_64_vio.c | 20 ++++++--------------
> arch/powerpc/kvm/book3s_64_vio_hv.c | 20 ++++++--------------
> 2 files changed, 12 insertions(+), 28 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> index 5cd2a66..5e3151b 100644
> --- a/arch/powerpc/kvm/book3s_64_vio.c
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -568,14 +568,10 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
> ret = kvmppc_tce_iommu_map(vcpu->kvm, stt, stit->tbl,
> entry, ua, dir);
>
> - if (ret == H_SUCCESS)
> - continue;
> -
> - if (ret == H_TOO_HARD)
> + if (ret != H_SUCCESS) {
> + kvmppc_clear_tce(stit->tbl, entry);
> goto unlock_exit;
> -
> - WARN_ON_ONCE(1);
> - kvmppc_clear_tce(stit->tbl, entry);
> + }
> }
>
> kvmppc_tce_put(stt, entry, tce);
> @@ -660,14 +656,10 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
> stit->tbl, entry + i, ua,
> iommu_tce_direction(tce));
>
> - if (ret == H_SUCCESS)
> - continue;
> -
> - if (ret == H_TOO_HARD)
> + if (ret != H_SUCCESS) {
> + kvmppc_clear_tce(stit->tbl, entry);
> goto unlock_exit;
> -
> - WARN_ON_ONCE(1);
> - kvmppc_clear_tce(stit->tbl, entry);
> + }
> }
>
> kvmppc_tce_put(stt, entry + i, tce);
> diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
> index e79ffbb..8d82133 100644
> --- a/arch/powerpc/kvm/book3s_64_vio_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
> @@ -380,14 +380,10 @@ long kvmppc_rm_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
> ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt,
> stit->tbl, entry, ua, dir);
>
> - if (ret == H_SUCCESS)
> - continue;
> -
> - if (ret == H_TOO_HARD)
> + if (ret != H_SUCCESS) {
> + kvmppc_rm_clear_tce(stit->tbl, entry);
> return ret;
> -
> - WARN_ON_ONCE_RM(1);
> - kvmppc_rm_clear_tce(stit->tbl, entry);
> + }
> }
>
> kvmppc_tce_put(stt, entry, tce);
> @@ -533,14 +529,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
> stit->tbl, entry + i, ua,
> iommu_tce_direction(tce));
>
> - if (ret == H_SUCCESS)
> - continue;
> -
> - if (ret == H_TOO_HARD)
> + if (ret != H_SUCCESS) {
> + kvmppc_rm_clear_tce(stit->tbl, entry);
> goto unlock_exit;
> -
> - WARN_ON_ONCE_RM(1);
> - kvmppc_rm_clear_tce(stit->tbl, entry);
> + }
> }
>
> kvmppc_tce_put(stt, entry + i, tce);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2018-08-30 4:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 3:16 [PATCH kernel 0/4] KVM: PPC: Some error handling rework Alexey Kardashevskiy
2018-08-30 3:16 ` [PATCH kernel 1/4] KVM: PPC: Validate all tces before updating tables Alexey Kardashevskiy
2018-08-30 4:01 ` David Gibson
2018-08-31 4:04 ` Alexey Kardashevskiy
2018-08-30 3:16 ` [PATCH kernel 2/4] KVM: PPC: Inform the userspace about TCE update failures Alexey Kardashevskiy
2018-08-30 4:01 ` David Gibson
2018-08-30 3:16 ` [PATCH kernel 3/4] KVM: PPC: Validate TCEs against preregistered memory page sizes Alexey Kardashevskiy
2018-08-30 4:03 ` David Gibson
2018-08-30 3:16 ` [PATCH kernel 4/4] KVM: PPC: Propagate errors to the guest when failed instead of ignoring Alexey Kardashevskiy
2018-08-30 4:04 ` David Gibson [this message]
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=20180830040413.GJ2222@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@ozlabs.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).