From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 98E61941109 for ; Fri, 24 May 2024 05:45:35 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Cj9iRbZveVcZwm0w2NBagphM7KVqZfOlE4rQH2g45dE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1716529534; v=1; b=LOlOI4qkqg1lQO2DCZijgbTSydVof0Wk4ypNzSYgwPVI0NjdAlKB93zrLqjyGgQp0uEYQd6I fkIxjxNMU0rxFEO+8iL91Xvnnrtyuodbscg0Cuf2O+cPh0IjNJTb12bZI2XY3djJjEnETwHyDzh OeEhXKF+P+5u7c0ImPc/Mdz83FifIrUeMcAvWAY3UMACR396dcsKeAjfWF902Tw3PLNrQ+AzOZ4 itdxs/6vuva4qQt8RMLQ8LGuOkO6dRSSjSNQnFloQ7DyDbHt39duk90cH31zrpzJLJH2Z5cyJ/l I/8Oa7EwFROxcMLUIAL6LjHWLh0ZuL6kFiEnt7/81kNiw== X-Received: by 127.0.0.2 with SMTP id O0lRYY7687511xOezrCF13YW; Thu, 23 May 2024 22:45:34 -0700 X-Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mx.groups.io with SMTP id smtpd.web11.9357.1716529532170590856 for ; Thu, 23 May 2024 22:45:32 -0700 X-Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6f8ec7e054bso493193b3a.3 for ; Thu, 23 May 2024 22:45:32 -0700 (PDT) X-Gm-Message-State: WzivDOY6LJLMJGGSV06PHGLpx7686176AA= X-Google-Smtp-Source: AGHT+IEsfTGHdbQLvVHrD96eZno7AjHIxZahnE9fkRP2skPM/cbAO6Eu3B2T5ssY8JG0X21WITr2LQ== X-Received: by 2002:a05:6a00:e87:b0:6f4:41f2:b869 with SMTP id d2e1a72fcca58-6f8f42b30d0mr1159454b3a.21.1716529531448; Thu, 23 May 2024 22:45:31 -0700 (PDT) X-Received: from localhost.localdomain (c-67-160-15-86.hsd1.wa.comcast.net. [67.160.15.86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fcfe64a4sm471919b3a.158.2024.05.23.22.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 22:45:31 -0700 (PDT) From: "Doug Flick via groups.io" X-Google-Original-From: Flickdm To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v3 18/20] ArmVirtPkg: Use dynamic PCD to set the SMCCC conduit Date: Thu, 23 May 2024 22:45:10 -0700 Message-Id: <20240524054512.523329-19-douglas.flick@microsoft.com> In-Reply-To: <20240524054512.523329-1-douglas.flick@microsoft.com> References: <20240524054512.523329-1-douglas.flick@microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 23 May 2024 22:45:32 -0700 Resent-From: dougflick@microsoft.com Reply-To: devel@edk2.groups.io,dougflick@microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=LOlOI4qk; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io From: Ard Biesheuvel On ARM systems, whether SMC or HVC instructions need to be used to issue monitor calls is typically dependent on the exception level, but there are also cases where EL1 might use SMC instructions, so there is no hard and fast rule. For ArmVirtQemu, this does depend strictly on the exception level, so set the default to HVC (for EL1 execution) and override it to SMC when booted at EL2. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Sami Mujawar Cc: Gerd Hoffmann Committed-by: Ard Biesheuvel Signed-off-by: Doug Flick [MSFT] --- ArmVirtPkg/ArmVirtCloudHv.dsc | 3 +++ ArmVirtPkg/ArmVirtQemu.dsc | 4 ++++ ArmVirtPkg/ArmVirtQemuKernel.dsc | 2 ++ ArmVirtPkg/ArmVirtXen.dsc | 2 ++ ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf | 1 + ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 14 ++++++++++++++ 6 files changed, 26 insertions(+) diff --git a/ArmVirtPkg/ArmVirtCloudHv.dsc b/ArmVirtPkg/ArmVirtCloudHv.dsc index 5cb2a609b1..d5055a0341 100644 --- a/ArmVirtPkg/ArmVirtCloudHv.dsc +++ b/ArmVirtPkg/ArmVirtCloudHv.dsc @@ -201,6 +201,9 @@ [PcdsDynamicHii]=0D gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gOvmfVariableGu= id|0x0|FALSE|NV,BS=0D =0D +[PcdsPatchableInModule.common]=0D + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE=0D +=0D ##########################################################################= ######=0D #=0D # Components Section - list of all EDK II Modules needed by this Platform= =0D diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 4498ca58a8..80dd4fbb14 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -293,6 +293,10 @@ gEfiNetworkPkgTokenSpaceGuid.PcdIPv4PXESupport|0x01=0D gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01=0D =0D + # whether to use HVC or SMC to issue monitor calls - this typically depe= nds=0D + # on the exception level at which the UEFI system firmware executes=0D + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE=0D +=0D #=0D # TPM2 support=0D #=0D diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index 94f48593c2..2700b97d09 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -203,6 +203,8 @@ gArmTokenSpaceGuid.PcdFdBaseAddress|0x0=0D gArmTokenSpaceGuid.PcdFvBaseAddress|0x0=0D =0D + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE=0D +=0D [PcdsDynamicDefault.common]=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3=0D =0D diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index 5809832e66..ceb37f8a2d 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -120,6 +120,8 @@ gArmTokenSpaceGuid.PcdFdBaseAddress|0x0=0D gArmTokenSpaceGuid.PcdFvBaseAddress|0x0=0D =0D + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE=0D +=0D [PcdsDynamicDefault.common]=0D =0D gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0=0D diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmVirt= Pkg/Library/PlatformPeiLib/PlatformPeiLib.inf index e9a34b6e2e..a38b89c103 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -45,6 +45,7 @@ =0D [Pcd]=0D gArmTokenSpaceGuid.PcdFvBaseAddress=0D + gArmTokenSpaceGuid.PcdMonitorConduitHvc=0D gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress ## SOMETIMES= _PRODUCES=0D gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress=0D =0D diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPk= g/Library/PlatformPeiLib/PlatformPeiLib.c index 7ab4aa2d6b..b8e9208301 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -18,6 +18,8 @@ #include =0D #include =0D =0D +#include =0D +=0D #include =0D #include =0D =0D @@ -224,5 +226,17 @@ PlatformPeim ( =0D BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize));=0D =0D + #ifdef MDE_CPU_AARCH64=0D + //=0D + // Set the SMCCC conduit to SMC if executing at EL2, which is typically = the=0D + // exception level that services HVCs rather than the one that invokes t= hem.=0D + //=0D + if (ArmReadCurrentEL () =3D=3D AARCH64_EL2) {=0D + Status =3D PcdSetBoolS (PcdMonitorConduitHvc, FALSE);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D +=0D + #endif=0D +=0D return EFI_SUCCESS;=0D }=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119245): https://edk2.groups.io/g/devel/message/119245 Mute This Topic: https://groups.io/mt/106276870/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-