From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7142A7803DE for ; Wed, 20 Sep 2023 12:39:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2Fw4QJy1VrdzXgNb5k4fxzivx+WtNxqikDSbN+0UqP8=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1695213584; v=1; b=oJJmkWxs4z3eueVzYAUFu+Fb4w62CaFLvG/hmXKOPHMFG4h2u/GPvBmZQEREGTGRIxzgOYAy av0H202cm9IwzLlqZgshGVGzTc67LEGdxFV3lDGTICmFNVQT3jHwaaa6cLHZWWKQnw55qvEkHAf r9+Q0BU4fpF/G7tvDw5/YKH8= X-Received: by 127.0.0.2 with SMTP id OquTYY7687511xW8fs4Ifoop; Wed, 20 Sep 2023 05:39:44 -0700 X-Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by mx.groups.io with SMTP id smtpd.web10.37510.1695213583292501025 for ; Wed, 20 Sep 2023 05:39:43 -0700 X-Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38KBOsja003236; Wed, 20 Sep 2023 12:39:39 GMT X-Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t7r8w11s5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 12:39:39 +0000 X-Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38KCdcTq019480 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 12:39:38 GMT X-Received: from qc-i7.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Wed, 20 Sep 2023 05:39:36 -0700 From: "Leif Lindholm" To: CC: Ard Biesheuvel , Sami Mujawar , Marcin Juszkiewicz Subject: [edk2-devel] [PATCH 1/1] ArmPkg/ArmLib: Add ArmHasVhe () helper function Date: Wed, 20 Sep 2023 13:39:28 +0100 Message-ID: <20230920123928.274026-1-quic_llindhol@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-GUID: 2x4YhoBeZgmk3LDyBBGSpYmri0Rb-E5O X-Proofpoint-ORIG-GUID: 2x4YhoBeZgmk3LDyBBGSpYmri0Rb-E5O 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 Reply-To: devel@edk2.groups.io,quic_llindhol@quicinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 0EcsouyhyoO6T5bXXos7Is3Yx7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=oJJmkWxs; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=quicinc.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Create a helper function to query whether ID_AA64MFR1_EL1 indicates presence of the Virtualization Host Extensions. This feature is only visible in AARCH64 state. Signed-off-by: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Marcin Juszkiewicz --- ArmPkg/Include/Chipset/AArch64.h | 3 +++ ArmPkg/Include/Library/ArmLib.h | 18 ++++++++++++++++++ ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 15 +++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/ArmPkg/Include/Chipset/AArch64.h b/ArmPkg/Include/Chipset/AArch64.h index 690433f68ec8..2e87917049f9 100644 --- a/ArmPkg/Include/Chipset/AArch64.h +++ b/ArmPkg/Include/Chipset/AArch64.h @@ -24,6 +24,9 @@ // Coprocessor Trap Register (CPTR) #define AARCH64_CPTR_TFP (1 << 10) +// ID_AA64MMFR1 - AArch64 Memory Model Feature Register 0 definitions +#define AARCH64_MMFR1_VH (0xF << 8) + // ID_AA64PFR0 - AArch64 Processor Feature Register 0 definitions #define AARCH64_PFR0_FP (0xF << 16) #define AARCH64_PFR0_GIC (0xF << 24) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h index 6c5315d7f45f..0169dbc1092c 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -764,6 +764,24 @@ ArmHasCcidx ( VOID ); +#ifdef MDE_CPU_AARCH64 +/// +/// AArch64-only ID Register Helper functions +/// + +/** + Checks whether the CPU implements the Virtualization Host Extensions. + + @retval TRUE FEAT_VHE is implemented. + @retval FALSE FEAT_VHE is not mplemented. +**/ +BOOLEAN +EFIAPI +ArmHasVhe ( + VOID + ); +#endif // MDE_CPU_AARCH64 + #ifdef MDE_CPU_ARM /// /// AArch32-only ID Register Helper functions diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c index 7ab28e3e05fe..da5755106e62 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c @@ -104,3 +104,18 @@ ArmHasCcidx ( Mmfr2 = ArmReadIdAA64Mmfr2 (); return (((Mmfr2 >> 20) & 0xF) == 1) ? TRUE : FALSE; } + +/** + Checks whether the CPU implements the Virtualization Host Extensions. + + @retval TRUE FEAT_VHE is implemented. + @retval FALSE FEAT_VHE is not mplemented. +**/ +BOOLEAN +EFIAPI +ArmHasVhe ( + VOID + ) +{ + return ((ArmReadIdAA64Mmfr1 () & AARCH64_MMFR1_VH) != 0); +} -- 2.30.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108909): https://edk2.groups.io/g/devel/message/108909 Mute This Topic: https://groups.io/mt/101477322/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-