Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2181542imm; Mon, 28 May 2018 03:24:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJtf5wZsTFpyEy/nYb3u7MLBRQpA0gkn9GOCg30Hv30YABk4vLpwDWSKQtqoysNkc+qe1bZ X-Received: by 2002:a63:7c55:: with SMTP id l21-v6mr592488pgn.352.1527503055052; Mon, 28 May 2018 03:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527503055; cv=none; d=google.com; s=arc-20160816; b=c11XchGDdUSD0CcmEF+QhyhjTMDAiG77v3YDwvQabA8qhttJeDBIr5TLU+Q2Ftl76c oqB7QZpAumt1cZ/dmeUd/cMEfnzncz0gjblBOw3n9gZ19aR8AKz4OqlkQCbHdJbFxgQo TZXe/tudf/7jPVIB/xmutDLZN06HmWP7Z0jVdHt4G9MPcu8MWgnDEqDAfboiT6QRivCp jTZhqtXL41Bd2qtt6JaifU63gGO/C8GE/vmVvzyChu0Z2hUkRwQ+hB93LubW+pgqkMAf Kq/sLpT33J6odo/1xRxEqu0j27z470N0SrwZo5mM5Q0U2De3kLLipEdYcKw9HsuDP/zN EkAg== 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:dkim-signature :arc-authentication-results; bh=UaHCFGmK576T3mEDt27L2j3ZSPuTsKNLV6edak1pXKw=; b=KQKsVpL4XD6o3IOKjiS8ePpda3cjvCPP+UJlDf1EsYrkfN6eeENAhV+LAEuei4ZJH1 gXePgRj2vYzq/feHay0XVE1P/bm6gozdKjcJlWbJ6vCOBMqNTUhMIfPrrpXsnt69TE4I m2Mn5mlf1bXj/LWHzJU6lw/dnnP4WYv0AUx7Lk2TQ1lSsfN6lh38EMXOHyo0UraeJ7Qg rNrqGg2OEJl3y06o36buw3bOIk0Ttrxr4MM2O26u1lCnxcviKIShNyS4A9K6cnWbAYN/ zKU1k5VfctK9lxOHA4K9TbYltG5y4OhUA9mku+IRal3NwznOU+PAkEKWVXkHPYeu+baa grYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1eWxeUF3; 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 l64-v6si3160401pgd.174.2018.05.28.03.24.00; Mon, 28 May 2018 03:24:15 -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=@kernel.org header.s=default header.b=1eWxeUF3; 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 S1033738AbeE1KXw (ORCPT + 99 others); Mon, 28 May 2018 06:23:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033712AbeE1KXq (ORCPT ); Mon, 28 May 2018 06:23:46 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 2267B2088E; Mon, 28 May 2018 10:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527503025; bh=ZlxfdRa3YJbaehH2Q+DnFtruyOvQIm0Fi7dHEKAwrFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1eWxeUF3CZCKl+ALrh8naPwcu2oTWgLs4qK78d/reo+sfs2BzuZoRyRxmBD4wIvyi bv2YxpF8hbSgB6jR1DXAvq4JvZzSgYHxTLhXPI35/q9ukNDBbZY8DEqy2xwuHyvzl8 LiXpawaIcoLF5BuLao20SXY1YpbLc2hrhuK90m9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Sasha Levin Subject: [PATCH 4.4 185/268] powerpc/mpic: Check if cpu_possible() in mpic_physmask() Date: Mon, 28 May 2018 12:02:39 +0200 Message-Id: <20180528100223.292347668@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman [ Upstream commit 0834d627fbea00c1444075eb3e448e1974da452d ] In mpic_physmask() we loop over all CPUs up to 32, then get the hard SMP processor id of that CPU. Currently that's possibly walking off the end of the paca array, but in a future patch we will change the paca array to be an array of pointers, and in that case we will get a NULL for missing CPUs and oops. eg: Unable to handle kernel paging request for data at address 0x88888888888888b8 Faulting instruction address: 0xc00000000004e380 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP .mpic_set_affinity+0x60/0x1a0 LR .irq_do_set_affinity+0x48/0x100 Fix it by checking the CPU is possible, this also fixes the code if there are gaps in the CPU numbering which probably never happens on mpic systems but who knows. Debugged-by: Nicholas Piggin Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/sysdev/mpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c @@ -626,7 +626,7 @@ static inline u32 mpic_physmask(u32 cpum int i; u32 mask = 0; - for (i = 0; i < min(32, NR_CPUS); ++i, cpumask >>= 1) + for (i = 0; i < min(32, NR_CPUS) && cpu_possible(i); ++i, cpumask >>= 1) mask |= (cpumask & 1) << get_hard_smp_processor_id(i); return mask; }