From patchwork Fri Dec 4 15:52:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1411149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=HCJtRjOy; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=d7k3jI8R; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=Fafj5yqL; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4CncgW4vgbz9sWQ for ; Sat, 5 Dec 2020 02:53:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TwKLnHxHZxaieWsj6NAKMtj6/3SK8aBdOJ2z67Z1Myg=; b=HCJtRjOy5vnT/3F/tJfdO0/IJ 61Xuw27E4LipYZJALvzGdvkzZ0rvfFHp35UMXVsy/+9Obu6ARouYc0prGsLcOBmPjybBbGjJ3CVS6 bESU7S3Yat94NXu28eR9O/qnEscw1sgK5Wh5iU1imrU0va0JSer/hjXvnVsUFhh57BRvGe6YP07lX GCfdlw5551tDlZaeCMvMmEiKZg82PCc4nhqwGb5oXv4aaoLdAAptPafFKn9s1VMpe+yDHBhjcbWjY BhhhBWmIlXebeCqr/MSkmBxEP9k030C/ml324jNFomDqfmMMhpWC0GK0BBSRV6dnLbHnZNlxcVXBO 12eWZ4QXA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1klDOb-0002BN-4L; Fri, 04 Dec 2020 15:53:21 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1klDOW-00027h-FZ for opensbi@lists.infradead.org; Fri, 04 Dec 2020 15:53:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1607097196; x=1638633196; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Y1bctFbkgLxwhg5e+TZZ9jcJaE4xDYnXjfw72T4NZk0=; b=d7k3jI8RnUC0OXrKHbt7+QQ/KVkC/xXGv4/DN3Z41/mK99TzlCPCtFXl 45lOlym4+cQ7B2sK+qAvkpmFb3D1e5DkEiTPJw+qRYxoeAWSIume9ojMm MrcaXYCpR/GEpZnM8Kot9uMDtIU07e4hm0GyIp91IddUf3Rc7rvRGa+B6 h1KeNl22lNdhizRnSx/IPrWRtCWO5s98beCvW0jkKmeYZJXZd1r5h5phj CsY7av4M/25mnilvwKAZmbFvBvx4V99E08iKc9KXlFktaIZRDM6yL/g4n bjXWXli6EqCX0OtA0ufpiw3As8xKjQRK85MaDTkfmUQl6IlyN7vyEU4+A A==; IronPort-SDR: GBgGqPU0Ymkt5R9UeqviFgrFCqMdAf4e0nIuBZJWvb5HxTXHBLSjS7Adk4x995IV9SFw2XqJL/ GY9KD9Ixl6rAPetRd7OiA/Y6BBF6YJ/kYD0ttWjHptjyJ0JK7H5vWIW9MCNplUdd0PxlYZ9Nhq 8tHeTRHipnXINQp3/DWknsc5BXXI3rzEfK2UyMKdGU33SkoyisCFi1nKR8HuoMhAQoUkB8slUc +gOZYI0eOswYoAr8w3efWC8hJNY9yx5LDx8tU3aamMHMzY4/+3mU9VZutxiXhmWzCjY20OMDIW Z94= X-IronPort-AV: E=Sophos;i="5.78,393,1599494400"; d="scan'208";a="158916083" Received: from mail-bn7nam10lp2107.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.107]) by ob1.hgst.iphmx.com with ESMTP; 04 Dec 2020 23:53:13 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kvpVGgd8fd1vDUeH4i3B3JWHAmwcZLJVhHUBZe3lOdndlBKkWABKHOUVkCwyzBbcNXQvV1+2RZEhWpUdGlM3Mw7TjdSOVYD8Wg6lfaVmuq6WKyQGdTY+cA+bscPg6NZh//+243Gzqh3G713QwL20wMgaiAf3wg9vMTRVCfHBF6+uNZgRSIp3Q2FhIV7uQU545ITP6mkgqs0gNCft4KE/0YNLXIWFzYVoMrKvtWsVmf2YnOQ1Owf4Jd+Zw9BlymAkUHz2TbSdaehbMJU6BoznRzo8/g2K3CfHqk9i5+IXlkle8UAUzFJ7hZhSvlVOUlH2x2A9sfC5+0D7+op4Qz9bmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kYalL6UXapvxLrXWXXROLr7NffbZg8DF0Trn1ObdHro=; b=hSE5eJ2yRjwbIp9hSCOagvfz4hnHCjMJbGK6zE3D9TZJJOTdNIzb+i6k54OkW1ru8Tn08KonGqseHMB1j+RYifgfqJt+twFZwy4x2SDWy9ZKeIfPhqMxq0CIpIzUDoZgmO+4YYUOvF1EQHdfLDBKZYgdduDEj65wsdvn3yMzKIv/TV3CXlfajG/kATjbyQm48pw4SEyA+qKEV8pyqnZiOeUNyFM6llSVN3xeGsvHDTchsLJwJ24sxoKchKyVOrkyICdJ/pqsqJB8u3VWBy4752eto5nDCEnBLogfYagWaCOqMI4F2y3NhUbeDa/VVqPLUfQUtfumXouna5iVMuiHyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kYalL6UXapvxLrXWXXROLr7NffbZg8DF0Trn1ObdHro=; b=Fafj5yqLRCpAymuAuv/d9yQKvWmfIHloGK3PMCiO+lo1NSSn+12oNRvI9PuntDKRW4hGr1kgoa0bEWjzfSlpGTUFOna6jdTN0MAB0gfGio11vWtC7nz/obGq9ejUrS3RaiyE4v42nR1sdoJkJivamPSALRHfLDVaK2i1W8a5eJU= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB3995.namprd04.prod.outlook.com (2603:10b6:5:af::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Fri, 4 Dec 2020 15:53:12 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3589.025; Fri, 4 Dec 2020 15:53:12 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 07/11] lib: sbi: Add error prints in sbi_domain_finalize() Date: Fri, 4 Dec 2020 21:22:20 +0530 Message-Id: <20201204155224.733188-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201204155224.733188-1-anup.patel@wdc.com> References: <20201204155224.733188-1-anup.patel@wdc.com> X-Originating-IP: [103.15.57.100] X-ClientProxiedBy: PN1PR0101CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::33) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (103.15.57.100) by PN1PR0101CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Fri, 4 Dec 2020 15:53:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e7cc5627-fe3d-485a-31b9-08d8986cb3de X-MS-TrafficTypeDiagnostic: DM6PR04MB3995: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:107; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 54sv58EDNmfKUvqrA50AVpXd1dTJKURLpI54zkOreY1vc4fDC3lIDtfmkSVOg6ZCtMCGm8i3DIPTeTeK/nmL17tyaTvTPJpCoaZIPbanqvo0WSZ8FcRRAFT6extn+4bDjs2cdAaLBBNaVcgXa5vUXs43NpVmNPxTZiJhF+ZvX33LdW5QxujTPWDAhchvBOnnFRgI8Ih7Fq8gfSFeS1wLxwEk/suh3jNwK6vv3oOgFM/LMdSc1UmBeKTOijGJp1HrPKSdQM4rpKOk3d0glGO/JPYwvnAY7kUrwfiuHELa7bk2G//n8TIhW5WI2JIBVQ5ZpOabj7HJUlTxQsvmXcP62w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(136003)(346002)(39860400002)(54906003)(5660300002)(8936002)(44832011)(110136005)(55016002)(83380400001)(26005)(2906002)(16526019)(186003)(478600001)(4326008)(66946007)(1076003)(66556008)(6636002)(316002)(6666004)(2616005)(36756003)(86362001)(8676002)(8886007)(52116002)(66476007)(956004)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: LWBvO37NZQrwRem4qhmEV/TukltH5rR9QNQmx87UcQ04LAK9oTxvondhlTyCI5b4O2lCbPsQcEIYH3YfXG+APMARAZGZJmlBXXyDp8l8Ye4N4IiAx3aokA9Sz/PlDdbuj4Jr+4lXxtzTAx+pFUXLQynr+fGipDRosWIUcg7ZYHoa9HZTMKPCk69R4yL2PTEfEqCJhcp+u2FO83J1hf0a5AS0yVzYhYg1T/XtxJP5f3jsAe0y1dODnVOoWA0xgb+/LgpFqxwBTC2mGur1Tgvewv5Un6OFE5kIPVIuXSeRd+pi/EQYFX8N3MCY2n36FV0pOgiRTP7C6kkgVEClJ5+89mkN8ExyMNM4ClhUrSKjxPocKI5OHYantOf2OU2zedFPbXMRnEoKMTD6t5deeEpCPSwMVqlR+MIf8+ROaH34ZrJwdP6x/6HFe5/QRwUSFPiTUXWKEvymnNLYUfnZz8EtmRyo/DzbYFTiVqiDBd67uh0VeaNlQ/Vti1O0X02D65nmN0hc8w08I1q/ZjS6AY/VD2j6t1sxXmzLx+3RCD1obOl1YU4rxo0XGQY4WKCPLnx295ey7tiUkUdcXXoi8PuEbSixwcRd5ktCEq94t1H/iTkbqphe47HOu7uWtfaznWnzHGEp07mltPtxxv9sp0eBPeOB+rAjqBQO227ggIXnHPL7w0h2Yt6F2OzLhdjGpSHhEWucGmKcJ8w5XAmOtf3GtqCU1uOI3AoF3ktwVuA5QzykFpeEfnie5F48TV/Xvga1/wb8wCOPJRp8FOJlwqQEtFwjHyuXJS6ERodcnib7VT1pw+qzNZ8Ds0oU9xLxdY6rvDP/98/7oRnPMxrFRXdEsS3zc2ZmVp353KXvgZZaZ+Kp98XLR+gUVH9YVTIa5qMfGcPfrQNHG5XN+Jx7xO1wS0VGGghNhBygiIk24CFUnlWAWoRuifJf+7tmsyHzhnOWJYMU77+9okPWZ9hEuYh31h/DP1lbGZWnrQxF+5qx10QtEg48dnVEPCe4G4Fdt+qS X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7cc5627-fe3d-485a-31b9-08d8986cb3de X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2020 15:53:12.1943 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 36YNjTxD80Fp5yUip9g5mx2cqoa/oQ0PuMjT6vTaU71Cj5w7bR3G+3PVHY3KXoQufCqYOMAK3Lw+bRJeCNM4Ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB3995 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201204_105317_537785_241371CA X-CRM114-Status: GOOD ( 17.89 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , Alistair Francis , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We add error prints in sbi_domain_finalize() and sanitize_domain() to help debug domain configuration issues. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Reviewed-by: Atish Patra --- lib/sbi/sbi_domain.c | 63 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 1b50604..639e016 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -174,19 +174,33 @@ static int sanitize_domain(const struct sbi_platform *plat, struct sbi_domain_memregion treg, *reg, *reg1; /* Check possible HARTs */ - if (!dom->possible_harts) + if (!dom->possible_harts) { + sbi_printf("%s: %s possible HART mask is NULL\n", + __func__, dom->name); return SBI_EINVAL; + } sbi_hartmask_for_each_hart(i, dom->possible_harts) { - if (sbi_platform_hart_invalid(plat, i)) + if (sbi_platform_hart_invalid(plat, i)) { + sbi_printf("%s: %s possible HART mask has invalid " + "hart %d\n", __func__, dom->name, i); return SBI_EINVAL; + } }; /* Check memory regions */ - if (!dom->regions) + if (!dom->regions) { + sbi_printf("%s: %s regions is NULL\n", + __func__, dom->name); return SBI_EINVAL; + } sbi_domain_for_each_memregion(dom, reg) { - if (!is_region_valid(reg)) + if (!is_region_valid(reg)) { + sbi_printf("%s: %s has invalid region base=0x%lx " + "order=%lu flags=0x%lx\n", __func__, + dom->name, reg->base, reg->order, + reg->flags); return SBI_EINVAL; + } } /* Count memory regions and check presence of firmware region */ @@ -199,8 +213,11 @@ static int sanitize_domain(const struct sbi_platform *plat, have_fw_reg = TRUE; count++; } - if (!have_fw_reg) + if (!have_fw_reg) { + sbi_printf("%s: %s does not have firmware region\n", + __func__, dom->name); return SBI_EINVAL; + } /* Sort the memory regions */ for (i = 0; i < (count - 1); i++) { @@ -208,8 +225,15 @@ static int sanitize_domain(const struct sbi_platform *plat, for (j = i + 1; j < count; j++) { reg1 = &dom->regions[j]; - if (is_region_conflict(reg1, reg)) + if (is_region_conflict(reg1, reg)) { + sbi_printf("%s: %s conflict between regions " + "(base=0x%lx order=%lu flags=0x%lx) and " + "(base=0x%lx order=%lu flags=0x%lx)\n", + __func__, dom->name, + reg->base, reg->order, reg->flags, + reg1->base, reg1->order, reg1->flags); return SBI_EINVAL; + } if (!is_region_before(reg1, reg)) continue; @@ -233,13 +257,19 @@ static int sanitize_domain(const struct sbi_platform *plat, * protect M-mode context and enforce checks on memory accesses. */ if (dom->next_mode != PRV_S && - dom->next_mode != PRV_U) + dom->next_mode != PRV_U) { + sbi_printf("%s: %s invalid next booting stage mode 0x%lx\n", + __func__, dom->name, dom->next_mode); return SBI_EINVAL; + } /* Check next address and next mode*/ if (!sbi_domain_check_addr(dom, dom->next_addr, dom->next_mode, - SBI_DOMAIN_EXECUTE)) + SBI_DOMAIN_EXECUTE)) { + sbi_printf("%s: %s next booting stage addres 0x%lx can't " + "execute\n", __func__, dom->name, dom->next_addr); return SBI_EINVAL; + } return 0; } @@ -371,13 +401,20 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) * Ensure that we have room for Domain Index to * HART ID mapping */ - if (SBI_DOMAIN_MAX_INDEX <= domain_count) + if (SBI_DOMAIN_MAX_INDEX <= domain_count) { + sbi_printf("%s: No room for %s\n", + __func__, dom->name); return SBI_ENOSPC; + } /* Sanitize discovered domain */ rc = sanitize_domain(plat, dom); - if (rc) + if (rc) { + sbi_printf("%s: sanity checks failed for" + " %s (error %d)\n", __func__, + dom->name, rc); return rc; + } /* Assign index to domain */ dom->index = domain_count++; @@ -437,8 +474,12 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) dom->next_addr, dom->next_mode, dom->next_arg1); - if (rc) + if (rc) { + sbi_printf("%s: failed to start boot HART %d" + " for %s (error %d)\n", __func__, + dhart, dom->name, rc); return rc; + } } }