コード例 #1
0
ファイル: loadpin.c プロジェクト: Anjali05/linux
static int loadpin_read_file(struct file *file, enum kernel_read_file_id id)
{
	struct super_block *load_root;
	const char *origin = kernel_read_file_id_str(id);

	/* This handles the older init_module API that has a NULL file. */
	if (!file) {
		if (!enforce) {
			report_load(origin, NULL, "old-api-pinning-ignored");
			return 0;
		}

		report_load(origin, NULL, "old-api-denied");
		return -EPERM;
	}

	load_root = file->f_path.mnt->mnt_sb;

	/* First loaded module/firmware defines the root for all others. */
	spin_lock(&pinned_root_spinlock);
	/*
	 * pinned_root is only NULL at startup. Otherwise, it is either
	 * a valid reference, or an ERR_PTR.
	 */
	if (!pinned_root) {
		pinned_root = load_root;
		/*
		 * Unlock now since it's only pinned_root we care about.
		 * In the worst case, we will (correctly) report pinning
		 * failures before we have announced that pinning is
		 * enforcing. This would be purely cosmetic.
		 */
		spin_unlock(&pinned_root_spinlock);
		check_pinning_enforcement(pinned_root);
		report_load(origin, file, "pinned");
	} else {
		spin_unlock(&pinned_root_spinlock);
	}

	if (IS_ERR_OR_NULL(pinned_root) || load_root != pinned_root) {
		if (unlikely(!enforce)) {
			report_load(origin, file, "pinning-ignored");
			return 0;
		}

		report_load(origin, file, "denied");
		return -EPERM;
	}

	return 0;
}
コード例 #2
0
ファイル: asan.c プロジェクト: elektrischermoench/optee_os
void __noreturn __asan_report_load_n_noabort(vaddr_t addr, size_t size)
{
	report_load(addr, size);
}
コード例 #3
0
static void update_load_stats_state(void)
{
	unsigned int load;
	unsigned int nr_cpu_online;
	unsigned int max_cpus = cpq_max_cpus();
	unsigned int min_cpus = cpq_min_cpus();
	u64 current_time;
	u64 this_time = 0;
	int index;
		
	if (load_stats_state == DISABLED)
		return;

	current_time = ktime_to_ms(ktime_get());
	if (current_time <= start_delay){
		load_stats_state = IDLE;
		return;
	}

	if (first_call) {
		first_call = false;
	} else {
		this_time = current_time - last_time;
	}
	total_time += this_time;
	load = report_load();
	nr_cpu_online = num_online_cpus();
	load_stats_state = IDLE;

	if (nr_cpu_online) {
		index = (nr_cpu_online - 1) * 2;
		if ((nr_cpu_online < CONFIG_NR_CPUS) && (load >= load_threshold[index])) {
			if (total_time >= twts_threshold[index]) {
           		if (nr_cpu_online < max_cpus){
           			hotplug_info("UP load=%d total_time=%lld load_threshold[index]=%d twts_threshold[index]=%d nr_cpu_online=%d min_cpus=%d max_cpus=%d\n", load, total_time, load_threshold[index], twts_threshold[index], nr_cpu_online, min_cpus, max_cpus);
           	    	load_stats_state = UP;
           	    }
			}
		} else if (load <= load_threshold[index+1]) {
			if (total_time >= twts_threshold[index+1] ) {
           		if ((nr_cpu_online > 1) && (nr_cpu_online > min_cpus)){
           			hotplug_info("DOWN load=%d total_time=%lld load_threshold[index+1]=%d twts_threshold[index+1]=%d nr_cpu_online=%d min_cpus=%d max_cpus=%d\n", load, total_time, load_threshold[index+1], twts_threshold[index+1], nr_cpu_online, min_cpus, max_cpus);
                   	load_stats_state = DOWN;
                }
			}
		} else {
			load_stats_state = IDLE;
			total_time = 0;
		}
	} else {
		total_time = 0;
	}

	if (input_boost_running && current_time > input_boost_end_time)
		input_boost_running = false;

	if (input_boost_running){
		if (load_stats_state != UP){
			load_stats_state = IDLE;
			hotplug_info("IDLE because of input boost\n");
		}
	}
	
	if (load_stats_state != IDLE)
		total_time = 0;

	last_time = ktime_to_ms(ktime_get());
}
コード例 #4
0
int main (int argc, char *argv[])
{
	static struct option long_options[] = {
		{ "help",      no_argument,       0, 'h' },
		{ "version",   no_argument,       0, 'V' },
		{ "timeout",   required_argument, 0, 't' },
		{ "community", required_argument, 0, 'C' },
		{ "hostname",  required_argument, 0, 'H' },
		{ "verbose",   no_argument,       0, 'v' },
		{ 0, 0, 0, 0 },
	};
	int option_index = 0;
	int c;

	int ret = STATE_UNKNOWN;

	bn = strdup(basename(argv[0]));
	version = VERSION;

#define OPTS "?hVvt:c:w:C:H:"

	while(1) {
		c = getopt_long(argc, argv, OPTS, long_options, &option_index);

		if (c == -1 || c == EOF) {
			break;
		}

		switch(c) {
			case '?':
			case 'h':
				print_help();
				exit(STATE_UNKNOWN);

			case 'V':
				print_version();
				exit(STATE_UNKNOWN);

			case 't':
				if (!is_integer(optarg)) {
					printf("%s: Timeout interval (%s)must be integer!\n",
								 bn,
								 optarg);
					exit(STATE_UNKNOWN);
				}

				timeout = atoi(optarg);
				if (verbose) {
					printf("%s: Timeout set to %d\n", bn, timeout);
				}
				break;

			case 'C':
				community = strdup(optarg);

				if (verbose) {
					printf("%s: Community set to %s\n", bn, community);
				}

				break;

			case 'H':
				hostname = strdup(optarg);

				if (verbose) {
					printf("%s: Hostname set to %s\n", bn, hostname);
				}

				break;

			case 'v':
				verbose = 1;
				printf("%s: Verbose mode activated\n", bn);
				break;
		}
	}

	if (!hostname || !community) {
		printf("%s: Hostname or Community missing!\n", bn);
		print_help();
		exit(STATE_UNKNOWN);
	}

	ret = report_load();

	if (verbose) {
		printf("%s: Returning %d\n", bn, ret);
	}

	exit(ret);
}