Skip to content

Multiprocessor support #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stlankes opened this issue Apr 27, 2025 · 5 comments
Closed

Multiprocessor support #54

stlankes opened this issue Apr 27, 2025 · 5 comments

Comments

@stlankes
Copy link

stlankes commented Apr 27, 2025

Hello,

do you test if your crate is able to support a multiprocessor configuration?

In my case, I configure the first processor as followed:

let mut gic = unsafe {
        GicV3::new(
	       gicd_address.as_mut_ptr(),
	       gicr_address.as_mut_ptr(),
	       2,
	       false,
	)
};

gic.setup(0);
let sgi_intid = IntId::sgi(3);
gic.set_interrupt_priority(sgi_intid, Some(0), 0x00);
gic.enable_interrupt(sgi_intid, Some(0), true);

Afterwards, the processor 0 is able to send a software interrupt to itself as followed:

let sgi_intid = IntId::sgi(3);
irq_enable();
GicV3::send_sgi(
    sgi_intid,
    SgiTarget::List {
        affinity3: 0,
        affinity2: 0,
        affinity1: 0,
        target_list: 1 << 0,
    },
);

Processor 0 receives as expected the interrupt.

In addition, the processor 1 initialize the GIC as followed:

gic.init_cpu(1);
let sgi_intid = IntId::sgi(3);
gic.set_interrupt_priority(sgi_intid, Some(0), 0x00);
gic.enable_interrupt(sgi_intid, Some(0), true);
irq_enable();

Now, processor 0 wants to send an interrupt to processor 1 as followed:

let sgi_intid = IntId::sgi(3);
irq_enable();
GicV3::send_sgi(
    sgi_intid,
    SgiTarget::List {
        affinity3: 0,
        affinity2: 0,
        affinity1: 0,
        target_list: 1 << 1,
    },
);

Processor 1 doesn't receive any interrupt. Do I misunderstand your interface?

@qwandor
Copy link
Collaborator

qwandor commented May 2, 2025

This should work, I'll see if I can reproduce your issue.

@stlankes
Copy link
Author

stlankes commented May 3, 2025

My mistake... Also core 1 has to use gic.setup(1) instead of gic.init_cpu(1). You crate works also in our kernel

@stlankes stlankes closed this as completed May 3, 2025
@qwandor
Copy link
Collaborator

qwandor commented May 3, 2025

My mistake... Also core 1 has to use gic.setup(1) instead of gic.init_cpu(1). You crate works also in our kernel

That shouldn't be necessary, but the setup method is currently a bit of a weird mix of different things. I'll try to clean that up.

@stlankes
Copy link
Author

stlankes commented May 4, 2025

If you are interested, I used your crate for hermit-os/kernel#1705

I forgot also to use GicV3::set_priority_mask(0xff); on the second core...

@qwandor
Copy link
Collaborator

qwandor commented May 5, 2025

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants