static bool block_rtas_call(int token, int nargs,
			    struct rtas_args *args)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(rtas_filters); i++) {
		struct rtas_filter *f = &rtas_filters[i];
		u32 base, size, end;

		if (token != f->token)
			continue;

		if (f->buf_idx1 != -1) {
			base = be32_to_cpu(args->args[f->buf_idx1]);
			if (f->size_idx1 != -1)
				size = be32_to_cpu(args->args[f->size_idx1]);
			else if (f->fixed_size)
				size = f->fixed_size;
			else
				size = 1;

			end = base + size - 1;
			if (!in_rmo_buf(base, end))
				goto err;
		}

		if (f->buf_idx2 != -1) {
			base = be32_to_cpu(args->args[f->buf_idx2]);
			if (f->size_idx2 != -1)
				size = be32_to_cpu(args->args[f->size_idx2]);
			else if (f->fixed_size)
				size = f->fixed_size;
			else
				size = 1;
			end = base + size - 1;

			/*
			 * Special case for ibm,configure-connector where the
			 * address can be 0
			 */
			if (!strcmp(f->name, "ibm,configure-connector") &&
			    base == 0)
				return false;

			if (!in_rmo_buf(base, end))
				goto err;
		}

		return false;
	}

err:
	pr_err_ratelimited("sys_rtas: RTAS call blocked - exploit attempt?\n");
	pr_err_ratelimited("sys_rtas: token=0x%x, nargs=%d (called by %s)\n",
			   token, nargs, current->comm);
	return true;
}
static bool block_rtas_call(int token, int nargs,
			    struct rtas_args *args)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(rtas_filters); i++) {
		struct rtas_filter *f = &rtas_filters[i];
		u32 base, size, end;

		if (token != f->token)
			continue;

		if (f->buf_idx1 != -1) {
			base = be32_to_cpu(args->args[f->buf_idx1]);
			if (f->size_idx1 != -1)
				size = be32_to_cpu(args->args[f->size_idx1]);
			else if (f->fixed_size)
				size = f->fixed_size;
			else
				size = 1;

			end = base + size - 1;
			if (!in_rmo_buf(base, end))
				goto err;
		}

		if (f->buf_idx2 != -1) {
			base = be32_to_cpu(args->args[f->buf_idx2]);
			if (f->size_idx2 != -1)
				size = be32_to_cpu(args->args[f->size_idx2]);
			else if (f->fixed_size)
				size = f->fixed_size;
			else
				size = 1;
			end = base + size - 1;

			 
			if (!strcmp(f->name, "ibm,configure-connector") &&
			    base == 0)
				return false;

			if (!in_rmo_buf(base, end))
				goto err;
		}

		return false;
	}

err:
	pr_err_ratelimited("sys_rtas: RTAS call blocked - exploit attempt?\n");
	pr_err_ratelimited("sys_rtas: token=0x%x, nargs=%d (called by %s)\n",
			   token, nargs, current->comm);
	return true;
}