From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.89]) by mx.groups.io with SMTP id smtpd.web11.10321.1624882954738900702 for ; Mon, 28 Jun 2021 05:22:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=j0PcNuyu; spf=pass (domain: arm.com, ip: 40.107.8.89, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PlShKf9RwgZdukGPzEcpiduN03XR5A+/VFJ4qfdhZ54=; b=j0PcNuyuZ2bpjH8rnCA5Oij7/z4s/KwBp79LT9j5Z4aMTjSEzzjRQIsYlzZ787vAEBRpNXVGvC0KTr0Xk3LIAHa8Ed5SJ36FufPpqtOuXjvT7xfXuw2JJ7paWv7S5YA3QbrnCKyZzfXCX5Z8HebM8FRM5COI0h6pqjpT0Ms86A4= Received: from DB6PR0501CA0032.eurprd05.prod.outlook.com (2603:10a6:4:67::18) by AM6PR08MB3061.eurprd08.prod.outlook.com (2603:10a6:209:4b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Mon, 28 Jun 2021 12:22:27 +0000 Received: from DB5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::5b) by DB6PR0501CA0032.outlook.office365.com (2603:10a6:4:67::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Mon, 28 Jun 2021 12:22:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT029.mail.protection.outlook.com (10.152.20.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Mon, 28 Jun 2021 12:22:27 +0000 Received: ("Tessian outbound 507383c3c879:v97"); Mon, 28 Jun 2021 12:22:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3eeb702a0bbc0b7d X-CR-MTA-TID: 64aa7808 Received: from bf1088943f6e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 56653537-350B-4B13-91E4-DC50AB9F36C1.1; Mon, 28 Jun 2021 12:22:13 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bf1088943f6e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 28 Jun 2021 12:22:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DuO16Ue1RGPWLtBirfVQ75gKsGjoL3rUBGtP8tIDyWAInnmhTjOu+STxYnil3akaQqFuEGfwnU4Dbwutu9ovMaXOjQin8asz7kqI0zTSD/nvzJ8LW6ZIe64jqDtI2qZe9uB7hs6nj+pVzsUseB625BRLP11DsnU1cFpZu8MQlZNEjBAfLQDnnqePIzQsDyx2foJa8w112DYp4jQlq/tmva36M+yyURdTSkB35JhBiAfjqXljbL3g4x9v4yXKEZ1nVQNJnDHGfdjmmXRV579pPdMqeRehaFigX/GTGUjD9lu+mQJarIN12QpRp663o6tVH2HsoyDSJ5MOPV2ZLCc+3g== 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=PlShKf9RwgZdukGPzEcpiduN03XR5A+/VFJ4qfdhZ54=; b=KbzNBvACiNdk35IhR4/OwwD0V12TUaBLHznA/67b4fElzy3Q7pFtbqiUNjFYh9DB3/AG9F+uaOkZGkcQWwvmHxUyiBJfF/M8wj4gt5NtuMi7sEsIzkGMHKcy8caI0cSzpopzImJlQFtG7c7G4FPmzq157t7MWYBFpiMkuqRiZcL2AYEvcfqVRGN7d7E0Ys3hRXBrQ+lbj7/1R1XUHngvXMx2RCKymlQ6wT6l6zije2FgzNy/m1CiWW6YfwFLZaS2i8eDxrh4e5P7RZ+1hPtVuhqT7DeffGKavdBwXYhLnM7BBeQx5yRhS+e+a6sLpuo55cd1d3KeOJ1uIgV48WnG7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PlShKf9RwgZdukGPzEcpiduN03XR5A+/VFJ4qfdhZ54=; b=j0PcNuyuZ2bpjH8rnCA5Oij7/z4s/KwBp79LT9j5Z4aMTjSEzzjRQIsYlzZ787vAEBRpNXVGvC0KTr0Xk3LIAHa8Ed5SJ36FufPpqtOuXjvT7xfXuw2JJ7paWv7S5YA3QbrnCKyZzfXCX5Z8HebM8FRM5COI0h6pqjpT0Ms86A4= Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AM5PR0801MB1652.eurprd08.prod.outlook.com (2603:10a6:203:3c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Mon, 28 Jun 2021 12:22:11 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::5c0d:142c:27df:c52b]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::5c0d:142c:27df:c52b%7]) with mapi id 15.20.4264.026; Mon, 28 Jun 2021 12:22:11 +0000 Subject: Re: [PATCH v3 2/3] Acpi: Install Acpi tables for Cloud hypervisor To: Jianyong Wu , devel@edk2.groups.io Cc: lersek@redhat.com, ardb+tianocore@kernel.org, justin.he@arm.com, nd References: <20210628095506.36076-1-jianyong.wu@arm.com> <20210628095506.36076-3-jianyong.wu@arm.com> From: "Sami Mujawar" Message-ID: <5676fa17-e4b6-b243-31a0-e957e12c4966@arm.com> Date: Mon, 28 Jun 2021 13:22:09 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20210628095506.36076-3-jianyong.wu@arm.com> X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.1.196.43] (217.140.106.54) by LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Mon, 28 Jun 2021 12:22:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54a16742-c43c-442a-50e4-08d93a2f645b X-MS-TrafficTypeDiagnostic: AM5PR0801MB1652:|AM6PR08MB3061: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3044;OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +RzKqVtA7e59C3svRx8bKan5FCMOkODyF+ZvqeqA/TfJguBem0w8NseFI2z15ky88nWkWCj1HFupwTfBER7z48imsfBtJFUS9ykvPhW+S3zD65zEzeweG/5uZw+nAXtHZYkrNxqQuSTHLdl0o5+HDt87uGAQ8jMyRbr1jb4z0rWystpjQ/X0/tn7QcnlFOTXduDo+6NphVTp97WpmvxVYmqirWUu1hrHQIzb3/Bm7I8ABw1RJWOP0nzQa0rSGPZkF7tQTexOGBTE0N1nqw8vilLfFc0+/VfioT5A3AVv2tadSHECUeO++DpYjZ3PT9jCvGDCMHTJANAqclsQOUfDHvae7qwjTVK9koVSwF7boYxQrxZTqXnXnOfrzDpXFnr2MIbE230TvFG1aUbgSFxtdc+kwti4AtaznetzJEdZfM21t+CMRskf8UsbC3DbxjSrg2tQ0djkuAsz6gzSfem2dZY5IOfNeTOlT2bGCn64S+Brm/km3RR+dIYPK48S4mhQM7Y3mUWR11Yq+Ez9rLXzXnL0mru+49cKeBrI2Js2xf9gfH5h29y0rvQG7djrBK0DgDy72biYZcHNm4tVPOg3w4pPXNzHH5QGKzjG9WNKhORTZKm+MgiWZ1FwTx1K+Pl5A0RtorAPsmYdPvilfqRvwqfJnZbgA0ph8jjaKICz3xCgCvwGh/wq+OrLs7ZNG+nd1vfpGPulPIFtOMWyNvvsen/d6L/8+/CmP7jjpz2SVrLRMzDP3i3JbSEl2Lqw9n9T20LGCWanDCdki1SBX9kACw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(136003)(376002)(346002)(366004)(396003)(6486002)(31686004)(8676002)(956004)(44832011)(36756003)(26005)(2616005)(4326008)(478600001)(53546011)(8936002)(5660300002)(2906002)(52116002)(83380400001)(16576012)(66946007)(186003)(16526019)(66556008)(66476007)(86362001)(31696002)(316002)(38100700002)(38350700002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZTQwdXMyNnpVbE8wTnVjVmFoSGdSdTVWVWZ1czhVTUxVNFJyOGUxWFJoeWJj?= =?utf-8?B?MUliWE8wYS9oTTUzL2FUeWNzNFF3WlBJYzFvdGFZTE43bzk4bDE4YUJ5VTNu?= =?utf-8?B?ai93M080a3YweHRRek5ZVmc1NTlPcFp1ZWVKTUU0VlFYMTA2M0hLV1R6elJi?= =?utf-8?B?NFBtTmZMZHVCNjRQdXN1TlZvL3E2WTN0RndiemFmR1p1bDViSDJjWnZaZ3p1?= =?utf-8?B?WmVxeExyb2srOGg1dnV2c3J6RExOQ0FVcUliZS9qRVNYZExKUG5Zb1lEcXZL?= =?utf-8?B?T2x6bjRRZUt1aGUwMmlncS9rZXdmQTV4NXJpc1l0Y0E4a04rZHc1S3J0cm1s?= =?utf-8?B?MW1rck1sT2dMV2JabFZ1QldrU2g5VEY5SW8vcjVYWEJFSmdOa1ptdUFaRWN4?= =?utf-8?B?V2hhWUZJM2xOWkR3VGx4cEhFTDJGMmdyUU9QQkR2VGFRSlk3VWlIRUZFZURi?= =?utf-8?B?VUtXQ3VpSkNBWE9aMHlqOGFkU1lOWnBhcnBaRHFiQ1ZGSThPY3FyMlNKYWV6?= =?utf-8?B?bnRzbGxKQytNTnRnaDk1UVVqYUtBRzdBQkpLS0p4SHRGRFc0Z2FnSEloZmxk?= =?utf-8?B?OHd2Rk9MUlFoUlg5MTQxWHo1NVliYW1vNkIvZWxjZEtVWXpYVm5tbWdRVWtU?= =?utf-8?B?K0pTMjBVaHJFTXl4NTJ5UDVFUCt4ejNKZ3VJWTlJUThvUmNiVVdEZFV4RmJn?= =?utf-8?B?eDRJVS9aVVhMSC83OTZFeEcxeGdIeUoweU1yZVVVZnRjNlRDMGlYcWhSNnJT?= =?utf-8?B?Y2lMZEJTQkVvSlZ4R2hwZG5qVlJMTTNlcXRUR3ZwUVJTRnpLVnBvRmpCMUds?= =?utf-8?B?OVpmL09OZlloTWRpMUdmUzJ5aEM1dnI1eC8wNW4wVVpYWFhsYkdMbWZ6VGlD?= =?utf-8?B?OVZIUnFDTmJJWkV4RkxsWkZBVk1KcUVXTjZLTjFvOVZIeTRFTWV5cG1pM1Bp?= =?utf-8?B?N3FKbDByN21jdU5TelpIR2Z6N3B5bzREbURyRTlpQ3ovbUtCdXNCNmlDTzJq?= =?utf-8?B?bDhWbkg0UXJCcmRLajc1VlNNaWpIY0FvbFI0ZVkxSU5la1BmOW1aL2ZrNDBn?= =?utf-8?B?bStyeGd2dG5PMjBSUENDOEFaUGRPbDhyL1MwWVZYNlhVRFdsQjRyMDdqb0Zv?= =?utf-8?B?VmZxV0tZTjBHYTdUWW1Tb3o2bDkyU3ZZSHl1QmszWDVXMERNTEVMNEZ2REdl?= =?utf-8?B?K2JDOHVhMThTS0hBU0N5V1ZmNzZzY1l3WjhsNTRIWGpYcVNQNHVydTBKYmVZ?= =?utf-8?B?NTZNaXZLdWxjaUVMQm1hQWhyNXJ6UG84Vy9uNDdCZWtQM1F2MkxmNUM1NzBy?= =?utf-8?B?RnovMnU4eFFIQjJRaEh2Ym80TU1xKzBMNW5ZMDVjYzNxMTZTY01ha2lUUEhs?= =?utf-8?B?WmpCd3BrcFpqYXFyZDYwalB4VENCMXdKTDBRWlM3NzlVb2xsWTdEUjV6Mkth?= =?utf-8?B?RVN6T0E1SmRBekRPLzQveElNbGxUeVNmcFJENVVQSjZEYVZzOCt0SWxsV2Zq?= =?utf-8?B?OFpyT1pBcndoY05Ea2dYbjBtMGYwVTJGVXhNSzFCays2SUdNQ0wweTFwL2t1?= =?utf-8?B?ZkFyMFdJMVo5R0tFZE1uYTUreFRIcWd6K051bS90QS9IRzRVREZCK3hkbEV4?= =?utf-8?B?TGM1Q2cwZ3NrUURRTzlaMlUxZzBmNXZEbzRoTVVpaENYZDFKY0dOdFRySHZz?= =?utf-8?B?cTlUZGhoRnNIZ1FwTERzMjMzTmdDVUNOejRTVUtiM3B6THJLQTJPM3V6c1d1?= =?utf-8?Q?SMRN3EBWAw5A53bq78D7LpyBMTqQYsjGjBoR7Ms?= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1652 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9ab30294-61fa-43f2-122c-08d93a2f5a88 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iRlL+Cf5O6E7hbiI4Lj31t2zoGAa1+iFycsUI3w34hwIZMK03FTdPtAS+NDwe376IhTtCCTZ/S/rWaguRRUNta9djaH5V9lceuGaBhyfqcJiHLZWuJoUA/4GVuYCeBAD+kq5gS/4ZIcrHEJp9To36dHRvHyCMgvvwgzfMjcePNah+2yxrlqyw7ovwXubcxC7uZwFXtJx3/4c5dgW2Wgcc8KIw4o5JpvwlRCgdobEuDwJILLFDckULfi8u+7s62UpIWUZ5qjWJBimfcnVB0zBbT/FmmRSG2NSFnDTGbe6oTVnsZdUEYglZ3/5JO5ia9hF5cXYCRGSY/4qABb8yIRyrK62iyljWfcAOMXXSiD1lhxXfdV6jB3uo42Q6t5NFMP58Oj11+qrZvK+B4/xgWF1d4Rvebauh6LVHNVQPpLW58Uk07UHCQ5iuTHMqhfZgRYHb8XrAkjWb9JmUBJCfS5tanaT/bvTKKAk7ZCc4QQXjhczbNDSIXO/icINGMAYyIxSNRm2EguZI9kIsSUsVjh9YcWQlDxdNQCnEkFDor6cDiY9d5eaiBTd6myGd55u0CvpuE+9cH321jcl4bGS8nGNpSnKecaIut3bptT7yZzu0V40LvGcYTCXWc3EgW2NppcS2sRuQTc9jnWhuipnHGLh1Q+rw0s++HKEtOl5hnt0heCYRReFcoBSCpPlHWlrMqNUH4XymXLaBmmZgO2moT4DZJz5jEnC590iSyZaHf8l0IU= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(396003)(136003)(376002)(39860400002)(36840700001)(46966006)(316002)(5660300002)(16576012)(8676002)(83380400001)(36860700001)(70586007)(36756003)(478600001)(82740400003)(82310400003)(70206006)(4326008)(44832011)(956004)(26005)(2906002)(336012)(356005)(86362001)(31696002)(2616005)(6486002)(47076005)(16526019)(31686004)(81166007)(8936002)(53546011)(186003)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2021 12:22:27.1035 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54a16742-c43c-442a-50e4-08d93a2f645b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3061 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Hi Jianyong, Please find my response inline marked [SAMI]. Regards, Sami Mujawar On 28/06/2021 10:55 AM, Jianyong Wu wrote: > There is no device like Fw-cfg in Qemu in Cloud Hypervisor, so a specific > Acpi handler is introduced here. > > The handler implemented here is in a very simple way: > 1. acquire the RSDP from the PCD variable in the top ".dsc"; > 2. get the XSDT address from RSDP structure; > 3. get the ACPI tables following the XSDT structure and install them > one by one; > 4. get DSDT address from FADT and install DSDT table. > > Signed-off-by: Jianyong Wu > --- > ArmVirtPkg/ArmVirtPkg.dec | 6 + > .../CloudHvAcpiPlatformDxe.inf | 47 ++++++ > .../CloudHvAcpiPlatformDxe/CloudHvAcpi.c | 141 ++++++++++++++++++ > 3 files changed, 194 insertions(+) > create mode 100644 ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf > create mode 100644 ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpi.c > > diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec > index bf82f7f1f3f2..4e4d758015bc 100644 > --- a/ArmVirtPkg/ArmVirtPkg.dec > +++ b/ArmVirtPkg/ArmVirtPkg.dec > @@ -66,6 +66,12 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] > # > gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6, 0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D}|VOID*|0x00000007 > > + ## > + # This is the physical address of Rsdp which is the core struct of Acpi. > + # Cloud Hypervisor has no other way to pass Rsdp address to the guest except use a PCD. > + # > + gArmVirtTokenSpaceGuid.PcdCloudHvAcpiRsdpBaseAddress|0x0|UINT64|0x00000005 > + > [PcdsDynamic] > # > # Whether to force disable ACPI, regardless of the fw_cfg settings > diff --git a/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf b/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf > new file mode 100644 > index 000000000000..01de76486686 > --- /dev/null > +++ b/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpiPlatformDxe.inf > @@ -0,0 +1,47 @@ > +## @file > +# ACPI Platform Driver for Cloud Hypervisor > +# > +# Copyright (c) 2021, ARM Limited. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = CloudHvgAcpiPlatform > + FILE_GUID = 6c76e407-73f2-dc1c-938f-5d6c4691ea93 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT = CloudHvAcpiPlatformEntryPoint > + > +# > +# The following information is for reference only and not required by the build tools. > +# > + VALID_ARCHITECTURES = AARCH64 > +# > + > +[Sources] > + CloudHvAcpi.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + OvmfPkg/OvmfPkg.dec > + ArmVirtPkg/ArmVirtPkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + MemoryAllocationLib > + OrderedCollectionLib > + UefiBootServicesTableLib > + UefiDriverEntryPoint > + > +[Protocols] > + gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED > + > +[Pcd] > + gArmVirtTokenSpaceGuid.PcdCloudHvAcpiRsdpBaseAddress > + > +[Depex] > + gEfiAcpiTableProtocolGuid > diff --git a/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpi.c b/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpi.c > new file mode 100644 > index 000000000000..0f1a50d63cd6 > --- /dev/null > +++ b/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpi.c > @@ -0,0 +1,141 @@ > +/** @file > + Install Acpi tables for Cloud Hypervisor > + > + Copyright (c) 2021, Arm Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + Find Acpi table Protocol and return it [SAMI]Please add description of value returned by this function. [/SAMI] > +**/ > +STATIC > +EFI_ACPI_TABLE_PROTOCOL * > +FindAcpiTableProtocol ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + EFI_ACPI_TABLE_PROTOCOL *AcpiTable; > + > + Status = gBS->LocateProtocol ( > + &gEfiAcpiTableProtocolGuid, > + NULL, > + (VOID**)&AcpiTable > + ); > + ASSERT_EFI_ERROR (Status); > + return AcpiTable; > +} > + > +/** Install Acpi tables for Cloud Hypervisor > + > + @param [in] AcpiProtocol Acpi Protocol which is used to install Acpi talbles > + > + @return EFI_SUCCESS The table was successfully inserted. > + @return EFI_INVALID_PARAMETER Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize > + and the size field embedded in the ACPI table pointed to by AcpiTableBuffer > + are not in sync. > + @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the request. > + @retval EFI_ACCESS_DENIED The table signature matches a table already > + present in the system and platform policy > + does not allow duplicate tables of this type. > +**/ > +EFI_STATUS > +EFIAPI > +InstallCloudHvAcpiTables ( > + IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol > + ) > +{ > + UINTN InstalledKey, TableSize, AcpiTableLength; [SAMI] Define each local variable separately on a new line. > + UINT64 RsdpPtr, XsdtPtr, TableOffset, AcpiTablePtr, DsdtPtr = ~0; [SAMI] I think DsdtPtr can be UINT64 pointer and initialised to NULL before first use. > + EFI_STATUS Status = EFI_SUCCESS; > + BOOLEAN GotFacp = FALSE; [SAMI] I think GotFacp could probably be avoided, see comments below. > + > + RsdpPtr = PcdGet64 (PcdCloudHvAcpiRsdpBaseAddress); > + XsdtPtr = ((EFI_ACPI_6_3_ROOT_SYSTEM_DESCRIPTION_POINTER *) RsdpPtr)->XsdtAddress; [SAMI] No space between typecast and their object. Same comment for similar instances in this patch series. > + AcpiTableLength = ((EFI_ACPI_COMMON_HEADER *) XsdtPtr)->Length; > + TableOffset = sizeof (EFI_ACPI_DESCRIPTION_HEADER); > + [SAMI] Set DsdtPtr = NULL, here. > + while (!EFI_ERROR(Status) > + && (TableOffset < AcpiTableLength)) > + { [SAMI] Starting curly brace at the end of previous line, please. > + AcpiTablePtr = *(UINT64 *) (XsdtPtr + TableOffset); > + TableSize = ((EFI_ACPI_COMMON_HEADER *) AcpiTablePtr)->Length; > + > + // > + // Install ACPI tables from XSDT > + // > + Status = AcpiProtocol->InstallAcpiTable ( [SAMI] AcpiProtocol pointer not checked before use. In release builds the ASSERTs in FindAcpiTableProtocol() would vanish and a failure to get the protocol would result in a crash when dereferencing the pointer here. > + AcpiProtocol, > + (VOID *)(UINT64)AcpiTablePtr, [SAMI] Can you check if typecast to UINT64 is needed here, please? Similarly, also check at other places. > + TableSize, > + &InstalledKey > + ); [SAMI] Please reconsider error handling in this function. Probably best check and return failure from here. This would mean the status would not need to be checked in the while () statement and correspondingly there is no need to initialise Status to EFI_SUCCESS at the begining of this function. > + > + TableOffset += sizeof (UINT64); > + > + // > + // Get DSDT from FADT > + // > + if (!GotFacp > + && !AsciiStrnCmp ((CHAR8 *) &((EFI_ACPI_COMMON_HEADER *) AcpiTablePtr)->Signature, "FACP", 4)) > + { [SAMI] Curly brace on previous line, please. '!GotFacp' could be replaced with (DsdtPtr != NULL). > + DsdtPtr = ((EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE *) AcpiTablePtr)->XDsdt; > + GotFacp = TRUE; > + } > + } > + > + if (DsdtPtr == ~0) { [SAMI] Please change to' If (DsdtPtr == NULL)'. > + DEBUG ((DEBUG_ERROR, "%a: no DSDT found\n", __FUNCTION__)); > + ASSERT (FALSE); > + CpuDeadLoop (); [SAMI] I think EFI_NOT_FOUND could be returned here, and the CpuDeadLoop () could be moved to CloudHvAcpiPlatformEntryPoint(). > + } > + > + // > + // Install DSDT table > + // > + TableSize = ((EFI_ACPI_COMMON_HEADER *) DsdtPtr)->Length; > + Status = AcpiProtocol->InstallAcpiTable ( > + AcpiProtocol, > + (VOID *)(UINT64) DsdtPtr, > + TableSize, > + &InstalledKey > + ); > + > + return Status; > +} > + > +/** Entry point for Cloud Hypervisor Platform Dxe > + > + @param [in] ImageHandle Handle for this image. > + @param [in] SystemTable Pointer to the EFI system table. > + > + @return EFI_SUCCESS The table was successfully inserted. > + @return EFI_INVALID_PARAMETER Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize > + and the size field embedded in the ACPI table pointed to by AcpiTableBuffer > + are not in sync. > + @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the request. > + @retval EFI_ACCESS_DENIED The table signature matches a table already > + present in the system and platform policy > + does not allow duplicate tables of this type. > +**/ > +EFI_STATUS > +EFIAPI > +CloudHvAcpiPlatformEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + > + Status = InstallCloudHvAcpiTables (FindAcpiTableProtocol ()); [SAMI] Check status code here and on failure execute CpuDeadLoop (). > + return Status; > +}