From: Hajime Tazaki <thehajime@gmail.com>
To: johannes@sipsolutions.net
Cc: linux-um@lists.infradead.org, ricarkol@google.com,
Liam.Howlett@oracle.com
Subject: Re: [PATCH v3 03/13] um: nommu: memory handling
Date: Thu, 05 Dec 2024 22:46:20 +0900 [thread overview]
Message-ID: <m27c8ew8cz.wl-thehajime@gmail.com> (raw)
In-Reply-To: <d6c80b918b3febd0eb572b4a945dfc200f6890ee.camel@sipsolutions.net>
On Thu, 05 Dec 2024 01:34:49 +0900,
Johannes Berg wrote:
>
> On Tue, 2024-12-03 at 13:23 +0900, Hajime Tazaki wrote:
> >
> > +++ b/arch/um/include/asm/futex.h
> > @@ -8,7 +8,11 @@
> >
> >
> > int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr);
> > +#ifdef CONFIG_MMU
> > int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> > u32 oldval, u32 newval);
> > +#else
> > +#include <asm-generic/futex.h>
> > +#endif
>
> That seems somewhat problematic since it also defines
> arch_futex_atomic_op_inuser ...
indeed, will fix it.
> > +++ b/arch/um/include/shared/os.h
> > @@ -195,7 +195,13 @@ extern void get_host_cpu_features(
> > extern int create_mem_file(unsigned long long len);
> >
> > /* tlb.c */
> > +#ifdef CONFIG_MMU
> > extern void report_enomem(void);
> > +#else
> > +static inline void report_enomem(void)
> > +{
> > +}
> > +#endif
>
> That still seems simply wrong? Why is that even called, and why should
> it do *nothing*?
>
> I'm thinking you might just have patch sequence issues here - I can't
> really see why this would be called at all, eventually.
report_enomem was used in trap.c, which both MMU and !MMU use. Now I
decouple the file to contain !mmu specific code so, the above chunk
can be reverted.
> > @@ -78,6 +79,7 @@ void __init mem_init(void)
> > * Create a page table and place a pointer to it in a middle page
> > * directory entry.
> > */
> > +#ifdef CONFIG_MMU
> > static void __init one_page_table_init(pmd_t *pmd)
> > {
> > if (pmd_none(*pmd)) {
> > @@ -149,6 +151,12 @@ static void __init fixrange_init(unsigned long start, unsigned long end,
> > j = 0;
> > }
> > }
> > +#else
> > +static void __init fixrange_init(unsigned long start, unsigned long end,
> > + pgd_t *pgd_base)
> > +{
> > +}
> > +#endif
>
> Really not a fan of all these randomly placed ifdefs ...
I decided to introduce nommu directory to avoid those ifdefs.
> > +#ifdef CONFIG_MMU
> > static const pgprot_t protection_map[16] = {
> > [VM_NONE] = PAGE_NONE,
> > [VM_READ] = PAGE_READONLY,
> > @@ -249,3 +258,4 @@ static const pgprot_t protection_map[16] = {
> > [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_SHARED
> > };
> > DECLARE_VM_GET_PAGE_PROT
> > +#endif
>
> Same here.
>
> I think we can do better - perhaps move some code to mmu.c and nommu.c
> or something like that.
will fix it.
> > diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
> > index a74f17b033c4..f55d46dbe173 100644
> > --- a/arch/um/kernel/physmem.c
> > +++ b/arch/um/kernel/physmem.c
> > @@ -84,7 +84,11 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
> > exit(1);
> > }
> >
> > +#ifdef CONFIG_MMU
> > physmem_fd = create_mem_file(len);
> > +#else
> > + physmem_fd = -1;
> > +#endif
>
> same here, create_mem_file() can just be in a file only built for mmu,
> and otherwise be an inline that returns -1?
ditto.
> > +#ifdef CONFIG_MMU
> > /*
> > * Special kludge - This page will be mapped in to userspace processes
> > * from physmem_fd, so it needs to be written out there.
> > */
> > os_seek_file(physmem_fd, __pa(__syscall_stub_start));
> > os_write_file(physmem_fd, __syscall_stub_start, PAGE_SIZE);
> > +#endif
>
> That doesn't even do anything if the fd is -1, do we need the ifdef? ;-)
>
> Still better as "if (IS_ENABLED())" or something anyway though.
I'll revert this part.
> > +++ b/arch/um/kernel/trap.c
> > @@ -24,6 +24,7 @@
> > int handle_page_fault(unsigned long address, unsigned long ip,
> > int is_write, int is_user, int *code_out)
> > {
> > +#ifdef CONFIG_MMU
> > struct mm_struct *mm = current->mm;
> > struct vm_area_struct *vma;
> > pmd_t *pmd;
> > @@ -129,6 +130,9 @@ int handle_page_fault(unsigned long address, unsigned long ip,
> > goto out_nosemaphore;
> > pagefault_out_of_memory();
> > return 0;
> > +#else
> > + return -EFAULT;
> > +#endif
> > }
>
> same comments here ... try not to sprinkle ifdefs everywhere.
will revert it.
-- Hajime
next prev parent reply other threads:[~2024-12-05 13:47 UTC|newest]
Thread overview: 131+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 12:09 [RFC PATCH 00/13] nommu UML Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 02/13] x86/um: nommu: elf loader for fdpic Hajime Tazaki
2024-10-25 8:56 ` Johannes Berg
2024-10-25 12:54 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 03/13] um: nommu: memory handling Hajime Tazaki
2024-10-25 9:11 ` Johannes Berg
2024-10-25 12:55 ` Hajime Tazaki
2024-10-25 15:15 ` Johannes Berg
2024-10-26 7:24 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 04/13] x86/um: nommu: syscall handling Hajime Tazaki
2024-10-25 9:14 ` Johannes Berg
2024-10-25 12:55 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 05/13] x86/um: nommu: syscall translation by zpoline Hajime Tazaki
2024-10-25 9:19 ` Johannes Berg
2024-10-25 12:58 ` Hajime Tazaki
2024-10-25 15:20 ` Johannes Berg
2024-10-26 7:36 ` Hajime Tazaki
2024-10-27 9:45 ` Johannes Berg
2024-10-28 7:47 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 06/13] x86/um: nommu: process/thread handling Hajime Tazaki
2024-10-25 9:22 ` Johannes Berg
2024-10-25 12:58 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 07/13] um: nommu: configure fs register on host syscall invocation Hajime Tazaki
2024-10-25 9:28 ` Johannes Berg
2024-10-25 13:27 ` Hajime Tazaki
2024-10-25 15:22 ` Johannes Berg
2024-10-26 7:34 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 08/13] x86/um/vdso: nommu: vdso memory update Hajime Tazaki
2024-10-25 9:29 ` Johannes Berg
2024-10-25 13:28 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 09/13] x86/um: nommu: signal handling Hajime Tazaki
2024-10-25 9:30 ` Johannes Berg
2024-10-25 13:04 ` Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 10/13] x86/um: nommu: stack save/restore on vfork Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 11/13] um: change machine name for uname output Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 12/13] um: nommu: add documentation of nommu UML Hajime Tazaki
2024-10-24 12:09 ` [RFC PATCH 13/13] um: nommu: plug nommu code into build system Hajime Tazaki
2024-10-25 9:33 ` Johannes Berg
2024-10-25 13:05 ` Hajime Tazaki
2024-10-25 15:27 ` Johannes Berg
2024-10-26 7:36 ` Hajime Tazaki
2024-10-26 10:19 ` [RFC PATCH 00/13] nommu UML Benjamin Berg
2024-10-27 9:10 ` Hajime Tazaki
2024-10-28 13:32 ` Benjamin Berg
2024-10-30 9:25 ` Hajime Tazaki
2024-11-09 0:52 ` Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 " Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec Hajime Tazaki
2024-11-11 22:32 ` kernel test robot
2024-11-11 6:27 ` [RFC PATCH v2 02/13] x86/um: nommu: elf loader for fdpic Hajime Tazaki
2024-11-12 12:48 ` Geert Uytterhoeven
2024-11-12 22:07 ` Hajime Tazaki
2024-11-13 8:19 ` Geert Uytterhoeven
2024-11-13 8:36 ` Johannes Berg
2024-11-13 8:36 ` Johannes Berg
2024-11-13 10:27 ` Geert Uytterhoeven
2024-11-13 13:17 ` Hajime Tazaki
2024-11-13 13:55 ` Geert Uytterhoeven
2024-11-13 23:32 ` Hajime Tazaki
2024-11-14 1:40 ` Greg Ungerer
2024-11-14 10:41 ` Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 03/13] um: nommu: memory handling Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 04/13] x86/um: nommu: syscall handling Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 05/13] x86/um: nommu: syscall translation by zpoline Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 06/13] um: nommu: prevent host syscalls from userspace by seccomp filter Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 07/13] x86/um: nommu: process/thread handling Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 08/13] um: nommu: configure fs register on host syscall invocation Hajime Tazaki
2024-11-12 9:36 ` kernel test robot
2024-11-27 10:00 ` Benjamin Berg
2024-11-27 10:26 ` Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 09/13] x86/um/vdso: nommu: vdso memory update Hajime Tazaki
2024-11-27 10:36 ` Benjamin Berg
2024-11-27 23:23 ` Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 10/13] x86/um: nommu: signal handling Hajime Tazaki
2024-11-12 11:00 ` kernel test robot
2024-11-28 10:37 ` Benjamin Berg
2024-12-01 1:38 ` Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 11/13] um: change machine name for uname output Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 12/13] um: nommu: add documentation of nommu UML Hajime Tazaki
2024-11-11 6:27 ` [RFC PATCH v2 13/13] um: nommu: plug nommu code into build system Hajime Tazaki
2024-11-15 10:12 ` [RFC PATCH v2 00/13] nommu UML Johannes Berg
2024-11-15 10:26 ` Anton Ivanov
2024-11-15 14:54 ` Hajime Tazaki
2024-11-15 14:48 ` Hajime Tazaki
2024-11-22 9:33 ` Lorenzo Stoakes
2024-11-22 9:53 ` Johannes Berg
2024-11-22 10:29 ` Lorenzo Stoakes
2024-11-22 12:18 ` Christoph Hellwig
2024-11-22 12:25 ` Lorenzo Stoakes
2024-11-22 12:38 ` Christoph Hellwig
2024-11-22 12:49 ` Damien Le Moal
2024-11-22 12:52 ` Lorenzo Stoakes
2024-11-23 7:27 ` David Gow
2024-11-24 1:25 ` Hajime Tazaki
2024-12-03 4:22 ` [PATCH v3 " Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 02/13] x86/um: nommu: elf loader for fdpic Hajime Tazaki
2024-12-04 16:20 ` Johannes Berg
2024-12-05 13:41 ` Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 03/13] um: nommu: memory handling Hajime Tazaki
2024-12-04 16:34 ` Johannes Berg
2024-12-05 13:46 ` Hajime Tazaki [this message]
2024-12-03 4:23 ` [PATCH v3 04/13] x86/um: nommu: syscall handling Hajime Tazaki
2024-12-04 16:37 ` Johannes Berg
2024-12-05 13:47 ` Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 05/13] x86/um: nommu: syscall translation by zpoline Hajime Tazaki
2024-12-04 16:37 ` Johannes Berg
2024-12-05 13:48 ` Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 06/13] um: nommu: syscalls handler from userspace by seccomp filter Hajime Tazaki
2024-12-04 16:42 ` Johannes Berg
2024-12-05 13:51 ` Hajime Tazaki
2024-12-05 13:54 ` Johannes Berg
2024-12-06 2:51 ` Hajime Tazaki
2024-12-04 17:54 ` kernel test robot
2024-12-03 4:23 ` [PATCH v3 07/13] x86/um: nommu: process/thread handling Hajime Tazaki
2024-12-04 16:50 ` Johannes Berg
2024-12-05 13:56 ` Hajime Tazaki
2024-12-05 13:58 ` Johannes Berg
2024-12-06 2:49 ` Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 08/13] um: nommu: configure fs register on host syscall invocation Hajime Tazaki
2024-12-04 16:52 ` Johannes Berg
2024-12-04 19:31 ` Geert Uytterhoeven
2024-12-05 13:58 ` Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 09/13] x86/um/vdso: nommu: vdso memory update Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 10/13] x86/um: nommu: signal handling Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 11/13] um: change machine name for uname output Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 12/13] um: nommu: add documentation of nommu UML Hajime Tazaki
2024-12-03 4:23 ` [PATCH v3 13/13] um: nommu: plug nommu code into build system Hajime Tazaki
2024-12-04 16:20 ` [PATCH v3 00/13] nommu UML Johannes Berg
2024-12-05 13:41 ` Hajime Tazaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m27c8ew8cz.wl-thehajime@gmail.com \
--to=thehajime@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=johannes@sipsolutions.net \
--cc=linux-um@lists.infradead.org \
--cc=ricarkol@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.