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

coresight-syscfg.h (4203B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * Coresight system configuration driver.
      4 */
      5
      6#ifndef CORESIGHT_SYSCFG_H
      7#define CORESIGHT_SYSCFG_H
      8
      9#include <linux/configfs.h>
     10#include <linux/coresight.h>
     11#include <linux/device.h>
     12
     13#include "coresight-config.h"
     14
     15/**
     16 * System configuration manager device.
     17 *
     18 * Contains lists of the loaded configurations and features, plus a list of CoreSight devices
     19 * registered with the system as supporting configuration management.
     20 *
     21 * Need a device to 'own' some coresight system wide sysfs entries in
     22 * perf events, configfs etc.
     23 *
     24 * @dev:		The device.
     25 * @csdev_desc_list:	List of coresight devices registered with the configuration manager.
     26 * @feat_desc_list:	List of feature descriptors to load into registered devices.
     27 * @config_desc_list:	List of system configuration descriptors to load into registered devices.
     28 * @load_order_list:    Ordered list of owners for dynamically loaded configurations.
     29 * @sys_active_cnt:	Total number of active config descriptor references.
     30 * @cfgfs_subsys:	configfs subsystem used to manage configurations.
     31 * @sysfs_active_config:Active config hash used if CoreSight controlled from sysfs.
     32 * @sysfs_active_preset:Active preset index used if CoreSight controlled from sysfs.
     33 */
     34struct cscfg_manager {
     35	struct device dev;
     36	struct list_head csdev_desc_list;
     37	struct list_head feat_desc_list;
     38	struct list_head config_desc_list;
     39	struct list_head load_order_list;
     40	atomic_t sys_active_cnt;
     41	struct configfs_subsystem cfgfs_subsys;
     42	u32 sysfs_active_config;
     43	int sysfs_active_preset;
     44};
     45
     46/* get reference to dev in cscfg_manager */
     47struct device *cscfg_device(void);
     48
     49/**
     50 * List entry for Coresight devices that are registered as supporting complex
     51 * config operations.
     52 *
     53 * @csdev:	 The registered device.
     54 * @match_flags: The matching type information for adding features.
     55 * @ops:	 Operations supported by the registered device.
     56 * @item:	 list entry.
     57 */
     58struct cscfg_registered_csdev {
     59	struct coresight_device *csdev;
     60	u32 match_flags;
     61	struct cscfg_csdev_feat_ops ops;
     62	struct list_head item;
     63};
     64
     65/* owner types for loading and unloading of config and feature sets */
     66enum cscfg_load_owner_type {
     67	CSCFG_OWNER_PRELOAD,
     68	CSCFG_OWNER_MODULE,
     69};
     70
     71/**
     72 * Load item - item to add to the load order list allowing dynamic load and
     73 *             unload of configurations and features. Caller loading a config
     74 *	       set provides a context handle for unload. API ensures that
     75 *	       items unloaded strictly in reverse order from load to ensure
     76 *	       dependencies are respected.
     77 *
     78 * @item:		list entry for load order list.
     79 * @type:		type of owner - allows interpretation of owner_handle.
     80 * @owner_handle:	load context - handle for owner of loaded configs.
     81 */
     82struct cscfg_load_owner_info {
     83	struct list_head item;
     84	int type;
     85	void *owner_handle;
     86};
     87
     88/* internal core operations for cscfg */
     89int __init cscfg_init(void);
     90void cscfg_exit(void);
     91int cscfg_preload(void *owner_handle);
     92const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name);
     93int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc,
     94				int param_idx, u64 value);
     95int cscfg_config_sysfs_activate(struct cscfg_config_desc *cfg_desc, bool activate);
     96void cscfg_config_sysfs_set_preset(int preset);
     97
     98/* syscfg manager external API */
     99int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs,
    100			   struct cscfg_feature_desc **feat_descs,
    101			   struct cscfg_load_owner_info *owner_info);
    102int cscfg_unload_config_sets(struct cscfg_load_owner_info *owner_info);
    103int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags,
    104			 struct cscfg_csdev_feat_ops *ops);
    105void cscfg_unregister_csdev(struct coresight_device *csdev);
    106int cscfg_activate_config(unsigned long cfg_hash);
    107void cscfg_deactivate_config(unsigned long cfg_hash);
    108void cscfg_csdev_reset_feats(struct coresight_device *csdev);
    109int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
    110				     unsigned long cfg_hash, int preset);
    111void cscfg_csdev_disable_active_config(struct coresight_device *csdev);
    112void cscfg_config_sysfs_get_active_cfg(unsigned long *cfg_hash, int *preset);
    113
    114#endif /* CORESIGHT_SYSCFG_H */