From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 93408940F33 for ; Wed, 14 Aug 2024 02:04:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=SJjLZjoEPAVU/0tj9Lo0oACaisYUOCpq1iITw3vO8kk=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20240206; t=1723601087; v=1; b=GQTuJGgXsbW3xzWciPT4p2sE6CFEuA1GplGY/D0JBWoE7b5URD3r/fXg2X/WDI8KcMHPIP69 ZvIU20KFxUdcAXUb8cCMxxlLUZRj8o2MWfpK8GiiCMoznhtjMZDFxd8Aol9pgy4yYrAyHpqaSbW 5RO73zmKZMpLyk8zGRSvN5XvJ9McGsXPWFmS0TcCNvGkxhVDWmG4FKvXTPjLYm4rjMdVIInLqQf jYyBG02aqOa4XPY3XT0iiOsfkwvzceB6dH3pzxt6YD966mue1CEYCPkDCuAmGHqH0FvU4QtDllR yLJ13dpRGH9yaaM/illdbrcYWS2cblQ0LGa2yD5fkj4aA== X-Received: by 127.0.0.2 with SMTP id CKl7YY7687511xjh2GrAkMSv; Tue, 13 Aug 2024 19:04:45 -0700 X-Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by mx.groups.io with SMTP id smtpd.web11.88774.1723601084626949233 for ; Tue, 13 Aug 2024 19:04:45 -0700 X-Received: from 30.250.56.149(mailfrom:huangming@linux.alibaba.com fp:SMTPD_---0WCqWxmk_1723601080) by smtp.aliyun-inc.com; Wed, 14 Aug 2024 10:04:41 +0800 Message-ID: <55716d25-240e-4a2f-9837-3e4bec2aceeb@linux.alibaba.com> Date: Wed, 14 Aug 2024 10:04:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 v1 1/1] MdePkg: Add error output for IoLib.c To: "Kinney, Michael D" , "devel@edk2.groups.io" , "gaoliming@byosoft.com.cn" , "Liu, Zhiguang" Cc: "ming.huang-@outlook.com" References: <20240813094207.104010-1-huangming@linux.alibaba.com> From: "Ming Huang" In-Reply-To: Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 13 Aug 2024 19:04:45 -0700 Resent-From: huangming@linux.alibaba.com Reply-To: devel@edk2.groups.io,huangming@linux.alibaba.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: CMFlw9LzQ8LqS7AvnMqyWPKWx7686176AA= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=GQTuJGgX; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.alibaba.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io On 8/13/24 11:29 PM, Kinney, Michael D wrote: > Hi, >=20 > We have moved to a PR based review process. Can you change this to a PR? OK, I will change this to a PR. >=20 > https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-= Process >=20 > Also, this change may impact the code size and performance of these APIs. > When ASSERTS() are disabled, an optimizing compiler can inline these oper= ations. > By adding conditional and DEBUG(), that optimization may only occur if bo= th > ASSERT() and DEBUG_ERROR messages are disabled and the optimization compi= ler > can optimize away the conditional statement as well. >=20 > Another option is to use a different DEBUG_X debug log level that is not = normally > enabled and a platform can choose to enable. Are you referring to using DEBUG_WARN/DEBUG_INFO ? Which is better for DEBU= G_WARN/DEBUG_INFO? >=20 > The DEBUG_CODE() macros can also be used to conditionally include the con= ditional > and DEBUG() message. >=20 > This patch is also incomplete because there are other APIs in the IoLib t= hat > ASSERT() on unaligned access. I will modify other ASSERT() in IoLib except ASSERT (FALSE). Thanks, Ming >=20 > Thanks, >=20 > Mike >=20 >> -----Original Message----- >> From: Ming Huang >> Sent: Tuesday, August 13, 2024 2:42 AM >> To: devel@edk2.groups.io; gaoliming@byosoft.com.cn; Kinney, Michael D >> ; Liu, Zhiguang >> Cc: ming.huang-@outlook.com; Ming Huang >> Subject: [PATCH v1 v1 1/1] MdePkg: Add error output for IoLib.c >> >> It is better to output error address information When Address is >> invalid before ASSERT. >> >> Signed-off-by: Ming Huang >> --- >> MdePkg/Library/BaseIoLibIntrinsic/IoLib.c | 24 ++++++++++++++++++++ >> 1 file changed, 24 insertions(+) >> >> diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c >> b/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c >> index 5bd02b56a1..57d05af5a9 100644 >> --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c >> +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c >> @@ -174,6 +174,10 @@ MmioRead16 ( >> UINT16 Value; >> BOOLEAN Flag; >> >> + if ((Address & 1) !=3D 0) { >> + DEBUG ((DEBUG_ERROR, "MmioRead16 invalid address: %lx\n", Address))= ; >> + } >> + >> ASSERT ((Address & 1) =3D=3D 0); >> Flag =3D FilterBeforeMmIoRead (FilterWidth16, Address, &Value); >> if (Flag) { >> @@ -220,6 +224,10 @@ MmioWrite16 ( >> { >> BOOLEAN Flag; >> >> + if ((Address & 1) !=3D 0) { >> + DEBUG ((DEBUG_ERROR, "MmioWrite16 invalid address: %lx\n", Address)= ); >> + } >> + >> ASSERT ((Address & 1) =3D=3D 0); >> >> Flag =3D FilterBeforeMmIoWrite (FilterWidth16, Address, &Value); >> @@ -266,6 +274,10 @@ MmioRead32 ( >> UINT32 Value; >> BOOLEAN Flag; >> >> + if ((Address & 3) !=3D 0) { >> + DEBUG ((DEBUG_ERROR, "MmioRead32 invalid address: %lx\n", Address))= ; >> + } >> + >> ASSERT ((Address & 3) =3D=3D 0); >> >> Flag =3D FilterBeforeMmIoRead (FilterWidth32, Address, &Value); >> @@ -313,6 +325,10 @@ MmioWrite32 ( >> { >> BOOLEAN Flag; >> >> + if ((Address & 3) !=3D 0) { >> + DEBUG ((DEBUG_ERROR, "MmioWrite32 invalid address: %lx\n", Address)= ); >> + } >> + >> ASSERT ((Address & 3) =3D=3D 0); >> >> Flag =3D FilterBeforeMmIoWrite (FilterWidth32, Address, &Value); >> @@ -359,6 +375,10 @@ MmioRead64 ( >> UINT64 Value; >> BOOLEAN Flag; >> >> + if ((Address & 7) !=3D 0) { >> + DEBUG ((DEBUG_ERROR, "MmioRead64 invalid address: %lx\n", Address))= ; >> + } >> + >> ASSERT ((Address & 7) =3D=3D 0); >> >> Flag =3D FilterBeforeMmIoRead (FilterWidth64, Address, &Value); >> @@ -404,6 +424,10 @@ MmioWrite64 ( >> { >> BOOLEAN Flag; >> >> + if ((Address & 7) !=3D 0) { >> + DEBUG ((DEBUG_ERROR, "MmioWrite64 invalid address: %lx\n", Address)= ); >> + } >> + >> ASSERT ((Address & 7) =3D=3D 0); >> >> Flag =3D FilterBeforeMmIoWrite (FilterWidth64, Address, &Value); >> -- >> 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120330): https://edk2.groups.io/g/devel/message/120330 Mute This Topic: https://groups.io/mt/107873366/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-