From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (NAM04-CO1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.13549.1605225929425846805 for ; Thu, 12 Nov 2020 16:05:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=girtg6xG; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: mark.wilson@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jM8GPgyGZi0SwjN+0fSe0T64VwNvli0ACFGNkOYwc2tX1nkdN7YpFV4E0r5dp6BF+b9+TrkLZpUHayVmwEeuNgRNT248OpxXKmHOpIgATeKN7HxSKKtYNyk7PbgORIPZ/IF5ffuqkQnp9fa6grYFLIvkU3Jf5VNB/2UfWl7d5wHSjgzYVOfZvmDBzEltyWiFIrzYtiWDy2Tw4fVaCBv5E0HTVfIr/IXNTJrEjJwgHh8mHsRoSC+dCgsycZI+Eergc4b6ISAHAH57u6GJToBeyNY5U49E4tSRwfxHbPn+pttKSAyYYVSEk2RyCEqyokc64+5J14Cefu9bgRQLzC9NBQ== 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-SenderADCheck; bh=H6cepMJIYy11uKfwfaU0Rn7vQVUZKDUiVsHT/Qxkns4=; b=cgdIzUhliKIjcYmFdAidsp+xtzLj3qb8BtH/87W/eDLEMKwmF2XLXKVk73UZ4JCrsGkeb2lEAYsvYuf64F6EadS9K5AetAUT8T7XHQu+YFWNncRFgYfmaOzXzSlNsuVQG/wsFWym+6mmIjcOCkXqZm6bc0my5gvM278oXKr41x95WoIKIz6PnbIbH88ddsPLioqpJSHcNt3B+wx3PZBHiWLiOvFQsujPggKbKDU1ENoPBrX+Co4wOCwITConMGulGnvCF76nH/b9ajt32UdjVSShaJLpNLTV9OvnxyaTaqqPZsp4F5B9lMIW5CqhZ6fURpTytRLCZSUazflurB7nKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H6cepMJIYy11uKfwfaU0Rn7vQVUZKDUiVsHT/Qxkns4=; b=girtg6xG7kJ7NJ8oCRsvFFPZEgKDxNhrTkfYxiUKserENJ3ju0eO5xKBQrlzFomxGTtUoYx5fo1lEItZudUIpAGUzEMpnQ21aUjQ4S84moGgktm0fTK0e1gemIJO+nI22F571xTPWJwbQWd2bGlBu8AhHgJbVRoEPF++78hHKIY= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3484.namprd12.prod.outlook.com (2603:10b6:5:3c::15) by DM5PR1201MB0138.namprd12.prod.outlook.com (2603:10b6:4:56::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.25; Fri, 13 Nov 2020 00:05:27 +0000 Received: from DM6PR12MB3484.namprd12.prod.outlook.com ([fe80::448b:c790:cbdd:d479]) by DM6PR12MB3484.namprd12.prod.outlook.com ([fe80::448b:c790:cbdd:d479%3]) with mapi id 15.20.3541.025; Fri, 13 Nov 2020 00:05:27 +0000 From: "Mark Wilson" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni Subject: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments. Date: Thu, 12 Nov 2020 18:05:18 -0600 Message-Id: <20201113000518.338-2-Mark.Wilson@amd.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201113000518.338-1-Mark.Wilson@amd.com> References: <20201113000518.338-1-Mark.Wilson@amd.com> X-Originating-IP: [165.204.77.11] X-ClientProxiedBy: DM5PR20CA0022.namprd20.prod.outlook.com (2603:10b6:3:93::32) To DM6PR12MB3484.namprd12.prod.outlook.com (2603:10b6:5:3c::15) Return-Path: Mark.Wilson@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from MSDN-MARWILSO.amd.com (165.204.77.11) by DM5PR20CA0022.namprd20.prod.outlook.com (2603:10b6:3:93::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21 via Frontend Transport; Fri, 13 Nov 2020 00:05:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a9715968-9f93-41c5-9034-08d88767d370 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0138: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T2aThLrRY9Ypdh4oDJsC8FE0QYv8m6uBM9lPtJEXeAfbSYtAnSY36swY6wGcbZyUO/aPcOTC5Rz4ZVV/R46AwcZouyvJh40Uh4v4I4ow8OQMnN92KRcKJ4rTAX5TvZmhwPNM98HfoscSFoyp8ZeJU6QuE5S5uxl+UO3tA9KoQ7QbSuYx51909e6pSbyK8H/jElTJUzD/Sn4RztL/4y70t2EADjB7OoPTwQphk34GZCzxwBg+vYvrlhBkbUE7OSVI59YOuqtZ/kXGv8BBiRXQAnwAQNOrGbERVDC5p0opOcIjV3gtuMwDuXiO5Y6Ry5PQyFN9t3D7LrjcVaFP7op+ZB5Gx8vqzRSVwhldSOJK6xWYpz/Nam426dTUmP1x15D/g2Fu7VqPuskBMJtvjJld/w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3484.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(346002)(396003)(39860400002)(6666004)(86362001)(8936002)(83380400001)(4326008)(54906003)(6916009)(7696005)(6486002)(26005)(16526019)(186003)(2906002)(478600001)(8676002)(52116002)(956004)(2616005)(316002)(1076003)(5660300002)(66556008)(66946007)(36756003)(66476007)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Fr7JStfwdAOZhOSgQtSqpOkJ3uWPXGr4jr5vzMXCtMa88mZi0gRPxttzIazmRWTl5nijgLEpqvmh8uSvdZHJ2EqmIMmTusokGldJ5f4JevMyIotXig7CF4buZLZW9dwAB6zGZ+dhZlpGYMqN3d6cyej+R98kiRqWzzfUnAcPWJA0aOP1CFG9/8jvPbFm3voPY04Mq3TjzUee8drkwKPa4eJVvympbFG74YAJKiYyhJWin633ntLKu+0/EW4KkwkowO2SS7Sibo/KftIoOanTxvPXuFip1xBKP/p4KIsGoG1YuuItJWYS8J/Nf4+JSs0Cnh2XBGL21CmEEh/GI9Kvro0I3RZnhF9KljIORiiH0SBaSgRbwGqpzGD/Zrkb2eSkJ0u8H2Or0F5cpTThmugZQ7wWBusk1OXHdIzkU6IBdlrMN8SkaSl1g2J9AOX47M2k49166/EoJhWPcUAjvvxmkCU8jMGt9lGb4KKAszM6NLk4P/EhN7VnC7qeE3I4J1IFupW5OLhhuQDZRdR3zxzZ010AmzmMq6cMjfy2Dr9/YSEceSA9CPShyGu9mpx/09L4c14NHZB8F58qUVuCK7lo/ucRFnDWHHCpx5SggXH8FrLlLubheP2EiS29OQn2r+4SVjOdYDlxx643jScCxyo/3eBf0zNuCHeSgWAN0QPjR3yhLpHLXWDv20ZPoPzpOBaqe8pjJH6N5zwtvZv1j23bGza+wfieTlrQU0z6dGdcrb1iUcLrR1CXcVHQVBbRE5m0fo58Ilf6lPwiF7I0t5DLK96RTNSDfkGzF+OVZ0TSjpWCDTO4vZ6xYYNBU99zRhjmG7LifV/wSmeoTVje6d91jJE2ejs9s3lG85z5V6RCwyD7E7tfL2g8cWPivrOZdk1PwGBPeepzhWB6nUyAXJi6jw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9715968-9f93-41c5-9034-08d88767d370 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3484.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2020 00:05:27.4484 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sd/Mg3EIucH1Yv+C+RTxZZj/pQsyQpFWoaeuuOkZhrsYmoR7Bd7sGML+3RZDEEjXfA2FgZQ9KCdzAvQj9gZ87Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0138 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2956 In functions ReadSaveStateRegisterByIndex and WriteSaveStateRegister: * check width > 4 instead of >=3D 4 when writing upper 32 bytes. - This improves the code but will not affect functionality. Cc: Eric Dong Cc: Ray Ni Signed-off-by: Mark Wilson --- UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmC= puDxeSmm/SmramSaveState.c index 661cc51f361a..0ab5e1ba0f14 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c @@ -315,12 +315,12 @@ ReadSaveStateRegisterByIndex ( }=0D =0D //=0D - // Write lower 32-bits of return buffer=0D + // Write at most 4 of the lower bytes of the return buffer=0D //=0D CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterInd= ex].Offset64Lo, MIN(4, Width));=0D - if (Width >=3D 4) {=0D + if (Width > 4) {=0D //=0D - // Write upper 32-bits of return buffer=0D + // Write at most 4 of the upper bytes of the return buffer=0D //=0D CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOff= set[RegisterIndex].Offset64Hi, Width - 4);=0D }=0D @@ -539,12 +539,12 @@ WriteSaveStateRegister ( }=0D =0D //=0D - // Write lower 32-bits of SMM State register=0D + // Write at most 4 of the lower bytes of SMM State register=0D //=0D CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offs= et64Lo, Buffer, MIN (4, Width));=0D - if (Width >=3D 4) {=0D + if (Width > 4) {=0D //=0D - // Write upper 32-bits of SMM State register=0D + // Write at most 4 of the upper bytes of SMM State register=0D //=0D CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Of= fset64Hi, (UINT8 *)Buffer + 4, Width - 4);=0D }=0D --=20 2.28.0.windows.1