From patchwork Mon May 11 08:41:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1288185 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 49Lmzv1Mjlz9sRR for ; Tue, 12 May 2020 15:47:55 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49Lmzt34M1zDqg5 for ; Tue, 12 May 2020 15:47:54 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49LDtm0b14zDqZp for ; Mon, 11 May 2020 18:41:34 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04B8WoFB012975; Mon, 11 May 2020 04:41:30 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30wsc2vn0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:30 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04B8XFvU014386; Mon, 11 May 2020 04:41:30 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 30wsc2vn00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:30 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04B8Yxkp030234; Mon, 11 May 2020 08:41:28 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 30wm569kqp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 08:41:28 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04B8fQwL50987114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 May 2020 08:41:26 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B3A35204F; Mon, 11 May 2020 08:41:26 +0000 (GMT) Received: from [192.168.0.24] (unknown [9.199.58.67]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 747F452050; Mon, 11 May 2020 08:41:25 +0000 (GMT) From: Mahesh Salgaonkar To: pdbg Date: Mon, 11 May 2020 14:11:24 +0530 Message-ID: <158918648405.16822.8656222589108716359.stgit@jupiter> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_02:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 spamscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110066 X-Mailman-Approved-At: Tue, 12 May 2020 15:47:51 +1000 Subject: [Pdbg] [PATCH RFC 1/4] pdbg: Add support for error injection framework. X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Add new command called "inject" to allow users to inject errors using pdbg. Signed-off-by: Mahesh Salgaonkar --- Makefile.am | 3 ++- src/err_inject.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 5 +++- src/parsers.c | 14 ++++++++++++ src/parsers.h | 3 +++ 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 src/err_inject.c diff --git a/Makefile.am b/Makefile.am index fdcbb09..1e444ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,7 +120,8 @@ pdbg_SOURCES = \ src/scom.c \ src/thread.c \ src/util.c \ - src/util.h + src/util.h \ + src/err_inject.c pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ $(ARCH_FLAGS) diff --git a/src/err_inject.c b/src/err_inject.c new file mode 100644 index 0000000..23463e7 --- /dev/null +++ b/src/err_inject.c @@ -0,0 +1,64 @@ +/* Copyright 2020 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +#include + +#include "main.h" +#include "optcmd.h" +#include "path.h" + +static void list_error_components(void) +{ + /* TODO: List error components */ +} + +static void list_err_type(char *component) +{ + /* TODO: List error type for a give component */ +} + +static void inject_errors(char *component, char *error) +{ + /* TODO: Inject errors */ +} + + +static void error_inject_init(void) +{ + /* Call error inject init routines. */ +} + +static int inject(char *component, char *error) +{ + error_inject_init(); + + if (!strcmp(component, "?")) + list_error_components(); + else if (!strcmp(error, "?")) + list_err_type(component); + else + inject_errors(component, error); + + return 0; +} +OPTCMD_DEFINE_CMD_WITH_ARGS(inject, inject, + (DEFAULT_STRING("?"), DEFAULT_STRING("?"))); diff --git a/src/main.c b/src/main.c index 5a5616d..7fd26f9 100644 --- a/src/main.c +++ b/src/main.c @@ -74,7 +74,7 @@ extern struct optcmd_cmd optcmd_getmem, optcmd_putmem, optcmd_getmemio, optcmd_putmemio, optcmd_getmempba, optcmd_putmempba, optcmd_getxer, optcmd_putxer, optcmd_getcr, optcmd_putcr, - optcmd_gdbserver, optcmd_istep; + optcmd_gdbserver, optcmd_istep, optcmd_inject; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -85,7 +85,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getmem, &optcmd_putmem, &optcmd_getmemio, &optcmd_putmemio, &optcmd_getmempba, &optcmd_putmempba, &optcmd_getxer, &optcmd_putxer, &optcmd_getcr, &optcmd_putcr, - &optcmd_gdbserver, &optcmd_istep, + &optcmd_gdbserver, &optcmd_istep, &optcmd_inject, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -130,6 +130,7 @@ static struct action actions[] = { { "regs", "[--backtrace]", "State (optionally display backtrace)" }, { "gdbserver", "", "Start a gdb server" }, { "istep", " |0", "Execute istep on SBE" }, + { "inject", "|? |?", "Inject an error in specified component" }, }; static void print_usage(void) diff --git a/src/parsers.c b/src/parsers.c index 8575784..ef71a0f 100644 --- a/src/parsers.c +++ b/src/parsers.c @@ -3,6 +3,7 @@ #include #include #include +#include uint64_t *parse_number64(const char *argv) { @@ -127,3 +128,16 @@ bool *parse_flag_noarg(const char *argv) *result = true; return result; } + +/* Just read the string and return */ +char **parse_string(const char *argv) +{ + char **str = malloc(sizeof(char *)); + + if (!argv) + return NULL; + + *str = malloc(strlen(argv) + 1); + strcpy(*str, argv); + return str; +} diff --git a/src/parsers.h b/src/parsers.h index be13ce9..ca8d74f 100644 --- a/src/parsers.h +++ b/src/parsers.h @@ -13,6 +13,8 @@ #define DEFAULT_DATA32(default) (parse_number32, default) #define GPR (parse_gpr, NULL) #define SPR (parse_spr, NULL) +#define STRING (parse_string, NULL) +#define DEFAULT_STRING(default) (parse_string, default) uint64_t *parse_number64(const char *argv); uint32_t *parse_number32(const char *argv); @@ -21,5 +23,6 @@ uint8_t *parse_number8_pow2(const char *argv); int *parse_gpr(const char *argv); int *parse_spr(const char *argv); bool *parse_flag_noarg(const char *argv); +char **parse_string(const char *argv); #endif From patchwork Mon May 11 08:41:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1288186 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 49Lmzx6Ls8z9sSg for ; Tue, 12 May 2020 15:47:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49Lmzx4CcRzDqgq for ; Tue, 12 May 2020 15:47:57 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49LDtr5W52zDqZp for ; Mon, 11 May 2020 18:41:40 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04B8bW3x164803; Mon, 11 May 2020 04:41:38 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30ws5dmscc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:38 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04B8cP1c167562; Mon, 11 May 2020 04:41:37 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 30ws5dmsb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:37 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04B8YtNb032043; Mon, 11 May 2020 08:41:35 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 30wm55kyx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 08:41:35 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04B8eMEU66060672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 May 2020 08:40:22 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 884A3A4051; Mon, 11 May 2020 08:41:33 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA906A4053; Mon, 11 May 2020 08:41:32 +0000 (GMT) Received: from [192.168.0.24] (unknown [9.199.58.67]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 11 May 2020 08:41:32 +0000 (GMT) From: Mahesh Salgaonkar To: pdbg Date: Mon, 11 May 2020 14:11:31 +0530 Message-ID: <158918649143.16822.6515319767989338898.stgit@jupiter> In-Reply-To: <158918648405.16822.8656222589108716359.stgit@jupiter> References: <158918648405.16822.8656222589108716359.stgit@jupiter> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_03:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110071 X-Mailman-Approved-At: Tue, 12 May 2020 15:47:51 +1000 Subject: [Pdbg] [PATCH RFC 2/4] pdbg: Introduce a error registration framework. X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Add an interface to register error injections that can be used through pdbg inject command. Error injection can be split component wise. This interface will allow one to introduce multiple error injections per component. e.g. A timer facility components could be "tb" and "tod". And each component will define multiple error injections under it. e.g. "tb" component will have below error injections and so on... tfmr_parity hdec_parity dec_parity ... Signed-off-by: Mahesh Salgaonkar --- Makefile.am | 3 + src/err_inject.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/err_inject.h | 20 ++++++++ 3 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 src/err_inject.h diff --git a/Makefile.am b/Makefile.am index 1e444ba..05522cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -121,7 +121,8 @@ pdbg_SOURCES = \ src/thread.c \ src/util.c \ src/util.h \ - src/err_inject.c + src/err_inject.c \ + src/err_inject.h pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ $(ARCH_FLAGS) diff --git a/src/err_inject.c b/src/err_inject.c index 23463e7..ef6bc97 100644 --- a/src/err_inject.c +++ b/src/err_inject.c @@ -21,26 +21,146 @@ #include #include +#include #include "main.h" #include "optcmd.h" #include "path.h" +#include "err_inject.h" + +struct list_head error_comp_list = LIST_HEAD_INIT(error_comp_list); + +struct error_type { + char *name; + char *desc; + inject_error_t inject_error; + void *data; + struct list_node error_link; +}; + +struct error_comp { + char *name; + struct list_head err_type_list; + struct list_node comp_link; +}; + +static struct error_comp *get_error_component(char *component) +{ + struct error_comp *err_comp = NULL; + + list_for_each(&error_comp_list, err_comp, comp_link) + if (!strcmp(err_comp->name, component)) + return err_comp; + return NULL; +} + +static struct error_comp *create_error_component(char *component) +{ + struct error_comp *err_comp = NULL; + + err_comp = malloc(sizeof(*err_comp)); + if (!err_comp) + return NULL; + + err_comp->name = strdup(component); + list_head_init(&err_comp->err_type_list); + list_add_tail(&error_comp_list, &err_comp->comp_link); + + return err_comp; +} + +static struct error_type *get_error_type(struct error_comp *err_comp, + char *error) +{ + struct error_type *err_type = NULL; + + list_for_each(&err_comp->err_type_list, err_type, error_link) + if (!strcmp(err_type->name, error)) + return err_type; + return NULL; +} + +int register_error_inject(char *component, char *error, char *error_desc, + inject_error_t func, void *data) +{ + struct error_comp *err_comp = NULL; + struct error_type *err_type = NULL; + + err_comp = get_error_component(component); + if (!err_comp) { + err_comp = create_error_component(component); + if (!err_comp) + return -ENOMEM; + } + + err_type = malloc(sizeof(*err_type)); + if (!err_type) + return -ENOMEM; + + err_type->name = strdup(error); + err_type->inject_error = func; + err_type->data = data; + if (error_desc) + err_type->desc = strdup(error_desc); + list_add_tail(&err_comp->err_type_list, &err_type->error_link); + + return 0; +} static void list_error_components(void) { - /* TODO: List error components */ + struct error_comp *err_comp = NULL; + + printf("Usage: pdbg inject \n"); + printf(" :\n"); + printf(" %-15s %s\n", "?", "Show component list"); + list_for_each(&error_comp_list, err_comp, comp_link) + printf(" %-15s\n", err_comp->name); } static void list_err_type(char *component) { - /* TODO: List error type for a give component */ + struct error_comp *err_comp = NULL; + struct error_type *err_type = NULL; + + err_comp = get_error_component(component); + if (!err_comp) { + printf("Invalid error component: %s\n", component); + return; + } + + printf("Usage: pdbg inject %s :\n", err_comp->name); + printf(" :\n"); + printf(" %-15s %s\n", "?", "Show error list"); + list_for_each(&err_comp->err_type_list, err_type, error_link) + printf(" %-15s %s\n", err_type->name, err_type->desc); } static void inject_errors(char *component, char *error) { - /* TODO: Inject errors */ -} + struct error_comp *err_comp = NULL; + struct error_type *err_type = NULL; + struct pdbg_target *target; + err_comp = get_error_component(component); + if (!err_comp) { + printf("Invalid error component: %s\n", component); + return; + } + + err_type = get_error_type(err_comp, error); + if (!err_type) { + printf("Invalid error type %s for %s\n", error, component); + return; + } + + for_each_path_target(target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + err_type->inject_error(target, err_type->data); + } +} static void error_inject_init(void) { diff --git a/src/err_inject.h b/src/err_inject.h new file mode 100644 index 0000000..76acee7 --- /dev/null +++ b/src/err_inject.h @@ -0,0 +1,20 @@ +#ifndef __ERR_INJECT_H +#define __ERR_INJECT_H + +#include +#include + +typedef int (*inject_error_t)(struct pdbg_target *target, void *data); + +/** + * @brief Register error injections that can be used through pdbg inject + * command + * @param[in] component Name of error component. + * @param[in] error Name of error type under given component. + * @param[in] error_desc Description of error to be injected. + * @param[in] func Error injection routine + * @param[in] data Opaque data pointer passed to func. + */ +extern int register_error_inject(char *component, char *error, + char *error_desc, inject_error_t func, void *data); +#endif From patchwork Mon May 11 08:41:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1288187 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 49Ln0002fbz9sSg for ; Tue, 12 May 2020 15:48:00 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49Lmzz5Z4gzDqg1 for ; Tue, 12 May 2020 15:47:59 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49LDv304kfzDqZp for ; Mon, 11 May 2020 18:41:50 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04B8bWT1164826; Mon, 11 May 2020 04:41:49 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30ws5dmsj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:48 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04B8bdhu165371; Mon, 11 May 2020 04:41:48 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 30ws5dmsg3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:48 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04B8Yxks030234; Mon, 11 May 2020 08:41:43 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 30wm569kr2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 08:41:43 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04B8ffDY65994782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 May 2020 08:41:41 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11EBE4C04E; Mon, 11 May 2020 08:41:41 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F9FF4C040; Mon, 11 May 2020 08:41:40 +0000 (GMT) Received: from [192.168.0.24] (unknown [9.199.58.67]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 11 May 2020 08:41:39 +0000 (GMT) From: Mahesh Salgaonkar To: pdbg Date: Mon, 11 May 2020 14:11:38 +0530 Message-ID: <158918649880.16822.9214964387579789187.stgit@jupiter> In-Reply-To: <158918648405.16822.8656222589108716359.stgit@jupiter> References: <158918648405.16822.8656222589108716359.stgit@jupiter> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_03:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=2 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110071 X-Mailman-Approved-At: Tue, 12 May 2020 15:47:51 +1000 Subject: [Pdbg] [PATCH RFC 3/4] pdbg: add timeer facility TB error injections. X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" # ./pdbg -p0 -c3 -t3 inject Usage: pdbg inject : ? Show component list tb # ./pdbg -p0 -c3 -t3 inject tb ? Usage: pdbg inject tb : : ? Show error list tfmr_parity TFMR parity error hdec_parity HDEC parity error tb_residue TB parity/residue error purr_parity PURR parity error spurr_parity SPURR parity error dec_parity DEC parity error # ./pdbg -p0 -c1 -t3 inject tb dec_parity p0:c1:t3: 0x20010a84 = 0x001e000000000000 # # ./pdbg -p0 -c1,2 inject tb hdec_parity p0:c1: 0x20010a84 = 0x0002000000000000 p0:c2: 0x20010a84 = 0x0002000000000000 # Signed-off-by: Mahesh Salgaonkar --- Makefile.am | 3 + src/err_inject.c | 46 +++++++++++++++++++++ src/err_inject.h | 43 +++++++++++++++++++ src/timefac_error.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 src/timefac_error.c diff --git a/Makefile.am b/Makefile.am index 05522cf..ed97505 100644 --- a/Makefile.am +++ b/Makefile.am @@ -122,7 +122,8 @@ pdbg_SOURCES = \ src/util.c \ src/util.h \ src/err_inject.c \ - src/err_inject.h + src/err_inject.h \ + src/timefac_error.c pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ $(ARCH_FLAGS) diff --git a/src/err_inject.c b/src/err_inject.c index ef6bc97..c059ef8 100644 --- a/src/err_inject.c +++ b/src/err_inject.c @@ -22,6 +22,7 @@ #include #include +#include #include "main.h" #include "optcmd.h" @@ -162,9 +163,54 @@ static void inject_errors(char *component, char *error) } } +static char *target_short_path(struct pdbg_target *target) +{ + char result[255]; + char *bufp = result; + int proc_index = -1, chip_index = -1, thread_index = -1; + int n = 0; + + if (get_target_type(target) == TARGET_TYPE_THREAD) { + thread_index = pdbg_target_index(target); + target = pdbg_target_parent("core", target); + } + if (get_target_type(target) == TARGET_TYPE_CORE) { + chip_index = pdbg_target_index(target); + target = pdbg_target_parent("pib", target); + } + if (get_target_type(target) == TARGET_TYPE_PROC) + proc_index = pdbg_target_index(target); + + if (proc_index >= 0) + n += sprintf(bufp + n, "p%d:", proc_index); + if (chip_index >= 0) + n += sprintf(bufp + n, "c%d:", chip_index); + if (thread_index >= 0) + n += sprintf(bufp + n, "t%d:", thread_index); + + return strdup(result); +} + +int target_inject_error(struct pdbg_target *target, uint32_t scom_addr, + uint64_t val) +{ + char *short_path; + int rc; + + rc = pib_write(target, scom_addr, val); + if (rc) + return rc; + + short_path = target_short_path(target); + printf("%s 0x%x = 0x%016llx\n", short_path, scom_addr, val); + free(short_path); + return 0; +} + static void error_inject_init(void) { /* Call error inject init routines. */ + timefac_err_init(); } static int inject(char *component, char *error) diff --git a/src/err_inject.h b/src/err_inject.h index 76acee7..d295470 100644 --- a/src/err_inject.h +++ b/src/err_inject.h @@ -3,6 +3,12 @@ #include #include +#include + +/* Target types */ +#define TARGET_TYPE_PROC 1 +#define TARGET_TYPE_CORE 2 +#define TARGET_TYPE_THREAD 3 typedef int (*inject_error_t)(struct pdbg_target *target, void *data); @@ -17,4 +23,41 @@ typedef int (*inject_error_t)(struct pdbg_target *target, void *data); */ extern int register_error_inject(char *component, char *error, char *error_desc, inject_error_t func, void *data); + +/* Get target type */ +static inline int get_target_type(struct pdbg_target *target) +{ + const char *classname; + + classname = pdbg_target_class_name(target); + if (!strcmp(classname, "pib")) + return TARGET_TYPE_PROC; + + if (!strcmp(classname, "core")) + return TARGET_TYPE_CORE; + + if (!strcmp(classname, "thread")) + return TARGET_TYPE_THREAD; + + return 0; +} + +/** + * @brief Inject an error on specified target using scom addr/value. + * @param[in] target pdbg target where error to be injected. + * @param[in] scom_adddr SCOM address to use. + * @param[in] val Value to set for a given scom address. + * + * This function uses pib_write() to write to scom address and on + * successfull injection it prints out target short path along with + * scom address and data written. + * e.g. + * p0:c1:t3: 0x20010a84 = 0x001e000000000000 + */ +int target_inject_error(struct pdbg_target *target, uint32_t scom_addr, + uint64_t val); + +/* Error inject init functions */ +extern void timefac_err_init(void); + #endif diff --git a/src/timefac_error.c b/src/timefac_error.c new file mode 100644 index 0000000..cb6c9ac --- /dev/null +++ b/src/timefac_error.c @@ -0,0 +1,114 @@ +/* Copyright 2020 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "main.h" +#include "optcmd.h" +#include "path.h" +#include "err_inject.h" + +/* SPR_MODE scom address */ +#define P9_SCOM_SPR_MODE 0x20010A84 + +/* TB Errors */ +#define TB_ERROR_MASK PPC_BITMASK(10, 15) +/* Core level TB errors */ +#define TB_ERROR_TFMR_PARITY 0x1 +#define TB_ERROR_HDEC_PARITY 0x2 +#define TB_ERROR_TB_PARITY 0x3 +/* Thread level TB errors */ +#define TB_ERROR_PURR_PARITY 0x4 +#define TB_ERROR_SPURR_PARITY 0x5 +#define TB_ERROR_DEC_PARITY 0x6 + +typedef struct error_type { + char *name; + char *desc; + uint64_t error; +} error_type_t; + +static error_type_t tb_error_type[] = { + { "tfmr_parity", "TFMR parity error", TB_ERROR_TFMR_PARITY }, + { "hdec_parity", "HDEC parity error", TB_ERROR_HDEC_PARITY }, + { "tb_residue", "TB parity/residue error", TB_ERROR_TB_PARITY }, + { "purr_parity", "PURR parity error", TB_ERROR_PURR_PARITY }, + { "spurr_parity", "SPURR parity error", TB_ERROR_SPURR_PARITY }, + { "dec_parity", "DEC parity error", TB_ERROR_DEC_PARITY }, +}; + +static int timefac_inject_tb_error(struct pdbg_target *target, void *data) +{ + int target_type = 0; + uint64_t err_type; + uint64_t val; + uint64_t tindex; + int rc; + + err_type = *((uint64_t *)data); + if (err_type < TB_ERROR_PURR_PARITY) + target_type = TARGET_TYPE_CORE; + else + target_type = TARGET_TYPE_THREAD; + + if (target_type != get_target_type(target)) + return -EINVAL; + + /* + * TODO: Add a check for proc type p8/p9/p10 and then use scom + * address appropriately. + */ + rc = pib_read(target, P9_SCOM_SPR_MODE, &val); + if (rc) { + /* just print the error message and continue. */ + printf("Failed to read scom addr: %x\n", P9_SCOM_SPR_MODE); + val = 0; + } + + /* set the error type and thread index where error to be injected */ + if (target_type == TARGET_TYPE_THREAD) { + tindex = pdbg_target_index(target); + err_type |= (tindex << 3); + } + val = SETFIELD(TB_ERROR_MASK, val, err_type); + + rc = target_inject_error(target, P9_SCOM_SPR_MODE, val); + if (rc) { + printf("Failed to inject\n"); + } + return rc; +} + +void timefac_err_init(void) +{ + int i; + + /* Register Tb error injects. */ + for (i = 0; i < ARRAY_SIZE(tb_error_type); i++) + register_error_inject("tb", tb_error_type[i].name, + tb_error_type[i].desc, timefac_inject_tb_error, + &tb_error_type[i].error); + +} From patchwork Mon May 11 08:41:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1288188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Ln05522dz9sRR for ; Tue, 12 May 2020 15:48:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49Ln0512yKzDqgB for ; Tue, 12 May 2020 15:48:05 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49LDv85BCnzDqbF for ; Mon, 11 May 2020 18:41:56 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04B8VN8F073281; Mon, 11 May 2020 04:41:52 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 30ws9y4tjj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:52 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04B8fq6h108889; Mon, 11 May 2020 04:41:52 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 30ws9y4thy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 04:41:52 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04B8Z0Fo008750; Mon, 11 May 2020 08:41:50 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 30wm55hkv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 08:41:50 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04B8fmh564094288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 May 2020 08:41:48 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E7DCAE057; Mon, 11 May 2020 08:41:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66427AE055; Mon, 11 May 2020 08:41:47 +0000 (GMT) Received: from [192.168.0.24] (unknown [9.199.58.67]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 11 May 2020 08:41:47 +0000 (GMT) From: Mahesh Salgaonkar To: pdbg Date: Mon, 11 May 2020 14:11:46 +0530 Message-ID: <158918650638.16822.2953054547382650577.stgit@jupiter> In-Reply-To: <158918648405.16822.8656222589108716359.stgit@jupiter> References: <158918648405.16822.8656222589108716359.stgit@jupiter> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_02:2020-05-08, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110066 X-Mailman-Approved-At: Tue, 12 May 2020 15:47:51 +1000 Subject: [Pdbg] [PATCH RFC 4/4] pdbg: Add timer facility TOD error injections. X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Add TOD error injections. # ./pdbg -p0 inject tod pp0_reg_parity p0: 0x40031 = 0x1000000000000000 # Signed-off-by: Mahesh Salgaonkar --- src/timefac_error.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/timefac_error.c b/src/timefac_error.c index cb6c9ac..92ccfc2 100644 --- a/src/timefac_error.c +++ b/src/timefac_error.c @@ -33,6 +33,9 @@ /* SPR_MODE scom address */ #define P9_SCOM_SPR_MODE 0x20010A84 +/* TOD Error inject register scom address */ +#define TOD_ERROR_INJECT 0x40031 + /* TB Errors */ #define TB_ERROR_MASK PPC_BITMASK(10, 15) /* Core level TB errors */ @@ -44,6 +47,21 @@ #define TB_ERROR_SPURR_PARITY 0x5 #define TB_ERROR_DEC_PARITY 0x6 +/* TOD Errors */ +#define TOD_ERR_MPATH_CREG_PARITY PPC_BIT(0) +#define TOD_ERR_PPORT0_CREG_PARITY PPC_BIT(3) +#define TOD_ERR_PPORT1_CREG_PARITY PPC_BIT(4) +#define TOD_ERR_SPORT0_CREG_PARITY PPC_BIT(5) +#define TOD_ERR_SPORT1_CREG_PARITY PPC_BIT(6) +#define TOD_ERR_SPATH_CREG_PARITY PPC_BIT(7) +#define TOD_ERR_IPATH_CREG_PARITY PPC_BIT(8) +#define TOD_ERR_PSMS_CREG_PARITY PPC_BIT(9) +#define TOD_ERR_PSS_HAMMING_DISTANCE PPC_BIT(18) +#define TOD_ERR_DELAY_COMPL_PARITY PPC_BIT(22) +#define TOD_ERR_CTCR_PARITY PPC_BIT(32) +#define TOD_ERR_TOD_SYNC_CHECK PPC_BIT(33) +#define TOD_ERR_TOD_FSM_PARITY PPC_BIT(34) + typedef struct error_type { char *name; char *desc; @@ -59,6 +77,45 @@ static error_type_t tb_error_type[] = { { "dec_parity", "DEC parity error", TB_ERROR_DEC_PARITY }, }; +static error_type_t tod_error_type[] = { + { "mp_reg_parity", + "Master path control register (0x00): data parity error", + TOD_ERR_MPATH_CREG_PARITY }, + { "pp0_reg_parity", + "port-0 primary configuration register (0x01): data parity error", + TOD_ERR_PPORT0_CREG_PARITY }, + { "pp1_reg_parity", + "port-1 primary configuration register (0x02): data parity error", + TOD_ERR_PPORT1_CREG_PARITY }, + { "sp0_reg_parity", + "port-0 secondary configuration register (0x03): data parity error", + TOD_ERR_SPORT0_CREG_PARITY }, + { "sp1_reg_parity", + "port-1 secondary configuration register (0x04): data parity error", + TOD_ERR_SPORT1_CREG_PARITY }, + { "sp_reg_parity", + "slave path control register (0x05): data parity error", + TOD_ERR_SPATH_CREG_PARITY }, + { "ip_reg_parity", + "internal path control register (0x06): data parity error", + TOD_ERR_IPATH_CREG_PARITY }, + { "psms_reg_parity", + "primary/secondary master/slave control register (0x07): data parity error", + TOD_ERR_PSMS_CREG_PARITY }, + { "pss_hum_dist", "PSS Hamming Distance", + TOD_ERR_PSS_HAMMING_DISTANCE }, + { "delay_parity", + "internal path: delay, STEP check components: parity error", + TOD_ERR_DELAY_COMPL_PARITY }, + { "ch_reg_parity", + "chip control register (0x10): data parity error", + TOD_ERR_CTCR_PARITY }, + { "sync_check", "internal path: SYNC check error", + TOD_ERR_TOD_SYNC_CHECK }, + { "fsm_st_parity", "internal path: FSM state parity error", + TOD_ERR_TOD_FSM_PARITY }, +}; + static int timefac_inject_tb_error(struct pdbg_target *target, void *data) { int target_type = 0; @@ -101,6 +158,23 @@ static int timefac_inject_tb_error(struct pdbg_target *target, void *data) return rc; } +static int timefac_inject_tod_error(struct pdbg_target *target, void *data) +{ + uint64_t err_val; + int rc; + + err_val = *((uint64_t *)data); + + if (TARGET_TYPE_PROC != get_target_type(target)) + return -EINVAL; + + rc = target_inject_error(target, TOD_ERROR_INJECT, err_val); + if (rc) { + printf("Failed to inject\n"); + } + return rc; +} + void timefac_err_init(void) { int i; @@ -111,4 +185,11 @@ void timefac_err_init(void) tb_error_type[i].desc, timefac_inject_tb_error, &tb_error_type[i].error); + /* Register TOD error injects */ + for (i = 0; i < ARRAY_SIZE(tod_error_type); i++) + register_error_inject("tod", tod_error_type[i].name, + tod_error_type[i].desc, + timefac_inject_tod_error, + &tod_error_type[i].error); + }