Received: by 10.213.65.68 with SMTP id h4csp2139335imn; Sun, 8 Apr 2018 20:42:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/VfL0x9Pg1mjy35ZDJvkaooeH5VO4IDPDQnV8v8bx/Pqsak3h4+iBMbpvpe1KA93AeCj2y X-Received: by 2002:a17:902:468:: with SMTP id 95-v6mr37424064ple.360.1523245356314; Sun, 08 Apr 2018 20:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523245356; cv=none; d=google.com; s=arc-20160816; b=Uc65LJEsrTOEz+O+NDNYZzFHyAezDGMna/mAILjFpUbN1aG3S+iiH3lvxfRHH04yHB wecjlbr8c8WCQfdOT+wPPiYP3E8JofGJYgSYQexOKWFe7io2l/gWfU9MMYeQCQQxW7Nu lNHuX6I4CCRhUprCeqsNI4toL6V4dsL6JGwJhEr4YS8JZH5UbNlFiGtpOny9pLYcLRXS 0WiNofPGjuFDnqCzFy0RiKa1HDNW9z0nL3D/2zDZEivijRtpnLeBNaKYvBXxQP73v+Xe XPM7KGRlkzFXlh8o1fKWbHqUAyhjb7HC6afn/6QVwSXaq28K5tHRdg3g7lPR9fJQ1Jqk fZrg== 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=WAcEfqbuCDMusKtqfp3KH8Te+KjpF87/rVI4Y1U5qDA=; b=GqECCqJZmmc64KuiSLdCEcnL86SMxeU0sNZTOrVYqMkyoepBahxIE0Vzzcx7ciTXVb n6W/CKbTaOU5VC149q/3O55VDhlQlL9VPGiRx0rWcq3j1LaVT1XfliMbSsAzEnW9Go/u 0+haWhmbSE6uQ4TzcVBA48VqQtEOyR1kCtprpgqmARjvCIpBoVnAfFjONqdX1Ag3G1Bm hcWf1R+7k7EnsI1U3Klh8QzQyNxI8g7o2wS7hXh7KlMRpdkuNLUO0AVRIMjgRWAXUwZb FAl15Hkv6YRvThwSVHxgjQNOGMhc7cwWYd5nTY78xddnaQFbKg7AyBK1WOF5ZYjSYA3i 2ocw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=VNpIHpxK; 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 i12si4701678pgq.322.2018.04.08.20.41.59; Sun, 08 Apr 2018 20:42:36 -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=VNpIHpxK; 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 S1753398AbeDIDeK (ORCPT + 99 others); Sun, 8 Apr 2018 23:34:10 -0400 Received: from mail-bl2nam02on0107.outbound.protection.outlook.com ([104.47.38.107]:21664 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754436AbeDIAVS (ORCPT ); Sun, 8 Apr 2018 20:21:18 -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=WAcEfqbuCDMusKtqfp3KH8Te+KjpF87/rVI4Y1U5qDA=; b=VNpIHpxKSaKStFX/Q6amuBKk5MaDAESUiVB4b8ThkGCWBYO2MD6PgHXAVToMkjmsXAgZJH/nkNVTeMw7huWnAM6ko19XQ8jFq9Q63nYgIobJCWfI1GtTfFxjBA6vnNm48boaVY3a3v5Qf5CoSs2q/qOLg1qN3l6EGZfvVAuxHww= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1125.namprd21.prod.outlook.com (52.132.130.150) 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:21:12 +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:21:12 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Paul Mackerras , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 174/189] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Thread-Topic: [PATCH AUTOSEL for 4.15 174/189] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Thread-Index: AQHTz5hfkpakKxfJS0irQYHNCn4Uaw== Date: Mon, 9 Apr 2018 00:19:06 +0000 Message-ID: <20180409001637.162453-174-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB1125;7:WFk4mFcbe+xmGIz+JTFn9WXzFmH37FHDUIL0KBTpg2w8x2pnKI10MQBkHLnITF4y3LGT1BtL6XM1Zb39N7O7AGmECKr1SvFGjjZ/VsENfl/G771lRW85ad4MzTqGtLM67UDIK3j95LGkBMzZUvvK88h0eunDhBxmxPqA+p6QzAsKcTjmV3KVOT0O1SSa0jgt2zhEGQgrpuJz2BuWhC1LKO639CZNmFz+SV3CbSwGkXto+pONn2GVTuluIgbg7SJd;20:LNsaKgYiS+Awa/D4smkPbTSOoP5aFpIm31goKUQYmAXHJGu6nV5u08Ba5BfLfQZ5PzXccDOQKAS9eY2Q7GyrLThtZedR2itZ+wn7A5L/edBVaFwjpVW1No9ooI09XiAptDk3tZWY9cJGNXc8dmM3AcpKHuClAAOkJm2Y4rStjNs= X-MS-Office365-Filtering-Correlation-Id: bd4b4eda-ccdf-453b-bbc3-08d59dafcce9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1125; x-ms-traffictypediagnostic: DM5PR2101MB1125: 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)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1125;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1125; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39380400002)(39860400002)(346002)(199004)(189003)(105586002)(7736002)(8676002)(97736004)(81166006)(106356001)(81156014)(305945005)(14454004)(66066001)(1076002)(102836004)(5250100002)(478600001)(2501003)(2900100001)(22452003)(72206003)(68736007)(26005)(86362001)(575784001)(8936002)(76176011)(6506007)(6116002)(6486002)(186003)(5660300001)(3660700001)(316002)(54906003)(110136005)(25786009)(2906002)(10090500001)(6512007)(3280700002)(6666003)(10290500003)(53936002)(99286004)(86612001)(3846002)(6436002)(486006)(4326008)(2616005)(11346002)(107886003)(36756003)(476003)(446003)(22906009)(32563001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1125;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: kyoB4n87hHJHuyZi87pgjBca8ZdFWQIMDG5xWSbEfdR/oYBRHRDf9Tru8+0kWwipac6fzoN+/xKxKYOUaaTh9SHJr84Prvc3K7ST6D+BbHAt4dymERogOfmIrhasuwGLerX26Fi/bBUAgNwVCgpL21lUgfAr0zZ9/ZIpsawCu4UEIqhj4j+W89h8ezBDwsogPHLJNnWTPVXwpGlnyVdzU4VCa3w9n1hGcPFVuqSwZZ8ANtIwKQflMpu9neLfvqAXT864iLAn0fkWsEBcSnQ193GrTEWPquIoHdeKGOxTWw/hbym84wdiH+fQsSgCuF+EkU/yO9KKv/+R87ro0X5S/PKXcub71eVjs5Fil8hDqjgyZWQf1NDEmcQCTsy3ZP00SQwGXSEQ3Xt0PcYiu4jmjC6tHrrJsP/l2urgmYd75qc= 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: bd4b4eda-ccdf-453b-bbc3-08d59dafcce9 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:19:06.7990 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1125 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 b73dbc9e797d..dc0f2ade589e 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1337,12 +1337,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