From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (NAM04-BN3-obe.outbound.protection.outlook.com [40.92.9.47]) by mx.groups.io with SMTP id smtpd.web10.4142.1614119517611913702 for ; Tue, 23 Feb 2021 14:31:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=K8FgFXYZ; spf=pass (domain: outlook.com, ip: 40.92.9.47, mailfrom: spbrogan@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FWG2h6AYy8R/FvysR7NbjrV5pfxq5B75MNVjoEizNAnW/np4z9lp3gpT6MKPz86Ga7gVMAs2MNwbDXQei5jRH1/003ll6WxevYqVGTVJI1zM4SQp2bNuKMDQzduBremwenKwBFaetEquD45n2C1cCumj2Oy/ks8D4TjxV1JQ7cE7m66dkzvvKKIVZEzbG2fxKDJ3G/bNDSjGPYL5A5HYVid0IHx/Ql+/r64t4mvkFZpvbVJ9Sue0Hc/iD75Wj0R628o6QD3eLmT0VaXodjvDWfJaGMyT8PILmFEEsr4TXjE5C1Vmi6NPrCWW3bI9U/zQUFmmTRs9+jhQOvz6Nb08JQ== 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=iYafKkWGCMUTXewwFHTs20ddLx94rvRS48fAaWJYcUE=; b=dDZx2YhbeMyOix1752yi00G+TH5KCFMRxKr/JSqG2HVbNh44q88lfyKMbLAjMnkcijz1Qbphqc6x3SsfP4mSBQI4ArcOAhtghlQlC5IaTxocrMLiP7N3ahQSXd5Cfs2e9lYMvz3QoWjgiP4hz0lbXuxDSqO9gKipqj583AqQYgTNkYTHpRkR4W8dyzCJEXFCP08ETdsFm8bizybGQfoIfHs9K0pYwBzszfG99XPV2S57nWpPMGLTvRqrp52MdcUNmKffDS4PhIfc0mL5es0QFCg76ryReZVlcch/TbU1RjhafKwcG8Qf5JgEfSnVW4ogpaMyXwWrsLi5c2g37+uDPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iYafKkWGCMUTXewwFHTs20ddLx94rvRS48fAaWJYcUE=; b=K8FgFXYZ5y9pjbM0jnQTRL0prXbK2PJNDMXw7bsBD6DkpY02hXAEOtxBea5ZV3Gols0n+hs5bIepPeCaizT/9FBD8ko71+BMYBYooQjaMhRvlpg4/QSKmCLt39JVuHjXiFBj0SIRZc3Iih/aCOt1z0dCWHcdpqwSCpbnkZ+wr0YC2G74NdQbT+oxMmZ6GdoTYcM1gn3K4QQt1kHb5wDoJRscUaiybtfUmMBDKRYYWRdpDHszACyvw8ScOtxJSBoikW4lV1nidAVIQHj0j5wZR9fujYu6q9rhEg3lm9dP4+zSx8Nylk9Lys1DhScdRDHR136XYaiLlPTofHhMqwzZrg== Received: from BN3NAM04FT063.eop-NAM04.prod.protection.outlook.com (10.152.92.56) by BN3NAM04HT115.eop-NAM04.prod.protection.outlook.com (10.152.93.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Tue, 23 Feb 2021 22:31:55 +0000 Received: from DM6PR19MB4010.namprd19.prod.outlook.com (2a01:111:e400:7e4e::41) by BN3NAM04FT063.mail.protection.outlook.com (2a01:111:e400:7e4e::426) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Tue, 23 Feb 2021 22:31:55 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E3412EEF63963AE676333544FB730B9FCD6AEED7466086016EF6464F3C5131F6;UpperCasedChecksum:DFB93A288B94B3A51ECC9A6B396CA8ACC41198B888C1466F153AE96F2D15CC1F;SizeAsReceived:8950;Count:48 Received: from DM6PR19MB4010.namprd19.prod.outlook.com ([fe80::3d83:7795:7cb8:1a94]) by DM6PR19MB4010.namprd19.prod.outlook.com ([fe80::3d83:7795:7cb8:1a94%8]) with mapi id 15.20.3868.031; Tue, 23 Feb 2021 22:31:55 +0000 Subject: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool To: devel@edk2.groups.io, sami.mujawar@arm.com Cc: ardb+tianocore@kernel.org, leif@nuviainc.com, sean.brogan@microsoft.com, Bret.Barkelew@microsoft.com, michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, lersek@redhat.com, Matteo.Carlini@arm.com, Ben.Adderson@arm.com, nd@arm.com References: <20210122171941.30724-1-sami.mujawar@arm.com> <20210122171941.30724-2-sami.mujawar@arm.com> From: "Sean" Message-ID: Date: Tue, 23 Feb 2021 14:31:52 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 In-Reply-To: <20210122171941.30724-2-sami.mujawar@arm.com> X-TMN: [dMyWyNEundTcwSD2PTRzs5SCLy6GPi4U] X-ClientProxiedBy: MW2PR16CA0029.namprd16.prod.outlook.com (2603:10b6:907::42) To DM6PR19MB4010.namprd19.prod.outlook.com (2603:10b6:5:24e::19) Return-Path: spbrogan@outlook.com X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.2.78] (50.47.113.221) by MW2PR16CA0029.namprd16.prod.outlook.com (2603:10b6:907::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Tue, 23 Feb 2021 22:31:54 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 83d7ed34-8792-4d21-8258-08d8d84ad313 X-MS-TrafficTypeDiagnostic: BN3NAM04HT115: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: giFkloVz+pX3Q0X95yGFyz009gPpjYUTZ1LJRL8gyCKvLDD4eYtRpBnXlywkVJyh068rnX5jfmqP0kalc2HdmJYz8hGohEnJJCvdwVQDuD8/9K/hrPnUh4/o1EHgqTxoIRyMBEdhoeuS9lOxLgq1N6OHxkZMMY+AKlOR+5RN5oUnQdQR5OgLo04s0QZFu/B8+Ue/2hWmO8mmhh5YgcNjhD3XXvj84eFQzq2153A1ArAbfzhGzMnXqFjq0dEIjc7EtOb2LgXhzhG8fKq51rEl7U6xGamKO0YcniqqcyEGC3zbRmMBS2/5wn0HqqyCegd4XU9+7yFVM9mW2y1Z7P3sf5mQVXu3Q22tVfF4CxpR13fu3OlFUgHlX1dryYkNIxZdgTyh5Lr5GMjkZ9bVSWq1xA== X-MS-Exchange-AntiSpam-MessageData: AC7XcvfzCckGq2rGQgWve3GDWaESeq65vW9xDeLonv1y/aVP4NT9Uh1AYFaEe19IsgVfzux193IMIe5pPAQARMbi8QjTPwa5XGZXQhE2UctQ88N9iBCKgjm9tgM2jlrvaCydwneRv4I75P3wv6teCA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83d7ed34-8792-4d21-8258-08d8d84ad313 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2021 22:31:55.7209 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BN3NAM04FT063.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3NAM04HT115 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sami, Do you have these in a PR or somewhere online that is already merged? Obviously i can do that but usually developers already have that (either edk2 PR for ci testing or on their fork). one comment below. Thanks Sean On 1/22/2021 9:19 AM, Sami Mujawar wrote: > Kvmtool is a virtual machine manager that can be used to launch > guest partitions. ArmVirtPkg already has UEFI (virtual/guest) > firmware support for Kvmtool guest. > > Therefore, update the Platform CI script to add support for > building the Kvmtool firmware. > > Signed-off-by: Sami Mujawar > --- > ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++--------- > ArmVirtPkg/PlatformCI/ReadMe.md | 21 ++-- > 2 files changed, 88 insertions(+), 65 deletions(-) > > diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py b/ArmVirtPkg/PlatformCI/PlatformBuild.py > index dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e210cb679679b28131 100644 > --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py > +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py > @@ -2,6 +2,7 @@ > # Script to Build ArmVirtPkg UEFI firmware > # > # Copyright (c) Microsoft Corporation. > +# Copyright (c) 2021, Arm Limited. All rights reserved.
> # SPDX-License-Identifier: BSD-2-Clause-Patent > ## > import os > @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting > > The tuple should be (, ) > ''' This doesn't look right. When returning the dsc to use it should only return 1 dsc file. The second parameter of the tuple is for key=value pairs to process the DSC file. > - return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {}) > + return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), > + os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {}) > > > # ####################################################################################### # > @@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting > class PlatformBuilder(UefiBuilder, BuildSettingsManager): > def __init__(self): > UefiBuilder.__init__(self) > + self.PlatformList = [os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), > + os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc")] > > def AddCommandLineOptions(self, parserObj): > ''' Add command line options to the argparser ''' > parserObj.add_argument('-a', "--arch", dest="build_arch", type=str, default="AARCH64", > help="Optional - Architecture to build. Default = AARCH64") > + parserObj.add_argument('-d', "--dsc", dest="active_platform", type=str, default=self.PlatformList[0], > + help="Optional - Platform to build. Default = " + self.PlatformList[0]) > > def RetrieveCommandLineOptions(self, args): > ''' Retrieve command line options from the argparser ''' > @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager): > shell_environment.GetBuildVars().SetValue( > "TARGET_ARCH", args.build_arch.upper(), "From CmdLine") > > - shell_environment.GetBuildVars().SetValue( > - "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc", "From CmdLine") > + if (args.active_platform == self.PlatformList[1]): > + shell_environment.GetBuildVars().SetValue( > + "ACTIVE_PLATFORM", self.PlatformList[1], "From CmdLine") > + else: > + shell_environment.GetBuildVars().SetValue( > + "ACTIVE_PLATFORM", self.PlatformList[0], "From CmdLine") > > def GetWorkspaceRoot(self): > ''' get WorkspacePath ''' > @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager): > > def SetPlatformEnv(self): > logging.debug("PlatformBuilder SetPlatformEnv") > - self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform Hardcoded") > self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to false") > self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to false") > + if (self.env.GetValue("ACTIVE_PLATFORM") == self.PlatformList[1]): > + self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool", "Platform Hardcoded") > + else: > + self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform Hardcoded") > return 0 > > def PlatformPreBuild(self): > @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager): > return 0 > > def FlashRomImage(self): > - VirtualDrive = os.path.join(self.env.GetValue( > - "BUILD_OUTPUT_BASE"), "VirtualDrive") > - os.makedirs(VirtualDrive, exist_ok=True) > - OutputPath_FV = os.path.join( > - self.env.GetValue("BUILD_OUTPUT_BASE"), "FV") > - Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd") > - > - # pad fd to 64mb > - with open(Built_FV, "ab") as fvfile: > - fvfile.seek(0, os.SEEK_END) > - additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell()) > - fvfile.write(additional) > - > - # QEMU must be on that path > - > - # Unique Command and Args parameters per ARCH > - if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"): > - cmd = "qemu-system-aarch64" > - args = "-M virt" > - args += " -cpu cortex-a57" # emulate cpu > - elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"): > - cmd = "qemu-system-arm" > - args = "-M virt" > - args += " -cpu cortex-a15" # emulate cpu > + if (self.env.GetValue("ACTIVE_PLATFORM") == self.PlatformList[1]): > + return 0 > else: > - raise NotImplementedError() > - > - # Common Args > - args += " -pflash " + Built_FV # path to fw > - args += " -m 1024" # 1gb memory > - # turn off network > - args += " -net none" > - # Serial messages out > - args += " -serial stdio" > - # Mount disk with startup.nsh > - args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk" > - > - # Conditional Args > - if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"): > - args += " -display none" # no graphics > - > - if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"): > - f = open(os.path.join(VirtualDrive, "startup.nsh"), "w") > - f.write("BOOT SUCCESS !!! \n") > - # add commands here > - f.write("reset -s\n") > - f.close() > - > - ret = RunCmd(cmd, args) > - > - if ret == 0xc0000005: > - # for some reason getting a c0000005 on successful return > - return 0 > - > - return ret > + VirtualDrive = os.path.join(self.env.GetValue( > + "BUILD_OUTPUT_BASE"), "VirtualDrive") > + os.makedirs(VirtualDrive, exist_ok=True) > + OutputPath_FV = os.path.join( > + self.env.GetValue("BUILD_OUTPUT_BASE"), "FV") > + Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd") > + > + # pad fd to 64mb > + with open(Built_FV, "ab") as fvfile: > + fvfile.seek(0, os.SEEK_END) > + additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell()) > + fvfile.write(additional) > + > + # QEMU must be on that path > + > + # Unique Command and Args parameters per ARCH > + if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"): > + cmd = "qemu-system-aarch64" > + args = "-M virt" > + args += " -cpu cortex-a57" # emulate cpu > + elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"): > + cmd = "qemu-system-arm" > + args = "-M virt" > + args += " -cpu cortex-a15" # emulate cpu > + else: > + raise NotImplementedError() > + > + # Common Args > + args += " -pflash " + Built_FV # path to fw > + args += " -m 1024" # 1gb memory > + # turn off network > + args += " -net none" > + # Serial messages out > + args += " -serial stdio" > + # Mount disk with startup.nsh > + args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk" > + > + # Conditional Args > + if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"): > + args += " -display none" # no graphics > + > + if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"): > + f = open(os.path.join(VirtualDrive, "startup.nsh"), "w") > + f.write("BOOT SUCCESS !!! \n") > + # add commands here > + f.write("reset -s\n") > + f.close() > + > + ret = RunCmd(cmd, args) > + > + if ret == 0xc0000005: > + # for some reason getting a c0000005 on successful return > + return 0 > + > + return ret > diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md b/ArmVirtPkg/PlatformCI/ReadMe.md > index 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069edd99e9680a1252e9 100644 > --- a/ArmVirtPkg/PlatformCI/ReadMe.md > +++ b/ArmVirtPkg/PlatformCI/ReadMe.md > @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure locally. > ## Supported Configuration Details > > This solution for building and running ArmVirtPkg has only been validated with Ubuntu > -18.04 and the GCC5 toolchain. Two different firmware builds are supported and are > -described below. > +18.04 and the GCC5 toolchain. The supported firmware builds are described below. > > -| Configuration name | Architecture | DSC File |Additional Flags | > -| :---------- | :----- | :----- | :---- | > -| AARCH64 | AARCH64 | ArmVirtQemu.dsc | None | > -| ARM | ARM | ArmVirtQemu.dsc | None | > +| Configuration name | Architecture | DSC File |Additional Flags | > +| :---------- | :----- | :----- | :---- | > +| AARCH64 | AARCH64 | ArmVirtQemu.dsc | None | > +| ARM | ARM | ArmVirtQemu.dsc | None | > +| AARCH64 | AARCH64 | ArmVirtKvmTool.dsc | None | > +| ARM | ARM | ArmVirtKvmTool.dsc | None | > > ## EDK2 Developer environment > > @@ -79,7 +80,13 @@ Pytools build system. > ``` > > - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h` option to see additional > - options like `--clean` > + options like `--clean`, `--dsc`, etc. > + > + Example: The `--dsc` option can be used to specify the platform to build. > + > + ``` bash > + stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py TOOL_CHAIN_TAG= -a --dsc ArmVirtPkg/ArmVirtKvmTool.dsc > + ``` > > 8. Running Emulator > - You can add `--FlashRom` to the end of your build command and the emulator will run after the >