From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.28586.1677268382017045655 for ; Fri, 24 Feb 2023 11:53:02 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Z09/GSuZ; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: andrei.warkentin@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677268382; x=1708804382; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=e08cnCW+3V8liFyJN7ZBKu3iAc4MLSxY6t0JH/wmi1U=; b=Z09/GSuZv6v+79JwrGmhKqcYZnXSgljB9RBjLJgPGbGp0OSVhcY9XjXu 7w7eJfWVlq/qSV5fbpJF/k+mFMr+MOpkpbJCFq0r8B7WuPIftEr+GkH7c MjXaT2yEtbUQ1f4+zhYQKTdkPx5intw3zI0kU/Hqd3ClO0uCqs6l6xuk8 MpxQGdq29YOJCDjkqGbzOrZWxwDkcNaTVgUxJaCdkSCcTS8+RJdCyR/nu 2qN1Ml4MiNSEbAC+IAM64npDvjYcURfYT5ZKH7mEogOSNFm/Via1k3Rtu clu6WKs2HAd61W1HOD0JJ1Muo/Rdmax2cOLvCEwWjK/V44M0LeLfZBmEH w==; X-IronPort-AV: E=McAfee;i="6500,9779,10631"; a="334996045" X-IronPort-AV: E=Sophos;i="5.97,325,1669104000"; d="scan'208";a="334996045" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2023 11:53:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10631"; a="736921298" X-IronPort-AV: E=Sophos;i="5.97,325,1669104000"; d="scan'208";a="736921298" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga008.fm.intel.com with ESMTP; 24 Feb 2023 11:53:01 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 24 Feb 2023 11:53:00 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Fri, 24 Feb 2023 11:53:00 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 24 Feb 2023 11:53:00 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TcDKkV+mekhngZsGPCfqgK9o7iqM1pCCxXRe9Xxe0kq2JbviypPq3nOxGL+oPinyZKbPap8oO1yill4FiK+hsqtUcHGAdX/xxICX0gSkOm6DuZhmkMTQipANkusROCZvPdAeDkYzMpXPLWbAhWXH3o5eOMYIvPEBMsaCykL7WQMcLQE5XMHhEYQmzOoNLwcwHE0lXCMieBWRptNUO+7S4cwUtvdudgHe68/Br8syw/HKu4g5RThDKEjAT0uJMoRL7no6VvnKqMop/6BPx50VQJ8HmKad6WcgKIQM+N/hRwa7VKmQ5UWuwGMgu4zp7LjbBLRm8c3K+VbhmmmbfCpmIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W6MEx2qzkFVOiCOr0ThH33my8xzjpJrY6iayNEQRGaA=; b=VXKe2cGaLox6XUDDbeceLxR73r6WegzMHaPbSspQNMdIaPEcrd8DQy6ApGf2U5dsE2aj2vSnFGmRCfBVFExmgUZr3PUjuGieUXXN0spD2McYTW2nPRRe/NVV2QErXdqJ1smPQxa9AInu93VKb8kHkXnR0Krr1djoEelwT1ZcfCIYswUWsSoA/PhXLKpd4TUkDhgWaj88bQMofe/lHkgTLrx9eqRMJKVgW5GDATeaZ8vHxFDt7PeOIpYJ1MUX/v6DPePvuRaogl3U5IeQUfOyeNsn3OVqpWHoQ6wQce6zx5kDH+9qbibDlp+8L3XpgIN0g7QGDxSDwqcH7YBDn27p9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH8PR11MB6856.namprd11.prod.outlook.com (2603:10b6:510:22b::7) by DS0PR11MB7409.namprd11.prod.outlook.com (2603:10b6:8:153::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.21; Fri, 24 Feb 2023 19:52:57 +0000 Received: from PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::f480:22ed:c915:13f1]) by PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::f480:22ed:c915:13f1%7]) with mapi id 15.20.6134.024; Fri, 24 Feb 2023 19:52:57 +0000 From: "Andrei Warkentin" To: Sunil V L , "devel@edk2.groups.io" CC: Ard Biesheuvel , "Yao, Jiewen" , "Justen, Jordan L" , "Gerd Hoffmann" Subject: Re: [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB Thread-Topic: [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB Thread-Index: AQHZSDPnF+4zHQHbYkaw66he2ovOv67egk7w Date: Fri, 24 Feb 2023 19:52:57 +0000 Message-ID: References: <20230224093920.2753375-1-sunilvl@ventanamicro.com> In-Reply-To: <20230224093920.2753375-1-sunilvl@ventanamicro.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH8PR11MB6856:EE_|DS0PR11MB7409:EE_ x-ms-office365-filtering-correlation-id: 4b26b224-33b5-42f1-35aa-08db16a0ba09 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9WujzOIuC5vxAyoMZCR3kDesPKfK3FOnHBNr1p+znERWF1ZGmMQcfNy/Ovyg6x/D3ta28RGF8Pr+QN7siPAIDv64BoQCxhRg/auoMWyAEHGfDqjoXh1T+tctrJkhUI6Ms6yUkooA3maRRH/IP/gRgitrOMH8anQ2Wb5T4onsgsaqxfH12d/394XUVpovnkv25kujM//utONftWAPQmSmRbOzxlnTPAYvifB1biHeKZRs+AelvtSNzxkS3Xm0vxIFtPnH141lSmlb4qxjI+IUeJz9lvADA8EDRiiXE2rMYUPzoNcIEI5oMeiVsqZ0WDa9/cwbuSCmbeNRMzhPfsl/TT3ViFfmVVXza0TDC/bacHnv2LA/RWubweyRLWCwJ+NrdT1rJCU9uRzn+gW0yJKWhp7oQQ1YvXSMdTDpEsOgD0hJTBQGsAEyagcsBHrIR7jsOY1DrFhdlxB1Igptq7NAyAsSEeGkATtIf1b97sUbq5KE8upsfI+pMNMblAdIHjmwM8X8dZ4z9E9afIS4Sc12zckAMlrgUA80beMdsZ0s6/3k/2RhpvVvtEG1lS/MT1b6C99nruBjK3du+esGNJH3PDOqPPH68JMr90Ms41jxkVZ7P4yqq4n7AX4bfbEdZSBkTV87nfB0xf+EaGUgsi2kYTpnX2KDm9sqRh2xLLvylyTkd/Ub3ACCZRcNr31bo9Lmeb3EU6+zkfQWjSrsNeJsfw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH8PR11MB6856.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(136003)(39860400002)(376002)(366004)(346002)(451199018)(8676002)(86362001)(54906003)(71200400001)(110136005)(316002)(4326008)(9686003)(53546011)(7696005)(186003)(478600001)(26005)(6506007)(66446008)(38100700002)(64756008)(66946007)(2906002)(55016003)(5660300002)(83380400001)(66556008)(41300700001)(66476007)(76116006)(33656002)(38070700005)(8936002)(52536014)(82960400001)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RSfdbp9Jyn3H3YJmt0qdTWtcfdnjiWxZmIKoumXEgyJ6IXrXoKeZgaxClfjd?= =?us-ascii?Q?/HvzlE/m5PaO64tiEmqfvHprNBXeCyNdtrrxzMr0j5ZtLVUg0c/jz88skMLy?= =?us-ascii?Q?8ipk5gtGiVf3F5mgFq7pVDCQx2pR7bWGmJgKlsy1tg2DZrHe77JI9gP6He7d?= =?us-ascii?Q?3s5LlN09d51RozgEuXOYDDTKifaUOjk+0Q1072Y+U3lFKZbfOD4hzMMr6LjB?= =?us-ascii?Q?gokkVtDtx9kEgMIelF13arfdgEPhm9ME7RSK3b5npao1DWv9EjvYDLeg1BMS?= =?us-ascii?Q?PmsFMH/+60XvqmL7lNYikqZgIecxvNm9NosYSSkYV8TBU1z7kenqfBGL/36l?= =?us-ascii?Q?+Ue7Kf44dfiM8ZNCIqfkfMTQzz0OREvsnRt6Pf7Ym1w1J4LwsWR7JmpV+Ojz?= =?us-ascii?Q?ITMnOrw28dZtcvDMohoXYVDeiMlYswPuN3MQ7rmP0a2qkAz/cyU9iOjcOxWj?= =?us-ascii?Q?+leYWs1yOrJOJjnH+bh2LvDOyBZot2XlmtaEW1q/RoSlRSy+Ndv0cRkMlY85?= =?us-ascii?Q?6FemCXrf2bft5s/rrjtOqiMW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E6+r?= =?us-ascii?Q?DO7iamBf4vR9O6sq66kQURTRz6scL4Fx6Aj5d4g70DY6cg89ySB3sa0n/oVW?= =?us-ascii?Q?9/2VQjo0kTC6rwV3u0f9pVLl+fyVTXqbkrekK+QKX8ToJ/nAML5592igRRRT?= =?us-ascii?Q?MrHsro2rw8jhJ9YDCG6zoWZZ4bVPdftpaYNJ1Tlb8+go/NivOtyJDHi3adnw?= =?us-ascii?Q?1g=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH8PR11MB6856.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b26b224-33b5-42f1-35aa-08db16a0ba09 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Feb 2023 19:52:57.4645 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uWjyTxVyCaYlJWHb7kNZe3Ksir4ezaiCldmNalgVl5Eb+6seO1bu+z9p4bB4lUV0yDyCLzC9oAE/olgGnwR5Nthn/JMkTeMplqhC4zwFNqM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7409 Return-Path: andrei.warkentin@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This fixes the strange corruption issues seen, when booting with 1GiB or 2G= iB of RAM on Qemu. Please pull into stable tag if possible. Tested-by: Andrei Warkentin Reviewed-by: Andrei Warkentin -----Original Message----- From: Sunil V L =20 Sent: Friday, February 24, 2023 3:39 AM To: devel@edk2.groups.io Cc: Warkentin, Andrei ; Ard Biesheuvel ; Yao, Jiewen ; Justen, Jordan L <= jordan.l.justen@intel.com>; Gerd Hoffmann Subject: [PATCH 1/1] OvmfPkg/RiscVVirt: Add Stack HOB 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 happen= s at this address causes random memory corruption. Fix this by creating the= stack HOB which marks the memory as BS data. Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Signed-off-by: Sunil V L --- 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/SecMai= n.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; =20 // // Report Status Code to indicate entering SEC core @@ -71,9 +72,9 @@ Se= cStartup ( FirmwareContext.FlattenedDeviceTree =3D (UINT64)DeviceTreeAddress; SetFirmwareContextPointer (&FirmwareContext); =20 - StackBase =3D (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + - FixedPcdGet32 (PcdOvmfSecPeiTempRamSize); - UefiMemoryBase =3D StackBase - SIZE_32MB; + StackBase =3D (UINT64)FixedPcdGet32 (PcdOvmfSecPeiTempRamBase); + StackSize =3D FixedPcdGet32 (PcdOvmfSecPeiTempRamSize); + UefiMemoryBase =3D StackBase + StackSize - SIZE_32MB; =20 // Declare the PI/UEFI memory region HobList =3D HobConstructor ( @@ -86,6 +87,8 @@ SecStartup ( =20 SecInitializePlatform (); =20 + BuildStackHob (StackBase, StackSize); + // // Process all libraries constructor function linked to SecMain. // -- 2.34.1