wsp/ \
nsp/ \
task_ctx/ \
- uihv/ \
got_patcher/
ifneq ($(CONFIG_SWAP_KERNEL_IMMUTABLE), y)
retprobe/swap_retprobe.ko
loader/swap_loader.ko
preload/swap_preload.ko
- uihv/swap_uihv.ko
fbiprobe/swap_fbiprobe.ko
wsp/swap_wsp.ko
nsp/swap_nsp.ko
+++ /dev/null
-EXTRA_CFLAGS := $(extra_cflags)
-
-obj-m := swap_uihv.o
-swap_uihv-y := uihv_module.o \
- uihv_debugfs.o
+++ /dev/null
-#ifndef __UIHV_H__
-#define __UIHV_H__
-
-#define UIHV_PREFIX "SWAP_UIHV: "
-#define UIHV_DEFAULT_PERMS (S_IRUSR | S_IWUSR) /* u+rw */
-
-#endif /* __UIHV_H__ */
+++ /dev/null
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-#include <master/swap_debugfs.h>
-#include "uihv.h"
-#include "uihv_module.h"
-
-static const char UIHV_FOLDER[] = "uihv";
-static const char UIHV_PATH[] = "path";
-static const char UIHV_APP_INFO[] = "app_info";
-static const char UIHV_ENABLE[] = "enable";
-
-static struct dentry *uihv_root;
-
-
-
-/* ===========================================================================
- * = UI VIEWER PATH =
- * ===========================================================================
- */
-
-
-static ssize_t uihv_path_write(struct file *file, const char __user *buf,
- size_t len, loff_t *ppos)
-{
- ssize_t ret;
- char *path;
-
- path = kmalloc(len, GFP_KERNEL);
- if (path == NULL) {
- ret = -ENOMEM;
- goto uihv_path_write_out;
- }
-
- if (copy_from_user(path, buf, len)) {
- ret = -EINVAL;
- goto uihv_path_write_out;
- }
-
- path[len - 1] = '\0';
-
- if (uihv_set_handler(path) != 0) {
- printk(UIHV_PREFIX "Cannot set ui viewer path %s\n", path);
- ret = -EINVAL;
- goto uihv_path_write_out;
- }
-
- ret = len;
-
- printk(UIHV_PREFIX "Set ui viewer path %s\n", path);
-
-uihv_path_write_out:
- kfree(path);
-
- return ret;
-}
-
-static const struct file_operations uihv_path_file_ops = {
- .owner = THIS_MODULE,
- .write = uihv_path_write,
-};
-
-
-/*
- * format:
- * main:app_path
- *
- * sample:
- * 0x00000d60:/bin/app_sample
- */
-static int uihv_add_app_info(const char *buf, size_t len)
-{
- int n, ret;
- char *app_path;
- unsigned long main_addr;
- const char fmt[] = "%%lx:/%%%ds";
- char fmt_buf[64];
-
- n = snprintf(fmt_buf, sizeof(fmt_buf), fmt, PATH_MAX - 2);
- if (n <= 0)
- return -EINVAL;
-
- app_path = kmalloc(PATH_MAX, GFP_KERNEL);
- if (app_path == NULL)
- return -ENOMEM;
-
- n = sscanf(buf, fmt_buf, &main_addr, app_path + 1);
- if (n != 2) {
- ret = -EINVAL;
- goto free_app_path;
- }
- app_path[0] = '/';
-
- printk(UIHV_PREFIX "Set ui viewer app path %s, main offset 0x%lx\n", app_path, main_addr);
-
- ret = uihv_data_set(app_path, main_addr);
-
-free_app_path:
- kfree(app_path);
- return ret;
-}
-
-static ssize_t write_uihv_app_info(struct file *file,
- const char __user *user_buf,
- size_t len, loff_t *ppos)
-{
- ssize_t ret = len;
- char *buf;
-
- buf = kmalloc(len, GFP_KERNEL);
- if (buf == NULL) {
- ret = -ENOMEM;
- goto free_buf;
- }
-
- if (copy_from_user(buf, user_buf, len)) {
- ret = -EINVAL;
- goto free_buf;
- }
-
- buf[len - 1] = '\0';
-
- if (uihv_add_app_info(buf, len))
- ret = -EINVAL;
-
-free_buf:
- kfree(buf);
-
- return ret;
-}
-
-static const struct file_operations uihv_app_info_file_ops = {
- .owner = THIS_MODULE,
- .write = write_uihv_app_info,
-};
-
-static ssize_t write_uihv_enable(struct file *file,
- const char __user *user_buf,
- size_t len, loff_t *ppos)
-{
- ssize_t ret = len;
- char *buf;
-
- buf = kmalloc(len, GFP_KERNEL);
- if (!buf) {
- ret = -ENOMEM;
- goto out;
- }
-
- if (copy_from_user(buf, user_buf, len)) {
- ret = -EINVAL;
- goto free_buf;
- }
-
- buf[len - 1] = '\0';
-
- if (buf[0] == '0')
- ret = uihv_disable();
- else
- ret = uihv_enable();
-
-free_buf:
- kfree(buf);
-
-out:
- return ret;
-}
-
-static const struct file_operations uihv_enable_file_ops = {
- .owner = THIS_MODULE,
- .write = write_uihv_enable,
-};
-
-int uihv_dfs_init(void)
-{
- struct dentry *swap_dentry, *root, *path, *app_info, *uihv_enable;
- int ret;
-
- ret = -ENODEV;
- if (!debugfs_initialized())
- goto fail;
-
- ret = -ENOENT;
- swap_dentry = swap_debugfs_getdir();
- if (!swap_dentry)
- goto fail;
-
- ret = -ENOMEM;
- root = swap_debugfs_create_dir(UIHV_FOLDER, swap_dentry);
- if (IS_ERR_OR_NULL(root))
- goto fail;
-
- uihv_root = root;
-
- path = swap_debugfs_create_file(UIHV_PATH, UIHV_DEFAULT_PERMS, root,
- NULL, &uihv_path_file_ops);
- if (IS_ERR_OR_NULL(path)) {
- ret = -ENOMEM;
- goto remove;
- }
-
- app_info = swap_debugfs_create_file(UIHV_APP_INFO,
- UIHV_DEFAULT_PERMS, root, NULL,
- &uihv_app_info_file_ops);
- if (IS_ERR_OR_NULL(app_info)) {
- ret = -ENOMEM;
- goto remove;
- }
-
- uihv_enable = swap_debugfs_create_file(UIHV_ENABLE,
- UIHV_DEFAULT_PERMS, root, NULL,
- &uihv_enable_file_ops);
- if (IS_ERR_OR_NULL(uihv_enable)) {
- ret = -ENOMEM;
- goto remove;
- }
-
- return 0;
-
-remove:
- debugfs_remove_recursive(root);
-
-fail:
- printk(UIHV_PREFIX "Debugfs initialization failure: %d\n", ret);
-
- return ret;
-}
-
-void uihv_dfs_exit(void)
-{
- if (uihv_root)
- debugfs_remove_recursive(uihv_root);
-
- uihv_root = NULL;
-}
+++ /dev/null
-#ifndef __UIHV_DEBUGFS_H__
-#define __UIHV_DEBUGFS_H__
-
-int uihv_dfs_init(void);
-void uihv_dfs_exit(void);
-
-#endif /* __UIHV_DEBUGFS_H__ */
+++ /dev/null
-#include <linux/namei.h>
-#include <us_manager/us_manager_common.h>
-#include <us_manager/pf/pf_group.h>
-#include <us_manager/sspt/sspt_page.h>
-#include <us_manager/sspt/sspt_file.h>
-#include <us_manager/sspt/sspt_proc.h>
-#include <us_manager/sspt/sspt_ip.h>
-#include <us_manager/callbacks.h>
-#include <us_manager/probes/probe_info_new.h>
-#include <us_manager/us_common_file.h>
-#include <writer/kernel_operations.h>
-#include <master/swap_initializer.h>
-#include <writer/swap_msg.h>
-#include <loader/loader.h>
-#include "uihv.h"
-#include "uihv_module.h"
-#include "uihv_debugfs.h"
-
-#define page_to_proc(page) ((page)->file->proc)
-#define ip_to_proc(ip) page_to_proc((ip)->page)
-#define urp_to_ip(rp) container_of(rp, struct sspt_ip, retprobe)
-
-static DEFINE_MUTEX(mutex_enable);
-
-static struct dentry *uihv_dentry = NULL;
-
-
-/* ============================================================================
- * = ui_viewer =
- * ============================================================================
- */
-
-/* main handler for ui viewer */
-static int uihv_main_eh(struct uretprobe_instance *ri, struct pt_regs *regs);
-static int uihv_main_rh(struct uretprobe_instance *ri, struct pt_regs *regs);
-static struct probe_desc pin_main = MAKE_URPROBE(uihv_main_eh,
- uihv_main_rh, 0);
-
-struct ui_viewer_data {
- struct dentry *app_dentry;
- struct probe_new p_main;
- struct pf_group *pfg;
- bool enable;
-};
-
-static struct ui_viewer_data __ui_data;
-
-static int uihv_data_inst(void)
-{
- struct pf_group *pfg;
-
- pfg = get_pf_group_by_dentry(__ui_data.app_dentry,
- (void *)__ui_data.app_dentry);
- if (!pfg)
- return -ENOMEM;
-
- __ui_data.pfg = pfg;
-
- return 0;
-}
-
-int uihv_data_set(const char *app_path, unsigned long main_addr)
-{
- struct dentry *dentry;
-
- if (__ui_data.enable) {
- pr_err("UIHV already enabled, can't set data\n");
- return -EBUSY;
- }
-
- dentry = dentry_by_path(app_path);
- if (dentry == NULL)
- return -ENOENT;
-
- __ui_data.app_dentry = dentry;
- __ui_data.p_main.desc = &pin_main;
- __ui_data.p_main.offset = main_addr;
-
- return uihv_data_inst();
-}
-
-int uihv_set_handler(char *path)
-{
- struct dentry *dentry;
- int ret;
-
- if (uihv_dentry != NULL) {
- swap_put_dentry(uihv_dentry);
- uihv_dentry = NULL;
- }
-
- dentry = swap_get_dentry(path);
- if (dentry == NULL) {
- printk(KERN_WARNING UIHV_PREFIX "Error! Cannot get handler %s\n",
- path);
- return -EINVAL;
- }
-
- ret = loader_add_handler(path);
- if (ret != 0)
- return ret;
-
- uihv_dentry = dentry;
-
- return 0;
-}
-
-
-
-/* ============================================================================
- * = ui viewer handlers =
- * ============================================================================
- */
-static int uihv_main_eh(struct uretprobe_instance *ri, struct pt_regs *regs)
-{
- struct pd_t *pd = lpd_get_by_task(current);
- struct hd_t *hd;
- unsigned long old_pc = swap_get_upc(regs);
- unsigned long vaddr = 0;
-
- if (uihv_dentry == NULL)
- return 0;
-
- hd = lpd_get_hd(pd, uihv_dentry);
- if (hd == NULL)
- return 0;
-
- if (lpd_get_state(hd) == NOT_LOADED)
- vaddr = loader_not_loaded_entry(ri, regs, pd, hd);
-
- loader_set_priv_origin(ri, vaddr);
-
- /* PC change check */
- return old_pc != swap_get_upc(regs);
-}
-
-static int uihv_main_rh(struct uretprobe_instance *ri, struct pt_regs *regs)
-{
- struct pd_t *pd = lpd_get_by_task(current);
- struct hd_t *hd;
-
- if (uihv_dentry == NULL)
- return 0;
-
- hd = lpd_get_hd(pd, uihv_dentry);
- if (hd == NULL)
- return 0;
-
- if (lpd_get_state(hd) == LOADING)
- loader_loading_ret(ri, regs, pd, hd);
-
- return 0;
-}
-
-int uihv_enable(void)
-{
- int ret = 0;
-
- mutex_lock(&mutex_enable);
- if (__ui_data.enable) {
- pr_err("UIHV already enabled\n");
- ret = -EBUSY;
- goto out;
- }
-
- ret = pin_register(&__ui_data.p_main, __ui_data.pfg,
- __ui_data.app_dentry);
- if (ret)
- goto out;
-
- __ui_data.enable = true;
-
-out:
- mutex_unlock(&mutex_enable);
- return ret;
-}
-
-int uihv_disable(void)
-{
- int ret = 0;
-
- mutex_lock(&mutex_enable);
- if (!__ui_data.enable) {
- pr_err("UIHV already disabled\n");
- ret = -EBUSY;
- goto out;
- }
-
- pin_unregister(&__ui_data.p_main, __ui_data.pfg);
- put_pf_group(__ui_data.pfg);
- __ui_data.pfg = NULL;
- __ui_data.enable = false;
-
-out:
- mutex_unlock(&mutex_enable);
- return ret;
-}
-
-static int uihv_init(void)
-{
- int ret;
-
- ret = uihv_dfs_init();
-
- return ret;
-}
-
-static void uihv_exit(void)
-{
- if (uihv_dentry != NULL) {
- swap_put_dentry(uihv_dentry);
- uihv_dentry = NULL;
- }
-
- uihv_dfs_exit();
-}
-
-SWAP_LIGHT_INIT_MODULE(NULL, uihv_init, uihv_exit, NULL, NULL);
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("SWAP UI Hierarchy Viewer");
-MODULE_AUTHOR("Alexander Aksenov <a.aksenov@samsung.com>, Anastasia Lypa");
+++ /dev/null
-#ifndef __UIHV_MODULE_H__
-#define __UIHV_MODULE_H__
-
-int uihv_data_set(const char *app_path, unsigned long main_addr);
-int uihv_set_handler(char *path);
-int uihv_enable(void);
-int uihv_disable(void);
-
-#endif /* __UIHV_MODULE_H__ */