Received: by 10.192.165.148 with SMTP id m20csp537714imm; Wed, 25 Apr 2018 03:55:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+xRyLxIToOqTkIO5GSvesLobVBL1RcFTRnInPD+EOotOfmZKjS/rAw/k0UsJEoZ1sujsGL X-Received: by 2002:a17:902:6949:: with SMTP id k9-v6mr28833130plt.185.1524653705556; Wed, 25 Apr 2018 03:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653705; cv=none; d=google.com; s=arc-20160816; b=qT1AECGihi2rJ4XXk04eSVnHToybjnpOmqg0mPX78eZAPIeVk0+ZK6dTmUTTS0UFir wPB71dNtjari/u7LCxwkqWNAt+kGZmooyefM08O/HrjL+pL47I/VDcRQNp0/mLgbrzJ9 gfZxEPWI4iBF3OyHQmILqcJbwuT6wwev8w8XrYnVCuy18IdgxpALT1VMb2ys5GuF54Oq LDptsJQXTbfIGm3i85ZHABRURbA8NfIvMlNSbFI0sCZF1oyFfmAq2XfspbExtxxdQawM L64as1plrFEUt+PuG3tRL0gxZmxHv/vsFUV5aIi74W/O4of5/pfzd/9sD+X38x100BE6 Y3Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FSa3NE3/If0g6mUnYqQ3r0Od3QLCLrt63nowtIYYTpY=; b=U6FPohZxWBVAYnN0hBIkNa/Q8Dm1WbfJojN7DvNw6hS2LbuidmH8+wheypTdVRcLf2 gREueNOarqPpLKBW/XEA8Yk32Itdi9SEzmlv7Zv+Awi+hRXprCKSW8YnOJF3GsRCNcP2 AukkEhxEUJeQvwr2l0T0nncJjoDdo7/XBvYQsynexOPxsQyEv+uP/ROhEV1GETV3BAAO Ea+w+bzr68Bbj0Sub4EmXSMApcsDBRowgi/41mamEXmKnAmViI59Nxbn/+9Z9xMTmBJJ vPacZERvlP+3++uKMbYvhOICE1yXFaedVc4ngwu5ypA1WctnryaREzFcpVwqQXZhgcrK TVnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u128si8662255pgc.247.2018.04.25.03.54.51; Wed, 25 Apr 2018 03:55:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754104AbeDYKxw (ORCPT + 99 others); Wed, 25 Apr 2018 06:53:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53112 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754240AbeDYKnp (ORCPT ); Wed, 25 Apr 2018 06:43:45 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3F27F266; Wed, 25 Apr 2018 10:43:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Gibson , Paul Mackerras , Sasha Levin Subject: [PATCH 4.14 157/183] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Date: Wed, 25 Apr 2018 12:36:17 +0200 Message-Id: <20180425103248.849517263@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Mackerras [ Upstream commit 05f2bb0313a2855e491dadfc8319b7da261d7074 ] 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. Reviewed-by: David Gibson Signed-off-by: Paul Mackerras Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1348,12 +1348,8 @@ static unsigned long resize_hpt_rehash_h } 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));