[PATCH v12 2/2 hurd] ddekit: Use libirqhelp for interrupt registration

2024-03-25 Thread Damien Zammit
Use the new irqhelp library in ddekit and clean up. --- libddekit/Makefile| 2 +- libddekit/interrupt.c | 211 -- 2 files changed, 40 insertions(+), 173 deletions(-) diff --git a/libddekit/Makefile b/libddekit/Makefile index 88a0c8909..c74ec1128

[PATCH v12 1/2 hurd] libirqhelp: Add library

2024-03-25 Thread Damien Zammit
Add a helper library for attaching interrupt handlers in userspace. --- Makefile | 1 + libirqhelp/Makefile | 28 libirqhelp/irqhelp.c | 358 +++ libirqhelp/irqhelp.h | 49 ++ 4 files changed, 436 insertions(+) create mode 100644

[PATCH v12 0/2 hurd] Add irqhelp library and clean up ddekit

2024-03-25 Thread Damien Zammit
Hi, This patchset adds a new library irqhelp for assisting the attachment of irq handlers in userspace. The previous problem was that calling a function with a local param from inside the wrapped_server_loop was crashing netdde due to a bogus stack offset. This is fixed by removing the nested

Re: [PATCH v11 0/2 hurd] Add irqhelp library and clean up ddekit

2024-03-24 Thread Damien Zammit
Hi, On 24 Mar 2024, 11:05 pm, Samuel Thibault < samuel.thiba...@gnu.org> wrote: > Ok, but there's not even a comment about it. If somebody else comes and > changes the code a bit, they'll very easily get to the unsafe side again. And > really, accessing local variables from nested functions is

Re: [PATCH v11 0/2 hurd] Add irqhelp library and clean up ddekit

2024-03-24 Thread Damien Zammit
Hi Samuel, Original Message On 24 Mar 2024, 9:32 pm, Samuel Thibault >... Your version 11 is however still accessing the `irq` local parameter, so >it's still only by luck that it's working. You need to restore allocating the >params structure to store irq and priv, which was

[PATCH v11 2/2 hurd] ddekit: Use libirqhelp for interrupt registration

2024-03-24 Thread Damien Zammit
Use the new irqhelp library in ddekit and clean up. --- libddekit/Makefile| 2 +- libddekit/interrupt.c | 214 ++ 2 files changed, 31 insertions(+), 185 deletions(-) diff --git a/libddekit/Makefile b/libddekit/Makefile index 88a0c8909..c74ec1128

[PATCH v11 1/2 hurd] libirqhelp: Add library

2024-03-24 Thread Damien Zammit
Add a helper library for attaching interrupt handlers in userspace. --- Makefile | 1 + libirqhelp/Makefile | 28 libirqhelp/irqhelp.c | 358 +++ libirqhelp/irqhelp.h | 49 ++ 4 files changed, 436 insertions(+) create mode 100644

[PATCH v11 0/2 hurd] Add irqhelp library and clean up ddekit

2024-03-24 Thread Damien Zammit
Hi, This patchset adds a new library irqhelp for assisting the attachment of irq handlers in userspace. The previous problem was that calling a function with a global param from inside the wrapped_server_loop was crashing netdde due to a bogus stack offset. This is fixed. The mach_msg_server

[PATCH v10 2/2 hurd] ddekit: Use libirqhelp for interrupt registration

2024-03-16 Thread Damien Zammit
Use the new irqhelp library in ddekit and clean up. --- libddekit/Makefile| 2 +- libddekit/interrupt.c | 208 ++ 2 files changed, 27 insertions(+), 183 deletions(-) diff --git a/libddekit/Makefile b/libddekit/Makefile index 88a0c8909..c74ec1128

[PATCH v10 1/2 hurd] libirqhelp: Add library

2024-03-16 Thread Damien Zammit
Add a helper library for attaching interrupt handlers in userspace. --- Makefile | 1 + libirqhelp/Makefile | 28 libirqhelp/irqhelp.c | 359 +++ libirqhelp/irqhelp.h | 49 ++ 4 files changed, 437 insertions(+) create mode 100644

[PATCH v10 0/2 hurd] Add irqhelp library and clean up ddekit

2024-03-16 Thread Damien Zammit
Hi, This patchset adds a new library irqhelp for assisting the attachment of irq handlers in userspace. The previous problem was that return(NULL) was crashing netdde while pthread_exit(NULL) works for exiting the irq thread cleanly. The mach_msg_server thread now shuts down cleanly by setting

Re: [PATCH v9 0/2 hurd] Add irqhelp and clean up ddekit

2024-03-09 Thread Damien Zammit
Hi, On 3/10/24 6:46 AM, Samuel Thibault wrote: > Damien Zammit, le sam. 09 mars 2024 01:18:37 +, a ecrit: >> So having discussed this, we allow the irq thread to be called one more time, >> but not actually call the user irq handler if the shutdown flag is set. &g

[PATCH web] faq: Add doc about recent SMP support and how to test

