From patchwork Sat May 2 11:36:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1281667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Dq9q0VyKz9sRf for ; Sat, 2 May 2020 23:05:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=iEsm7620; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49Dq9p55S5zDrQq for ; Sat, 2 May 2020 23:05:50 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1042; helo=mail-pj1-x1042.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=iEsm7620; dkim-atps=neutral Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49DnD41st9zDqWL for ; Sat, 2 May 2020 21:37:40 +1000 (AEST) Received: by mail-pj1-x1042.google.com with SMTP id a32so1166815pje.5 for ; Sat, 02 May 2020 04:37:40 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=gZYGXpeVs5B7m2moPBY2pbUXuHmuNfaeZQ3sEEec0PI=; b=iEsm7620Vfub4c7MDnHa+/C5i+RzAuU9PDBkVucd7hhB7vK2/bQoYjFvR6S9Dcpvlw JNtrzlTStbMfKVT8OCNuWRCnGKCRnWpto5IXPEZ9+7b3LKXWUuhlo4xvsLlsdP4dA7ti YbViqvGf/K05AI1cGRklAhYq2e7CMVS5SEzR3IiEJAbH2f45uCI4XGeAe00+aTllq5DN ng/MnH2r/1zq42v6NVu7u57fQBLVldyko4ZXgQV+9S1KDIhZ2WlZlrkXspkLu85smTl7 ErKS9Cc/B8k2hHs28z8MO13yg2830IDriQ1cALSfqKYhLFmuaYoMbJEjEs93MoLzmUqM oWTw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gZYGXpeVs5B7m2moPBY2pbUXuHmuNfaeZQ3sEEec0PI=; b=sH7xMcyBOfAkB7sD11++FgPCpud64fMvc8+vdlhZQQnX1OvD81/u14kdV+HqITQMwl 5lslLv36KLo8B7iCTI2p/zAakpglxnXVKeit7Ih13hPpQpKniGdnPvyOY7DZBQqSyoHK fiOfNQBKYNNNjk2us7jHj49MUuZd1d8TfFGiJ7aC2iwsbCVMcSFsHkCilMbljmL7AUdf Ts/q8dcSlrtshIchI7JLeyNxxQdB6zB8yVBZMbyDyROS3o0ZN+Lk7RCfsqtVYBPv27cm ky5mqbBSapDTopgkIgsdRlF0vtj/pdZ+tojHNR0u1gNHg/kFojITPsU9bUjcMa1oor7M MDvQ== X-Gm-Message-State: AGi0PuYZ8vRKqAhihffl1RlxrKfAfy5dGY7hLBZ0APBmAlDmjqeClLbD G2s2Nl1sCpP3PnGqE5Uz4qlCZuiz X-Google-Smtp-Source: APiQypJPy6akT9/m/osWpz/L6fYs60+nNNO/DXDX/fYRGywUgWqJeONnGOJ5IJNmsitKy5MxC1dBcA== X-Received: by 2002:a17:902:aa94:: with SMTP id d20mr8530519plr.15.1588419457707; Sat, 02 May 2020 04:37:37 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([203.220.177.17]) by smtp.gmail.com with ESMTPSA id e135sm4367513pfh.37.2020.05.02.04.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2020 04:37:37 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 2 May 2020 21:36:43 +1000 Message-Id: <20200502113649.176329-4-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200502113649.176329-1-npiggin@gmail.com> References: <20200502113649.176329-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 3/9] Add OPAL_REPORT_TRAP interface X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" If the OS takes over OPAL's assert trap interrupts, it needs a way to report them and get metadata. This API leaves room for a WARN type of assertion without actually implementing one yet. The changes behaviour of OPAL asserts when the OS is running. They don't get put into an infinite loop, but rather try to kill the calling process. Not sure if this is quite the best way to go yet, it's possible we should be more recoverable like Linux BUG(), but there may be other issues with that. There is a way to ask for a panic, but that's also not used yet. Again the benefit of trap over the inline assertion is (aside from the above killing the process and attempting to continue), that a more precise snapshot of registers can be reported, and the current stack is not required (OS can use an alternative stack if it chooses). Signed-off-by: Nicholas Piggin --- core/utils.c | 22 ++++++++++++++++++++++ include/opal-api.h | 7 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/utils.c b/core/utils.c index d53bcf374..2ec11255d 100644 --- a/core/utils.c +++ b/core/utils.c @@ -166,6 +166,28 @@ static int64_t opal_sym_to_addr(const char *name, __be64 *symaddr, __be64 *symsi } opal_call(OPAL_SYM_TO_ADDR, opal_sym_to_addr, 3); +static int64_t opal_report_trap(uint64_t nip) +{ + struct trap_table_entry *tte; + + for (tte = __trap_table_start; tte < __trap_table_end; tte++) { + if (tte->address == nip) { + prerror("< %s >\n", tte->message); + prerror(" .\n"); + prerror(" .\n"); + prerror(" .\n"); + prerror(" OO__)\n"); + prerror(" <\"__/\n"); + prerror(" ^ ^\n"); + + return OPAL_TRAP_FATAL; + } + } + + return OPAL_EMPTY; +} +opal_call(OPAL_REPORT_TRAP, opal_report_trap, 1); + size_t snprintf_symbol(char *buf, size_t len, uint64_t addr) { unsigned long saddr; diff --git a/include/opal-api.h b/include/opal-api.h index ab8fc721f..76d751c75 100644 --- a/include/opal-api.h +++ b/include/opal-api.h @@ -229,7 +229,8 @@ #define OPAL_PHB_GET_OPTION 180 #define OPAL_ADDR_TO_SYM 181 #define OPAL_SYM_TO_ADDR 182 -#define OPAL_LAST 182 +#define OPAL_REPORT_TRAP 183 +#define OPAL_LAST 183 #define QUIESCE_HOLD 1 /* Spin all calls at entry */ #define QUIESCE_REJECT 2 /* Fail all calls with OPAL_BUSY */ @@ -1257,6 +1258,10 @@ struct opal_mpipl_fadump { struct opal_mpipl_region region[]; }; +#define OPAL_TRAP_FATAL 1 +#define OPAL_TRAP_WARN 2 +#define OPAL_TRAP_PANIC 3 + #endif /* __ASSEMBLY__ */ #endif /* __OPAL_API_H */