Skip to content

Commit 381b9fb

Browse files
author
Axel Heider
committed
vm_arm: add priority in vm config struct
- Cleanup the definitions. - Set a default base value for the attribute. - Derive the other priorities in the config params template. - Do sanity check during template processing. Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
1 parent 03ada4d commit 381b9fb

5 files changed

Lines changed: 41 additions & 13 deletions

File tree

components/VM_Arm/configurations/vm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
emits HaveNotification notification_ready_connector; \
6464
maybe uses VMDTBPassthrough dtb_self; \
6565
provides VMDTBPassthrough dtb; \
66-
attribute int base_prio; \
66+
attribute int base_prio = 100; \
6767
attribute int num_vcpus = 1; \
6868
attribute int num_extra_frame_caps; \
6969
attribute int extra_frame_map_address; \

components/VM_Arm/src/main.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ seL4_CPtr camkes_alloc(seL4_ObjectType type, size_t size, unsigned flags);
7676
extern void *fs_buf;
7777
int start_extra_frame_caps;
7878

79-
int VM_PRIO = 100;
8079
int NUM_VCPUS = 1;
8180

82-
#define IRQSERVER_PRIO (VM_PRIO + 1)
8381
#define IRQ_MESSAGE_LABEL 0xCAFE
8482

8583
#define DMA_VSTART 0x40000000
@@ -552,7 +550,7 @@ static int vmm_init(const vm_config_t *vm_config)
552550
assert(!err);
553551

554552
/* Create an IRQ server */
555-
_irq_server = irq_server_new(vspace, vka, IRQSERVER_PRIO,
553+
_irq_server = irq_server_new(vspace, vka, vm_config->priority.irqserver,
556554
simple, simple_get_cnode(simple), fault_ep_obj.cptr,
557555
IRQ_MESSAGE_LABEL, 256, &_io_ops.malloc_ops);
558556
assert(_irq_server);
@@ -1241,7 +1239,7 @@ static int main_continued(void)
12411239
assert(!err);
12421240

12431241
for (int i = 0; i < NUM_VCPUS; i++) {
1244-
vm_vcpu_t *new_vcpu = create_vmm_plat_vcpu(&vm, VM_PRIO - 1);
1242+
vm_vcpu_t *new_vcpu = create_vmm_plat_vcpu(&vm, vm_config.priority.vcpu);
12451243
assert(new_vcpu);
12461244
}
12471245
vm_vcpu_t *vm_vcpu = vm.vcpus[BOOT_VCPU];
@@ -1291,15 +1289,10 @@ static int main_continued(void)
12911289
}
12921290

12931291
/* base_prio and num_vcpus are optional attributes of the VM component. */
1294-
extern const int __attribute__((weak)) base_prio;
12951292
extern const int __attribute__((weak)) num_vcpus;
12961293

12971294
int run(void)
12981295
{
1299-
/* if the base_prio attribute is set, use it */
1300-
if (&base_prio != NULL) {
1301-
VM_PRIO = base_prio;
1302-
}
13031296
/* if the num_vcpus attribute is set, try to use it */
13041297
if (&num_vcpus != NULL) {
13051298
if (num_vcpus > CONFIG_MAX_NUM_NODES) {

components/VM_Arm/vm_common.camkes

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ assembly {
3030
vm.cnode_size_bits = 23;
3131
vm.simple_untyped24_pool = 12;
3232

33-
vm.base_prio = 100;
34-
35-
vm._priority = 101;
33+
vm._priority = 101; /* priority of VM component's main thread */
3634
vm.sem_value = 0;
3735

3836
}

templates/seL4VMParameters.template.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,37 @@
2020

2121
const vm_config_t vm_config = {
2222

23+
.priority = {
24+
/*#
25+
* The CAmkES attribute '_priority' define the control thread's
26+
* priority, which is the thread that does the VMM setup and executes
27+
* the VMM even loop eventually.
28+
* The VMM attribute 'base_prio' defines the priorities to be used
29+
* - interrupt server thread: base_prio + 1
30+
* - vmm thread: base_prio
31+
* - vcpu thread(s): base_prio - 1
32+
* but these can never exceed the component priority. Furthermore these
33+
* constrains apply:
34+
* - the vcpu thread can't have a higher priority than the VMM's event
35+
* loop, otherwise it can't be preempted when an even arrives. It may
36+
* have equal priority, in this case events like IRQ injection get
37+
* delayed until the vcpu thread was preempted or yielded.
38+
* - the VMM thread can have a higher priority than the interrupt
39+
* server thread. They may have equal priority, but this also
40+
* increases e.g. interrupt latency.
41+
#*/
42+
/*- set comp_prio = config.get('_priority') -*/
43+
/*- set base_prio = config.get('base_prio') -*/
44+
/*- set irqserver_prio = min(comp_prio, base_prio + 1) -*/
45+
/*- set vcpu_prio = min(comp_prio, base_prio - 1) -*/
46+
/*- if ((vcpu_prio >= base_prio) or (irqserver_prio <= base_prio) -*/
47+
/*? raise(Exception('Invalid priority configuration')) ?*/
48+
/*- endif -*/
49+
.irqserver = /*? irqserver_prio ?*/,
50+
.vmm = /*? base_prio ?*/,
51+
.vcpu = /*? vcpu_prio ?*/,
52+
},
53+
2354
/*- if vm_address_config -*/
2455

2556
.ram = {

templates/seL4VMParameters.template.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
typedef struct {
1515

16+
struct {
17+
uint8_t vmm;
18+
uint8_t irqserver;
19+
uint8_t vcpu;
20+
} priority;
21+
1622
struct {
1723
uintptr_t phys_base;
1824
uintptr_t base;

0 commit comments

Comments
 (0)