On 2/22/19 14:17, Jan Beulich wrote: >>>> On 21.02.19 at 09:16, <nmant...@amazon.de> wrote: >> --- /dev/null >> +++ b/xen/include/asm-x86/nospec.h >> @@ -0,0 +1,38 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. >> */ >> + >> +#ifndef _ASM_X86_NOSPEC_H >> +#define _ASM_X86_NOSPEC_H >> + >> +#include <asm/alternative.h> >> + >> +/* Allow to insert a read memory barrier into conditionals */ >> +static always_inline bool barrier_nospec_true(void) >> +{ >> +#ifdef CONFIG_HVM >> + alternative("", "lfence", X86_FEATURE_SC_L1TF_VULN); >> +#endif >> + return true; >> +} >> + >> +/* Allow to protect evaluation of conditionasl with respect to speculation >> */ >> +#ifdef CONFIG_HVM >> +#define evaluate_nospec(condition) \ >> + ((condition) ? barrier_nospec_true() : !barrier_nospec_true()) >> +#else >> +#define evaluate_nospec(condition) (condition) >> +#endif >> + >> +/* Allow to block speculative execution in generic code */ >> +#define block_speculation() ((void)barrier_nospec_true()) > Seeing Julien's request for switching to inline functions on the Arm side, > is there anything preventing these two to become inline functions too?
No, there is nothing preventing using functions here. I mostly copied the macro style from other nospec constructs. I tested the generated binary for the functions being always_inline, and the result is the same as when using macros. I will turn the macros into functions that use the always_inline keyword, as there have been problems with the barrier_nospec_true function when not using always_inline. Best, Norbert Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich Ust-ID: DE 289 237 879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel