Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp822818pxb; Tue, 3 Nov 2020 13:32:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrZZ6i8vBGY7gn4+d1qb7V+pLXnsqf47Y5qlC/BV/8o2zAhx2Mg108php9+NJ/5MQMw+D8 X-Received: by 2002:a17:906:9458:: with SMTP id z24mr13992572ejx.318.1604439170893; Tue, 03 Nov 2020 13:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439170; cv=none; d=google.com; s=arc-20160816; b=Z+QPQAjMxW4nfKd+MGssR0zAUhVqf/iH0IshSgbs9xGd9Hi6wib5QRjhmw3/8Ewvn2 yEyXnFkk32PsA/hRv5IUeqm3y+zrUbemYWFjQxjl2Uvs1zrpOCfQlfRvopjQrSVloYel QFZBQYbcUrCYhNq/lbuV2fOJkVLVWJzBxcZrC2Ivl1E8TTjJUjhKO7+sN8LN0l5DnXG6 iGeEUqtFtQdKj/s2Q2T8dch03DPZdsXCvZyejanFoI27GgkhAVoOk5iCQd9JZ4jTXT2A OI9ghOpi5/HpAKN89v/SAlTMQD6SJoteAm57hoYTKTwm+xFf0jOhSwJpxQrNhXtCOWm6 1COg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eG5aG0Yh0/ar64qErnLDsIN1oIvA7bPtI6eCTDZDte0=; b=uRwblqeYg9RozkRR234IYmsQRytLO/hLBGSDfARLu+CGRqx90cg8OneQXST/nGNSFK G0MJcnAjfOfHH6rAEnsPuL/1MQLnSVl6ONgsz4USbRdhLkAn0fylr3qsP6ohAhusUb4+ T1iemxNJc6X+a2Njih+/zRRRV2qfXxKOi9PIcUdor/TDdbGDydG/48M3AkQnQwqphyoc Qd2DG/7XTVn68p2Lh72YkTnQPshLhsImuzdS4yomCak3oj8D+mgIY9Cu1MHTstlYRGwh QU44odZAFHJf22lzz55NUpD+ymB1XvqywfOY+mDwO9m4Go8POWULbDLDqubgLYanAtr+ IKFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hXGKisvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx13si13760151edb.260.2020.11.03.13.32.27; Tue, 03 Nov 2020 13:32:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hXGKisvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733237AbgKCVA2 (ORCPT + 99 others); Tue, 3 Nov 2020 16:00:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:36036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733185AbgKCVAV (ORCPT ); Tue, 3 Nov 2020 16:00:21 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F4BF223BF; Tue, 3 Nov 2020 21:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437220; bh=xqG+fTUmgaQ/vKT6h4IaipzHW2KvYVEABwaPKeUy88M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hXGKisvcWlTAF9b7/IgOfzVNpmBgw0olWV5jom+2tixCDest0GsFaMlefFeP6P6d0 lY6faO/Qljp6rpY04Ho3ASfgGNXu6hd0RiasN5LaVmvqRJY6Iujlq0ZdWDadmzJcia jkUTLZGZEoNj9FeHMNXPQ3Ewq7QFXfM97kEKgWEo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Aneesh Kumar K.V" , Michael Ellerman Subject: [PATCH 5.4 160/214] powerpc/memhotplug: Make lmb size 64bit Date: Tue, 3 Nov 2020 21:36:48 +0100 Message-Id: <20201103203305.777246317@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aneesh Kumar K.V commit 301d2ea6572386245c5d2d2dc85c3b5a737b85ac upstream. Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit. This was found by code audit. Cc: stable@vger.kernel.org Signed-off-by: Aneesh Kumar K.V Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20201007114836.282468-3-aneesh.kumar@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/pseries/hotplug-memory.c | 43 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 14 deletions(-) --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -279,7 +279,7 @@ static int dlpar_offline_lmb(struct drme return dlpar_change_lmb_state(lmb, false); } -static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size) +static int pseries_remove_memblock(unsigned long base, unsigned long memblock_size) { unsigned long block_sz, start_pfn; int sections_per_block; @@ -310,10 +310,11 @@ out: static int pseries_remove_mem_node(struct device_node *np) { - const __be32 *regs; + const __be32 *prop; unsigned long base; - unsigned int lmb_size; + unsigned long lmb_size; int ret = -EINVAL; + int addr_cells, size_cells; /* * Check to see if we are actually removing memory @@ -324,12 +325,19 @@ static int pseries_remove_mem_node(struc /* * Find the base address and size of the memblock */ - regs = of_get_property(np, "reg", NULL); - if (!regs) + prop = of_get_property(np, "reg", NULL); + if (!prop) return ret; - base = be64_to_cpu(*(unsigned long *)regs); - lmb_size = be32_to_cpu(regs[3]); + addr_cells = of_n_addr_cells(np); + size_cells = of_n_size_cells(np); + + /* + * "reg" property represents (addr,size) tuple. + */ + base = of_read_number(prop, addr_cells); + prop += addr_cells; + lmb_size = of_read_number(prop, size_cells); pseries_remove_memblock(base, lmb_size); return 0; @@ -620,7 +628,7 @@ static int dlpar_memory_remove_by_ic(u32 #else static inline int pseries_remove_memblock(unsigned long base, - unsigned int memblock_size) + unsigned long memblock_size) { return -EOPNOTSUPP; } @@ -953,10 +961,11 @@ int dlpar_memory(struct pseries_hp_error static int pseries_add_mem_node(struct device_node *np) { - const __be32 *regs; + const __be32 *prop; unsigned long base; - unsigned int lmb_size; + unsigned long lmb_size; int ret = -EINVAL; + int addr_cells, size_cells; /* * Check to see if we are actually adding memory @@ -967,12 +976,18 @@ static int pseries_add_mem_node(struct d /* * Find the base and size of the memblock */ - regs = of_get_property(np, "reg", NULL); - if (!regs) + prop = of_get_property(np, "reg", NULL); + if (!prop) return ret; - base = be64_to_cpu(*(unsigned long *)regs); - lmb_size = be32_to_cpu(regs[3]); + addr_cells = of_n_addr_cells(np); + size_cells = of_n_size_cells(np); + /* + * "reg" property represents (addr,size) tuple. + */ + base = of_read_number(prop, addr_cells); + prop += addr_cells; + lmb_size = of_read_number(prop, size_cells); /* * Update memory region to represent the memory add