From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.45]) by mx.groups.io with SMTP id smtpd.web10.347.1681508367554163369 for ; Fri, 14 Apr 2023 14:39:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=PX8R4GIy; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.95.45, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mrw4VJNdEXvci9bYqDx780jEiQEh96XZs3nfxpxlanOu5STCt8hoXpEtkN6jSbc+oSbNY/r3ZzHg1Axx1FlpnuabI7OFn9enk52nQpGy64ZO3aJ8Zbv25ILkCcyFXWvxeVDestyaM0lrjlidSobmJlo5TP2fhivUPhA1YRkKwcI5L3CUe56Figxi3AxhF6uXAGiEJ4ux7MPaVvBKRDCxNJQDxFXExV5hR6srN0f+rt7imVKEGdk0jUY91Z3YUU4b7jp7bynaxmu1Y5L40PmHp7i5F2zOwTfoIsYNd+F8REzKI6D4vUCPN12lZvyKkGYb5Kd5KGzeLsQMIUoBhaLfUA== 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=u7VeWUyry5hdH4BQ5qtdNSbfr+MREBeknleEyPz7h3A=; b=jMqoAchrslsLtmZzWQ8Rr6W7vYFsf7GPExQ4SE2pWDvVHU+LLKYFshr25hytk0hvaP27Gn+O9CEME5NiqBonkHsljpG7Hnpwy9MPMjLavaJDRjUKEAog9KQdy3/+D9JWpTt4TcpXXiT7Sv1VOHHbU2wMtgGOh+HeZlj4wf2E78XxP95l/i7XeQUmJWqg/VZ4Y+zY3slZ6MKIDE5LKqL7JHmeeFbFjX8N+rN7yu6BSKJGRzrPv1umOqxpy1qpcSZHE3J6nysC9JkFTms/dcL6W9AjEbMUlgH+87SSRgtZpOomkMozrMbdc0yM0H4/ydVyiXj0nghxYqnYooj2dh01pA== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u7VeWUyry5hdH4BQ5qtdNSbfr+MREBeknleEyPz7h3A=; b=PX8R4GIy6jgLmElpyMQw9Kbtv+Pb7Jr1cytMoRLdgF6pJk6Y6/lRCvKTj2UWzaXYcf1j68hc4aEFc4YzIZQWoR9qB5rWMC8dj4Qfr+ssPhG+YapuNhQWkql/ZQo1tcxpfNx5TofJSItD7qi3W7Mu3j6JiF+l176utEQndAsbAP4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by CH0PR12MB5105.namprd12.prod.outlook.com (2603:10b6:610:bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 21:39:25 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::ea32:baf8:cc85:9648]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::ea32:baf8:cc85:9648%6]) with mapi id 15.20.6298.030; Fri, 14 Apr 2023 21:39:25 +0000 Message-ID: <653323a0-67d9-f896-83fe-46cf207fc83d@amd.com> Date: Fri, 14 Apr 2023 16:39:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: Strange behavior between GCC 11 and GCC 12 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" CC: Ard Biesheuvel , Gerd Hoffmann References: <7f0f5f8e-09c7-4ae4-ffca-1a7c322949a8@amd.com> In-Reply-To: <7f0f5f8e-09c7-4ae4-ffca-1a7c322949a8@amd.com> X-ClientProxiedBy: SA9PR13CA0088.namprd13.prod.outlook.com (2603:10b6:806:23::33) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) Return-Path: Thomas.Lendacky@amd.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5229:EE_|CH0PR12MB5105:EE_ X-MS-Office365-Filtering-Correlation-Id: db4c44ab-f2a4-4714-0f4c-08db3d30b7b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZgqlfaBHPAi/hB/nTJg+d8IPlDzK9MhBAgL5YI3OTZi6Uaq6RXxGQU25UUzJLZ0W/kBDOAc8UueMJSg4A8Fq3tou+ORjbz6IYTVO6Wc2rArMwNTZ5Mf+cXrzq5KbX+5Hqi3s+b/VESGI8H+M1YCOCmEE1Eb0VxNT7ASM0/ePB+ZLy1+5zHm0tXiA8hELoismYANF0JzwUHSE60J2pw3TFKz2HJTmZnHsAtKjU1skjhLUeV9lQUlUVBfEb+Joacr5qZAX5qSDkGymWQZCEKaMRz3tx995q4SQqSykHGDDFUJQOIcogtIHHd+h6qknFNWXkSrqjZRQTkA1xXUlAuHm7Dxmy+B0jKClD2GaJjGIQGZWSnCvR/iH9hhDPRXBQy8jewrmJKdtpDs8z49IKnCaB3/ZWWzoSN7hjKKYtVjCsiRX2607Cz/3Tu0uir6ZoNNf+XV6UsIKCMzXi81B9OgD+cZWZWKE3I3A5TaIdRF+/weB57rzQKycwvyaTwd49lCpQrBAUDqefNpn+hK2BkrgMCVouA+Kz9YGNdpiAajFQsVoqy0hVkJkvxeWjuFk2/981m5bwoEAwmvf0gF6H2WiK3Y2XzrjZfa+ymywiCAyVhswUiZuxWFiTj/paK4ouGCrBefuP2O1cioJggCHxenyfA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(366004)(376002)(346002)(396003)(451199021)(54906003)(2616005)(19627235002)(6506007)(6486002)(4326008)(26005)(478600001)(6512007)(186003)(53546011)(2906002)(38100700002)(316002)(36756003)(5660300002)(66556008)(41300700001)(66946007)(6916009)(66476007)(8676002)(31696002)(8936002)(86362001)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pky2COi0FR9r+5+lB0/YrQEJG2zfB8IwtsKNutaOeLyAiH+u84GETqFXonsv?= =?us-ascii?Q?tLkc4o1tE33eF8yu8aeGYfSWq4KkR142plTVY7yfP4n+jeQoyvaq8asRL+59?= =?us-ascii?Q?R1ttDHuQpwy5kOHf54X8xOlVuKMKsNw4JcgTJplCNZEScVsrGzo3Qgf1Py+r?= =?us-ascii?Q?bjJDmT1Kb6dFVe0BRdb6s7xvxOChF9w8yxhFpH0dGSkXp1eNGbwqUZGTtEU6?= =?us-ascii?Q?kQOHgNm2pa2UcLA6CBlBZq5Mk80EejnM5SB5CsWdhSQIt78VmbTNqLNjGBh3?= =?us-ascii?Q?lmH+hk7iLR2Nu+COBD/r/OzfViIpIJi4OritmCTUyCPDjCg9uDfJJwXgUSAR?= =?us-ascii?Q?CiSOUpKDgbhFMgIQaxa5ZesHadRQfMXuJsdziwW9mORT/5vFsXO6AfSsR4zg?= =?us-ascii?Q?i+lcctnGAXta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?= =?us-ascii?Q?ZVdpGVhf+NxY5H5Q2dS+m5YuSx5n2VVfnaUIeBifrSu9PeRFAV9GEL8l+6SS?= =?us-ascii?Q?5/KwINfCA2IHAapeb0rPKY6ulcXbbnRxBAuqUvu5QcSXNhjfdRySRDoj/i3l?= =?us-ascii?Q?YBAm2UHiTyCiopg46qHjJiNvbyqufdLH6Js4e3UjFgxeew9EFWCD7Ggs3Ufl?= =?us-ascii?Q?dTBe3iqXkqb9MP1HWnc2fjHGeZmeU+QV33DgQyoZD5Pb58o1TyeCDUTVZhBD?= =?us-ascii?Q?fcm2LuD0wsrcy7oCT+8il4EablsdbkulsqAgCXjV?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: db4c44ab-f2a4-4714-0f4c-08db3d30b7b8 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 21:39:25.4411 (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: zYyt+gN4A/YlOllQ6gxoI/w4vqBzp2uFNnjyNYAk4S7RWIcTkFjPT0lS52uUycE3BFOglSp+QP7zvSurAveP1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5105 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 4/14/23 15:23, Tom Lendacky wrote: > I've been trying to debug a problem I'm seeing when I moved to the GCC 12 > compiler. Under SEV it results in the guest crashing. False alarm, I was on the wrong branch that does not have ff36b2550f94=20 ("OvmfPkg/Sec: fix stack switch")... disregard. Thanks, Tom >=20 > I narrowed the issue down to the call to TemporaryRamMigration() in > PeiCheckAndSwitchStack() of MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c= . >=20 > I get this output on GCC11: > =C2=A0 Old Stack size 32768, New stack size 131072 > =C2=A0 Stack Hob: BaseAddress=3D0x3BF76000 Length=3D0x20000 > =C2=A0 Heap Offset =3D 0x3B786000 Stack Offset =3D 0x3B776000 > =C2=A0 *** DEBUG: PeiCheckAndSwitchStack:851 - SecCoreData=3D3BF95D20 > =C2=A0 TemporaryRamMigration(0x810000, 0x3BF8E000, 0x10000) > =C2=A0 *** DEBUG: PeiCheckAndSwitchStack:871 - SecCoreData=3D3BF95D20 >=20 > and everything is good. >=20 > However, I get this output on GCC12: > =C2=A0 Old Stack size 32768, New stack size 131072 > =C2=A0 Stack Hob: BaseAddress=3D0x3BF76000 Length=3D0x20000 > =C2=A0 Heap Offset =3D 0x3B786000 Stack Offset =3D 0x3B776000 > =C2=A0 *** DEBUG: PeiCheckAndSwitchStack:851 - SecCoreData=3D3BF95D20 > =C2=A0 TemporaryRamMigration(0x810000, 0x3BF8E000, 0x10000) > =C2=A0 *** DEBUG: PeiCheckAndSwitchStack:871 - SecCoreData=3D7770BD20 > =C2=A0 MMIO using encrypted memory: 7770BD48 > =C2=A0 !!!! X64 Exception Type - 0D(#GP - General Protection)=C2=A0 CPU = Apic ID -=20 > 00000000 !!!! >=20 > and terminate because SecCoreData has been corrupted and points to an > address in an MMIO range (this is an SEV-ES/SEV-SNP example). >=20 > As near as I can tell from looking at the object code, on GCC12 it looks > like the SecCoreData value is stored in the RBP register, which appears t= o > be getting corrupted when calling TemporaryRamMigration(). >=20 > Does anyone have any thoughts on this? >=20 > Thanks, > Tom >=20 >=20