Skip to content

Updated: GICv3 emulation#58

Draft
kent-mcleod wants to merge 2 commits intoseL4:masterfrom
kent-mcleod:kent/gicv3
Draft

Updated: GICv3 emulation#58
kent-mcleod wants to merge 2 commits intoseL4:masterfrom
kent-mcleod:kent/gicv3

Conversation

@kent-mcleod
Copy link
Copy Markdown
Member

@kent-mcleod kent-mcleod commented Jun 16, 2022

This PR adds an emulated GIC500 (GICv3) to libsel4vmm as a virtual device.

This branch is based off of an earlier PR, #8, by @pingerino which already included commits pulled together from a couple authors.
This has been tested with the imx8mm-evk platform to run a Linux guest VM with several pass-through peripherals.

Marking the PR as a draft for now, as some minor cleanup is still needed.

Some imx8mm changes: kent-mcleod@bd4b06c

uint32_t res4; /* 0x0054 */
uint32_t clrspi_sr; /* 0x0058 */
uint32_t res5[9]; /* [0x005C, 0x0080) */
uint32_t irq_group0[CONFIG_MAX_NUM_NODES]; /* [0x080, 0x84) */
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.

This copies the same sloppiness than in the GICv2. We are not adding 1 filed here, but multiple in case there are multiple codes. So the offsets mentioned in the comments are not really right. It does not matter practically, but it might be a bit misleading of one really does offset calculation here - they wont always work. But that's a separate thing to clean up one day

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.

This code was originally written several years ago. I've tried to fold through the updates to the original files as I've rebased it, but some things may have been missed. Thanks for pointing out any changes that were missed.

@axel-h
Copy link
Copy Markdown
Member

axel-h commented Jul 4, 2022

In some commit message you say

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>

I wonder, is this a toolin quirk or is Co-Author missing?

@kent-mcleod
Copy link
Copy Markdown
Member Author

In some commit message you say

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>

I wonder, is this a toolin quirk or is Co-Author missing?

I'm not sure what you mean. Co-authored-by: is how some Git applications can track multiple authors of a commit (https://stackoverflow.com/a/7442255)

@axel-h
Copy link
Copy Markdown
Member

axel-h commented Jul 4, 2022

Could you split this up and make the fixes a PR to merge first (remove unused function, vgic cleanups - calloc, use correct index in VGIC fault) before the refactoring and adding GICv3?

@axel-h
Copy link
Copy Markdown
Member

axel-h commented Jul 4, 2022

In some commit message you say

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>

I wonder, is this a toolin quirk or is Co-Author missing?

I'm not sure what you mean. Co-authored-by: is how some Git applications can track multiple authors of a commit (https://stackoverflow.com/a/7442255)

Ah ok, I did not see that you kept the original commits.

Comment thread libsel4vm/src/arch/arm/vgic/vgic_v2.c Outdated
assert(!"Unable to calloc memory for VGIC");
return -1;
}
vgic_virq_init(vgic);
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.

Agree, I found the same thing in one of my dev branches.

Comment thread libsel4vm/src/arch/arm/vgic/vdist.h Outdated
#define IRQ_IDX(irq) ((irq) / 32)
#define IRQ_BIT(irq) (1U << ((irq) % 32))

extern const struct vgic_dist_device dev_vgic_dist;
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.

if we put this here, for consistency we should also include a header that has the type definition.

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.

This doesn't need to be here anyway.

Comment thread libsel4vm/src/arch/arm/vgic/vgic.c Outdated
return is_spi_enabled(gic_dist, irq);
}

static inline void set_sgi_ppi_active(struct gic_dist_map *gic_dist, int irq, bool set_active, int vcpu_id)
Copy link
Copy Markdown
Member

@axel-h axel-h Jul 4, 2022

Choose a reason for hiding this comment

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

Yes, this seems unused, we are only accessing the field directly. I was a assuming this was kept in case a VMM needs to be able to manage something here. But activating interrupts unter the hood of a VM seems an odd thing to do.

@axel-h
Copy link
Copy Markdown
Member

axel-h commented Jul 5, 2022

Could you split this up and make the fixes a PR to merge first (remove unused function, vgic cleanups - calloc, use correct index in VGIC fault) before the refactoring and adding GICv3?

I have created #65 for this.

@kent-mcleod kent-mcleod force-pushed the kent/gicv3 branch 6 times, most recently from 3e88b18 to 94d29d5 Compare July 10, 2022 00:24
@kent-mcleod kent-mcleod force-pushed the kent/gicv3 branch 2 times, most recently from f785b5f to 615fdab Compare July 10, 2022 02:58
@axel-h axel-h mentioned this pull request Jul 10, 2022
return -1;
}

registers->dist = calloc(1, sizeof(struct gic_dist_map));
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.

I wonder, why do we allocate dist and redist separately and not make this a fixed part of vgic_reg_t, so we only have to allocate things once? That saves us 2 calls to calloc() and there would not be much difference because neither of these structs gets a special 4K alignment anyway.

@kent-mcleod kent-mcleod force-pushed the kent/gicv3 branch 2 times, most recently from f01cdbc to 051079c Compare July 13, 2022 02:45
kent-mcleod and others added 2 commits August 13, 2022 08:01
There are a few subtle differences in the gic distributor between gicv2
and v3. Refactor these into the gicv2 header to prepare for a gicv3
implementation.

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
This commit adds support for emulating the gicv3. Work for this commit
was pulled from prototype works by the following authors:

Co-authored-by: Kent McLeod <kent@kry10.com>
Co-authored-by: Yanyan Shen <yanyan.shen@data61.csiro.au>
Co-authored-by: Chris Guikema <chris.guikema@dornerworks.com>
Signed-off-by: Kent McLeod <kent@kry10.com>
@wom-bat
Copy link
Copy Markdown
Member

wom-bat commented Aug 16, 2022

How is this going? Are you @kent-mcleod still working on it?

@kent-mcleod
Copy link
Copy Markdown
Member Author

How is this going? Are you @kent-mcleod still working on it?

Most of the refactoring was merged in #68.
The remaining commits requires a little bit more cleanup, but I've not had time to finish it recently unfortunately.

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.

3 participants