From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.14203.1684407677895461422 for ; Thu, 18 May 2023 04:01:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nc4Btho6; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4ECDC60BF9 for ; Thu, 18 May 2023 11:01:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B668BC433D2 for ; Thu, 18 May 2023 11:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684407676; bh=xBlmuIkrAhhvt2lVCJ4VZLg/aX0WEXvvUHn+PJUMEa8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nc4Btho6h0efy4n1SNx6igp/EaOfPO4NTL60bCnOx0Y133QCaXEb3LXDdr6BwrlzN EUK9MYAzHGfOMe3um+KCG+/01k04N+UWKhdcsrMSHJrlLMob2xSizS9qoVOBKUWf/I qK5oPZl125dl594iUzRqAa6N/fAznwsQvofAyOyw2ngjtOZYV+GmWKwTkORoN47U8e urOpm64iDmtuVmQabdkzLOuCEGKNnXDggXWm3wF27fbIUtGVx8Xr7N1kfeKaei70Au pEJpPtAClIAzjWg/AQgJxw3OeOs5uJ+yA9R/xuBK5tomBK69nYEAAf9oPQ0Scqo99/ DOV9dMzD1rtdg== Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2ac89e6a5a1so20221531fa.0 for ; Thu, 18 May 2023 04:01:16 -0700 (PDT) X-Gm-Message-State: AC+VfDyz8szFFzn+ubiOiyn0Tcn7F79U5iWGefYTc8485YHYZLMlJ4/K AH40U5752SpF0FrFyxpcuUQOoI4zwjWqJg92OzI= X-Google-Smtp-Source: ACHHUZ62MdqXjajDzETb44DcPzxBhF63lSdFol6OABCRf0LyfIIl6+7xyaIQU4T77AAUv6sR+Kfli1G/MJWrx5/3w3I= X-Received: by 2002:a2e:7304:0:b0:2a7:6f82:4a87 with SMTP id o4-20020a2e7304000000b002a76f824a87mr10737424ljc.35.1684407674766; Thu, 18 May 2023 04:01:14 -0700 (PDT) MIME-Version: 1.0 References: <20230518090935.10984-1-sami.mujawar@arm.com> <20230518090935.10984-6-sami.mujawar@arm.com> In-Reply-To: <20230518090935.10984-6-sami.mujawar@arm.com> From: "Ard Biesheuvel" Date: Thu, 18 May 2023 13:01:03 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 5/6] ArmVirtPkg: Kvmtool: Increase primary core stack size To: Sami Mujawar Cc: devel@edk2.groups.io, ardb+tianocore@kernel.org, quic_llindhol@quicinc.com, kraxel@redhat.com, Pierre.Gondois@arm.com, jean-philippe@linaro.org, Matteo.Carlini@arm.com, Akanksha.Jain2@arm.com, Ben.Adderson@arm.com, Sibel.Allinson@arm.com, nd@arm.com Content-Type: text/plain; charset="UTF-8" On Thu, 18 May 2023 at 11:10, Sami Mujawar wrote: > > The patch "f07a9df9af60 ArmVirtPkg: Enable stack guard" > enabled stack overflow detection for ArmVirtPkg. Following > this patch, running UEFI shell command 'dmpstore' resulted > in a crash indicating a stack overflow. Invoking 'dmpstore' > results in recursive calls to CascadeProcessVariables () > which apparently consumes the available stack space and > overflows. > > Therefore, increase the primary core stack size. > Thanks for the fix. I imagine diagnosing this may not have been trivial. However, I don't think this is the right fix tbh. Normally, SEC and PEI run off this initial stack, and the DxeIpl PEIM is in charging of launching the DxeCore with a full sized stack, and remapping it non-executable as well. These PrePi platforms take some shortcuts and apparently, one of the consequences is that DXE and BDS run off the initial stack, which points into the firmware image IIRC. IOW, it would be better to explicitly allocate 128 KiB worth of bootservices data memory and let the DxeCore run off of that. > Signed-off-by: Sami Mujawar > --- > ArmVirtPkg/ArmVirtKvmTool.dsc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc > index 4541d03d23e0d98915b3d3ada688c48d979b75d2..664a624fd2a30bb466a3df2103482e3e6c1f303a 100644 > --- a/ArmVirtPkg/ArmVirtKvmTool.dsc > +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc > @@ -126,7 +126,7 @@ [PcdsFixedAtBuild.common] > gArmTokenSpaceGuid.PcdVFPEnabled|1 > !endif > > - gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000 > + gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x8000 > gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 > gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 > > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >