From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FE1BC4167B for ; Wed, 29 Nov 2023 12:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FNtZ6Cb/Vm4VTAyK9MekCw2A5pvdwmasesFbEEgGz9k=; b=1+annLutHEpb6oFKhxO98pRk0O zIXz9/bw+esms83j036tu7cnAhGzWN7EEBxHoLLGT8nuoCVoe+beCEHZNaiSuqKU2bh4p9eCn1aIh WnlXxQSFdudpv6LaTEn5BuOOy80Z/YxqXefjeR70LUQZNIZk+flLJqmc1PEIJC9nD8vBMBMRCqYgz 8rc4+62Vb3E6T/b/0d0uCFjlSEavT3R9bwS6A4uqveqR2ZjCZqRwUICarCLjghywjOOPe45iKtHsr 9cv7rn8AHMc8xELoS9W4oAJSpuHn16UaOnHNDnNYWXD1woPS6b0DqcMLG3KZyDrziCPWSOKunslDn vPI5O6fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Jip-008KNs-1T; Wed, 29 Nov 2023 12:31:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Iag-0080Fr-22 for linux-arm-kernel@bombadil.infradead.org; Wed, 29 Nov 2023 11:18:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0/Ere96t0JTzXLwcIaj5k4Yo7ZjrWBfOAf3a6ik+gYI=; b=ebKtkeY/dAy5MstfrQ9xcCLehs TuOE7xCDEhn634P0bNfRCvVqG3vE+ePX63kNbtkuFz0cVCeObH4vCSt0jsd8BoBlXsQqZRSnvcnUP M2Aeq+mcWu/QIDZYHtaer+rPL7ASlB5h1VFYNGn6XkuUrd+1iO1SLKSb4o2t3ygLBQXLsx3CbHLUU 6WCucp2k+c+Zr4Uj6AmSDqXbCWPw0az51FdfTPP5e2WUzqlo4578Qu/JPGlGtLmNd3EqDDk34CDj8 s4gDzjOUVnEBYuN+s28I8ibqM2nXhG29LWMVISug6YvMHAcSqK3BuGj4GV9MYepWDYWqP+gxecCJm XDH0MVzA==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8IaQ-000KDM-28 for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2023 11:18:48 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5d1b431fa7bso26289827b3.1 for ; Wed, 29 Nov 2023 03:18:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701256704; x=1701861504; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0/Ere96t0JTzXLwcIaj5k4Yo7ZjrWBfOAf3a6ik+gYI=; b=030sjXZLBZNxi6nv/nk6FJK/w5qubEwOs7XcNMTvDyZQEG1XpA925GTb7Kqg4OBcMV AQMpCnSfg1EgGfQhAGXEqLpkvpWU2U9s866+2bU8msx27U3tU3AULXAuohCwD8IZAqhZ Vy4vgKV12omSB2lR6TsGL6EadmTsxsgUB20+Bdfu8UNHw0/FDF84JmFs8q46vDKsGz0R 8GhCE3KH8zVlLQv7ko0tS5rS1gr8pmyhKlqwceK/edhEcEOpbVlaQGmueXv4FMvaBFEv /81GLbf992lAHqAFOX4c+KFQWBOpw5+uztHXjwDuvWeWvwSGcMiEgsXhK5C2PFkSrE96 oN+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701256704; x=1701861504; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0/Ere96t0JTzXLwcIaj5k4Yo7ZjrWBfOAf3a6ik+gYI=; b=pWPbVy7PnvTyoK/WG+vKdpds7e7iIY4N5mblQnRUm/l5cCP/KoKjIU+CBS3fJVTq8G LyK0Op7qsCQq1DyFsAHn3GztfzBxBoLiD4X5Zfz9w8y+IM2zI/0YFJrbdazRezPKa9MR WtA7QYFeTgrxeoMRIiQx21o4BIgc9HtAsitLLAJ4RrmRKFjhSQI/0lbvaMqEvmiszAhw u/JVlJWxhyYuJCKx8cYdFYpLh0weFHhumUNQgn5ZBrh2KfnrnoN3QrOju9Zub1KqUji4 mIBRGeVw/PM0KicZRWjseSj1/RYuZSleLLBZAYaHV97nfFI2LMVcIAwAV2dkfWk1L47O Dveg== X-Gm-Message-State: AOJu0YywMlQBtFD7TI1Dj4x2hqrgAdMdgypF9gBzYnKZNtPftH26aPje neJ8H5Ts2FYRR8FpO837VCTAWC+983dS0uu43Ifn7UoUf3n9h22+o8yGHPGMK1Ga9UMDE20zvbQ lTpz/+IL5i2lFPGIp1IEV1Mj6ycf+oMOaMEeLEX4pN/gTOwATo5GROBofIHcVWtWU3ZN7IiWopb E= X-Google-Smtp-Source: AGHT+IFGc5uafEBfzcU4GaBENTYt8a795NVZcQYWpTcnni1kcYUXw6pJ8z4F08ROf8DN5yTT+foz7CXl X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:690c:3183:b0:5cc:412c:27c7 with SMTP id fd3-20020a05690c318300b005cc412c27c7mr567356ywb.5.1701256704653; Wed, 29 Nov 2023 03:18:24 -0800 (PST) Date: Wed, 29 Nov 2023 12:16:26 +0100 In-Reply-To: <20231129111555.3594833-43-ardb@google.com> Mime-Version: 1.0 References: <20231129111555.3594833-43-ardb@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1680; i=ardb@kernel.org; h=from:subject; bh=qAaNfPlFENJ/3a14Pv6raxoS+2zPqpfKUx9z0oWZolE=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JITVdtm/horQ/G1jLxR1+3riaG+agU3HxINtsr4/3ZzTap RyNyq3sKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABOZ+oqRYUvsx4XCF1WcWHY9 36SkueiC8fwVP032cCiV/7vPb/omzJmR4daZw9Zuake52Ky+ThNZ8Cat1/SLmmmSyaM/FxdbLi8 KZwEA X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231129111555.3594833-73-ardb@google.com> Subject: [PATCH v6 30/41] arm64: Add helpers to probe local CPU for PAC and BTI support From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_111840_320019_92ABBDE6 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ard Biesheuvel Add some helpers that will be used by the early kernel mapping code to check feature support on the local CPU. This permits the early kernel mapping to be created with the right attributes, removing the need for tearing it down and recreating it. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/cpufeature.h | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 5e71d5ebe918..33b7749313c5 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -957,6 +957,38 @@ static inline bool kaslr_disabled_cmdline(void) u32 get_kvm_ipa_limit(void); void dump_cpu_features(void); +static inline bool cpu_has_bti(void) +{ + if (!IS_ENABLED(CONFIG_ARM64_BTI)) + return false; + + return arm64_apply_feature_override(read_cpuid(ID_AA64PFR1_EL1), + ID_AA64PFR1_EL1_BT_SHIFT, 4, + &id_aa64pfr1_override); +} + +static inline bool cpu_has_pac(void) +{ + u64 isar1, isar2; + + if (!IS_ENABLED(CONFIG_ARM64_PTR_AUTH)) + return false; + + isar1 = read_cpuid(ID_AA64ISAR1_EL1); + isar2 = read_cpuid(ID_AA64ISAR2_EL1); + + if (arm64_apply_feature_override(isar1, ID_AA64ISAR1_EL1_APA_SHIFT, 4, + &id_aa64isar1_override)) + return true; + + if (arm64_apply_feature_override(isar1, ID_AA64ISAR1_EL1_API_SHIFT, 4, + &id_aa64isar1_override)) + return true; + + return arm64_apply_feature_override(isar2, ID_AA64ISAR2_EL1_APA3_SHIFT, 4, + &id_aa64isar2_override); +} + #endif /* __ASSEMBLY__ */ #endif -- 2.43.0.rc1.413.gea7ed67945-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel