From nobody Fri May 17 07:56:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1588852177; cv=none; d=zohomail.com; s=zohoarc; b=ABXBwlzkb0+8rcjC015t/fEEIxp/A3PTBK4E64XxPTCP+ejceK/l9ulo7hZ81+/WfGBpjd9e+QocrnWIxFXPxAT4nZn8mlAO1NV6greqN5x2lx4R3K4dFPd6pBN8jf9ILE9qg+AofvjbfYOGJhVvO4hMAl47RBemkEcKoZf+hq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588852177; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IBT7B6CvDHf8I4ku+FpRwqydxDEojpZEtoiwU805UXI=; b=Iwi1CivCgRPEEPp9WNG0sdz59pK0Uct2WOeDMmqYpLy4qjNv2pCX57uAxSJDuSth8k0pbgvhbDXix53ZgWGpO6t9guNStlcZqe71cn5PqQqJ6EhLfDJAfW1dCne7XsKfdpliyZCO7R50c/xw5Ovanr//qkKXlMPbCLtrZejq+uM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588852177710876.4015427538731; Thu, 7 May 2020 04:49:37 -0700 (PDT) Received: from localhost ([::1]:54696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWf20-0002PX-BY for importer@patchew.org; Thu, 07 May 2020 07:49:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWf14-0001nF-JI; Thu, 07 May 2020 07:48:38 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:39991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jWf13-00066T-LV; Thu, 07 May 2020 07:48:38 -0400 Received: by mail-pl1-x643.google.com with SMTP id t16so1964559plo.7; Thu, 07 May 2020 04:48:36 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (61-68-214-199.tpgi.com.au. [61.68.214.199]) by smtp.gmail.com with ESMTPSA id 6sm4723446pfj.123.2020.05.07.04.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 04:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IBT7B6CvDHf8I4ku+FpRwqydxDEojpZEtoiwU805UXI=; b=mIWUJA3WqFO2opScDNSUd6zJbsblza9F8ZruBxcJwL2i2CDvUzPsUBlqcEY5enHAl/ 0noJcAx0OE4df2BE/i0nkk3qZ/NCf/ErPZfXDfaglC8URjOe1T+bp1lfOCoYGRnDq1ZL ZTXIYuXhVCu9k6iTKT0hAd/RYM7tOE7rluJnfivHsywX/n6qxlwnSEQTMa94G/WhbM89 HE7PyJBM8PdFiz5FbfF5gT4T/omR+CJLbQ2WGumnXfA2+l9EsprIJUSFaNdrs3UzNaNZ mn4BSURzd5ShMBADfZ0ascOvxxF3KuLXbtBeCLMNVTwSY335aqpSWnAG54vCK5Twy8ys WuDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IBT7B6CvDHf8I4ku+FpRwqydxDEojpZEtoiwU805UXI=; b=GBxaIp5RQlm2Oi33hkM4sGiv7fVugsKwDeJqZpU/QhMsdwGEItAdBvRQF3fbnJRbr2 xORfIxBOJ6cMb134aaPBmkSGvVjmTJvF+ha04Uty2Ay4S0wfPw0pPZGp5XYOdre/YX5X +TDEdBEzHfqXrw+pTEyzMtj0Hm+v96GcqY9eS+vlSrErRkYweC2Hfsb2F1KbFh0SjYrq TMitQf8FEO63+4ky/R/vgmdKzwwD3ZOU21TRoHJRETsx+GMTBUWY5jBLzaYKmGCFaooX nQrnuMoZOUkwkFRsYNtRifM/juECev8wdB6xCmKerGPwYD8W54Hy1lLAzzyqzYBd1Um4 D+8g== X-Gm-Message-State: AGi0PuZePuDmw0ztESqey7rpbpAfxRbQ9q8PXggKAxKTTdJ1H+jBzcWz taSraVIj9NJL2GkuXC8GukKCHm9Z X-Google-Smtp-Source: APiQypIEfBh9T/QdQyc5vt8d/0TtAXkFQGNXhF8g4hEkL1grzJcDIIN8F2YEwPkNMzHHrG0f8P6qmg== X-Received: by 2002:a17:902:403:: with SMTP id 3mr12895545ple.102.1588852115101; Thu, 07 May 2020 04:48:35 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH] ppc/pnv: Fix NMI system reset SRR1 value Date: Thu, 7 May 2020 21:48:24 +1000 Message-Id: <20200507114824.788942-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=npiggin@gmail.com; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-devel@nongnu.org, Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Commit a77fed5bd926 ("ppc/pnv: Add support for NMI interface") got the SRR1 setting wrong for sresets that hit outside of power-save states. Fix this, better documenting the source for the bit definitions. Fixes: a77fed5bd926 ("ppc/pnv: Add support for NMI interface") got the Cc: C=C3=A9dric Le Goater Cc: David Gibson Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- Thanks to Cedric for pointing out concerns with a previous MCE patch that unearthed this as well. Linux does not actually care what these SRR1[42:45] bits look like for non-powersave sresets, but we should follow documented behaviour as far as possible. hw/ppc/pnv.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index a3b7a8d0ff..1b4748ce6d 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1986,12 +1986,26 @@ static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run= _on_cpu_data arg) =20 cpu_synchronize_state(cs); ppc_cpu_do_system_reset(cs); - /* - * SRR1[42:45] is set to 0100 which the ISA defines as implementation - * dependent. POWER processors use this for xscom triggered interrupts, - * which come from the BMC or NMI IPIs. - */ - env->spr[SPR_SRR1] |=3D PPC_BIT(43); + if (env->spr[SPR_SRR1] & PPC_BITMASK(46, 47)) { + /* + * Power-save wakeups, as indicated by non-zero SRR1[46:47] put the + * wakeup reason in SRR1[42:45], system reset is indicated with 0b0100 + * (PPC_BIT(43)). + */ + if (!(env->spr[SPR_SRR1] & PPC_BIT(43))) { + warn_report("ppc_cpu_do_system_reset does not set system reset= wakeup reason"); + env->spr[SPR_SRR1] |=3D PPC_BIT(43); + } + } else { + /* + * For non-powersave system resets, SRR1[42:45] are defined to be + * implementation-dependent. The POWER9 User Manual specifies that + * an external (SCOM driven, which may come from a BMC nmi command or + * another CPU requesting a NMI IPI) system reset exception should be + * 0b0010 (PPC_BIT(44)). + */ + env->spr[SPR_SRR1] |=3D PPC_BIT(44); + } } =20 static void pnv_nmi(NMIState *n, int cpu_index, Error **errp) --=20 2.23.0