Re: [RFC][PATCH 07/17] x86/cpu/kvm: Provide UNTRAIN_RET_VM

From: Josh Poimboeuf
Date: Wed Aug 09 2023 - 09:50:14 EST


On Wed, Aug 09, 2023 at 09:12:25AM +0200, Peter Zijlstra wrote:
> With the difference being that UNTRAIN_RET_VM uses
> X86_FEATURE_IBPB_ON_VMEXIT instead of X86_FEATURE_ENTRY_IBPB.
>
> This cures VMEXIT doing potentially unret+IBPB or double IBPB.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> arch/x86/include/asm/nospec-branch.h | 11 +++++++++++
> arch/x86/kernel/cpu/bugs.c | 17 ++++++++++++++++-
> arch/x86/kvm/svm/vmenter.S | 7 ++-----
> 3 files changed, 29 insertions(+), 6 deletions(-)
>
> --- a/arch/x86/include/asm/nospec-branch.h
> +++ b/arch/x86/include/asm/nospec-branch.h
> @@ -299,6 +299,17 @@
> #endif
> .endm
>
> +.macro UNTRAIN_RET_VM
> +#if defined(CONFIG_CPU_UNRET_ENTRY) || defined(CONFIG_CPU_IBPB_ENTRY) || \
> + defined(CONFIG_CALL_DEPTH_TRACKING) || defined(CONFIG_CPU_SRSO)

Maybe can be simplified?

#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY)

--
Josh