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 3F046740049 for ; Wed, 20 Sep 2023 13:51:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=EBgpYUklflp2EU+yUH5h9JLmDaxENEepl5UP0fBxbrs=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:Organization:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1695217887; v=1; b=o/d8TX3S1mhEiCWoRbuAm9+SwN5ugXcTtz/JmRkhnzebHqzfdhgZTVvUGf3E5qlDDntVH1cU kdJj2tosJz388TnjbSjT+sPkyEQsEnYbifiV8BF+q9JqKNECdkQFo7Bpk5jLCxTSTz9praRZeME tN/BC2Q9VCxzTEQWeYbFCgMY= X-Received: by 127.0.0.2 with SMTP id kf7qYY7687511xTJT6cW039Z; Wed, 20 Sep 2023 06:51:27 -0700 X-Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by mx.groups.io with SMTP id smtpd.web11.40209.1695217886494650000 for ; Wed, 20 Sep 2023 06:51:26 -0700 X-Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-503012f4e71so1142238e87.0 for ; Wed, 20 Sep 2023 06:51:26 -0700 (PDT) X-Gm-Message-State: 13pcx8RsbARYa05lg5O8d41Cx7686176AA= X-Google-Smtp-Source: AGHT+IE+EYhieKoSX3riIfxEOMZq1o1jEb20crn+hSLpYqgmKtqSCjrd/V+wliB9P2/LuPSFHvGUsQ== X-Received: by 2002:a2e:9182:0:b0:2c0:8fe:95b1 with SMTP id f2-20020a2e9182000000b002c008fe95b1mr1065109ljg.21.1695217884681; Wed, 20 Sep 2023 06:51:24 -0700 (PDT) X-Received: from [192.168.200.206] (83.11.3.58.ipv4.supernova.orange.pl. [83.11.3.58]) by smtp.gmail.com with ESMTPSA id l22-20020a2e8696000000b002c02cf6cac5sm748952lji.83.2023.09.20.06.51.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Sep 2023 06:51:24 -0700 (PDT) Message-ID: Date: Wed, 20 Sep 2023 15:51:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH 1/1] ArmPkg/ArmLib: Add ArmHasVhe () helper function To: Leif Lindholm , devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar References: <20230920123928.274026-1-quic_llindhol@quicinc.com> From: "Marcin Juszkiewicz" Organization: Linaro In-Reply-To: <20230920123928.274026-1-quic_llindhol@quicinc.com> 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,marcin.juszkiewicz@linaro.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Language: pl-PL, en-GB, en-HK Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="o/d8TX3S"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linaro.org (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 W dniu 20.09.2023 o 14:39, Leif Lindholm pisze: > 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 Tested-by: Marcin Juszkiewicz GTDT for SBSA Reference Platform will use it for NS EL2 virtual timer: default: Virtual EL2 Timer GSIV : 0x1C Virtual EL2 Timer Flags : 0x6 non-vhe cpu: Virtual EL2 Timer GSIV : 0x0 Virtual EL2 Timer Flags : 0x0 > --- > 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); > +} -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108911): https://edk2.groups.io/g/devel/message/108911 Mute This Topic: https://groups.io/mt/101477322/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-