Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp872586ybe; Wed, 4 Sep 2019 09:00:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2GlIdP3MPadQ8ng6YEn1Q8435DEOkr8TjrZ/dqyMmxbpWIX+Q6ZmDRtyf2IfgYsTOwxha X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr41066492plo.110.1567612834880; Wed, 04 Sep 2019 09:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567612834; cv=none; d=google.com; s=arc-20160816; b=IGsWZSpaOm78mxTyVQO4/wMaKBHBJhpfpoqpjxqP/ob7x6WIbIh7eM5VBeNo6xrZmC 5wTBevS787YWW4hM4uZ2PX0gV2rGCWZxtP89IwN3JT/ajhaiNepxYwL3CdacC1nP8Ldb 9FhEYjToyGOGr7O0wpyl3bjmYu0+ausEmhVUyljub4S5vf7CFcdqEV6xOget8wfC4eKw UPPilyZhNjr3NLBzAXm6rCuivTTjHTC6mzEYNbSA546sqJ9qYWbMtmtQmQcHriUxZ4ED eB1KuAlKln2QmWSkMMZmhz4G6mZkYy5SUhyYt7fLa/nVxnyObvZbpmHRXG9tNpHI3wlX ZgBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AvuEx9U6j1Fex3LMEbx3kwaa4Hy3MHE3GnzaIiibHzQ=; b=MZ2aTcUa6IqcdTFJ4PBQRxf0FZwYhOA9ygxfBjlYh0JIUcHKrk4NL2GAzxHGwb7AYo WT3xeW52H7OMLXHTfYylncVOnwMDBkhdRjtbuxOoD2HhJmhBSz4u2/ZxxwKKfvo2oKaW J1FUupr6T4TJwFODFXGATrqvY3PaNo/FlvUE3C2jNU2qvMazNrm8b17O0HcXG9AKfkKB q/6bGDOn8DC470xJMM9ldpNmtc5EPMT51M8+s76zVm6+dIwoJMCbOPHV+Y5nvqbcGiPn jQcuOJOnRu5On+Qhy3kxnBD2yJu+RP1M0c7MLLAoJzlLEM2PXQg94pFWxDllbCAR5yDJ C2gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="W/9sBGXg"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si8480723pfe.247.2019.09.04.09.00.18; Wed, 04 Sep 2019 09:00:34 -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="W/9sBGXg"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732124AbfIDP6u (ORCPT + 99 others); Wed, 4 Sep 2019 11:58:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:32954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731540AbfIDP6s (ORCPT ); Wed, 4 Sep 2019 11:58:48 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 073732339E; Wed, 4 Sep 2019 15:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567612727; bh=UK3c53+5Ln36+1z3mp+kBI3ksWKT8ZfYTQ98LiYFiWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W/9sBGXgqiR2/lFVLwiX3dCsat/nYUfaWBo67j8up7GpXVdQxqRLex0tbcn0b8Z8t pY/gOmDEcxxhUeJ9ihOwI9cXJ7ttfg4d25qElXSitMwjn8MGEZthRWmXTMuZWpQy+l n3FML7rVuIFIeo8uBt2/9UhrY0lgK19C7zG0PFCw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Gleixner , Rahul Tanwar , Andy Shevchenko , Alexander Shishkin , Linus Torvalds , Peter Zijlstra , alan@linux.intel.com, bp@alien8.de, cheol.yong.kim@intel.com, qi-ming.wu@intel.com, rahul.tanwar@intel.com, rppt@linux.ibm.com, tony.luck@intel.com, Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 5.2 44/94] x86/apic: Fix arch_dynirq_lower_bound() bug for DT enabled machines Date: Wed, 4 Sep 2019 11:56:49 -0400 Message-Id: <20190904155739.2816-44-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190904155739.2816-1-sashal@kernel.org> References: <20190904155739.2816-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit 3e5bedc2c258341702ddffbd7688c5e6eb01eafa ] Rahul Tanwar reported the following bug on DT systems: > 'ioapic_dynirq_base' contains the virtual IRQ base number. Presently, it is > updated to the end of hardware IRQ numbers but this is done only when IOAPIC > configuration type is IOAPIC_DOMAIN_LEGACY or IOAPIC_DOMAIN_STRICT. There is > a third type IOAPIC_DOMAIN_DYNAMIC which applies when IOAPIC configuration > comes from devicetree. > > See dtb_add_ioapic() in arch/x86/kernel/devicetree.c > > In case of IOAPIC_DOMAIN_DYNAMIC (DT/OF based system), 'ioapic_dynirq_base' > remains to zero initialized value. This means that for OF based systems, > virtual IRQ base will get set to zero. Such systems will very likely not even boot. For DT enabled machines ioapic_dynirq_base is irrelevant and not updated, so simply map the IRQ base 1:1 instead. Reported-by: Rahul Tanwar Tested-by: Rahul Tanwar Tested-by: Andy Shevchenko Signed-off-by: Thomas Gleixner Cc: Alexander Shishkin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: alan@linux.intel.com Cc: bp@alien8.de Cc: cheol.yong.kim@intel.com Cc: qi-ming.wu@intel.com Cc: rahul.tanwar@intel.com Cc: rppt@linux.ibm.com Cc: tony.luck@intel.com Link: http://lkml.kernel.org/r/20190821081330.1187-1-rahul.tanwar@linux.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/kernel/apic/io_apic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index c9fec0657eea2..e8c6466ef65ed 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2434,7 +2434,13 @@ unsigned int arch_dynirq_lower_bound(unsigned int from) * dmar_alloc_hwirq() may be called before setup_IO_APIC(), so use * gsi_top if ioapic_dynirq_base hasn't been initialized yet. */ - return ioapic_initialized ? ioapic_dynirq_base : gsi_top; + if (!ioapic_initialized) + return gsi_top; + /* + * For DT enabled machines ioapic_dynirq_base is irrelevant and not + * updated. So simply return @from if ioapic_dynirq_base == 0. + */ + return ioapic_dynirq_base ? : from; } #ifdef CONFIG_X86_32 -- 2.20.1