From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.3484.1599811302478728609 for ; Fri, 11 Sep 2020 01:01:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=LEhnyrDp; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=05237a886b=daniel.schaefer@hpe.com) Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08B81bVb019698; Fri, 11 Sep 2020 08:01:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=subject : to : cc : references : from : message-id : date : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=mMrXfFRTAI1addNT9whv0MV3RiObWkrzgtzjrDYIBD0=; b=LEhnyrDpVSlfIsY0OvvoBupQaSwa/hlNwoRn5JddT+3eCwsFHx3JoYrJmTlBRdR7co/F VrkV4Ov1U11T5EW0ga3vpvizxXvhCIfols3bdrOwZySOMCrS2CVrGRyI5RDQzZJ1cUE6 PgvHAWxn7qtjFuepRnBtIfme0hR798Eph3LkwSNI7TDbhgqhrALT9X1no+kK69RPbuz4 I1dUljd7T7U2ex55FW7Jh0lFiwKxhY32pb/iFlKcu2u/O4GE1P08Vq8FAdVOBVK3Tov5 AQAhrpoGkhRejsSRa+6REjyFDTu6oKuakDOnuQ4V3JgA/4ZwgHQs6OgvWUiyTM+ZvrAF Gg== Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com with ESMTP id 33f0uf8jn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2020 08:01:41 +0000 Received: from G4W9119.americas.hpqcorp.net (g4w9119.houston.hp.com [16.210.20.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2353.austin.hpe.com (Postfix) with ESMTPS id BD2DE82; Fri, 11 Sep 2020 08:01:40 +0000 (UTC) Received: from G1W8108.americas.hpqcorp.net (2002:10c1:483c::10c1:483c) by G4W9119.americas.hpqcorp.net (2002:10d2:14d6::10d2:14d6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 11 Sep 2020 08:01:40 +0000 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (15.241.52.12) by G1W8108.americas.hpqcorp.net (16.193.72.60) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 11 Sep 2020 08:01:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZOxP4MnczE+F5q+4Ifa2kuKSmZJrWiDa2LaJf2GuIk8NtMY52/SJ8BgXweWfHrD2aqqyjpI1sH0ET8tWXMwYhPl99zuPSyyn1VBvaOrZRONLRSEAdRakudtbtaCG+1dt1ZnoUq3uav5GUvRbnTVahdn/J713RVmMRpzA+lWb3N16j01e4LfrsqScXe/8Zr3aQrTswgfLP0Ss4LAIcgLSfo46062TDngq+ZJ3LCC9bvdway2dKpb4Azmh3gLIyR4DNUxvGpzlrqQ7KCUphn9m2QEzfWoas5jgMhlb1VrPcROp9663zEgLFUJ89A2o7FpZ1yqcjzni1NzzlGCfWA6KaQ== 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=mMrXfFRTAI1addNT9whv0MV3RiObWkrzgtzjrDYIBD0=; b=gIgieOo3RhDB74jpIlq7KIIiyHGOhjILfYFLX3rJKPqAoWv5VER1lBd7UBiwyii12BT7/NiwDKv5hJVgNQrV80vYHuAS3JeXlAJDlDYAJ+/g7ux/INkXH4HemwpVx3+5JEZQLZxX984OsZczwH4hIekkcQoAfeePnKebiLAxrp1HNg/RRi7mplOYaOR+TXTvVIe5WwptPseCfxhn3nKlBkmXEwtbCJagg8YdD1KAkiBldLr7J4lREL7A1l0mEWyBksgr2JFOy+JuivDCQeIgRNMN0kV4tnPO6mvzHKI5iRMesVmwaOyKvlBGQc9v8+1dSbs6Ja+Ig73lRMNnGQqYXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Authentication-Results: nuviainc.com; dkim=none (message not signed) header.d=none;nuviainc.com; dmarc=none action=none header.from=hpe.com; Received: from DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760d::23) by DF4PR8401MB1242.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7610::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Fri, 11 Sep 2020 08:01:39 +0000 Received: from DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM ([fe80::11b0:1862:f48c:d2a9]) by DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM ([fe80::11b0:1862:f48c:d2a9%9]) with mapi id 15.20.3370.016; Fri, 11 Sep 2020 08:01:38 +0000 Subject: Re: [edk2-platforms][PATCH 2/2] Silicon/SiFive: Error handling for locating firmware context To: Abner Chang , CC: Leif Lindholm References: <20200908054844.25755-1-abner.chang@hpe.com> <20200908054844.25755-2-abner.chang@hpe.com> From: "Daniel Schaefer" Message-ID: Date: Fri, 11 Sep 2020 16:01:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 In-Reply-To: <20200908054844.25755-2-abner.chang@hpe.com> X-ClientProxiedBy: SGAP274CA0016.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::28) To DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760d::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.10.6.166] (15.211.146.34) by SGAP274CA0016.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Fri, 11 Sep 2020 08:01:36 +0000 X-Originating-IP: [15.211.146.34] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 91d4a3b8-7e22-49e0-2845-08d85628e903 X-MS-TrafficTypeDiagnostic: DF4PR8401MB1242: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QHdtQrdaH8Vao384Q65DP8pTURWRnTI3GIHhZ8n45s4KaS/fRBEs2P2tunYRHPokGQUqZMhn67oaknJm2G1oGJ7xkHIkqVWs2TnGc9bE4IPugP3O4UmgtvKCX6qOwS6IYSsHtaXKSbHI2w4tIsXgcJZ9r4qJWk7y6pyuj0h1mOCkgVAfuBukF9nkUMuhIaln4NIIDmCmDeaxlzqeENkDeYUwLjl6yzMW5L8u/+/0vp7zHo2pQqlptTjsJIMEX2hkFxyAxmxM+8+8IuUKRL57cukvY173ohyeBEgjBGpj0z8VFxUXR1i2y63CCR+VYdAVX9GDRGRenzfqHzUiqWA7LUXdjDP9JTtLUoQRfrlM/VihpTuB9MXi+BOS0fAIvqtY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(6029001)(376002)(346002)(396003)(136003)(366004)(39860400002)(316002)(8936002)(16576012)(44832011)(186003)(4326008)(16526019)(36756003)(6486002)(86362001)(26005)(31686004)(2616005)(53546011)(8676002)(478600001)(52116002)(83380400001)(66476007)(956004)(2906002)(5660300002)(31696002)(6666004)(66556008)(19627235002)(66946007)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: y71xBmSiBbKWacWp/OVDHY+eNXXET4PGUuhFVJPPoxpHtDAkUKiOsjdz5XAdn4QZWRWnFXo/fYHvNcyWUL6gtORCh54nT6JZXh8Ncb2/hnXCjiCk0pVxNsXBeCQJPOVgNb3DNSqqPwPvEbcjxCidayWF1gqQNS9uysiqK6gIm1fFSknk2NZX7HWnKXsCPeQZcDkUnvlI4RkbSPOCVkY3hu2MaMJa0UcUxNqWfLMn9JixrER/7tGDz78fGqT1MyEU20pCbikJ/hCJIOgng/jo2fmTfXHT3F2S4haSwiVrp8CJ31vhRaBQH7kBkSjkwg/2cxSpVtwS6G5KcPZGFczTrNjWagdhjMxhFs8VIank1FUF7TIP/iKZ3gk8LPjXEFhXmta3c0c+UM+5X/Bgh/wBURmj8d1lFypPHbI5wQBEu/PL/RsMvOUHzi7Bb678hC8QnZt4FRNnokDRrNV+Yjb/VqV5v4ifDVaWIrxPnl7hzUYP63dUixiictFTebRGupAWITmNgHif1+RxXB9T+zilrLfcyEFfObzt7Jw5P8TreYM6o7v8emaUn61zEe7VCB/RLSPJPDocsrx0eIwDmEoN4zFrNETZowzDMebQzeD03fDV+hUVTdpgRQ9dz+PTQMdRCrXsWP/zPpDiP778TMydwQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 91d4a3b8-7e22-49e0-2845-08d85628e903 X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0444.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2020 08:01:38.2583 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zDdLbvBSW5/xWwW0M5i+cmBqubB0i/GwjWWlMJdWNLmZyPqn7ocQ/wDtMMQ39vs3BHT2Hc0T6IhP4xtvjt3mjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB1242 X-OriginatorOrg: hpe.com X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-11_02:2020-09-10,2020-09-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxscore=0 malwarescore=0 adultscore=0 priorityscore=1501 suspectscore=2 impostorscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009110062 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 9/8/20 1:48 PM, Abner Chang wrote: > Add error handling in CreateU54E51CoreProcessorSpecificDataHob () > when opensbi firmware context can't be located. > > Signed-off-by: Abner Chang > Cc: Daniel Schaefer > Cc: Leif Lindholm > --- > .../SiFive/U54/Library/PeiCoreInfoHobLib/CoreInfoHob.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/CoreInfoHob.c b/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/CoreInfoHob.c > index edeabf028f..ea947a9d28 100644 > --- a/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/CoreInfoHob.c > +++ b/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/CoreInfoHob.c > @@ -38,7 +38,7 @@ > > @return EFI_SUCCESS The PEIM initialized successfully. > EFI_UNSUPPORTED HART is ignored by platform. > - > + EFI_NOT_FOUND Processor specific data hob is not available. > **/ > EFI_STATUS > EFIAPI > @@ -64,9 +64,14 @@ CreateU54E51CoreProcessorSpecificDataHob ( > return EFI_INVALID_PARAMETER; > } > > + FirmwareContext = NULL; > Status = SbiGetFirmwareContext (&FirmwareContext); > ASSERT_EFI_ERROR (Status); > - DEBUG ((DEBUG_INFO, " Firmware Context is at 0x%x.\n", FirmwareContext)); > + if (EFI_ERROR (Status) || FirmwareContext == NULL) { The assert should already catch this, right? Especially if we fix the return value for SbiGetFirmwareContext we don't also need to check the pointer. I'd say: Let's fix the return value (like your other patch) and remove assert, as well as the null-check here. > + DEBUG ((DEBUG_ERROR, "Failed to get the pointer of EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT of hart %d\n", HartId)); > + return Status; > + } > + DEBUG((DEBUG_INFO, " Firmware Context is at 0x%x.\n", FirmwareContext)); > FirmwareContextHartSpecific = FirmwareContext->HartSpecific[HartId]; > DEBUG ((DEBUG_INFO, " Firmware Context Hart specific is at 0x%x.\n", FirmwareContextHartSpecific)); > if (FirmwareContextHartSpecific == NULL) { >