From patchwork Wed Nov 28 11:02:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1004433 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434dD621MPz9ryk for ; Wed, 28 Nov 2018 22:07:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 434dD572ZdzDqTs for ; Wed, 28 Nov 2018 22:07:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.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 434d7D0PnGzDqgD for ; Wed, 28 Nov 2018 22:03:35 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wASAxKci078338 for ; Wed, 28 Nov 2018 06:03:34 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2p1qjwnn93-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Nov 2018 06:03:33 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Nov 2018 11:03:30 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 28 Nov 2018 11:03:27 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wASB3QID9044346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Nov 2018 11:03:26 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30E19A405D; Wed, 28 Nov 2018 11:03:26 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 26774A4059; Wed, 28 Nov 2018 11:03:25 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.109.198.143]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Nov 2018 11:03:24 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Wed, 28 Nov 2018 16:32:34 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181128110244.17664-1-hegdevasant@linux.vnet.ibm.com> References: <20181128110244.17664-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112811-4275-0000-0000-000002E7F0B0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112811-4276-0000-0000-000037F530A4 Message-Id: <20181128110244.17664-13-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-28_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811280100 Subject: [Skiboot] [PATCH v6 12/22] hdata: Add result table property to "dump" node 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: , Cc: stewart@linux.vnet.ibm.com, hbathini@linux.vnet.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" During MPIPL hostboot updates MDRT table with details of memory movement (source, destination address, size, etc). Convert these details to fadump structure format and pass it to kernel via 'result-table' property. Device tree property: /ibm,opal/dump/result-table - follows fadump structure format Signed-off-by: Vasant Hegde --- hdata/spira.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hdata/spira.h | 4 +++ 2 files changed, 95 insertions(+) diff --git a/hdata/spira.c b/hdata/spira.c index d1748511c..d52df3f05 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "hdata.h" #include "hostservices.h" @@ -1033,6 +1035,92 @@ static void dt_init_secureboot_node(const struct iplparams_sysparams *sysparams) dt_add_property_cells(node, "hw-key-hash-size", hw_key_hash_size); } +static void fadump_add_result_table(const struct iplparams_iplparams *p) +{ + int i, j = 0; + u32 mdrt_cnt = spira.ntuples.mdump_res.act_cnt; + u32 mdrt_max_cnt = MDRT_TABLE_SIZE / sizeof(struct mdrt_table); + size_t prop_size; + struct mdrt_table *mdrt = (void *)(MDRT_TABLE_BASE); + struct fadump_section *fadump_section; + struct fadump *result_table; + struct dt_node *dump_node; + + dump_node = dt_find_by_path(opal_node, "dump"); + if (!dump_node) + return; + + /* Check boot params to detect MPIPL boot or not */ + if (p->cec_ipl_maj_type != IPLPARAMS_MAJ_TYPE_REIPL) + return; + /* + * On FSP system we get minor type as post dump IPL and on BMC system + * we get platform reboot. Hence lets check for both values + */ + if (p->cec_ipl_min_type != IPLPARAMS_MIN_TYPE_POST_DUMP && + p->cec_ipl_min_type != IPLPARAMS_MIN_TYPE_PLAT_REBOOT) { + prlog(PR_DEBUG, "FADUMP: Non MPIPL reboot " + "[minor type = 0x%x]\n", p->cec_ipl_min_type); + return; + } + if (p->cec_ipl_attrib != IPLPARAMS_ATTRIB_MEM_PRESERVE) { + prlog(PR_DEBUG, "FADUMP: Memory not preserved \n"); + return; + } + + if (mdrt_cnt == 0 || mdrt_cnt >= mdrt_max_cnt) { + prlog(PR_ERR, "FADUMP: Invalid MDRT count : %x\n", mdrt_cnt); + return; + } + + prlog(PR_DEBUG, "FADUMP: Dump found, MDRT count = 0x%x\n", mdrt_cnt); + + /* Calculcate property size */ + prop_size = sizeof(struct fadump) + + (mdrt_cnt * sizeof(struct fadump_section)); + result_table = zalloc(prop_size); + if (!result_table) { + prlog(PR_ERR, "FADUMP: Failed to allocate memory\n"); + return; + } + + /* Copy MDRT entries to result-table */ + result_table->fadump_section_size = sizeof(struct fadump_section); + for (i = 0; i < mdrt_cnt; i++) { + /* Skip garbage entry */ + if ((mdrt->dest_addr == 0) || (mdrt->size == 0)) { + mdrt++; + continue; + } + + if (mdrt->dump_type != DUMP_TYPE_FADUMP) { + mdrt++; + continue; + } + + fadump_section = &(result_table->section[j++]); + fadump_section->source_type = mdrt->data_region; + /* Clear top bit */ + fadump_section->source_addr = mdrt->src_addr & ~(HRMOR_BIT); + fadump_section->dest_addr = mdrt->dest_addr & ~(HRMOR_BIT); + fadump_section->source_size = mdrt->size; + fadump_section->dest_size = mdrt->size; + mdrt++; + } + + if (j == 0) { + prlog(PR_DEBUG, "FADUMP: MDRT table is empty\n"); + free(result_table); + return; + } + + result_table->section_count = j; + /* Actual property size */ + prop_size = sizeof(struct fadump) + (j * sizeof(struct fadump_section)); + dt_add_property(dump_node, "result-table", result_table, prop_size); + free(result_table); +} + static void fadump_add_node(void) { u64 fw_load_area[4]; @@ -1196,6 +1284,9 @@ static void add_iplparams_ipl_params(const void *iplp, struct dt_node *node) else dt_add_property_strings(led_node, DT_PROPERTY_LED_MODE, LED_MODE_GUIDING_LIGHT); + + /* Populate fadump result table */ + fadump_add_result_table(p); } static void add_iplparams_serials(const void *iplp, struct dt_node *node) diff --git a/hdata/spira.h b/hdata/spira.h index 5c030692e..ed759d50f 100644 --- a/hdata/spira.h +++ b/hdata/spira.h @@ -401,8 +401,12 @@ struct iplparams_iplparams { #define IPLPARAMS_FSP_FW_IPL_SIDE_TEMP 0x01 uint8_t ipl_speed; __be16 cec_ipl_attrib; +#define IPLPARAMS_ATTRIB_MEM_PRESERVE PPC_BIT16(2) uint8_t cec_ipl_maj_type; +#define IPLPARAMS_MAJ_TYPE_REIPL 0x1 uint8_t cec_ipl_min_type; +#define IPLPARAMS_MIN_TYPE_POST_DUMP 0xc +#define IPLPARAMS_MIN_TYPE_PLAT_REBOOT 0xd uint8_t os_ipl_mode; uint8_t keylock_pos; uint8_t lmb_size;