static int notify_exec(struct mm_struct *mm)
{
	char *buf, *path;
	struct vm_area_struct *vma;

#ifndef CONFIG_KVM_GUEST   /* see notify_sim_task_change() */
	if (!sim_is_simulator())
#endif
		return 1;

	if (mm->exe_file == NULL)
		return 0;

	for (vma = current->mm->mmap; ; vma = vma->vm_next) {
		if (vma == NULL)
			return 0;
		if (vma->vm_file == mm->exe_file)
			break;
	}

	buf = (char *) __get_free_page(GFP_KERNEL);
	if (buf == NULL)
		return 0;

	path = d_path(&mm->exe_file->f_path, buf, PAGE_SIZE);
	if (IS_ERR(path)) {
		free_page((unsigned long)buf);
		return 0;
	}

	/*
	 * Notify simulator of an ET_DYN object so we know the load address.
	 * The somewhat cryptic overuse of SIM_CONTROL_DLOPEN allows us
	 * to be backward-compatible with older simulator releases.
	 */
	if (vma->vm_start == (ELF_ET_DYN_BASE & PAGE_MASK)) {
		char buf[64];
		int i;

		snprintf(buf, sizeof(buf), "0x%lx:@", vma->vm_start);
		for (i = 0; ; ++i) {
			char c = buf[i];
			__insn_mtspr(SPR_SIM_CONTROL,
				     (SIM_CONTROL_DLOPEN
				      | (c << _SIM_CONTROL_OPERATOR_BITS)));
			if (c == '\0')
				break;
		}
	}

	sim_notify_exec(path);
	free_page((unsigned long)buf);
	return 1;
}
static int notify_exec(struct mm_struct *mm)
{
	int ret = 0;
	char *buf, *path;
	struct vm_area_struct *vma;
	struct file *exe_file;

	if (!sim_is_simulator())
		return 1;

	buf = (char *) __get_free_page(GFP_KERNEL);
	if (buf == NULL)
		return 0;

	exe_file = get_mm_exe_file(mm);
	if (exe_file == NULL)
		goto done_free;

	path = file_path(exe_file, buf, PAGE_SIZE);
	if (IS_ERR(path))
		goto done_put;

	down_read(&mm->mmap_sem);
	for (vma = current->mm->mmap; ; vma = vma->vm_next) {
		if (vma == NULL) {
			up_read(&mm->mmap_sem);
			goto done_put;
		}
		if (vma->vm_file == exe_file)
			break;
	}

	/*
	 * Notify simulator of an ET_DYN object so we know the load address.
	 * The somewhat cryptic overuse of SIM_CONTROL_DLOPEN allows us
	 * to be backward-compatible with older simulator releases.
	 */
	if (vma->vm_start == (ELF_ET_DYN_BASE & PAGE_MASK)) {
		char buf[64];
		int i;

		snprintf(buf, sizeof(buf), "0x%lx:@", vma->vm_start);
		for (i = 0; ; ++i) {
			char c = buf[i];
			__insn_mtspr(SPR_SIM_CONTROL,
				     (SIM_CONTROL_DLOPEN
				      | (c << _SIM_CONTROL_OPERATOR_BITS)));
			if (c == '\0') {
				ret = 1; /* success */
				break;
			}
		}
	}
	up_read(&mm->mmap_sem);

	sim_notify_exec(path);
done_put:
	fput(exe_file);
done_free:
	free_page((unsigned long)buf);
	return ret;
}