2024-03-09 Thread Damien Zammit
--- faq/smp.mdwn | 31 ++- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/faq/smp.mdwn b/faq/smp.mdwn index c0133b80..ee0bf53f 100644 --- a/faq/smp.mdwn +++ b/faq/smp.mdwn @@ -13,21 +13,34 @@ License|/fdl]]."]]"""]] [[!meta title="Does GNU/Hurd

[PATCH v9 1/2 hurd] libirqhelp: Add library

2024-03-08 Thread Damien Zammit
Add a helper library for attaching interrupt handlers in userspace. --- Makefile | 1 + libirqhelp/Makefile | 28 libirqhelp/irqhelp.c | 360 +++ libirqhelp/irqhelp.h | 49 ++ 4 files changed, 438 insertions(+) create mode 100644

[PATCH v9 0/2 hurd] Add irqhelp and clean up ddekit

2024-03-08 Thread Damien Zammit
Hi, So having discussed this, we allow the irq thread to be called one more time, but not actually call the user irq handler if the shutdown flag is set. We acknowledge the interrupt has been handled, however. I tested this behaviour and it works on netdde.static to ifup and ifdown, and send a

[PATCH v9 2/2 hurd] ddekit: Use libirqhelp for interrupt registration

2024-03-08 Thread Damien Zammit
Use the new irqhelp library in ddekit and clean up. --- libddekit/Makefile| 2 +- libddekit/interrupt.c | 208 ++ 2 files changed, 28 insertions(+), 182 deletions(-) diff --git a/libddekit/Makefile b/libddekit/Makefile index 88a0c8909..c74ec1128

[PATCH v8 2/2 hurd] ddekit: Use libirqhelp for interrupt registration

2024-03-07 Thread Damien Zammit
Use the new irqhelp library in ddekit and clean up. --- libddekit/Makefile| 2 +- libddekit/interrupt.c | 208 ++ 2 files changed, 28 insertions(+), 182 deletions(-) diff --git a/libddekit/Makefile b/libddekit/Makefile index 88a0c8909..c74ec1128

[PATCH v8 1/2 hurd] libirqhelp: Add library

2024-03-07 Thread Damien Zammit
Add a helper library for attaching interrupt handlers in userspace. --- Makefile | 1 + libirqhelp/Makefile | 28 libirqhelp/irqhelp.c | 359 +++ libirqhelp/irqhelp.h | 49 ++ 4 files changed, 437 insertions(+) create mode 100644

[PATCH v8 0/2 hurd] Add irqhelp and clean up ddekit

2024-03-07 Thread Damien Zammit
Hi, I think we need to allow the irq handler to be called one more time, because we don't know if there is a pending interrupt until we need to handle one. Once we enable the irq one more time, it is necessary to handle the last interrupt before quitting the handler. I tested this behaviour and

[PATCH 1/1 hurd] ext2fs: New default: use xattrs to store translator records

2024-03-02 Thread Damien Zammit
Replaces experimental option --x-xattr-translator-records with --no-xattr-translator-records to allow rolling back to previous behaviour. NB: - Legacy records still work with either setting. - Adding a new record removes a legacy one. --- ext2fs/ext2fs.c | 18 +-

[PATCH 0/1 hurd] ext2fs - new translator entries in xattrs

2024-03-02 Thread Damien Zammit
Hi, I have prepared this patch for inclusion into hurd, however we may need to think of the best migration strategy: Do we allow a soft migration where translator entries are kept as is, but new ones are migrated only upon creation. Or do we write a script that will migrate all translator

[PATCH v7 1/2 hurd] libirqhelp: Add library

2024-03-02 Thread Damien Zammit
Add a helper library for attaching interrupt handlers in userspace. --- Makefile | 1 + libirqhelp/Makefile | 28 libirqhelp/irqhelp.c | 362 +++ libirqhelp/irqhelp.h | 49 ++ 4 files changed, 440 insertions(+) create mode 100644

[PATCH v7 2/2 hurd] ddekit: Use libirqhelp for interrupt registration

2024-03-02 Thread Damien Zammit
Use the new irqhelp library in ddekit and clean up. --- libddekit/Makefile| 2 +- libddekit/interrupt.c | 208 ++ 2 files changed, 28 insertions(+), 182 deletions(-) diff --git a/libddekit/Makefile b/libddekit/Makefile index 88a0c8909..c74ec1128

[PATCH v7 0/2 hurd] Add irqhelp and clean up ddekit

2024-03-02 Thread Damien Zammit
Hi, I figured out that a semaphore is needed in ddekit to wait until the thread_init(priv) is called. This was initially confusing because I thought a semaphore was needed in the irqhelp library, but it is not required there. TESTED: copying a large file from hurd to linux and ifup/ifdown a

Re: [PATCH v3 gnumach] smp: Rearrange IPI sending mechanism

2024-02-23 Thread Damien Zammit
Hi Almu, On 2/24/24 12:24 AM, Almudena Garcia wrote: > I set the code as this way because it's the standard of Intel's guides. > > The guide explain that although most machines turn on the cpu with an unique > SIPI, some machines could require a second SIPI. Even some older machines > could

[PATCH v2 gnumach] vm_map: Add comment and assert for vm_map_delete

2024-02-23 Thread Damien Zammit
This will prevent calling vm_map_delete without the map locked unless ref_count is zero. --- vm/vm_map.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/vm/vm_map.c b/vm/vm_map.c index c237afbe..7db76b7b 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -551,10 +551,12 @@ void

[PATCH v3 gnumach] smp: Rearrange IPI sending mechanism

2024-02-23 Thread Damien Zammit
Wait for ICR then just assert the signal. Linux and NetBSD does it this way, assume they know better. --- i386/i386/smp.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/i386/i386/smp.c b/i386/i386/smp.c index 05e9de67..a758eea3 100644 --- a/i386/i386/smp.c +++

[PATCH gnumach] pmap: Add assert_splsched calls to ensure at SPL7

2024-02-23 Thread Damien Zammit
--- i386/intel/pmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index e43b06c1..cf075a43 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -3114,6 +3114,7 @@ void process_pmap_updates(pmap_t my_pmap) pmap_t pmap;

[PATCH gnumach] kern: Use _nocheck variants of locks taken at splsched()

2024-02-23 Thread Damien Zammit
Fixes assertion errors when LDEBUG is compiled in. --- kern/machine.c| 6 -- kern/sched_prim.c | 38 -- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/kern/machine.c b/kern/machine.c index f757d146..a350fad4 100644 ---

[PATCH gnumach] kern: Use _irq variant of lock and disable interrupts

2024-02-23 Thread Damien Zammit
During quantum adjustment, disable interrupts and call appropriate lock. --- kern/priority.c | 4 ++-- kern/processor.c | 2 +- kern/processor.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kern/priority.c b/kern/priority.c index fe11d0d4..7f28b3d7 100644 ---

[PATCH gnumach] kern/processor: Do not set default_pset.empty on bootstrap

2024-02-23 Thread Damien Zammit
This is not needed because cpu_up does this when it comes online, it calls pset_add_processor(). --- kern/processor.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kern/processor.c b/kern/processor.c index 33733a59..0e42fa37 100644 --- a/kern/processor.c +++ b/kern/processor.c @@ -76,7

[PATCH v2 3/3 gnumach] kern/gsync: Use vm_map_lookup with keep_map_locked

2024-02-22 Thread Damien Zammit
This prevents a deadlock in smp where a read lock on the map is taken in gsync and then the map is locked again inside vm_map_lookup() but another thread had a pre-existing write lock, therefore the second read lock blocks. This is fixed by removing the initial gsync read lock on the map but

[PATCH v2 1/3 gnumach] vm_map: Add comment and assert for vm_map_delete

2024-02-22 Thread Damien Zammit
This will prevent calling vm_map_delete without the map locked unless ref_count is zero. --- vm/vm_map.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/vm/vm_map.c b/vm/vm_map.c index e454bb2a..f221c532 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -551,10 +551,12 @@ void

[PATCH v2 2/3 gnumach] vm_map_lookup: Add parameter for keeping map locked

2024-02-22 Thread Damien Zammit
This adds a parameter called keep_map_locked to vm_map_lookup() that allows the function to return with the map locked. This is to prepare for fixing a bug with gsync where the map is locked twice by mistake. Co-Authored-By: Sergey Bugaev --- i386/intel/read_fault.c | 4 ++-- kern/gsync.c

[PATCH v2 0/3 gnumach] vm_map and gsync changes

2024-02-22 Thread Damien Zammit
Hi, I addressed the points in review of first round. I tested this patchset using Sergey's patch additionally but dropped it from this set so Sergey can mail in his version instead. It still compiles gnumach with 7 cores using slave_pset. Thanks, Damien

[PATCH 2/3 gnumach] vm_map_lookup: Add parameter for exiting with map locked

2024-02-21 Thread Damien Zammit
This adds a parameter called exit_map_locked to vm_map_lookup() that allows the function to return with the map locked. This is to prepare for fixing a bug with gsync where the map is locked twice by mistake. Co-Authored-By: Sergey Bugaev --- i386/intel/read_fault.c | 4 ++-- kern/gsync.c

[PATCH 0/3 gnumach] vm_map and gsync changes

2024-02-21 Thread Damien Zammit
This patchset fixes two critical deadlocks when running with SMP: The first one is isolated to patch 1 (vm_map), the second is a combination of patch 2 and 3 (vm_map_lookup + gsync). When applied, these patches allow slave_pset to be entered and gnumach source code to be compiled on 7 cores

[PATCH 1/3 gnumach] vm_map: Fix deadlock in vm code

2024-02-21 Thread Damien Zammit
Authored-by: Sergey Bugaev --- vm/vm_map.c | 32 ++-- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/vm/vm_map.c b/vm/vm_map.c index f221c532..e4672260 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -1424,8 +1424,9 @@ vm_map_pageable_scan(struct vm_map

[PATCH 3/3 gnumach] kern/gsync: Use vm_map_lookup with exit_map_locked as appropriate

2024-02-21 Thread Damien Zammit
This refactors gsync functions so that the read lock on vm map is only taken once and extended throughout appropriate calls. Co-Authored-By: Sergey Bugaev --- kern/gsync.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/kern/gsync.c

Re: [PATCH v2] Port GDB to Hurd x86_64.

2024-02-15 Thread Damien Zammit
Thank you Flavio, great job! This will be an essential part of the new system. Damien Sent from Proton Mail mobile Original Message On 16 Feb 2024, 12:18 pm, Samuel Thibault < samuel.thiba...@gnu.org> wrote: Seems now to work fine with libraries indeed, thanks! I have uploaded

Test program for running task on slave_pset

2024-02-11 Thread Damien Zammit
Hi, This program requires master branch PLUS a one line patch I just mailed in for gnumach. Here is a simple test program to enable a new task to run on slave_pset processor set containing the rest of the processors in SMP kernel. You can compile it as a sutil in hurd/sutils: usage must be run

[PATCH gnumach] smp: Set processor set to non-empty when adding a processor

2024-02-11 Thread Damien Zammit
This allows the slave_pset to be used for actual tasks with the processor_set RPCs. --- kern/processor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kern/processor.c b/kern/processor.c index f06b5d62..71bbb757 100644 --- a/kern/processor.c +++ b/kern/processor.c @@ -245,6 +245,7 @@ void

[PATCH v2 gnumach] smp: Create AP processor set and put all APs inside it

2024-02-11 Thread Damien Zammit
This has the effect of running with one cpu only with smp, but has the ability to enable APs in userspace with the right processor set RPCs. --- ddb/db_print.c | 10 +++--- kern/machine.c | 13 + kern/processor.c | 3 +++ kern/processor.h | 3 +++ 4 files changed, 26

[PATCH v2 gnumach] Enable MACH_HOST and fix non-addressable bitfields

2024-02-11 Thread Damien Zammit
This is only enabled when NCPUS > 1. Enables some older code paths that allows userspace to manage cpu resources via processor set RPCs. Size of struct task is preserved while making 4 bitfields addressable as 4 single byte fields. --- configfrag.ac | 8 ++-- kern/task.h | 10 +-

[PATCH v2 gnumach] smp: Fix unable to enter kdb during boot

2024-02-11 Thread Damien Zammit
--- i386/i386at/kd.c | 1 + i386/i386at/kd_event.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 984d62e3..2bea3c8c 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1127,6 +1127,7 @@ kdinit(void) k_comm |=

[PATCH v2 gnumach] smp: Rearrange IPI sending mechanism

2024-02-11 Thread Damien Zammit
Wait for ICR then just assert the signal. No need for deassert. This is how Linux and NetBSD does it. I couldn't find documentation on the correct method, however. --- i386/i386/smp.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/i386/i386/smp.c b/i386/i386/smp.c

Re: [PATCH gnumach] Enable MACH_HOST and fix non-addressable bitfields

2024-02-11 Thread Damien Zammit
Hi, On 2/11/24 10:07 PM, Samuel Thibault wrote: > Damien Zammit, le dim. 11 févr. 2024 10:55:26 +, a ecrit: >>>> diff --git a/kern/task.h b/kern/task.h >>>> index dec3a530..27970620 100644 >>>> --- a/kern/task.h >>>> +++

Re: [PATCH gnumach] Enable MACH_HOST and fix non-addressable bitfields

2024-02-11 Thread Damien Zammit
Hi, On 2/11/24 9:43 PM, Samuel Thibault wrote: > Damien Zammit, le dim. 11 févr. 2024 07:09:48 +, a ecrit: >> diff --git a/configfrag.ac b/configfrag.ac >> index f9285c9d..d059c7b9 100644 >> --- a/configfrag.ac >> +++ b/configfrag.ac >> @@ -71,7 +7

[PATCH gnumach] smp: Create AP processor set and put all APs inside it

2024-02-10 Thread Damien Zammit
This has the effect of running with one cpu only with smp, but has the ability to enable APs in userspace with the right processor set RPCs. --- ddb/db_print.c | 4 +++- kern/machine.c | 7 ++- kern/processor.c | 30 +++--- kern/processor.h | 1 + 4 files

[PATCH gnumach] Enable MACH_HOST and fix non-addressable bitfields

2024-02-10 Thread Damien Zammit
--- configfrag.ac | 2 +- kern/task.h | 10 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configfrag.ac b/configfrag.ac index f9285c9d..d059c7b9 100644 --- a/configfrag.ac +++ b/configfrag.ac @@ -71,7 +71,7 @@ AC_DEFINE([MACH_DEBUG], [1], [MACH_DEBUG])

[PATCH gnumach] smp: Fix parenthesis around logic expression value

2024-02-10 Thread Damien Zammit
--- kern/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/thread.c b/kern/thread.c index 38287581..de9d1982 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1921,7 +1921,7 @@ Restart: * Reset policy and priorities if needed. */ #if

[PATCH gnumach] smp: Fix unable to enter kdb during boot

2024-02-10 Thread Damien Zammit
--- i386/i386at/kd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 984d62e3..486dea67 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -458,6 +458,7 @@ kdopen( kdinit(); } tp->t_state |= TS_CARR_ON; +

[PATCH gnumach] smp: Rearrange IPI sending mechanism

2024-02-10 Thread Damien Zammit
Wait for ICR then just assert the signal. No de-assert. --- i386/i386/smp.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/i386/i386/smp.c b/i386/i386/smp.c index 05e9de67..a758eea3 100644 --- a/i386/i386/smp.c +++ b/i386/i386/smp.c @@ -54,17 +54,11 @@ static void

[PATCH gnumach] smp: Fix compile error with missing apboot_addr

2024-02-08 Thread Damien Zammit
--- i386/i386/model_dep.h | 5 + i386/i386/mp_desc.h | 5 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/i386/i386/model_dep.h b/i386/i386/model_dep.h index 095eec9b..5369e288 100644 --- a/i386/i386/model_dep.h +++ b/i386/i386/model_dep.h @@ -28,6 +28,11 @@ #include

Re: [PATCH v3 2/4 gnumach] Add HPET timer for small accurate delays

2024-02-07 Thread Damien Zammit
Hi, On 2/8/24 10:28 AM, Samuel Thibault wrote: > Could you check with your mailer how to prevent it from using the > quoted-printable encoding? git am often has troubles applying your > patches, and I have to fix the patch by hand, it's really inconvenient. For others' benefit, I think I

Re: [PATCH v3 2/4 gnumach] Add HPET timer for small accurate delays

2024-02-07 Thread Damien Zammit
wrote: > Applied, thanks! Could you check with your mailer how to prevent it from > using the quoted-printable encoding? git am often has troubles applying your > patches, and I have to fix the patch by hand, it's really unconvenient. > Samuel Damien Zammit, le mer. 07 févr. 2024 05

[PATCH v3 4/4 gnumach] smp: Fix INIT/STARTUP IPI sequence

2024-02-06 Thread Damien Zammit
TODO: Don't hardcode 0x3000 as the starting eip. TESTED: works in qemu TESTED: works hardware with AMD cpu --- i386/i386/mp_desc.c | 15 +++-- i386/i386/smp.c | 125 +--- i386/i386/smp.h | 5 +- i386/i386at/cram.h | 5 ++

[PATCH v3 2/4 gnumach] Add HPET timer for small accurate delays

2024-02-06 Thread Damien Zammit
TESTED: This works in qemu correctly TESTED: This works on an AMD board with ACPI v2.0 correctly --- i386/i386/apic.c | 89 +++ i386/i386/apic.h | 5 ++ i386/i386at/acpi_parse_apic.c | 35 ++ i386/i386at/acpi_parse_apic.h |

[PATCH v3 3/4 gnumach] smp: Use HPET instead of pit one-shot that is unreliable

2024-02-06 Thread Damien Zammit
NB: Every x86 board that uses ACPI most likely has a HPET since 2005. We can roll back to PIT in the cases where its not present, but the PIT one shot code is definitely currently broken. --- i386/i386/smp.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git

[PATCH v3 1/4 gnumach] separate lapic_enable from lapic_setup

2024-02-06 Thread Damien Zammit
This initializes the lapic without turning on the IOAPIC interrupts during SMP init. --- i386/i386/apic.c | 15 +-- i386/i386/apic.h | 2 ++ i386/i386/mp_desc.c | 18 +++--- i386/i386at/ioapic.c | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff

[PATCH v3 0/4 gnumach] SMP on AMD

2024-02-06 Thread Damien Zammit
Hi, I addressed all the points in review 2. Here is version 3. It still boots! Thanks, Damien

[PATCH v2 4/4 gnumach] smp: Fix INIT/STARTUP IPI sequence

2024-02-05 Thread Damien Zammit
To be fixed: Find a way to allocate memory below 1MiB. Otherwise, this hardcodes 0x3000 as the starting eip. TESTED: works in qemu TESTED: works hardware with AMD cpu --- i386/i386/mp_desc.c | 15 +++-- i386/i386/smp.c | 126 +--- i386/i386/smp.h

[PATCH v2 1/4 gnumach] separate lapic_enable from lapic_setup

2024-02-05 Thread Damien Zammit
This allows us to init the lapic without necessarily turning on the IOAPIC interrupts. --- i386/i386/apic.c | 15 +-- i386/i386/apic.h | 2 ++ i386/i386/mp_desc.c | 12 +--- i386/i386at/ioapic.c | 1 + 4 files changed, 25 insertions(+), 5 deletions(-) diff --git

[PATCH v2 0/4 gnumach] SMP on AMD

2024-02-05 Thread Damien Zammit
Hi, Here are the changes from previous review. I did not make changes to ensure pit fallback because the pit one-shot code is broken; there is no point making it fall back to a delay that does not work. I tried fixing the pit code, but it resulted in strange behaviour. We can assume every x86

[PATCH v2 3/4 gnumach] smp: Use HPET instead of pit one-shot that is unreliable

2024-02-05 Thread Damien Zammit
NB: Assume every x86 board that uses ACPI has a HPET. We can roll back to PIT in the cases where its not present, but the PIT one shot code is currently broken. --- i386/i386/smp.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/i386/i386/smp.c b/i386/i386/smp.c index

[PATCH v2 2/4 gnumach] Add HPET timer for small accurate delays

2024-02-05 Thread Damien Zammit
TESTED: This works in qemu correctly TESTED: This works on an AMD board with ACPI v2.0 correctly --- i386/i386/apic.c | 97 +++ i386/i386/apic.h | 5 ++ i386/i386at/acpi_parse_apic.c | 35 ++--- i386/i386at/acpi_parse_apic.h | 23

[PATCH 5/6 gnumach] smp: Use HPET instead of pit one-shot that is unreliable

2024-02-05 Thread Damien Zammit
NB: Every x86 board that uses ACPI most likely has a HPET. We can roll back to PIT in the cases where its not present, but the PIT one shot code is definitely currently broken. --- i386/i386/smp.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/i386/i386/smp.c

[PATCH 3/6 gnumach] smp: Remove hardcoded AP_BOOT_ADDR

2024-02-05 Thread Damien Zammit
This took some time to figure out. Involves a hand-crafted 16 bit assembly instruction [1] because it requires an immediate for the memory address of far jump. This required self-modifying code to inject the next instruction, therefore I added a near jump to clear the instruction cache queue in

[PATCH 2/6 gnumach] separate lapic_enable from lapic_setup

2024-02-05 Thread Damien Zammit
This allows us to init the lapic without necessarily turning on the IOAPIC interrupts. --- i386/i386/apic.c | 15 +-- i386/i386/apic.h | 2 ++ i386/i386/mp_desc.c | 6 +++--- i386/i386at/ioapic.c | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) diff --git

[PATCH 6/6 gnumach] smp: Fix INIT/STARTUP IPI sequence

2024-02-05 Thread Damien Zammit
Outstanding: Find a way to allocate memory below 1MiB. Otherwise, this hardcodes 0x3000 as the starting eip. TESTED: works in qemu TESTED: works hardware with AMD cpu --- i386/i386/mp_desc.c | 15 -- i386/i386/smp.c | 114 +--- i386/i386/smp.h

[PATCH 4/6 gnumach] Add HPET timer for small accurate delays

2024-02-05 Thread Damien Zammit
TESTED: This works in qemu correctly TESTED: This works on an AMD board with ACPI v2.0 correctly --- i386/i386/apic.c | 87 +++ i386/i386/apic.h | 4 ++ i386/i386at/acpi_parse_apic.c | 35 ++ i386/i386at/acpi_parse_apic.h | 23

[PATCH 0/6 gnumach] SMP on AMD hardware

2024-02-05 Thread Damien Zammit
Hi all, This patchset fixes a number of things wrong with smp and most of all fixes the root cause of an AP startup problem (Patch 1), which may also be affecting IPIs in general. In qemu with smp, I get a new panic after all modules are loaded: ../kern/slab.c:966: kmem_cache_alloc_from_slab: \

[PATCH 1/6 gnumach] Fix apic_send_ipi function clobbering read only fields

2024-02-05 Thread Damien Zammit
This was the root cause of failing to INIT. We were clobbering remote_read_status. And also, we need to reference the .r register when writing the ICR regs otherwise I think it writes all of the block. --- i386/i386/apic.c | 8 ++-- i386/i386/apic.h | 2 +- 2 files changed, 7 insertions(+), 3

[PATCH 2/2 gnumach] smp: Use HPET instead of unreliable pit one-shot

2024-02-01 Thread Damien Zammit
--- i386/i386/smp.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/i386/i386/smp.c b/i386/i386/smp.c index fb43ecb6..87f59913 100644 --- a/i386/i386/smp.c +++ b/i386/i386/smp.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include

[PATCH 1/2 gnumach] Add HPET timer for small accurate delays

2024-02-01 Thread Damien Zammit
Enables a 32 bit periodic HPET timer without generating interrupts. The purpose of this is to provide a convenient udelay/mdelay in mach since the pit one-shot mode is unreliable. TESTED: This works in qemu correctly TESTED: This works on an AMD board with ACPI v2.0 correctly ---

[PATCH gnumach] model_dep: Fix serial console with APIC enabled

2024-01-31 Thread Damien Zammit
Move cninit() further down so that IOAPIC has a chance to initialize before the com port interrupt is unmasked in the IOAPIC, fixing a fault and reboot. --- i386/i386at/model_dep.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/i386/i386at/model_dep.c

[PATCH v3 gnumach] ACPI: Support XSDT (ACPI >= v2.0)

2024-01-30 Thread Damien Zammit
This enables gnumach to additionally parse the XSDT table if the revision of ACPI is 2. TESTED: Still works on qemu (ACPI v1.0) TESTED: Works on a x86 board with XSDT (ACPI v2.0) --- i386/i386at/acpi_parse_apic.c | 258 ++ i386/i386at/acpi_parse_apic.h | 18 ++-

[PATCH v2 gnumach] smp: Remove hardcoded AP_BOOT_ADDR

2024-01-30 Thread Damien Zammit
This took some time to figure out. Involves a hand-crafted 16 bit assembly instruction [1] because it requires an immediate for the memory address of far jump. This required self-modifying code to inject the next instruction, therefore I added a near jump to clear the instruction cache queue in

[PATCH v2 gnumach] ACPI: Support XSDT (ACPI >= v2.0)

2024-01-30 Thread Damien Zammit
This enables gnumach to additionally parse the XSDT table if the revision of ACPI is 2. NB: I removed a few checksum checks in acpi tables where there is no checksum present in the table. TESTED: Still works on qemu (ACPI v1.0) TESTED: Works on a x86 board with XSDT (ACPI v2.0) ---

[PATCH v2 gnumach] apic: Set up LAPICs in xAPIC mode

2024-01-30 Thread Damien Zammit
Clear flag in msr for xAPIC mode. --- i386/i386/apic.h | 3 ++- i386/i386/cpuboot.S | 4 ++-- i386/i386at/boothdr.S | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/i386/i386/apic.h b/i386/i386/apic.h index b8fff2af..e410e9c6 100644 --- a/i386/i386/apic.h +++

Re: [PATCH gnumach] smp: Remove hardcoded AP_BOOT_ADDR

2024-01-29 Thread Damien Zammit
Hi Samuel, On 1/29/24 9:20 PM, Samuel Thibault wrote: > Damien Zammit, le lun. 29 janv. 2024 10:07:30 +, a ecrit: >> -ljmp$BOOT_CS, $M(0f) >> +xorl%eax, %eax >> +mov %cs, %ax >> +shll$4, %eax >> +addl$M(0f), %eax >

[PATCH gnumach] smp: Remove hardcoded AP_BOOT_ADDR

2024-01-29 Thread Damien Zammit
This took some time to figure out. Involves hand-crafted 16 bit assembly instructions [1] because GNU AS does not fully understand real-mode x86. [1] Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual --- i386/i386/cpuboot.S | 32

[PATCH gnumach] apic: Set up LAPICs in xAPIC mode

2024-01-29 Thread Damien Zammit
Clear flag in msr for xAPIC mode. --- i386/i386/apic.h | 3 ++- i386/i386/cpuboot.S | 3 ++- i386/i386at/boothdr.S | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/i386/i386/apic.h b/i386/i386/apic.h index e870dcf8..9f908159 100644 --- a/i386/i386/apic.h +++

[PATCH] Support up to two IOAPICs with up to 32 GSIs on each

2024-01-29 Thread Damien Zammit
Previously, only IOAPIC[0] was supported. Now this supports up to two IOAPICs. --- i386/i386/apic.c | 13 + i386/i386/apic.h | 6 ++- i386/i386/locore.S| 43 + i386/i386at/acpi_parse_apic.c | 3 ++ i386/i386at/int_init.c| 6 ++-

Re: [PATCH 0/2 gnumach] ACPI v2.0 support

2024-01-24 Thread Damien Zammit
Hi, On 1/25/24 3:41 AM, Almudena Garcia wrote: > Maybe the next crash is in APIC step. Check if it's using xAPIC or x2APIC, > and force xAPIC if necessary I checked it is definitely using xAPIC mode, I also patched it to set the right MSR bit. But the cpu still crashes when interrupts are

[PATCH 2/2 gnumach] ACPI: Support XSDT (ACPI >= v2.0)

2024-01-23 Thread Damien Zammit
--- i386/i386at/acpi_parse_apic.c | 203 -- i386/i386at/acpi_parse_apic.h | 18 ++- i386/i386at/model_dep.c | 8 +- 3 files changed, 169 insertions(+), 60 deletions(-) diff --git a/i386/i386at/acpi_parse_apic.c b/i386/i386at/acpi_parse_apic.c index

[PATCH 1/2 gnumach] ioapic: Remove IMCR toggle

2024-01-23 Thread Damien Zammit
Since we are not using legacy MP tables but intending to use ACPI to configure interrupt routing, we can assume all boards have virtual wire mode, thus do not require setting of IMCR register. (This may fix crashes on machines that do not have IMCR registers). --- i386/i386at/ioapic.c | 6 --

[PATCH 0/2 gnumach] ACPI v2.0 support

2024-01-23 Thread Damien Zammit
This enables gnumach to additionally parse the XSDT table if the version of ACPI is detected to be greater than 1. TESTED: Should not break existing ACPI v1.0 support. Almost boots on HP T620 but crashes further downstream of ACPI table detection (to be fixed in follow up patches).

Progress on AMD x86 with gnumach

2024-01-22 Thread Damien Zammit
Hi, I am trying to port gnumach to HP T620 which is an AMD FAM16h board running my port of coreboot. With --disable-apic --enable-cpus=1 the board boots to a shell (but NIC locks up). Under GNU/Linux, using command line options "noapic nolapic", the same thing happens and the NIC locks up

[PATCH gnumach] console: Fix baud rate on com ports, use 115200 default baud, 8 data bits

2024-01-18 Thread Damien Zammit
TESTED: By booting gnumach off an HP T620 with console=com0 and receiving 115200 8N1 console on another machine connected via the serial port in minicom. Without this patch, part of the console is garbled by mismatching com params (9600 7N1). --- i386/i386at/com.c | 27

[PATCH gnumach] x86_64/locore.S: Fix int stack checks when NCPUS > 1

2023-10-27 Thread Damien Zammit
--- x86_64/locore.S | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/x86_64/locore.S b/x86_64/locore.S index f0d1298d..2db0d49b 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -692,13 +692,14 @@ _kret_iret: trap_from_kernel: #ifMACH_KDB || MACH_TTD

Re: 64bit startup

2023-10-26 Thread Damien Zammit
Please check the locore.S on 64 bit. I think the int stack checks may not be pointing to the right location. I remember making some changes a long time ago without updating 64 bit because i had no way to test. Damien Sent from ProtonMail mobile Original Message On 27 Oct

Re: Initial POWER9 port of GNU Mach

2023-10-18 Thread Damien Zammit
Hi, On 17/10/23 3:10 am, Tobias Alexandra Platen wrote: > On Mon, 2023-10-16 at 02:39 +0000, Damien Zammit wrote: >> I dont think that is correct. I often use -kernel flag with qemu to >> boot gnumach on i386. >> I think it supports multiboot so you may need to add some st

[PATCH gnumach] Fix interrupt handling

2023-10-01 Thread Damien Zammit
Logic for interrupts: - interrupt.S raises spl (thus IF cleared) - interrupt.S EOI - interrupt.S calls the handler - for pure in-kernel handlers, they do whatever they want with IF cleared. - when a userland handler is registers, queue_intr masks the irq. - interrupt.S lowers spl with

Re: [PATCH gnumach] interrupt: Mask, eoi, unmask

2023-10-01 Thread Damien Zammit
On 2/10/23 10:56, Samuel Thibault wrote: > So in the end, I'd tend to think that it's up to queue_intr to do the > unmasking, like it does now, while spl is still high and thus we don't > risk nesting. That way it's the in-kernel intr handler that knows > whether to mask/unmask or not. I.e. it'd

Re: [PATCH gnumach] interrupt: Mask, eoi, unmask

2023-10-01 Thread Damien Zammit
Hi, On 1/10/23 20:13, Samuel Thibault wrote: > Sometimes the "why" of a commit is obvious, so it doesn't need to be > explained, but here it's really not and thus it definitely needs to > be. We have had various pings-pongs in the past about whether to EOI > before/after the interrupt, masking

[PATCH gnumach] interrupt: Mask, eoi, unmask

2023-09-30 Thread Damien Zammit
--- i386/i386at/interrupt.S | 19 --- x86_64/interrupt.S | 19 +++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/i386/i386at/interrupt.S b/i386/i386at/interrupt.S index 8ae6b97c..ec2fc656 100644 --- a/i386/i386at/interrupt.S +++

[PATCH gnumach] com/lpr: Handle masking of interrupts in the driver

2023-09-30 Thread Damien Zammit
--- i386/i386at/autoconf.c | 6 ++ i386/i386at/model_dep.c | 8 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/i386/i386at/autoconf.c b/i386/i386at/autoconf.c index ef813d92..5c69988f 100644 --- a/i386/i386at/autoconf.c +++ b/i386/i386at/autoconf.c @@ -29,6 +29,11 @@

[PATCH gnumach] kd: Handle masking of keyboard interrupt in the driver

2023-09-30 Thread Damien Zammit
--- i386/i386at/kd.h| 1 + i386/i386at/kd_event.c | 7 +++ i386/i386at/model_dep.c | 2 -- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 3ee707b5..5bfabce2 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -546,6 +546,7

[PATCH 1/4 gnumach] ioapic: Detect version of IOAPIC for correct EOI handling

2023-09-30 Thread Damien Zammit
--- i386/i386at/ioapic.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/i386/i386at/ioapic.c b/i386/i386at/ioapic.c index 218f9a51..57d18789 100644 --- a/i386/i386at/ioapic.c +++ b/i386/i386at/ioapic.c @@ -33,7 +33,7 @@ #include #include -static int

  1   2   3   4   5   6   7   >