Received: by 10.213.65.68 with SMTP id h4csp2113005imn; Sun, 8 Apr 2018 20:02:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/tt3RaL48E0Q2jwaFT293shOc+gUGjA/zyLWs/hg9ldMFjkDEMgm301MoFOp9e/03lSUVs X-Received: by 10.99.114.2 with SMTP id n2mr24130160pgc.274.1523242973212; Sun, 08 Apr 2018 20:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242973; cv=none; d=google.com; s=arc-20160816; b=f7hnQmUFSZ9kGXBT9T5+4/0ux6HcQpj7kWoeiEbYRgK6f0D2G4y5Q97M8lGJzb5DP4 D5R6oSV7fEiEteIRC418sanGXK7iUi60/Li9H1tCTuUi+QYagXI6kkT1U/sd/TFZK2CY /xLPuW5nY2sLsy/aft538/fX+bQx+c8TZXQfa7OSGuvtM4ArtWNmV8i1RuWkqxJf18HU 7+n5mIp0mtBvYYs/Qxw/UWZQ3DxVYvfcs4PC9gdngAxBm5FsnlQPs+cfdbHb8KpmN/h4 SEm3jzxzA2uOJ3L5yWtgI2fqEp5biOC2woml0XYj+AIMiFEifzJzbcp2v3isyhspT43R dLAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=PBzGKsoLwzyiBVNnZQt9QI9sopp7h9MQ19AIa9fWJO8=; b=MCpA+mwxNplpURLxgfbM8iOMxuYpMAYng5/n95bpK99vt4poJXaJG1SP+2IJhBnPrG 4Zzrk+b0TMu6ALhebM7KWku5qfxlOMrWTAmscHm5utPDsjQZuWLDJ5an9ESdpAQjcoQ4 v5CsQiJLXPjZwN9dqBL9EyJidcUmPoNeXAiJ4ALs52cjAQh+537uKWWfK1xBZFkgspRN qFj84zpzRr6+TAGs2I4IB9i4rELxVBF8YIWhehWV3o010KL7RTICuV0fO8dBpLObA32K Q/7kBgtZGKQ4HT+DNF+k+K5etG5ZKH0kNX3p26sOR1r+ie1d4WVsRLPeGZru6m4poaRm uOkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RK6suKuQ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si10590943pgo.639.2018.04.08.20.02.16; Sun, 08 Apr 2018 20:02:53 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RK6suKuQ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755373AbeDIA0f (ORCPT + 99 others); Sun, 8 Apr 2018 20:26:35 -0400 Received: from mail-sn1nam02on0138.outbound.protection.outlook.com ([104.47.36.138]:42256 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755330AbeDIA02 (ORCPT ); Sun, 8 Apr 2018 20:26:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PBzGKsoLwzyiBVNnZQt9QI9sopp7h9MQ19AIa9fWJO8=; b=RK6suKuQCLaDTo62TGNn2NGUkcgW7AcCy3g8nFOnxY3JqZsYgs9dwKdlHbPYa4LYt1DGVC+7nf04P1FwnVJldz9uF+mgHZhicobfNALpl8fdLsjdUGNwuP//hSAkbVi8JyuyPxwcpRxWpKqapFtF1X9CHFJ9emGb45ssDLnB6UE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0725.namprd21.prod.outlook.com (10.167.107.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:26:18 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:26:18 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Paul Mackerras , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 147/161] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Thread-Topic: [PATCH AUTOSEL for 4.14 147/161] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Thread-Index: AQHTz5jCCfT3c+KkdUGQTzB4+308CA== Date: Mon, 9 Apr 2018 00:21:53 +0000 Message-ID: <20180409001936.162706-147-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0725;7:DJfeZMGQdsLxYhYkODNEuD19ZVV0vBePMCrbm+xAo2JV4ORsWax7r4Zhljjhn7K8s3nMvgKRedG4Zl4KdtAyvL7Rd5anelm7D/L1Yrc9CGDe3iR/uMkuZGSH7nUzqEFd8XR1MsWxSJOWYnFZWlLqq2eKKN5mY2Xlf/nZKmLun2tqhEYbYMGkOfUDCySeRRyeFDsVIFLKZ0er7+rX+Zufv+FSUR6F2Q/lxqlUN8uRhFjp/7hjdfffZxxMGz0rx2ue;20:fqHv77Y4KbJ4tL0cpRUSFzc9DFCIunLYW6Sr7yL0EL7OY4a0d/Qj5DDL2+9gfCYDWBm2PCOU6TaIaV5yJcBW2fYYwVDbyWsTZMSnK6RYAFBv8jHZ2cgCjuToWhdv6GqJojpgJD+APG+rG6qy+PGC1TQjaAAmtCH55gJKBmHZtgA= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 85132aa2-ac34-468f-f569-08d59db08348 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0725; x-ms-traffictypediagnostic: DM5PR2101MB0725: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0725;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0725; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(366004)(376002)(396003)(39860400002)(199004)(189003)(6486002)(81166006)(26005)(6512007)(4326008)(6666003)(6436002)(81156014)(8676002)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(86362001)(76176011)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(6116002)(22906009)(32563001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0725;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Kxb1iBOSBGiY/EMqADZ4YkOnvOPX0I6sDUXU2o22zzsM1UtFwPK8Sc6TUZBlFfSvAKcikf4pPWuD5jAqKiZH+oG16WtqHDrbcyz83z9mg1rnn9hIs3scA7EqhLHYdtiZKvj33+67s6cNIMMR01SvUhenqaQ6gphNvImL74KOGdMPQ+IMuJK6QEEMUynSrThqOtl7kOv+Ws30GEDx1X6j/et+nCKGyF6majyLZh30XpEC6IfzrB07ahKjxFGFFZFb9m+mr5L7sEWi5FnDw3VDjc1DgI1n1RxKtRDGmY5fyn6qm5xC2dx2L+VaasliOXSTejwmioq5Fm/7UEq9A2URqsuRaWyECjeeQnM4C196xRRNLI/SJD7Xb/CMIRGv7JXqmY5+rEhU0zI/ZbeiQa2fBoX3iiomuAR7I56a3DtW8+w= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85132aa2-ac34-468f-f569-08d59db08348 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:53.5498 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0725 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 2645d484e945..df9b53f40b1e 100644 --- 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_hpte(struct k= vm_resize_hpt *resize, } =20 new_pteg =3D hash & new_hash_mask; - if (vpte & HPTE_V_SECONDARY) { - BUG_ON(~pteg !=3D (hash & old_hash_mask)); - new_pteg =3D ~new_pteg; - } else { - BUG_ON(pteg !=3D (hash & old_hash_mask)); - } + if (vpte & HPTE_V_SECONDARY) + new_pteg =3D ~hash & new_hash_mask; =20 new_idx =3D new_pteg * HPTES_PER_GROUP + (idx % HPTES_PER_GROUP); new_hptep =3D (__be64 *)(new->virt + (new_idx << 4)); --=20 2.15.1