After to solve the compilation problems, We continue with our SMP work. We have fixed many little errors and now have just found another big problem, this time with pmap.c
This feels a problem about page tables and MMU, which feels aren't implemented for many CPUs I attach a patch will all changes that we have applied, and the log of the latest compilation. Can you help me? 2018-06-19 17:22 GMT+02:00 Joshua Branson <jbra...@fastmail.com>: > Almudena Garcia <liberamenso10...@gmail.com> writes: > > > Here attach the patch files. > > > > About the sources, the gnumach apt sources are dated in 2018/02/18, so > It don't includes your latest fixes. > > > > How can I download sources from git repository? > > I believe the gnumach repo is located here: > > git clone git://git.sv.gnu.org/hurd/gnumach.git > > You can find more info underneath the heading, "Instant Development > Environment". > > https://www.gnu.org/software/hurd/contributing.html > > > > 2018-06-19 2:26 GMT+02:00 Samuel Thibault <samuel.thiba...@gnu.org>: > > > > Hello, > > > > Almudena Garcia, le lun. 18 juin 2018 21:16:28 +0200, a ecrit: > > > [1]http://dpaste.com/32VFE37 > > > > > > [2]http://dpaste.com/1F3YETN > > > > Please post them as attached text files to your mail, so review can take > > place. > > > > > But my sources were downloaded from apt, so these are outdated. > > > > gnumach doesn't change that fast :) > > > > Samuel > >
make all-recursive make[1]: Entering directory '/home/diwou/gnumach/build' make[2]: Entering directory '/home/diwou/gnumach/build' depbase=`echo i386/intel/pmap.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -DHAVE_CONFIG_H -I. -I.. -ffreestanding -nostdinc -imacros config.h -Ii386 -I. -I../i386 -I../i386/include/mach/sa -I../include -fno-builtin-log --no-pie --no-pic -Wall -fgnu89-inline -fno-strict-aliasing -fno-stack-protector -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -g -O2 -MT i386/intel/pmap.o -MD -MP -MF $depbase.Tpo -c -o i386/intel/pmap.o ../i386/intel/pmap.c &&\ mv -f $depbase.Tpo $depbase.Po In file included from ../kern/thread.h:50:0, from ../i386/intel/pmap.c:65: ../kern/sched_prim.h:188:1: warning: parameter names (without types) in function declaration extern void cause_ast_check(processor); /*new*/ ^~~~~~ In file included from ../i386/intel/pmap.c:65:0: ../kern/thread.h:348:1: warning: parameter names (without types) in function declaration extern void cause_ast_check(processor); /*new*/ ^~~~~~ ../i386/intel/pmap.c: In function ‘pmap_map_bd’: ../i386/intel/pmap.c:238:8: warning: implicit declaration of function ‘splvm’ [-Wimplicit-function-declaration] spl = splvm(); \ ^ ../i386/intel/pmap.c:253:2: note: in expansion of macro ‘SPLVM’ SPLVM(spl); \ ^~~~~ ../i386/intel/pmap.c:546:2: note: in expansion of macro ‘PMAP_READ_LOCK’ PMAP_READ_LOCK(pmap, spl); ^~~~~~~~~~~~~~ In file included from ../kern/lock.h:41:0, from ../kern/queue.h:38, from ../kern/mach_clock.h:31, from ../kern/thread.h:46, from ../i386/intel/pmap.c:65: ../i386/intel/pmap.c:546:17: error: ‘pmap’ undeclared (first use in this function) PMAP_READ_LOCK(pmap, spl); ^ ./machine/lock.h:50:31: note: in definition of macro ‘_simple_lock_xchg_’ : "0" (new_val), "m" (*(lock)) : "memory" \ ^~~~ ../i386/intel/pmap.c:255:2: note: in expansion of macro ‘simple_lock’ simple_lock(&(pmap)->lock); \ ^~~~~~~~~~~ ../i386/intel/pmap.c:546:2: note: in expansion of macro ‘PMAP_READ_LOCK’ PMAP_READ_LOCK(pmap, spl); ^~~~~~~~~~~~~~ ../i386/intel/pmap.c:546:17: note: each undeclared identifier is reported only once for each function it appears in PMAP_READ_LOCK(pmap, spl); ^ ./machine/lock.h:50:31: note: in definition of macro ‘_simple_lock_xchg_’ : "0" (new_val), "m" (*(lock)) : "memory" \ ^~~~ ../i386/intel/pmap.c:255:2: note: in expansion of macro ‘simple_lock’ simple_lock(&(pmap)->lock); \ ^~~~~~~~~~~ ../i386/intel/pmap.c:546:2: note: in expansion of macro ‘PMAP_READ_LOCK’ PMAP_READ_LOCK(pmap, spl); ^~~~~~~~~~~~~~ ../i386/intel/pmap.c:244:2: warning: implicit declaration of function ‘splx’ [-Wimplicit-function-declaration] splx(spl); \ ^ ../i386/intel/pmap.c:266:2: note: in expansion of macro ‘SPLX’ SPLX(spl); \ ^~~~ ../i386/intel/pmap.c:575:2: note: in expansion of macro ‘PMAP_READ_UNLOCK’ PMAP_READ_UNLOCK(pmap, spl); ^~~~~~~~~~~~~~~~ In file included from ../i386/intel/pmap.c:63:0: ../i386/intel/pmap.c: In function ‘pmap_enter’: ../i386/intel/pmap.c:1866:13: warning: format ‘%p’ expects argument of type ‘void *’, but argument 5 has type ‘vm_offset_t {aka long unsigned int}’ [-Wformat=] panic("pmap_enter(%p, %p) falls in physical memory area!\n", v, pa); ^ ../kern/debug.h:67:43: note: in definition of macro ‘panic’ Panic (__FILE__, __LINE__, __FUNCTION__, s, ##__VA_ARGS__) ^ ../i386/intel/pmap.c:1866:13: warning: format ‘%p’ expects argument of type ‘void *’, but argument 6 has type ‘phys_addr_t {aka long unsigned int}’ [-Wformat=] panic("pmap_enter(%p, %p) falls in physical memory area!\n", v, pa); ^ ../kern/debug.h:67:43: note: in definition of macro ‘panic’ Panic (__FILE__, __LINE__, __FUNCTION__, s, ##__VA_ARGS__) ^ ../i386/intel/pmap.c:1923:9: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘vm_offset_t {aka long unsigned int}’ [-Wformat=] panic("pmap_expand kernel pmap to %#x", v); ^ ../kern/debug.h:67:43: note: in definition of macro ‘panic’ Panic (__FILE__, __LINE__, __FUNCTION__, s, ##__VA_ARGS__) ^ ../i386/intel/pmap.c: In function ‘signal_cpus’: ../i386/intel/pmap.c:2778:22: warning: implicit declaration of function ‘ffs’ [-Wimplicit-function-declaration] while ((which_cpu = ffs(use_list)) != 0) { ^~~ ../i386/intel/pmap.c:2804:3: warning: implicit declaration of function ‘interrupt_processor’; did you mean ‘current_processor’? [-Wimplicit-function-declaration] interrupt_processor(which_cpu); ^~~~~~~~~~~~~~~~~~~ current_processor In file included from ../kern/lock.h:41:0, from ../kern/queue.h:38, from ../kern/mach_clock.h:31, from ../kern/thread.h:46, from ../i386/intel/pmap.c:65: ../i386/intel/pmap.c: In function ‘pmap_map_bd’: ./machine/lock.h:48:2: error: memory input 2 is not directly addressable asm volatile("xchgl %0, %2" \ ^ ./machine/lock.h:60:8: note: in expansion of macro ‘_simple_lock_xchg_’ while(_simple_lock_xchg_(l, 1)) \ ^~~~~~~~~~~~~~~~~~ ../i386/intel/pmap.c:255:2: note: in expansion of macro ‘simple_lock’ simple_lock(&(pmap)->lock); \ ^~~~~~~~~~~ ../i386/intel/pmap.c:546:2: note: in expansion of macro ‘PMAP_READ_LOCK’ PMAP_READ_LOCK(pmap, spl); ^~~~~~~~~~~~~~ ./machine/lock.h:48:2: error: memory input 2 is not directly addressable asm volatile("xchgl %0, %2" \ ^ ./machine/lock.h:67:3: note: in expansion of macro ‘_simple_lock_xchg_’ (_simple_lock_xchg_(l, 0)) ^~~~~~~~~~~~~~~~~~ ../i386/intel/pmap.c:264:2: note: in expansion of macro ‘simple_unlock’ simple_unlock(&(pmap)->lock); \ ^~~~~~~~~~~~~ ../i386/intel/pmap.c:575:2: note: in expansion of macro ‘PMAP_READ_UNLOCK’ PMAP_READ_UNLOCK(pmap, spl); ^~~~~~~~~~~~~~~~ Makefile:4535: recipe for target 'i386/intel/pmap.o' failed make[2]: *** [i386/intel/pmap.o] Error 1 make[2]: Leaving directory '/home/diwou/gnumach/build' Makefile:7083: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/diwou/gnumach/build' Makefile:2946: recipe for target 'all' failed make: *** [all] Error 2
diff -Naur '--exclude=.git' gnumach/configfrag.ac gnumach-dev/configfrag.ac --- gnumach/configfrag.ac 2018-06-27 16:52:47.000000000 -0400 +++ gnumach-dev/configfrag.ac 2018-06-27 15:50:47.000000000 -0400 @@ -32,7 +32,7 @@ # Multiprocessor support is still broken. AH_TEMPLATE([MULTIPROCESSOR], [set things up for a uniprocessor]) -mach_ncpus=1 +mach_ncpus=2 AC_DEFINE_UNQUOTED([NCPUS], [$mach_ncpus], [number of CPUs]) [if [ $mach_ncpus -gt 1 ]; then] AC_DEFINE([MULTIPROCESSOR], [1], [set things up for a multiprocessor]) diff -Naur '--exclude=.git' gnumach/i386/i386/cpu_number.h gnumach-dev/i386/i386/cpu_number.h --- gnumach/i386/i386/cpu_number.h 2018-06-27 16:52:47.000000000 -0400 +++ gnumach-dev/i386/i386/cpu_number.h 2018-06-27 16:48:53.000000000 -0400 @@ -34,6 +34,7 @@ /* More-specific code must define cpu_number() and CPU_NUMBER. */ #define CX(addr, reg) addr(,reg,4) +#define CPU_NUMBER(reg) /*XXX: we think this is not right, but we wanted to bypass the compiling error. Please review. */ #else /* NCPUS == 1 */ diff -Naur '--exclude=.git' gnumach/kern/cpu_number.h gnumach-dev/kern/cpu_number.h --- gnumach/kern/cpu_number.h 2018-06-27 16:52:47.000000000 -0400 +++ gnumach-dev/kern/cpu_number.h 2018-06-27 15:36:46.000000000 -0400 @@ -35,9 +35,41 @@ #if (NCPUS == 1) /* cpu number is always 0 on a single processor system */ -#define cpu_number() (0) + #define cpu_number() (0) + #define CPU_L1_SIZE (1 << CPU_L1_SHIFT) + +#else #define CPU_L1_SIZE (1 << CPU_L1_SHIFT) +int apic2kernel[255]; +int cpu_number_start = 0, cpu_number_counter = 0; + +static int cpu_number(void) { + int eax = 1, ebx = 0, ecx = 0, edx = 0; + unsigned int i = 0; + int apic_id = 0; + + if (!cpu_number_start) { + for (i = 0; i < 255; i++) { + apic2kernel[i] = -1; + } + cpu_number_start = 1; + } + + asm("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (eax)); + apic_id = (char) (ebx >> 24) & 0xff; + //printf("apic_id = %d\n", apic_id); + + if (apic2kernel[apic_id] != -1) { + return apic2kernel[apic_id]; + } else { + apic2kernel[apic_id] = cpu_number_counter; + cpu_number_counter++; + } + + return apic2kernel[apic_id]; +} + #endif /* NCPUS == 1 */ #endif /* _KERN_CPU_NUMBER_H_ */ diff -Naur '--exclude=.git' gnumach/kern/machine.h.rej gnumach-dev/kern/machine.h.rej --- gnumach/kern/machine.h.rej 1969-12-31 19:00:00.000000000 -0500 +++ gnumach-dev/kern/machine.h.rej 2018-06-27 15:36:46.000000000 -0400 @@ -0,0 +1,9 @@ +--- kern/machine.h 2016-10-02 19:45:20.000000000 +0200 ++++ kern/machine.h 2018-06-17 02:11:40.000000000 +0200 +@@ -54,5 +54,6 @@ + * action_thread() shuts down processors or changes their assignment. + */ + extern void action_thread_continue (void) __attribute__((noreturn)); ++extern void action_thread (void)__attribute__((noreturn)); + + #endif /* _MACHINE_H_ */ diff -Naur '--exclude=.git' gnumach/kern/sched_prim.h gnumach-dev/kern/sched_prim.h --- gnumach/kern/sched_prim.h 2018-06-27 16:52:47.000000000 -0400 +++ gnumach-dev/kern/sched_prim.h 2018-06-27 15:36:46.000000000 -0400 @@ -185,4 +185,6 @@ extern void idle_thread(void) __attribute__((noreturn)); extern void sched_thread(void); +extern void cause_ast_check(processor); /*new*/ + #endif /* _KERN_SCHED_PRIM_H_ */ diff -Naur '--exclude=.git' gnumach/kern/thread.h gnumach-dev/kern/thread.h --- gnumach/kern/thread.h 2018-06-27 16:52:47.000000000 -0400 +++ gnumach-dev/kern/thread.h 2018-06-27 15:36:46.000000000 -0400 @@ -344,6 +344,9 @@ extern kern_return_t thread_assign_default( thread_t thread); extern void stack_collect(void); + +extern void cause_ast_check(processor); /*new*/ + #endif /* diff -Naur '--exclude=.git' gnumach/Makefile.am gnumach-dev/Makefile.am --- gnumach/Makefile.am 2018-06-27 16:52:47.000000000 -0400 +++ gnumach-dev/Makefile.am 2018-06-27 15:35:42.000000000 -0400 @@ -52,7 +52,7 @@ -I$(top_srcdir)/include AM_CFLAGS += \ - -fno-builtin-log + -fno-builtin-log -no-pie -fno-pic # Yes, this makes the eyes hurt. But perhaps someone will finally take care of # all that scruffy Mach code... Also see <http://savannah.gnu.org/task/?5726>.