From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.87]) by mx.groups.io with SMTP id smtpd.web10.483.1620169409677495727 for ; Tue, 04 May 2021 16:03:30 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=Ba6tbTUf; 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.244.87, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nLo0Rf1OszFJ9jBRYPgYtW72H7Ii5ZUTaGZKuDeN8Wv0JztEP6Ge+8LQFyR2xspzwkO98q+nn0WNrVJpoCK7YgV0y4wgzDfN+JnVL0APAJROVCk3Z/kbwKDPRt0I39J1mTI9SY1PBNFlXQC7qV952SlnGKYNuH7j/unbmLKwPHefIlrHaaVOaB3Ug+L+fPYfYQeMpy6TiwHyS+MXFxUp/wU3hWTHsW6sc2oCSNAErxD9oEn/2PeINLDaMOoHZLpkp0ukap/Sbbg5fqkdGOWSzopjvacvuxgOz8X70X4VTP6lIweqDYUUY5No7vY65ylQCGdIve3/N/Wj6M1D1FT+tg== 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=1ryjkuSAG/nFFBbF8SgBR6ur2J/XOb9m9Uy3VjDSY1M=; b=WFkmsekfakQp9qodJKGfvyz4wH6yWKZEcHqz8jXKDrGz+JxFOYi+I13AiONBJ+HcpW2jR3Mh8eoreCA0rxoJNX7i4s31pSDBqyFRdwm6sCF1IaESIaC83RhJdPdaTzaqutQrGDxYP6xHbmic3QGxxBvtlfGW6omSdYfdfakbM5qwhHl2RPfRA2guWp7yT2oDcWLgvKVqREpHo7FGMlejKQYtp3Qcs2Kdn+7ZZZ+ejqMeuYY0DhhVh7kuhDRaXdLrYgxYLl9ud2A/IQK4ISgkp0qeKNprs04tFoVTV9CVy+igbW0qcUYpFSvx99SokxunAzH8lCXmBagcwPw11jIX+w== 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=1ryjkuSAG/nFFBbF8SgBR6ur2J/XOb9m9Uy3VjDSY1M=; b=Ba6tbTUfCaMS6GwgRx5MITzel8YQAeYfuGTzbhZgyZgswbsCsRu3LC3z0jEs4VQeJpo424E/3NTRF65qNeRJpZJVrPhNvuL26wl+T7O2sr9MJaDBIJDfAmgaImdwCWlwJACwrmKgDSr+dOvlu2oihHiYLwxCzCdfNHlz6rnVkF8= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN1PR12MB2512.namprd12.prod.outlook.com (2603:10b6:802:31::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24; Tue, 4 May 2021 23:03:28 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4108.025; Tue, 4 May 2021 23:03:28 +0000 CC: brijesh.singh@amd.com, James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Erdem Aktas Subject: Re: [edk2-devel] [PATCH RFC v2 05/28] MdePkg: Add AsmPvalidate() support To: devel@edk2.groups.io, Laszlo Ersek References: <20210430115148.22267-1-brijesh.singh@amd.com> <20210430115148.22267-6-brijesh.singh@amd.com> <167BF2A01FA60569.6407@groups.io> <167BF53DA09B327E.22277@groups.io> From: "Brijesh Singh" Message-ID: <68377db4-c1b6-afc9-3885-ad1e702aff0c@amd.com> Date: Tue, 4 May 2021 18:03:26 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 In-Reply-To: X-Originating-IP: [70.112.153.56] X-ClientProxiedBy: SN6PR2101CA0004.namprd21.prod.outlook.com (2603:10b6:805:106::14) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from Brijeshs-MacBook-Pro.local (70.112.153.56) by SN6PR2101CA0004.namprd21.prod.outlook.com (2603:10b6:805:106::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.2 via Frontend Transport; Tue, 4 May 2021 23:03:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5491d3ea-2972-4147-e97f-08d90f50d412 X-MS-TrafficTypeDiagnostic: SN1PR12MB2512: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nPNEW1u9mvAxS7h+XOxAYF/Wahioatvz4HgZlLJbdilXsH0E2hy8UHTGNbAzXiUWrz3iQSWy7F17Cpu3p7tIaoDomt+/RhI0Pu7VG5KY0kpvg840BS51fDWVT6DZVgFRSEblGlfCqNr8C07g1d6HLAoX5NgZAsC5Hf+I3XqiD9M9ze+M4eq2W9Ty56qoZIuWArbMFhzdreiAMJQVZYIAEdVp+DY03jkLNN+lGsICHGCFDB5ywsHOW/hBHQKIMCxNAdy3gBipQ0g0XEWZBhn3Pa8WjSP8UYOqRJ/XKQzj8aiBYdd1uhK+4zLqYFtuhDsXqB84TQjBY5lEU3Ks/v0PHNYgPnIYBoOzY1gnsD3nmRytYzcgrFombAQWKiVUejD3Y4a1HQ2WVuqtR3OKkhliwte4OR+xG7jlyUBbJNY2Kt319owPHpuN8KfJqCkVIAxAvpQJ86Z5OM6m850Exe0+1E0xJeujBDd46e+mQzoNrx1hOCJVYIsaPbhqTe3e0hsvCyeFGQcHdkpssEq4qFcFT+hQz47dM+tZs5glIX22sJbUYmdIWruiSPT+QavQKcQ+/hdNuoPRsDydnF8S2B457Umag99xrAUFDZBMYeKrx4wdJOaxZlPMPmKg1CZDRo8eEd1v1ZTMjL6NStRVChYkZ9TavA6d+coLflpQIJebUMzz9XRROwOL9E803AoqFT37T31vporUuIUSS73uuOzvJX8YOMbhCaXm+rLDAb92iAQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(366004)(39850400004)(396003)(136003)(376002)(86362001)(956004)(4326008)(478600001)(6486002)(2616005)(31696002)(38350700002)(5660300002)(38100700002)(8676002)(36756003)(6506007)(186003)(54906003)(53546011)(66476007)(26005)(316002)(16526019)(66556008)(83380400001)(66946007)(44832011)(31686004)(8936002)(52116002)(2906002)(6916009)(6512007)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?kMVAJYogpnY9wuHvh7dllh72Fb0cn6GwfHC3XTIKREGNC8R1WFgCUld5xNnQ?= =?us-ascii?Q?KJhIWr5Qtc+clKO3ZHL6XEy+GUbXX73ar1kzRF9DsS5PbruaHA+dofyO5qxU?= =?us-ascii?Q?fptjdpw5H5kk3GYLa7/zJ5PAVkPTy+PLlyon0eQ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gaDqTnQhVSfoxsBPD7rxk+Wu6DhmsBVMUDOKecOnLW/RKmCp1br/GKz?= =?us-ascii?Q?3oBQ4BuXc9lA9ENV+el4HePD31U2d8wKoLg4kZchcM66SFKlFEVQPU+7J8JK?= =?us-ascii?Q?t4Tvn04B/xT5Wd6ZoG+CPIHf7kSwMn/ltUOzQvmTB04EQuVzBTCe49bZqryB?= =?us-ascii?Q?+2Drg2COzY74DKnLSHSG9xH5xP5qccwmSbpFJGrVEfIi9daoNm/rxVB7gjVg?= =?us-ascii?Q?bAJKIdUqqysh2mHgeK/I45YUanZLAAoFfzo+jLARajhYR24hOaxbUYyqwiSG?= =?us-ascii?Q?RmgeDn9vGLYnxcqTe2ZHKb2D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5491d3ea-2972-4147-e97f-08d90f50d412 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 23:03:28.1444 (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: Poqz30lqVtU4+I/WXZputRlVD+GpcXoDiUHI9nypxbDJMNbb6OtvPB3ZNIUZJyqZ121rt3w36AONwCBe72cGCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2512 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US On 5/4/21 3:28 PM, Brijesh Singh wrote: > On 5/4/21 2:55 PM, Brijesh Singh via groups.io wrote: >> On 5/4/21 2:07 PM, Brijesh Singh via groups.io wrote: >>>> Return EFI_UNSUPPORTED (0x8000_0003), or even EFI_NO_MAPPING >>>> (0x8000_0017), for value 6 (FAIL_SIZEMISMATCH). >>> I am not sure if we really want to do this. You will see later in the >>> patches that in some cases the PVALIDATE will return a failure and we >>> will need to know the failure code to determine the next steps. >>> Especially this particular error code is used later. This error happens >>> when the page size of the backing pages does not match with the >>> pvalidated size. In those cases we need to retry the PVALIDATE with >>> lower page size so that a validation succeed. One such a example is: >>> >>> - Guest ask hypervisor to add the page as 2M in RMP table. >>> >>> - Hypervisor added the page as 512 4K pages - because it was not able t= o >>> find a large backing pages. >>> >>> - Guest attempts to pvalidate the page as a 2M. The pvalidate will >>> return a failure saying its a size mismatch between the requested >>> pvalidated and RMP table. The recommendation is that guest should try >>> with a smaller page size. >>> >>> I would prefer to pass the pvalidate error as-is to caller so that it >>> can make the correct decision. >>> >> I am perfectly fine if the function return UINTN and then use #define >> instead of the enum to define the PVALIDATE return code. So that caller >> can check the error code. Let me know your thought on #define instead of >> the enum. > Apologies, I missed the fact that you said document the mapping between > the PVALIDATE return value and EFI_STATUS. So a caller is responsible to > look at the EFI document to know what the error code means. The > unsupported here does not mean that PVALIDATE is not support on > platform. I am good with it. I will go ahead with it. While coding it I am coming to realizing that mapping from PVALIDATE return value to EFI will add more code in assemblym and wanted to make sure that we all are okay with it. The proposed mapping looks like this: // No mapping required, both the values are zero PVALIDATE_RET_SUCCESS -> EFI_SUCCESS=C2=A0=C2=A0=C2=A0 // Pvalidate.nasm need to map from PVALIDATE fail input (1) to EFI_INVALID_PRAMS (2) PVALIATE_RET_FAIL_INPUT -> EFI_INVALID_PARAMS // Pvalidate.nasm need to map from PVALIDATE SIZE_MISMATCH (6) to EFI_UNSUPPORT(3) PVALIATE_RET_SIZEMISMATCH -> EFI_UNSUPPORTED May I recommend to use UINTN and simply propagate the PVALIDATE return value=C2=A0 or use the below mapping to simplify the pvalidate.nasm implementation: PVALIDATE_RET_SUCCESS(0) -> EFI_SUCCESS(0) PVALIDATE_RET_FAIL_INPUT(1) -> EFI_LOAD_ERROR(1) PVALIDATE_RET_SIZE_MISMATCH(6) -> EFI_NOT_READY(6) Thanks