Skip to content

GICv3 emulation preparation PR#68

Merged
kent-mcleod merged 6 commits intoseL4:masterfrom
kent-mcleod:kent/gicv3-1
Jul 13, 2022
Merged

GICv3 emulation preparation PR#68
kent-mcleod merged 6 commits intoseL4:masterfrom
kent-mcleod:kent/gicv3-1

Conversation

@kent-mcleod
Copy link
Copy Markdown
Member

These changes are the first few commits from #58 which reorganize the vgic code to allow adding support for GICv3.

For reviewing, these changes shouldn't be changing any behavior of the current implementation and are only supposed to be moving code around with a few function prototype changes, eg static -> static inline.

@kent-mcleod kent-mcleod requested a review from axel-h July 10, 2022 00:31
@kent-mcleod kent-mcleod force-pushed the kent/gicv3-1 branch 5 times, most recently from 5cea508 to a5500a1 Compare July 10, 2022 02:58
Comment thread libsel4vm/src/arch/arm/vgic/vgic_v2.c Outdated
Comment thread libsel4vm/src/arch/arm/vgic/virq.h Outdated
virq->ack = ack_fn;
}

static inline struct vgic *vgic_device_get_vgic(struct vgic_dist_device *d)
Copy link
Copy Markdown
Member

@axel-h axel-h Jul 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not really belong here, it would fit better in vgic_v2.c even if this duplicates code for GICv3 then. I have a branch where struct vgic_dist_device is dropped completely and this is all part of the struct vgic (see #69) then, but have to check how this would work with the GICv3 code then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you say makes sense about the function staying in vgic_v2.c, I need to check with the old version whether it had it in there or whether I accidentally pulled it in during a rebase.

I'm not sure whether dropping vgic_dist_device would make the code cleaner and it'd be better to wait until v3 code is merged before we consider IMO.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new commit to address this: 0ec24c1. I think it's a bit reactive, but still reasonable to fix it this way.

return 0;
}

int vm_inject_irq(vm_vcpu_t *vcpu, int irq)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seem this function remains the same in GICv2 and GICv3. Thus I think it would make sense to keep thios in a common file and avoid code duplication. If there are differences in the future, we can still split this up,

return 0;
}

int vm_vgic_maintenance_handler(vm_vcpu_t *vcpu)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this function and alsdo handle_vgic_maintenance() are the same in GICv2 and GIV3, so I'd keep this in a common file for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're slightly different since GICv3 uses group 1 while GICv2 uses group 0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(only handle_vgic_maintenance differs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but that could be a constant then. My main point at the moment it trying to have GICv3 support with out renaming the source file and moving code, so the change are easier to maintain.

Copy link
Copy Markdown
Member

@axel-h axel-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I not too happy with some things in the code, but it the greater goal is adding some GICv3 support finally, then I wont block this.

kent-mcleod and others added 6 commits July 13, 2022 12:43
Declare dev_vgic_dist as containing a vgic_t object, but leave the
definition abstract for the implementation to define. This doesn't
change much for the public API, but allows the internal implementation
to assume that the field is always a vgic_t reference which it always
is.

Signed-off-by: Kent McLeod <kent@kry10.com>
- pull virq functionality that is not only relevant to the gicv2 into
another header file, virq.h

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
Makes inlining consistent and allows header file to be included in more
than one source file if necessary.

Signed-off-by: Kent McLeod <kent@kry10.com>
This code is common between the gicv2 and giv3

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
vgic.c virtualises the gicv2

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
The incoming gic_v3 driver needs to use group 1 for interrupts it
injects, while gic_v2 needs to use group 0.

Signed-off-by: Kent McLeod <kent@kry10.com>
@kent-mcleod kent-mcleod merged commit 39c5097 into seL4:master Jul 13, 2022
@kent-mcleod kent-mcleod deleted the kent/gicv3-1 branch July 13, 2022 04:34
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

Successfully merging this pull request may close these issues.

4 participants