From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web12.24982.1574349423682206470 for ; Thu, 21 Nov 2019 07:17:03 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Nw+2AqEn; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574349422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5oDCCuA2u3398id0s+No8YFqOM6jpaqKSx5SYqpLJ9A=; b=Nw+2AqEnh9ySbEXAQ9QEGwOsKz0JO5GQKdA+t32TCxhtwchYAAkeq0fuyE84Z6pKe1Q3RM CwE2+t34gwks1VttStV7f/wcO53rgRSpXC9qlV4Tr0FndBOvtDt6X0Pji10eMpAWmoLypH QG/x0JJlcDtLI0Tjf7Z56m9nrUPtw/Y= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-LbCwXbSHM3qk_VcHz7Oygg-1; Thu, 21 Nov 2019 10:16:59 -0500 Received: by mail-wm1-f71.google.com with SMTP id z3so1718678wmk.1 for ; Thu, 21 Nov 2019 07:16:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=M3dl4d9M6Pg5eW0BQeevYysnqPCKlExomNMcIofhCyU=; b=CxwvTBZq5r5ELs6CxfyoNRat2Z7CI55Gw9SrHKEIkzv3Tvi3UKKXJ7uLv6xbTb+osd ufDgvpkjYcvsZeMtrSuCHAuBIa1F3mEP9k8cnMzkJ86SVq088THewPS8TCpOTeAlZk8V 4cEiL/SrumOnbloQEyQXj/G53Tle8qWJ4GOlCyKT4SrCD4Rzv4k18tubuUmggByDqP+5 0jfSpUDNDO3XtONmoVmWl3hVwcadxS+RXJ1tU8Yxp0jW0VtPQD21VCvmiQSRDvpvhkRF t5FC0VGpDKxsoW7aHQaTqiy+2pAME/VN2WltYBXixh6nGFUb91WTgwlcjCs9pVrh1auk H+Xg== X-Gm-Message-State: APjAAAU3v/1m1FM0mwjxfb8vovmpbO6U+KgQzNwN0bs+AC8mdasvJCkz kKuPOGf28LSKJlyOWsQ64AyWXzM69tI7OHHGld0b7PJaFyX17Ef9A4mB6SqvPJyoa7bjl99rPH9 lWV3Hzs0rscyofQ== X-Received: by 2002:adf:e5c5:: with SMTP id a5mr11762821wrn.103.1574349417844; Thu, 21 Nov 2019 07:16:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxA3odeP9SZmZwv7eOvGqc7F5txkgNA69AYNtb3jO0jTiUB5Xj29kdWhGEnB3TgPbg2AQnHdA== X-Received: by 2002:adf:e5c5:: with SMTP id a5mr11762791wrn.103.1574349417579; Thu, 21 Nov 2019 07:16:57 -0800 (PST) Return-Path: Received: from [192.168.1.35] (131.red-88-21-102.staticip.rima-tde.net. [88.21.102.131]) by smtp.gmail.com with ESMTPSA id a15sm3942170wrx.81.2019.11.21.07.16.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2019 07:16:56 -0800 (PST) Subject: Re: [edk2-devel] [PATCH v1 04/19] DynamicTablesPkg: Fix serial port subtype warning To: devel@edk2.groups.io, sami.mujawar@arm.com Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com, nd@arm.com References: <20190823105539.13260-1-sami.mujawar@arm.com> <20190823105539.13260-5-sami.mujawar@arm.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: Date: Thu, 21 Nov 2019 16:16:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20190823105539.13260-5-sami.mujawar@arm.com> X-MC-Unique: LbCwXbSHM3qk_VcHz7Oygg-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 8/23/19 12:55 PM, Sami Mujawar wrote: > The VS2017 compiler reports 'warning C4244: '=3D': conversion > from 'UINT16' to 'UINT8', possible loss of data' for the > SPCR InterfaceType field assignment. >=20 > The SPCR InterfaceType field uses the same encoding as that > of the DBG2 table Port Subtype field. However SPCR.InterfaceType > is 8-bit while the Port Subtype field in DBG2 table is 16-bit. >=20 > Since the Configuration Manager represents the Serial port > information using the struct CM_ARM_SERIAL_PORT_INFO, the > PortSubtype member in this struct is 16-bit. >=20 > To fix the warning an explicit type case is added. A validation > is also added to ensure that the Serial Port Subtype value > provided by the Configuration Manager is within the 8-bit > range (less than 256). >=20 > Signed-off-by: Sami Mujawar > --- > DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c | 15 += +++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) >=20 > diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerat= or.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c > index 1404279f828d5c06bb7605cb2fe6d864ef7a080e..4b2580da7df9b4472ae9bcc3d= f2138a9e13004d0 100644 > --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c > +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c > @@ -217,8 +217,21 @@ BuildSpcrTable ( > goto error_handler; > } > =20 > + // The SPCR InterfaceType uses the same encoding as that of the > + // DBG2 table Port Subtype field. However InterfaceType is 8-bit > + // while the Port Subtype field in the DBG2 table is 16-bit. > + if ((SerialPortInfo->PortSubtype & 0xFF00) !=3D 0) { > + Status =3D EFI_INVALID_PARAMETER; > + DEBUG (( > + DEBUG_ERROR, > + "ERROR: SPCR: Invalid Port Sybtype (must be < 256). Status =3D %r\= n", > + Status > + )); > + goto error_handler; > + } > + > // Update the serial port subtype > - AcpiSpcr.InterfaceType =3D SerialPortInfo->PortSubtype; > + AcpiSpcr.InterfaceType =3D (UINT8)SerialPortInfo->PortSubtype; > =20 > // Update the base address > AcpiSpcr.BaseAddress.Address =3D SerialPortInfo->BaseAddress; >=20 Reviewed-by: Philippe Mathieu-Daude