linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 1/3] arm64: Factor out checks for KASLR in KPTI code into separate function
Date: Fri, 18 Oct 2019 13:01:02 +0100	[thread overview]
Message-ID: <20191018120102.GA55431@arrakis.emea.arm.com> (raw)
In-Reply-To: <20191016151421.27708-2-broonie@kernel.org>

On Wed, Oct 16, 2019 at 04:14:19PM +0100, Mark Brown wrote:
> +static inline bool arm64_kernel_use_ng_mappings(void)
> +{
>  	/* What's a kpti? Use global mappings if we don't know. */
>  	if (!IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0))
>  		return false;
> @@ -52,29 +79,21 @@ static inline bool arm64_kernel_use_ng_mappings(void)
>  	if (arm64_kernel_unmapped_at_el0())
>  		return true;
>  
> -	if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
> +	/*
> +	 * Once we are far enough into boot for capabilities to be
> +	 * ready we will have confirmed if we are using non-global
> +	 * mappings so don't need to consider anything else here.
> +	 */
> +	if (static_branch_likely(&arm64_const_caps_ready))
>  		return false;
>  
>  	/*
>  	 * KASLR is enabled so we're going to be enabling kpti on non-broken
>  	 * CPUs regardless of their susceptibility to Meltdown. Rather
>  	 * than force everybody to go through the G -> nG dance later on,
> -	 * just put down non-global mappings from the beginning.
> +	 * just put down non-global mappings from the beginning
>  	 */
> -	if (!IS_ENABLED(CONFIG_CAVIUM_ERRATUM_27456)) {
> -		tx1_bug = false;
> -#ifndef MODULE
> -	} else if (!static_branch_likely(&arm64_const_caps_ready)) {
> -		extern const struct midr_range cavium_erratum_27456_cpus[];
> -
> -		tx1_bug = is_midr_in_range_list(read_cpuid_id(),
> -						cavium_erratum_27456_cpus);
> -#endif
> -	} else {
> -		tx1_bug = __cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456);
> -	}
> -
> -	return !tx1_bug && kaslr_offset() > 0;
> +	return kaslr_requires_kpti();
>  }

While that's a step in the right direction, I'd like to see
{PTE,PMD}_MAYBE_NG move away from the current use of
arm64_kernel_use_ng_mappings(). These macros are used during early
during boot and we seem to rely on cpu_hwcaps not being populated yet
(arm64_kernel_unmapped_at_el0() checking it via cpus_have_const_cap()).

Could we have a global variable (boot or a pgtable attr type) which we
populate during early boot and subsequently use in the PTE_MAYBE_NG
macro?

Thanks.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-10-18 12:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 15:14 [PATCH v3 0/3] arm64: E0PD support Mark Brown
2019-10-16 15:14 ` [PATCH v3 1/3] arm64: Factor out checks for KASLR in KPTI code into separate function Mark Brown
2019-10-16 15:19   ` Mark Brown
2019-10-18 12:01   ` Catalin Marinas [this message]
2019-10-18 12:22     ` Mark Brown
2019-10-16 15:14 ` [PATCH v3 2/3] arm64: Add initial support for E0PD Mark Brown
2019-10-16 15:14 ` [PATCH v3 3/3] arm64: Don't use KPTI where we have E0PD Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191018120102.GA55431@arrakis.emea.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).