cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

isolation.h (1475B)


      1#ifndef _LINUX_SCHED_ISOLATION_H
      2#define _LINUX_SCHED_ISOLATION_H
      3
      4#include <linux/cpumask.h>
      5#include <linux/init.h>
      6#include <linux/tick.h>
      7
      8enum hk_type {
      9	HK_TYPE_TIMER,
     10	HK_TYPE_RCU,
     11	HK_TYPE_MISC,
     12	HK_TYPE_SCHED,
     13	HK_TYPE_TICK,
     14	HK_TYPE_DOMAIN,
     15	HK_TYPE_WQ,
     16	HK_TYPE_MANAGED_IRQ,
     17	HK_TYPE_KTHREAD,
     18	HK_TYPE_MAX
     19};
     20
     21#ifdef CONFIG_CPU_ISOLATION
     22DECLARE_STATIC_KEY_FALSE(housekeeping_overridden);
     23extern int housekeeping_any_cpu(enum hk_type type);
     24extern const struct cpumask *housekeeping_cpumask(enum hk_type type);
     25extern bool housekeeping_enabled(enum hk_type type);
     26extern void housekeeping_affine(struct task_struct *t, enum hk_type type);
     27extern bool housekeeping_test_cpu(int cpu, enum hk_type type);
     28extern void __init housekeeping_init(void);
     29
     30#else
     31
     32static inline int housekeeping_any_cpu(enum hk_type type)
     33{
     34	return smp_processor_id();
     35}
     36
     37static inline const struct cpumask *housekeeping_cpumask(enum hk_type type)
     38{
     39	return cpu_possible_mask;
     40}
     41
     42static inline bool housekeeping_enabled(enum hk_type type)
     43{
     44	return false;
     45}
     46
     47static inline void housekeeping_affine(struct task_struct *t,
     48				       enum hk_type type) { }
     49static inline void housekeeping_init(void) { }
     50#endif /* CONFIG_CPU_ISOLATION */
     51
     52static inline bool housekeeping_cpu(int cpu, enum hk_type type)
     53{
     54#ifdef CONFIG_CPU_ISOLATION
     55	if (static_branch_unlikely(&housekeeping_overridden))
     56		return housekeeping_test_cpu(cpu, type);
     57#endif
     58	return true;
     59}
     60
     61#endif /* _LINUX_SCHED_ISOLATION_H */