From: David Gibson <david@gibson.dropbear.id.au>
To: Paul Mackerras <paulus@ozlabs.org>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code
Date: Fri, 9 Feb 2018 10:35:26 +1100 [thread overview]
Message-ID: <20180208233526.GE11634@umbus.fritz.box> (raw)
In-Reply-To: <20180207090445.GC19335@fergus.ozlabs.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]
On Wed, Feb 07, 2018 at 08:04:45PM +1100, Paul Mackerras wrote:
> This fixes the computation of the HPTE index to use when the HPT
> resizing code encounters a bolted HPTE which is stored in its
> secondary HPTE group. The code inverts the HPTE group number, which
> is correct, but doesn't then mask it with new_hash_mask. As a result,
> new_pteg will be effectively negative, resulting in new_hptep
> pointing before the new HPT, which will corrupt memory.
>
> In addition, this removes two BUG_ON statements. The condition that
> the BUG_ONs were testing -- that we have computed the hash value
> incorrectly -- has never been observed in testing, and if it did
> occur, would only affect the guest, not the host. Given that
> BUG_ON should only be used in conditions where the kernel (i.e.
> the host kernel, in this case) can't possibly continue execution,
> it is not appropriate here.
Fair enough. I think those were there because they were useful during
early development, but should have been removed after that.
>
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> arch/powerpc/kvm/book3s_64_mmu_hv.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> index 9660972..d196499 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -1329,12 +1329,8 @@ static unsigned long resize_hpt_rehash_hpte(struct kvm_resize_hpt *resize,
> }
>
> new_pteg = hash & new_hash_mask;
> - if (vpte & HPTE_V_SECONDARY) {
> - BUG_ON(~pteg != (hash & old_hash_mask));
> - new_pteg = ~new_pteg;
> - } else {
> - BUG_ON(pteg != (hash & old_hash_mask));
> - }
> + if (vpte & HPTE_V_SECONDARY)
> + new_pteg = ~hash & new_hash_mask;
>
> new_idx = new_pteg * HPTES_PER_GROUP + (idx % HPTES_PER_GROUP);
> new_hptep = (__be64 *)(new->virt + (new_idx << 4));
--
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-02-08 23:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 9:04 [PATCH 1/2] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Paul Mackerras
2018-02-07 9:06 ` [PATCH 2/2] KVM: PPC: Book3S HV: Make HPT resizing work on POWER9 Paul Mackerras
2018-02-07 9:11 ` [PATCH v2] " Paul Mackerras
2018-02-08 18:11 ` Laurent Vivier
2018-02-08 23:40 ` David Gibson
2018-02-08 23:35 ` 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=20180208233526.GE11634@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.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).