From: James Morse <james.morse@arm•com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix•de>,
kvmarm@lists•cs.columbia.edu,
linux-arm-kernel@lists•infradead.org
Cc: Suzuki K Poulose <suzuki.poulose@arm•com>,
Catalin Marinas <catalin.marinas@arm•com>,
Marc Zyngier <maz@kernel•org>,
Thomas Gleixner <tglx@linutronix•de>,
Will Deacon <will@kernel•org>,
Julien Thierry <julien.thierry.kdev@gmail•com>
Subject: Re: [PATCH] arm64: KVM: Invoke compute_layout() before alternatives are applied
Date: Thu, 17 Oct 2019 18:41:35 +0100 [thread overview]
Message-ID: <ecfbb413-e97e-c3eb-e051-1f218b387edd@arm.com> (raw)
In-Reply-To: <20191016165953.o6ogh4fdmsjmd2sw@linutronix.de>
Hi Sebastian,
On 16/10/2019 17:59, Sebastian Andrzej Siewior wrote:
> compute_layout() is invoked as part of an alternative fixup under
> stop_machine(). This function invokes get_random_long() which acquires a
> sleeping lock on -RT which can not be acquired in this context.
> Rename compute_layout() to kvm_compute_layout() and invoke it before
> stop_machines() invokes the fixups.
Nit: stop_machine() applies the alternatives.
> Add a __init prefix to
> kvm_compute_layout() because the caller has it, too (and so the code can
> be discarded after boot).
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index b9f8d787eea9f..7532f044d713b 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -35,6 +35,12 @@ void apply_alternatives_module(void *start, size_t length);
> static inline void apply_alternatives_module(void *start, size_t length) { }
> #endif
>
> +#ifdef CONFIG_KVM_ARM_HOST
> +void kvm_compute_layout(void);
> +#else
> +static inline void kvm_compute_layout(void) { }
> +#endif
I don't think alternative.h is where this belongs... Could you move it to kvm_mmu.h, which
is where the kvm_update_va_mask macro that depends on it lives.
You can avoid the #ifdef if you use if(IS_ENABLED()) in the caller.
This has the advantage that the compiler will catch invalid C regardless of the build
options. (and its easier on the eye)
> diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
> index d1757ef1b1e74..c28652ee06f64 100644
> --- a/arch/arm64/kernel/alternative.c
> +++ b/arch/arm64/kernel/alternative.c
> @@ -238,6 +238,7 @@ static int __apply_alternatives_multi_stop(void *unused)
> void __init apply_alternatives_all(void)
> {
> /* better not try code patching on a live SMP system */
> + kvm_compute_layout();
> stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask);
> }
This is a funny place to do this kvm check, its not needed to apply the alternatives.
apply_alternatives_all() is only called from smp_cpus_done(), immediately before it calls
hyp_mode_check(), could we move it there to live with the 'started at EL2' message?
(to save you battling the header-jungle: To include asm/kvm_mmu.h, you need to include
linux/kvm_host.h first)
We end up calling it unconditionally, but I don't think that matters, both callers do the
right thing.
With that:
Reviewed-by: James Morse <james.morse@arm•com>
Thanks,
James
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-17 17:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 16:59 [PATCH] arm64: KVM: Invoke compute_layout() before alternatives are applied Sebastian Andrzej Siewior
2019-10-17 17:41 ` James Morse [this message]
2019-11-28 19:58 ` [PATCH v2] " Sebastian Andrzej Siewior
2019-12-06 11:22 ` Marc Zyngier
2019-12-06 11:46 ` Catalin Marinas
2019-12-06 11:57 ` Catalin Marinas
2019-12-06 12:12 ` Marc Zyngier
2019-12-06 12:21 ` Catalin Marinas
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=ecfbb413-e97e-c3eb-e051-1f218b387edd@arm.com \
--to=james.morse@arm$(echo .)com \
--cc=bigeasy@linutronix$(echo .)de \
--cc=catalin.marinas@arm$(echo .)com \
--cc=julien.thierry.kdev@gmail$(echo .)com \
--cc=kvmarm@lists$(echo .)cs.columbia.edu \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=maz@kernel$(echo .)org \
--cc=suzuki.poulose@arm$(echo .)com \
--cc=tglx@linutronix$(echo .)de \
--cc=will@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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