From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mx.groups.io with SMTP id smtpd.web10.39016.1677303125886478654 for ; Fri, 24 Feb 2023 21:32:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ventanamicro.com header.s=google header.b=QVodXB/x; spf=pass (domain: ventanamicro.com, ip: 209.85.216.48, mailfrom: sunilvl@ventanamicro.com) Received: by mail-pj1-f48.google.com with SMTP id k21-20020a17090aaa1500b002376652e160so1372024pjq.0 for ; Fri, 24 Feb 2023 21:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FZiqjMMCsX/3BXtZfOcsG6d/KDmyH2pCC2U3G9fOJ9Y=; b=QVodXB/xaxlN22mbj6tcHl4qEiJU0fBpGKFfKxT2H4teGw80gZXEEEJGCKzdN5P2eV 2HZiTyQ105O5jYR0WYaSvj57mU2VmmA5kBLSVrrkXZ+jT4+Ct+VRknj3wu7Lj25kgoFx Yigpyw2fG7/kSagcKRZUHZVrqiwgjt3koBQoiC7fEKdNn2EAfvx2bW524m+VCEoHs5E2 WXD5Eg7jnGhtn1oLEvXihaZCmrRKGvP6dXa4gNuwEjECxaFUMtMUw6xcwZRDiUoVP1Au oxVUdcc/eYZMRbcykj2CUkf/7lDFde/pJqUy3X1+D+Wek20D/M9jPZ0vege4Sz66kpn6 AhlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FZiqjMMCsX/3BXtZfOcsG6d/KDmyH2pCC2U3G9fOJ9Y=; b=h9ClW1i4NjIWN2chtTwjp6YLhbAzbR3xHLq6FZdHPn2+FbUu54yP2lVlBCIymcT8fF bdKOcuTwHGyQBcHMtf3+3lv4A5P6LlAZ2smmZXDDmc5Px8MVJSZ2oec8V/7NqiIPcoMa a7nM4FL2j4G4oIFQOMTmSsz4IP/jzGSzGixI1aIU9r4w0MED3ZOFe7UTeu0a1uHJXVqg FaqHTcRg9590dZzvygYIusF8M/OYkrpf2Jeed0a7L3Gw5uNaw6rgI+yxJfUv0dIM0a+F RUoiAg/6ZDxIGOu5bsAcggnoy6wUzNR6snOyiSRBdnsbbcqaYG7mgomEWTAK531YfqGk cCtw== X-Gm-Message-State: AO0yUKU9aLRmR0/6js3MUG3ectyDW5XijRMMs3XM/SLW9s+1q/td2Q8g rPfThshJPqxQY3JVDya1qP4VY7/Uj8bSIxjK X-Google-Smtp-Source: AK7set/AvB9rMwRszemE0aSqI4HzmbetoHN42Rh2q/HudMDU62EYrHVvusx84wHBhuShlZuVzZHyPQ== X-Received: by 2002:a17:902:e888:b0:19a:95ab:6b2b with SMTP id w8-20020a170902e88800b0019a95ab6b2bmr21665804plg.69.1677303125086; Fri, 24 Feb 2023 21:32:05 -0800 (PST) Return-Path: Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id s22-20020a170902a51600b0019956f23fc1sm359783plq.302.2023.02.24.21.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 21:32:04 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Liming Gao , Andrei Warkentin , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann Subject: [edk2-stable202302 PATCH V2 1/1] OvmfPkg/RiscVVirt: Add Stack HOB Date: Sat, 25 Feb 2023 11:02:00 +0530 Message-Id: <20230225053200.2051719-1-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4350 Currently, stack HOB is not created for the stack memory. This causes stack memory to be treated as free memory and any memory allocation which happens at this address causes random memory corruption. Fix this by creating the stack HOB which marks the memory as BS data. Cc: Liming Gao Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Signed-off-by: Sunil V L Reported-by: Andrei Warkentin Tested-by: Andrei Warkentin Reviewed-by: Andrei Warkentin --- Changes since V1: 1) Added BZ reference 2) Added edk2-stable202302 in the title to request to catch the stable tag 3) Updated tags OvmfPkg/RiscVVirt/Sec/SecMain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.c b/OvmfPkg/RiscVVirt/Sec/SecMain.c index 73b9b21a67ba..adf73f2eb66c 100644 --- a/OvmfPkg/RiscVVirt/Sec/SecMain.c +++ b/OvmfPkg/RiscVVirt/Sec/SecMain.c @@ -55,6 +55,7 @@ SecStartup ( EFI_STATUS Status; UINT64 UefiMemoryBase; UINT64 StackBase; + UINT32 StackSize; // // Report Status Code to indicate entering SEC core @@ -71,9 +72,9 @@ SecStartup ( FirmwareContext.FlattenedDeviceTree = (UINT64)DeviceTreeAddress; SetFirmwareContextPointer (&FirmwareContext); - StackBase = (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + - FixedPcdGet32 (PcdOvmfSecPeiTempRamSize); - UefiMemoryBase = StackBase - SIZE_32MB; + StackBase = (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase); + StackSize = FixedPcdGet32 (PcdOvmfSecPeiTempRamSize); + UefiMemoryBase = StackBase + StackSize - SIZE_32MB; // Declare the PI/UEFI memory region HobList = HobConstructor ( @@ -86,6 +87,8 @@ SecStartup ( SecInitializePlatform (); + BuildStackHob (StackBase, StackSize); + // // Process all libraries constructor function linked to SecMain. // -- 2.34.1