From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mx.groups.io with SMTP id smtpd.web11.10543.1608300984606921061 for ; Fri, 18 Dec 2020 06:16:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=YbY6sQKo; spf=pass (domain: nuviainc.com, ip: 209.85.221.45, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f45.google.com with SMTP id 91so2335264wrj.7 for ; Fri, 18 Dec 2020 06:16:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GwRFmo4/T5ICL1ZEUaGBj6qGdgoVccPN5uClZ9xr0eo=; b=YbY6sQKo1plP1l0rrcjL9lJnOHx0tPU+g0Fax0prZtdJWeWz+E6AW1msBb2rOCApNJ 10WdTKojx6BkVaQJqU+ToeZCjqWLUe1KdbSHK5ucyhkRQiJBhEbptdO82vrPstHWkvWr uGQsHS1U5aqmcHfhdSXeg1lAt8Kbm3DB5P04COtac4VgDcNu3X6ZseTBX8BD3ujH1ODG h7DEyyfOMNszqO0n80/OST4dGGKvUpXVC/oeIsukXrSw0Drts+sk12kKawmR1QgUWhGD NLmim8xWsGrtgyCD5YghZ/jZCkw01Y5nqpFH/o7icxGIBu6jw6WpkrI+ZWdOaI+2Fzp/ brVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GwRFmo4/T5ICL1ZEUaGBj6qGdgoVccPN5uClZ9xr0eo=; b=kjoLyrTMdM/qnCJDqBHJuo3Jf+lXhvbyXj1dqIgieE/KvyOJI8pl2yE9HrHvlMf5mL UTZqVbvjXE2AVlcUAlpoXFaSwUaM45Nk8Ml5sYrZSZPrioEitmrglek2T0HDR9hkTjAO +CnweOg2gAPfMW2Gk0vQuLqznGvMOXCAHs1SbKG6bLJRAo4Et9zi7FjYSnLoMImHg/Q9 1SlKThqm8h9pjdP4PcSGkkQ7rcpFSMosaNkYQVY3D+QP8vy3MAaFueIO1f1wtu6A0Wqp yPRNJ8Eg9DsfyAloSlqpNRbhLtogUAeRmWFYjtwdg0ZZmmn0/r7DGZIsJP6E7MqQHzC4 IvOw== X-Gm-Message-State: AOAM531Zni3CHZS/GZtoqCOUh6qmkS4s2HPvOpkSzlr3989/ZergzO/P xKPqn4QkDp4Vuf7G5L/MPOkSfsAOis7rErwMqKAWyOsdi5uigiZ4WqrkU9B9GKb+mlCOr/wcn54 T/PfjGs21Xdv//C7mpLI4udUrY0WEmtA0MaAIAxkGfo1B0rQyaYu4pueyh5QbUVxRXQ== X-Google-Smtp-Source: ABdhPJynixOxqOZ0expNPY7AIwfAu016r3D0vZF8a7gkLE+SXq8T5ISdeJjBxiqXKO4A4R6/OPeq2w== X-Received: by 2002:adf:e84f:: with SMTP id d15mr4839967wrn.245.1608300982872; Fri, 18 Dec 2020 06:16:22 -0800 (PST) Return-Path: Received: from vanye.hemma.eciton.net (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id b12sm18558569wmj.2.2020.12.18.06.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 06:16:22 -0800 (PST) From: "Leif Lindholm" To: devel@edk2.groups.io Cc: Ard Biesheuvel Subject: [PATCH 5/9] ArmPkg: add ArmHasSecurityExtensions () helper function Date: Fri, 18 Dec 2020 14:16:13 +0000 Message-Id: <20201218141617.26947-6-leif@nuviainc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201218141617.26947-1-leif@nuviainc.com> References: <20201218141617.26947-1-leif@nuviainc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Create a helper function to eliminate direct feature register reading. Returns BOOLEAN True if the CPU implements the Security extensions, otherwise returns BOOL False. This function is only implemented for ARM, not AArch64. Cc: Ard Biesheuvel Signed-off-by: Leif Lindholm --- ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++ ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h index 8a364f2ca96f..c2ed72112b73 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -733,4 +733,21 @@ ArmHasGicSystemRegisters ( VOID ); +#ifdef MDE_CPU_ARM +/// +/// AArch32-only ID Register Helper functions +/// +/** + Check whether the CPU supports the Security extensions + + @return Whether the Security extensions are implemented + +**/ +BOOLEAN +EFIAPI +ArmHasSecurityExtensions ( + VOID + ); +#endif // MDE_CPU_ARM + #endif // __ARM_LIB__ diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c index 3faada3a6539..9f81a7223732 100644 --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c @@ -87,3 +87,18 @@ ArmHasGicSystemRegisters ( { return ((ArmReadIdPfr1 () & ARM_PFR1_GIC) != 0); } + +/** + Check whether the CPU supports the Security extensions + + @return Whether the Security extensions are implemented + +**/ +BOOLEAN +EFIAPI +ArmHasSecurityExtensions ( + VOID + ) +{ + return ((ArmReadIdPfr1 () & ARM_PFR1_SEC) != 0); +} -- 2.20.1