blob: 80ab9be96e06e5927b1522515195e957f08e3270 [file] [log] [blame]
/*************************************************************************/ /*!
@Title Macro to limit CPU speculative execution in kernel code
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Per-version macros to allow code to seamlessly use older kernel
@License MIT
The contents of this file are subject to the MIT license as set out below.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /**************************************************************************/
#ifndef __KERNEL_NOSPEC_H__
#define __KERNEL_NOSPEC_H__
#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 2) || \
(LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) && \
LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 18)) || \
(LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) && \
LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 81)) || \
(LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) && \
LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 118)))
#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/nospec.h>
#else
#define array_index_nospec(index, size) (index)
#endif
/*
* For Ubuntu kernels, the features available for a given Linux version code
* may not match those in upstream kernels. This is the case for the
* availability of the array_index_nospec macro.
*/
#if !defined(array_index_nospec)
#define array_index_nospec(index, size) (index)
#endif
#endif /* __KERNEL_NOSPEC_H__ */