diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2016-07-24 11:30:25 -0400 |
---|---|---|
committer | Greg Ungerer <gerg@linux-m68k.org> | 2016-07-27 23:29:12 -0400 |
commit | 015feacf932108429f59b511b29d7e98a629e333 (patch) | |
tree | 1308d3c390739f4186e7e6711ebf45cb8680d30f /fs/binfmt_flat.c | |
parent | af521f92dcf636c59330233a61cb689d0383c291 (diff) |
binfmt_flat: add MMU-specific support
Not much else to do at this point except for the different stack setups.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Greg Ungerer <gerg@linux-m68k.org>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
Diffstat (limited to 'fs/binfmt_flat.c')
-rw-r--r-- | fs/binfmt_flat.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 83e507137112..506139bfdc9e 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -537,7 +537,7 @@ static int load_flat_file(struct linux_binprm *bprm, | |||
537 | * case, and then the fully copied to RAM case which lumps | 537 | * case, and then the fully copied to RAM case which lumps |
538 | * it all together. | 538 | * it all together. |
539 | */ | 539 | */ |
540 | if ((flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP)) == 0) { | 540 | if (!IS_ENABLED(CONFIG_MMU) && !(flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP))) { |
541 | /* | 541 | /* |
542 | * this should give us a ROM ptr, but if it doesn't we don't | 542 | * this should give us a ROM ptr, but if it doesn't we don't |
543 | * really care | 543 | * really care |
@@ -677,7 +677,9 @@ static int load_flat_file(struct linux_binprm *bprm, | |||
677 | */ | 677 | */ |
678 | current->mm->start_brk = datapos + data_len + bss_len; | 678 | current->mm->start_brk = datapos + data_len + bss_len; |
679 | current->mm->brk = (current->mm->start_brk + 3) & ~3; | 679 | current->mm->brk = (current->mm->start_brk + 3) & ~3; |
680 | #ifndef CONFIG_MMU | ||
680 | current->mm->context.end_brk = memp + memp_size - stack_len; | 681 | current->mm->context.end_brk = memp + memp_size - stack_len; |
682 | #endif | ||
681 | } | 683 | } |
682 | 684 | ||
683 | if (flags & FLAT_FLAG_KTRACE) { | 685 | if (flags & FLAT_FLAG_KTRACE) { |
@@ -870,7 +872,7 @@ static int load_flat_binary(struct linux_binprm *bprm) | |||
870 | { | 872 | { |
871 | struct lib_info libinfo; | 873 | struct lib_info libinfo; |
872 | struct pt_regs *regs = current_pt_regs(); | 874 | struct pt_regs *regs = current_pt_regs(); |
873 | unsigned long stack_len; | 875 | unsigned long stack_len = 0; |
874 | unsigned long start_addr; | 876 | unsigned long start_addr; |
875 | int res; | 877 | int res; |
876 | int i, j; | 878 | int i, j; |
@@ -884,7 +886,9 @@ static int load_flat_binary(struct linux_binprm *bprm) | |||
884 | * pedantic and include space for the argv/envp array as it may have | 886 | * pedantic and include space for the argv/envp array as it may have |
885 | * a lot of entries. | 887 | * a lot of entries. |
886 | */ | 888 | */ |
887 | stack_len = PAGE_SIZE * MAX_ARG_PAGES - bprm->p; /* the strings */ | 889 | #ifndef CONFIG_MMU |
890 | stack_len += PAGE_SIZE * MAX_ARG_PAGES - bprm->p; /* the strings */ | ||
891 | #endif | ||
888 | stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */ | 892 | stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */ |
889 | stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ | 893 | stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ |
890 | stack_len = ALIGN(stack_len, FLAT_STACK_ALIGN); | 894 | stack_len = ALIGN(stack_len, FLAT_STACK_ALIGN); |
@@ -912,6 +916,11 @@ static int load_flat_binary(struct linux_binprm *bprm) | |||
912 | 916 | ||
913 | set_binfmt(&flat_format); | 917 | set_binfmt(&flat_format); |
914 | 918 | ||
919 | #ifdef CONFIG_MMU | ||
920 | res = setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT); | ||
921 | if (!res) | ||
922 | res = create_flat_tables(bprm, bprm->p); | ||
923 | #else | ||
915 | /* Stash our initial stack pointer into the mm structure */ | 924 | /* Stash our initial stack pointer into the mm structure */ |
916 | current->mm->start_stack = | 925 | current->mm->start_stack = |
917 | ((current->mm->context.end_brk + stack_len + 3) & ~3) - 4; | 926 | ((current->mm->context.end_brk + stack_len + 3) & ~3) - 4; |
@@ -921,6 +930,7 @@ static int load_flat_binary(struct linux_binprm *bprm) | |||
921 | res = transfer_args_to_stack(bprm, ¤t->mm->start_stack); | 930 | res = transfer_args_to_stack(bprm, ¤t->mm->start_stack); |
922 | if (!res) | 931 | if (!res) |
923 | res = create_flat_tables(bprm, current->mm->start_stack); | 932 | res = create_flat_tables(bprm, current->mm->start_stack); |
933 | #endif | ||
924 | if (res) | 934 | if (res) |
925 | return res; | 935 | return res; |
926 | 936 | ||