From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.74]) by mx.groups.io with SMTP id smtpd.web08.68.1626711547152362282 for ; Mon, 19 Jul 2021 09:19:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=V81FXkOE; 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.93.74, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SIpW5XgwlD/JPJ14vE5RuJbsoT1WNHSRwobGl13386r24Z8a+pbKiaNn1zqN0UpY5dACElxfuD4FTzGD4HOj03Vwy5Vrywle9P3SSG3vMo+JBvrw6o07MaTL+8X9MEkHa7CC8ngBdeCOg6K2N//JNgSe5mdkLZGlYInraP6HTKZyvmGoqQ5aMsx9lxaog5LkzRcdyvPJjUojxfrJX0MrPiEx4pAzOLEtma+AvJ6XdMs1gbG6cgT7lX7RFaZy+9XFaMtfjLiBrZnLo6k2qMN5GqIQ6aqJX0mzx8U6RtleoCSjB/ZnW9tY1E5gmDPMs+DJNMmIGx75Mn7kYlxEyfeCBw== 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=0g2hOWMHOrW0Exu00qG9AfvNj/h8IcFF0ApEN/ZAHXU=; b=cvpQxf9AmuVaNnoyP0i3ghXzGdM66bAeVY4QH8EvuivmZyTJ59dWaFDCJFnt5Qwhz6gjE8ZTwdiwSRopDCG0to4YVDkFa/IomNocUiUXtZRa3WWj/hEWLXQOg6coS6hKte4VzRAlSOZNvZ0pQ6fzI0egga4vkpF0bdzhyhkDZnRE0tUoBUbM5mdfMfu1xZwvm0xOT/WOzZfqJ/xqIhHWnu36Qw+BMZdgku8Jm+1bP747PCs9FG9EeIu/ne/PZ+TPn1KQ0CV5yKrMrPaM+rSdTZyt9aj3FfIwyRF3cBlPl+V6jDxu8r6mpt9vLfd5M9LUsc2jGyMX0tz+aLPogmtUvQ== 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=0g2hOWMHOrW0Exu00qG9AfvNj/h8IcFF0ApEN/ZAHXU=; b=V81FXkOE70uG80s9YaCA1No8b3UyLbXautZo5p6f1vNE6iDsqLCmPfQUUfhH9afKjXk5beA7GVcpTnQ3BnMJAEOTVlOkQmSqJC9gvzXs1rlUF1mf+0ULeXgvUmsiTbxO9Kvtb8Wm7meegmoMOjqLtUxtjMlRsEjL+tfySy3vJmU= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by DM8PR12MB5463.namprd12.prod.outlook.com (2603:10b6:8:27::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.24; Mon, 19 Jul 2021 16:19:05 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::73:2581:970b:3208]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::73:2581:970b:3208%3]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 16:19:05 +0000 Subject: Re: [PATCH v2 08/11] OvmfPkg/AmdSev/SecretPei: build hob for full page To: Dov Murik , devel@edk2.groups.io Cc: Tobin Feldman-Fitzthum , Tobin Feldman-Fitzthum , Jim Cadden , James Bottomley , Hubertus Franke , Laszlo Ersek , Ard Biesheuvel , Jordan Justen , Ashish Kalra , Brijesh Singh , Erdem Aktas , Jiewen Yao , Min Xu References: <20210706085501.1260662-1-dovmurik@linux.ibm.com> <20210706085501.1260662-9-dovmurik@linux.ibm.com> From: "Lendacky, Thomas" Message-ID: Date: Mon, 19 Jul 2021 11:19:03 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <20210706085501.1260662-9-dovmurik@linux.ibm.com> X-ClientProxiedBy: SA9PR13CA0132.namprd13.prod.outlook.com (2603:10b6:806:27::17) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.236.30.241] (165.204.77.1) by SA9PR13CA0132.namprd13.prod.outlook.com (2603:10b6:806:27::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.10 via Frontend Transport; Mon, 19 Jul 2021 16:19:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f7585e7-af87-4f49-d8ec-08d94ad0ee02 X-MS-TrafficTypeDiagnostic: DM8PR12MB5463: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6njYtLX2IlUThqruDqLqVpBQCn+yus3woTYVuII9aLnH7UcjvEPLm1SkPVht4zl8THwKVbajEw2QBaTXku0JxdfAQCujYOCtmPzxZmlzI//HpX31rc+zUgpsg4knW1O55SuL1vp7iyRmESAKFhdGQQJzm4jnANzQrmVVFQRa5FzwDmIRrZihBK5RtOp2YzLijxbia7PsDDXQPucQQVBZZxiXPChL70h6C+DumHgLQ2GnJi8ranH61BzTkYoLnLTwGx4HuV3ylnUXYm6Y8kZRkAtE/XyryMzZcgTMjUm9FuY5RbsKxPbJhOvo2V5BNuhBnBxcEvxUExqdQ6YFltXoM8OmqSkGNMXi9TVW8Pif8oG8W/V5rR3sXZktr/JSDMpbnmCG1O81iYe5wXMekpBp019rXA0klpu+245/HCxKCXazG549cHdFfWB3Yl5jCwHtI5JTfdy3uA6eQ5V+9KhgX97YM7ZuVHH0v2LXeezp+IjQGCHz8Lup9qKXWYjR32QYA62JhPQKJKEK2ZncV9FJ0CVGwceRyu0bxxnNXl0CS5dwju0OyrZCx8rYCmltovl1scAmoqHRkovhxt+xSljScM4TR9/Dtq9ExQrGRDae4mJxAk4NfrWK/X+PDVIkax/X1CNBEv1XgQO9GV73rcl1m9+2Zk710gVfNBKlHKn7ofm0n2GLS2u4+q+FJ6biP9E8DuvBckId4W8c7CZwSuxkuMCxOX7hpl7gmoMmyBuoI1ZR/4spK4HQgF2Vy6J6CwcpmclfhwSK5Wozrm6aiE+0tWWdBXl++FOpzfq8nKK/ZqzBjcQJ0lC88nV05+Pf5e8m 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:(4636009)(136003)(376002)(396003)(39860400002)(366004)(346002)(66556008)(36756003)(966005)(4326008)(26005)(478600001)(38100700002)(956004)(2616005)(66476007)(66946007)(83380400001)(186003)(86362001)(2906002)(6486002)(53546011)(8936002)(5660300002)(7416002)(31686004)(8676002)(31696002)(54906003)(16576012)(316002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?djBEbXZBdkRxSUZHQWVPUXlmZXdXbFRqZnltOFZFUE9ZeGQ0TDg2UTFrOFZF?= =?utf-8?B?bTRWWEVVR0R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42?= =?utf-8?B?b1l0aDB1cXFNb0MzYUVrVkFvMzBWUEFuTTdZRzRwS25sYkowTGZlUER2dExP?= =?utf-8?B?VWkxNENmMnZxM0VRVGdJZDJ1VHp0TGowMzM0cFlRdzQ2Yll2RE5zR21YUndT?= =?utf-8?B?RnZSc25qcTBvZG1JTElZNEY0N205QkJpU3dldmQyMkNuS0ZXcVdEZWdQdFpY?= =?utf-8?B?YjBCRmh1eitidTcrSjJVeG1IR0FUZk52NDJZZTBxeEx0MHNsUGdBU3NSeE4y?= =?utf-8?B?dW54Q0l6V2h3eGNpRHdJTlI0MkwyeU44N2h2bEZwSW52aVgzT0FwVFR5cFlT?= =?utf-8?B?NGUzYjlxdkEwdS9Kb0VybUVNZDdaRnB1K3Ywazk0cGdJdm9BazdCWnhGeFVE?= =?utf-8?B?UGlZbG1BZmhuY3hXQ2hha016UjdacjQ5RS8zUXczS0VndWVKaU4wWjk2YW8w?= =?utf-8?B?aDJPYWVVUENIVnBoZ3ppdVcyN3N0V1hnUTlWOThRYnJkTHplN2JTc1VwRlFh?= =?utf-8?B?SURoaUM4QndnMnNOcU9QNnNxaFVTdnhZK2MzbTdKMFlrbDVTdzg0ZlR4TkZW?= =?utf-8?B?QVgzdWNQTzlQRC95eGg0VmhoTDBMSG1DbzFkVEpIZ3luUVJQdnZyODVvODVD?= =?utf-8?B?enZodzR0bVk3TFpiZEg3aEtJdVdEUUZWUERNSlRad3V5bDB5Vm5lYTJvc1p1?= =?utf-8?B?UmJxVkdFQU5DcFRwTDNTSCtPSFVZS0FZaEFIS0w3Mks4cVJKTUtLV1NJcEF2?= =?utf-8?B?WnBTNU1yNzY2QzROdDExZGxPcCtRdW1DNFZHRGJvNHhBQUdKZTY0cStQbnMv?= =?utf-8?Q?2HtUPZEdR6uShdmioL7xvkcKfEpfm25BF/AHDCX?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f7585e7-af87-4f49-d8ec-08d94ad0ee02 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 16:19:05.7358 (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: jric5BqFy8oAlun3GWPWhb0o2kL+0J9pv+dyWynHEecAv6Mc5VF8hmW/fU6n2POapL0IpiROOUCIqSX7uU838g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5463 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 7/6/21 3:54 AM, Dov Murik wrote: > Round up the size of the SEV launch secret area to a whole page, as > required by BuildMemoryAllocationHob. This will allow the secret > area defined in the MEMFD to take less than a whole 4KB page. > > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Ashish Kalra > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Min Xu > Cc: Tom Lendacky > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3457 > Signed-off-by: Dov Murik > --- > OvmfPkg/AmdSev/SecretPei/SecretPei.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/AmdSev/SecretPei/SecretPei.c b/OvmfPkg/AmdSev/SecretPei/SecretPei.c > index ad491515dd5d..db4267428e5a 100644 > --- a/OvmfPkg/AmdSev/SecretPei/SecretPei.c > +++ b/OvmfPkg/AmdSev/SecretPei/SecretPei.c > @@ -15,9 +15,16 @@ InitializeSecretPei ( > IN CONST EFI_PEI_SERVICES **PeiServices > ) > { > + UINT64 RoundedSize; > + > + RoundedSize = PcdGet32 (PcdSevLaunchSecretSize); Can you just unconditionally perform: RoundedSize = ALIGN_VALUE (RoundedSize, EFI_PAGE_SIZE); Or use ALIGN_VALUE () in the if statement if you don't want to do it unconditionally? Or even use ALIGN_VALUE on size value in the BuildMemoryAllocationHob() call below. Thanks, Tom > + if (RoundedSize % EFI_PAGE_SIZE != 0) { > + RoundedSize = (RoundedSize / EFI_PAGE_SIZE + 1) * EFI_PAGE_SIZE; > + } > + > BuildMemoryAllocationHob ( > PcdGet32 (PcdSevLaunchSecretBase), > - PcdGet32 (PcdSevLaunchSecretSize), > + RoundedSize, > EfiBootServicesData > ); > >