Message ID | 20240214122845.2033971-58-ardb+git@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 AA4C2C48BEE for <linux-arm-kernel@archiver.kernel.org>; Wed, 14 Feb 2024 13:30:57 +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=bFTsK6qs13KIvoKErUQ2aggD3PatFBclPSCOlLwUS7Q=; b=0KIXogTd97HcGRbAOzagdKjLkt Vgt5zB3Yrjctpp7je6kJUprKV+M2bMGrwnEAU/Ba1JlU3TY+8UW2G+QNZ5tMYGg1jxrBgcd/krsS+ 80Up/eu/QW0nW0eFd36zefd916jO1f6rcOVFDIoi4lVlNWLYoogf3Lbm7qe71rwUvJR0BiXMeyA3z iNoae5lWCT+5wazKg35r74eH3sXGep79kvpCbuptX0dNRcayNNSNcLM7tOv2qqSzE4ls8Td0w9ngd iAG0STg+Mvhq59LrhP4FRQfDAOvSEguSL6fnNP6EbPn4z+3CQytPQeWfFzK4h1WB2ynFkXNUia6MP 8DRlrmvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raFLb-0000000D1lw-0m9U; Wed, 14 Feb 2024 13:30:47 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raEOv-0000000CoQy-3cFE for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 12:30:13 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-607ac7dbd61so5953437b3.3 for <linux-arm-kernel@lists.infradead.org>; Wed, 14 Feb 2024 04:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707913808; x=1708518608; 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=wQr7EbRosa58dp4pneKL9GcaOGkXWnBFM1NcrTS6enM=; b=PcaTWhwnRjPuRnmKOSzlb9L37W/lZRsEPqPhF/icfq1SXJiJrnn1rE7kRedZzoX5yg iByO/ndXmL0Nh3tRXnFSK3meAOFtfij+Ahsx5ecHaS7sVWgGoxQlVIy0UA2lmcc17Lli yPEWIHzWVTKNK0EkpczxXcq6fE/emjX/SsfWt6XyCsZme/FBRkNd+78Ns2AHmhE9uCpg ns2LGEDk7wEnB6Bb8YbHfJTkxC0LrF65HBccuMrNjV9l7NYk9zNsJHd70mU034BJwvV/ h9uu8N7y0I69SQN8wInsD3li7GieBiP5DDxkDes+TgrzJ40a7fxJV6G+gPXb4x1ByYdr 8neg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707913808; x=1708518608; 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=wQr7EbRosa58dp4pneKL9GcaOGkXWnBFM1NcrTS6enM=; b=AlJA1WORCc3mguqbmgak4RMnH3eIQrSltHZnTXqg7Vu655So2tpiJ4AGZzc9kLi2Q5 MwLMa+Q8Wf26fD5jBrU4QgeoPeNHGsyxmgFJSSLwPAa9aK6Oer0e/O401pEQtQ5GqVpC gw7xVjgVGKVab1XNhhxefczXpV/CvZlBBsrLxfEmH8d4mv7HZMZ4mciiQkEcS20+e5VP eLsinN2R+yJpwid77AF+/a/+Nt5h/Xwb+QwzJBIj5HWF5LtH5bh2gf3VUFP44bsPn5Eu caiUsv6Waa/jkzDoFrSZZBGrKt6GtafQzn0zsKBFhB+wzHTd/xC+iH5AXjaBO/5U9pfz Dzdw== X-Gm-Message-State: AOJu0YxzRgcgItm+k471RNNojeWlD5Qcczxm8E17lAzDvwOtEpBhwVxw Axf7ED9EULK+qghabvLJ3EnlbZ6t8dkA7vtl0m2PZ4DaiA9Qcqh9efoQkdI7M9pIYNPUcxcSVpi MJJGp2TsZLnkSZnlsZvpCP8x5z5MqixKzDCnXBezY7JJkzw33AprtrocSu7y68hP6o+jjGtyr0B WShQTIXUDVtSdvDs9jCYxusl0tKGxDaYTsQW+IA+np X-Google-Smtp-Source: AGHT+IHfQS9Iqrj2kyhGmJ5mSO7uOD4TZT+0YyPOijnEzex6HZABST7GHhZ0ARcvxWhQKZMEYk9SvpeP X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:4b0:b0:dc7:865b:22c6 with SMTP id r16-20020a05690204b000b00dc7865b22c6mr66609ybs.8.1707913808067; Wed, 14 Feb 2024 04:30:08 -0800 (PST) Date: Wed, 14 Feb 2024 13:28:59 +0100 In-Reply-To: <20240214122845.2033971-45-ardb+git@google.com> Mime-Version: 1.0 References: <20240214122845.2033971-45-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1676; i=ardb@kernel.org; h=from:subject; bh=5qdPvoVrtwaUhGBvnLf1VQ9UAGDdk5pMw1SfLLPmHgI=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIfXMJp6+5TH/UzZ9mV+nZ5JU2vX0/7Gpn+Qlj/qsz7psv K5R4f29jlIWBjEOBlkxRRaB2X/f7Tw9UarWeZYszBxWJpAhDFycAjCR61GMDIv4TT6v1erKmucy LevKLDVuy7XpNZExjz4Xb1HkMdyyIJuR4fafFv5QVWt37r2Sem9uaFdtdpvTomzWmJT31OqP53Z /JgA= X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214122845.2033971-58-ardb+git@google.com> Subject: [PATCH v8 13/43] arm64: Add helpers to probe local CPU for PAC and BTI support From: Ard Biesheuvel <ardb+git@google.com> To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel <ardb@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Ryan Roberts <ryan.roberts@arm.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Kees Cook <keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_043010_187805_488DC594 X-CRM114-Status: GOOD ( 12.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
arm64: Add support for LPA2 and WXN at stage 1
|
expand
|
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 03c34242bfc7..e3edae1825f3 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -963,6 +963,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