Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9943147ybi; Wed, 24 Jul 2019 12:46:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdHaro8a0FisUopy/ceOtHv4gJz+OVu4Sc3jKcAlx/fMiDqu8vCpEkRN9epif9srWRH/Kh X-Received: by 2002:a63:593:: with SMTP id 141mr81127465pgf.78.1563997560884; Wed, 24 Jul 2019 12:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997560; cv=none; d=google.com; s=arc-20160816; b=ysgXgxBmc1q6Nsb3kKXTVU/g4NO2Aqw2YOU1xPwy9M1p3LFjHlZbs8S2VpUIYV+kVg rf2HhTKg01NpjoDUeo4cV5U9qHkKS4vsvWXs9h4k7Qihc+m9wlndSu7yoIwMDfT4Y3B4 b9DzHVQd+xcGsxPYorCco0Sq6le35zlFV9vzxmr4AsaaosefIr9IUv7FNYo6f1OP5ISq boPU6uaQLLomzVD8prvC5dPA8Z1ounvmCVJGu8gW9fPibJVi6aJmhtFsGxvQu7gIAmVR bGGgVeueSfTOe2i0ytoI6f0Wlme95X79GJOz1LwtlM1+3vqjzWLrFLruCgazy+LeoXmS jMAA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lC/UeNmLNtWpx0bj9JpLVkAYutif9ODnzd/HbiskWGA=; b=tTUbvR6ENXENQmn6QEJ/WvJDw1NCwM5cZYKAMkjznCKv/dyeyiD3ZJVSu5zqXbik/b nxokULNvzyZQpSnudJ1has1sSp8YLSJzZM7rcZ8K2yPHuSiAnexyfaIzUGzdlBn6FCiy kuHeuzHa0ik4rU1En6B9xC0s/mUN0HnutQk1CGnfjfSVTQnPhZrxuseHB85yx56WEJi0 ZbCyN/bzmWO2gHcLtneBJ8y/9HL+lzRSZzdk/9YS7XD+VRaPG1aU2V1QIKlrjym7gByT n7OKcibGv2B79akNf/DjNnanNOY+kVuJEhsQ5igq5rmqp1SepA+gpaZ4xLJCdPHiLLwy FQZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FKi/EfAf"; 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 z17si14678109pgj.147.2019.07.24.12.45.46; Wed, 24 Jul 2019 12:46:00 -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="FKi/EfAf"; 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 S2390509AbfGXTnO (ORCPT + 99 others); Wed, 24 Jul 2019 15:43:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:45202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390491AbfGXTnL (ORCPT ); Wed, 24 Jul 2019 15:43:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7E1AE21873; Wed, 24 Jul 2019 19:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997390; bh=jv2Sx3+12uO3gAGfSdMC3SqdmcDAMN/U/EXWfucTZKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKi/EfAf9J4oWb9D+BWC2EHf++C3s39ygaPzrilZRTGMPS/qOtLmG9utxnNhDsFLG PmNa+eUzWJe/BP9vADACxEOHdxJp9oLEOhTaTm9CKiTiWPldMbEe5J0TSugwkoHiuo Eos4ndrqZR0qmm9H918FfEkNDaQ0GzbgYzwnhZvQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Pavithra R. Prakash" , Greg Kurz , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Michael Ellerman Subject: [PATCH 5.2 393/413] powerpc/pseries: Fix xive=off command line Date: Wed, 24 Jul 2019 21:21:24 +0200 Message-Id: <20190724191803.003712091@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kurz commit a3bf9fbdad600b1e4335dd90979f8d6072e4f602 upstream. On POWER9, if the hypervisor supports XIVE exploitation mode, the guest OS will unconditionally requests for the XIVE interrupt mode even if XIVE was deactivated with the kernel command line xive=off. Later on, when the spapr XIVE init code handles xive=off, it disables XIVE and tries to fall back on the legacy mode XICS. This discrepency causes a kernel panic because the hypervisor is configured to provide the XIVE interrupt mode to the guest : kernel BUG at arch/powerpc/sysdev/xics/xics-common.c:135! ... NIP xics_smp_probe+0x38/0x98 LR xics_smp_probe+0x2c/0x98 Call Trace: xics_smp_probe+0x2c/0x98 (unreliable) pSeries_smp_probe+0x40/0xa0 smp_prepare_cpus+0x62c/0x6ec kernel_init_freeable+0x148/0x448 kernel_init+0x2c/0x148 ret_from_kernel_thread+0x5c/0x68 Look for xive=off during prom_init and don't ask for XIVE in this case. One exception though: if the host only supports XIVE, we still want to boot so we ignore xive=off. Similarly, have the spapr XIVE init code to looking at the interrupt mode negotiated during CAS, and ignore xive=off if the hypervisor only supports XIVE. Fixes: eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE interrupt controller") Cc: stable@vger.kernel.org # v4.20 Reported-by: Pavithra R. Prakash Signed-off-by: Greg Kurz Reviewed-by: Cédric Le Goater Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/prom_init.c | 16 +++++++++++- arch/powerpc/sysdev/xive/spapr.c | 52 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -168,6 +168,7 @@ static unsigned long __prombss prom_tce_ #ifdef CONFIG_PPC_PSERIES static bool __prombss prom_radix_disable; +static bool __prombss prom_xive_disable; #endif struct platform_support { @@ -804,6 +805,12 @@ static void __init early_cmdline_parse(v } if (prom_radix_disable) prom_debug("Radix disabled from cmdline\n"); + + opt = prom_strstr(prom_cmd_line, "xive=off"); + if (opt) { + prom_xive_disable = true; + prom_debug("XIVE disabled from cmdline\n"); + } #endif /* CONFIG_PPC_PSERIES */ } @@ -1212,10 +1219,17 @@ static void __init prom_parse_xive_model switch (val) { case OV5_FEAT(OV5_XIVE_EITHER): /* Either Available */ prom_debug("XIVE - either mode supported\n"); - support->xive = true; + support->xive = !prom_xive_disable; break; case OV5_FEAT(OV5_XIVE_EXPLOIT): /* Only Exploitation mode */ prom_debug("XIVE - exploitation mode supported\n"); + if (prom_xive_disable) { + /* + * If we __have__ to do XIVE, we're better off ignoring + * the command line rather than not booting. + */ + prom_printf("WARNING: Ignoring cmdline option xive=off\n"); + } support->xive = true; break; case OV5_FEAT(OV5_XIVE_LEGACY): /* Only Legacy mode */ --- a/arch/powerpc/sysdev/xive/spapr.c +++ b/arch/powerpc/sysdev/xive/spapr.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -659,6 +660,55 @@ static bool xive_get_max_prio(u8 *max_pr return true; } +static const u8 *get_vec5_feature(unsigned int index) +{ + unsigned long root, chosen; + int size; + const u8 *vec5; + + root = of_get_flat_dt_root(); + chosen = of_get_flat_dt_subnode_by_name(root, "chosen"); + if (chosen == -FDT_ERR_NOTFOUND) + return NULL; + + vec5 = of_get_flat_dt_prop(chosen, "ibm,architecture-vec-5", &size); + if (!vec5) + return NULL; + + if (size <= index) + return NULL; + + return vec5 + index; +} + +static bool xive_spapr_disabled(void) +{ + const u8 *vec5_xive; + + vec5_xive = get_vec5_feature(OV5_INDX(OV5_XIVE_SUPPORT)); + if (vec5_xive) { + u8 val; + + val = *vec5_xive & OV5_FEAT(OV5_XIVE_SUPPORT); + switch (val) { + case OV5_FEAT(OV5_XIVE_EITHER): + case OV5_FEAT(OV5_XIVE_LEGACY): + break; + case OV5_FEAT(OV5_XIVE_EXPLOIT): + /* Hypervisor only supports XIVE */ + if (xive_cmdline_disabled) + pr_warn("WARNING: Ignoring cmdline option xive=off\n"); + return false; + default: + pr_warn("%s: Unknown xive support option: 0x%x\n", + __func__, val); + break; + } + } + + return xive_cmdline_disabled; +} + bool __init xive_spapr_init(void) { struct device_node *np; @@ -671,7 +721,7 @@ bool __init xive_spapr_init(void) const __be32 *reg; int i; - if (xive_cmdline_disabled) + if (xive_spapr_disabled()) return false; pr_devel("%s()\n", __func__);