From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.14099.1683718735624878582 for ; Wed, 10 May 2023 04:38:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z1yZe8Kr; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1B84E648CC for ; Wed, 10 May 2023 11:38:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EE4AC4339E for ; Wed, 10 May 2023 11:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683718734; bh=gG6+n6ImkGkEMNI+AzppAqmcbfDzF7ecxY/gWS1+ZmY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Z1yZe8KrJuSpszCQMTGBcCnb/9pbGwyEKagBWyjQeLo3iXhsevcC95RKOAEZPGhgH frKiUz9672+evNTxz9+B6aCIdBUg10hKeY8CiXbIT58cryu0FynRjb1TzUYxHI+x5r FXD5uR64js06OWqz4Nn4p6KhhVKNVAea0WAZXYu4bzTJNffeEiXwu6I/16cE5nx8/s bNrcgRv9YVmV391Jo+3anV70anVFwne+DhSgQAefB/Gu15qZ4iqUgFQDD46t/gtbdD IArrMjL6LhK3bcSKkBo1l3z1YbboyOU+hPBgmcI1xRymU/HpN/SZemZKJxJ4OMwL+J SQHBPioT9sPtg== Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-4f139de8cefso39375898e87.0 for ; Wed, 10 May 2023 04:38:54 -0700 (PDT) X-Gm-Message-State: AC+VfDzPSAVD6oGGJ3IybAz7VZUahcQ4lmpJIENFA1qFhXkZZZJsxLRc nst+D43Kl2pg6FtkvVAYVlD22X8jOcZJmMmtpFU= X-Google-Smtp-Source: ACHHUZ6T/yrmo9gglNdFITftTFomQRH5o/tIn9cPgvi5OpY/jj6jupN+3esaWQxV4iSt/W8cBEJVEF0gbbWUfGO2iac= X-Received: by 2002:a2e:8850:0:b0:2a7:8b35:8274 with SMTP id z16-20020a2e8850000000b002a78b358274mr1807543ljj.19.1683718732345; Wed, 10 May 2023 04:38:52 -0700 (PDT) MIME-Version: 1.0 References: <20230425160428.27980-1-sami.mujawar@arm.com> <20230425160428.27980-6-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-6-sami.mujawar@arm.com> From: "Ard Biesheuvel" Date: Wed, 10 May 2023 13:38:41 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v1 05/30] ArmPkg & ArmVirtPkg: Make PcdMonitorConduitHvc a dynamic PCD To: Sami Mujawar Cc: devel@edk2.groups.io, ardb+tianocore@kernel.org, quic_llindhol@quicinc.com, kraxel@redhat.com, Pierre.Gondois@arm.com, Suzuki.Poulose@arm.com, jean-philippe@linaro.org, Matteo.Carlini@arm.com, Akanksha.Jain2@arm.com, Ben.Adderson@arm.com, nd@arm.com Content-Type: text/plain; charset="UTF-8" On Tue, 25 Apr 2023 at 18:04, Sami Mujawar wrote: > > The monitor call conduit is fixed for a platform firmware in > most scenarios. For a normal virtual machine guest firmware, > the default conduit is HVC. However, for Arm CCA the Realm > code must use SMC as the conduit. > > To have a common code base for Guest/Virtual firmware to be used > by both normal VMs and Realm VMs, make PcdMonitorConduitHvc as a > dynamic PCD. This allows the firmware to detect if it is running > in a Realm and it can configure the PcdMonitorConduitHvc as FALSE > (i.e. to use SMC as the conduit when running in a Realm). > > Also update the ArmVirtPkg/ArmVirtKvmTool.dsc workspace to move > the PcdMonitorConduitHvc in the PcdsDynamic section to prevent > the build from breaking. > Do you mean realm VMs will use SMC even for PSCI calls etc? The change looks fine to me, given that other platforms that rely on the default will still get a fixed PCD after this change. > Signed-off-by: Sami Mujawar > --- > ArmPkg/ArmPkg.dec | 10 +++++----- > ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c | 4 ++-- > ArmVirtPkg/ArmVirtKvmTool.dsc | 4 ++-- > 3 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec > index f17ba913e6de1326d49b93d6a15378ff2f522d24..0730533e512d60fcba19c4cfa84944061d16f02e 100644 > --- a/ArmPkg/ArmPkg.dec > +++ b/ArmPkg/ArmPkg.dec > @@ -139,11 +139,6 @@ [PcdsFeatureFlag.common] > # Define if the GICv3 controller should use the GICv2 legacy > gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 > > - ## Define the conduit to use for monitor calls. > - # Default PcdMonitorConduitHvc = FALSE, conduit = SMC > - # If PcdMonitorConduitHvc = TRUE, conduit = HVC > - gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047 > - > [PcdsFeatureFlag.ARM] > # Whether to map normal memory as non-shareable. FALSE is the safe choice, but > # TRUE may be appropriate to fix performance problems if you don't care about > @@ -393,6 +388,11 @@ [PcdsFixedAtBuild.common, PcdsDynamic.common] > gArmTokenSpaceGuid.PcdPciBusMin|0x0|UINT32|0x00000059 > gArmTokenSpaceGuid.PcdPciBusMax|0x0|UINT32|0x0000005A > > + ## Define the conduit to use for monitor calls. > + # Default PcdMonitorConduitHvc = FALSE, conduit = SMC > + # If PcdMonitorConduitHvc = TRUE, conduit = HVC > + gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047 > + > [PcdsDynamicEx] > # > # This dynamic PCD hold the GUID of a firmware FFS which contains > diff --git a/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c b/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c > index 741f5c615744dc5cc5381ff3848078f93858dd2b..221724125ce3a8f351a55a81f441409a99bcb5cf 100644 > --- a/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c > +++ b/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c > @@ -1,7 +1,7 @@ > /** @file > Arm Monitor Library. > > - Copyright (c) 2022, Arm Limited. All rights reserved.
> + Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -26,7 +26,7 @@ ArmMonitorCall ( > IN OUT ARM_MONITOR_ARGS *Args > ) > { > - if (FeaturePcdGet (PcdMonitorConduitHvc)) { > + if (PcdGetBool (PcdMonitorConduitHvc)) { > ArmCallHvc ((ARM_HVC_ARGS *)Args); > } else { > ArmCallSmc ((ARM_SMC_ARGS *)Args); > diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc > index d2228a95726b24fe5c2edfbc84b1f5c23a85feba..467e5c166e1bbad3acbae78f53c225f5bac525a9 100644 > --- a/ArmVirtPkg/ArmVirtKvmTool.dsc > +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc > @@ -117,8 +117,6 @@ [PcdsFeatureFlag.common] > # Use MMIO for accessing RTC controller registers. > gPcAtChipsetPkgTokenSpaceGuid.PcdRtcUseMmio|TRUE > > - gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE > - > [PcdsFixedAtBuild.common] > gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F > > @@ -237,6 +235,8 @@ [PcdsDynamicDefault.common] > gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister64|0x0 > gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0 > > + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE > + > ################################################################################ > # > # Components Section - list of all EDK II Modules needed by this Platform > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >