From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web10.45719.1585555893677603411 for ; Mon, 30 Mar 2020 01:11:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=VzUPhN4X; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f67.google.com with SMTP id j19so1991404wmi.2 for ; Mon, 30 Mar 2020 01:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pcAAjHt7Qga7vNMgx8Rce6E7unAEGHN1pK9xIOJ0L7c=; b=VzUPhN4XvlMjUV1dCQz+irWaccyO9msJERGPIhpB10/pxFEJYcgefLH247OV8GBic7 JqvGVadoXUE6bnrD+yIitBTtIsHDJlItyGxjDFGR08gTcUxn7/fcRtq6IDpmO8rohpTb K3OzW8xA7VLGLNe57sBRiqhUEv9uoqisBhUIUdi8Qstq1n8GwMSn+Y/lUsbP1qSAAWL3 h6RGg0BkvsDToxvWi8O+4hp29CxBRWRENwofhB0mK0hCAtesDWyPUSB2+EV62Kzf7wCF XiQZ5z48Py9TcTgKxhuboKfyFLGOxbWEhwup3p79WJaAbNjSEPWTPPTk4GKDPPeyXF28 G8vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pcAAjHt7Qga7vNMgx8Rce6E7unAEGHN1pK9xIOJ0L7c=; b=SdgKEf4kaPoxXh0ZkhlahYiMhtgBJfRtjN8ZoNdlr40YoxhSyymzoIr6sBaSS4Sg+1 vzwYesAojUYD3pDr5oBOoFHgUtJcLskiVLUCEET/bO4cHPEhpjkH2XRCF5iRJ8q4LISj IV9nXqWUXUKbydGE6PAY2HWnk2Xv9EtC0zufVdHygJ2gGq3Yy6GjZ+4pOzB4n4FFGCS+ bCzbTvSOyXIkqf+20r5npaZVaUwOIb7L5jL6nYr+tIHUIyUEYse7i5f8N0mA3qtja0Bc I6tNBMeK/WK9WviOPiFgzXpxjl1UyGrQimcVa4VNZDiRkK7Y9t4bvWlAteevHQAAE2V9 e9zQ== X-Gm-Message-State: ANhLgQ3nRBEUQugeJY0OCwY8yDr97gabgGIf3yKjlb3T+AYev009aATH sXWZNfU6mz/nZTdBVnayKAECogLrKKOjdPsmkD4r3HmDCAm2JQ== X-Google-Smtp-Source: ADFU+vuVy2eJX0QkfUI2WgdrzlDbt4kCr4oqpOU6+JNHntN5RPILtg5PrivjOqbY6g3bRxd3hHZ9O6EW01nun+hpg1I= X-Received: by 2002:a1c:6285:: with SMTP id w127mr12501306wmb.133.1585555891848; Mon, 30 Mar 2020 01:11:31 -0700 (PDT) MIME-Version: 1.0 References: <20200329151353.14096-1-sami.mujawar@arm.com> <20200329151353.14096-6-sami.mujawar@arm.com> In-Reply-To: <20200329151353.14096-6-sami.mujawar@arm.com> From: "Ard Biesheuvel" Date: Mon, 30 Mar 2020 10:11:20 +0200 Message-ID: Subject: Re: [edk2-devel] [PATCH v2 05/16] DynamicTablesPkg: Fix Proc node length assignment To: edk2-devel-groups-io , Sami Mujawar Cc: Alexei Fedorov , "(Exiting) Leif Lindholm" , Matteo Carlini , Laura Moretta , nd Content-Type: text/plain; charset="UTF-8" On Sun, 29 Mar 2020 at 17:14, Sami Mujawar wrote: > > The length field for the Processor Hierarchy node structure is > 8-bit wide while the number of private resource field is 32-bit > wide. Therefore, the GetProcHierarchyNodeSize() returns the size > as a 32-bit value. > > The VS2017 compiler reports 'warning C4244: '=': conversion from > 'UINT32' to 'UINT8', possible loss of data' while assigning the > length field of the Processor Hierarchy node structure. > > To fix this, a type cast is added. In addition, there is a check > to ensure that the Processor Hierarchy node size does not exceed > MAX_UINT8. > > Signed-off-by: Sami Mujawar > Reviewed-by: Alexei Fedorov Reviewed-by: Ard Biesheuvel > --- > > Notes: > v2: > Splitting patch series and re-submitting DynamicTablesPkg [SAMI] > patches from https://edk2.groups.io/g/devel/message/46261 > > DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c > index 9e42eee9b75bb330833b0f56c98947563d9eb821..40699ce113caa8530c89ac20562cf5abda26b88e 100644 > --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c > +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c > @@ -504,6 +504,7 @@ AddProcHierarchyNodes ( > > PPTT_NODE_INDEXER * ProcNodeIterator; > UINT32 NodeCount; > + UINT32 Length; > > ASSERT ( > (Generator != NULL) && > @@ -539,8 +540,8 @@ AddProcHierarchyNodes ( > // imposed on the Processor Hierarchy node by the specification. > // Note: The length field is 8 bit wide while the number of private > // resource field is 32 bit wide. > - if ((sizeof (EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR) + > - (ProcInfoNode->NoOfPrivateResources * sizeof (UINT32))) > MAX_UINT8) { > + Length = GetProcHierarchyNodeSize (ProcInfoNode); > + if (Length > MAX_UINT8) { > Status = EFI_INVALID_PARAMETER; > DEBUG (( > DEBUG_ERROR, > @@ -556,7 +557,7 @@ AddProcHierarchyNodes ( > > // Populate the node header > ProcStruct->Type = EFI_ACPI_6_3_PPTT_TYPE_PROCESSOR; > - ProcStruct->Length = GetProcHierarchyNodeSize (ProcInfoNode); > + ProcStruct->Length = (UINT8)Length; > ProcStruct->Reserved[0] = EFI_ACPI_RESERVED_BYTE; > ProcStruct->Reserved[1] = EFI_ACPI_RESERVED_BYTE; > > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > > > >