Skip to content

Commit

Permalink
WiP: booting into the first instructions of the ME
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-rossier committed Jul 14, 2024
1 parent fa44abe commit 3c391dc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
16 changes: 11 additions & 5 deletions linux/linux/soo/core/injector.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,30 @@ size_t current_size = 0;
* @return slotID or -1 if no slotID available.
*/
int inject_ME(void *buffer, size_t size) {
int slotID;
int *val;
void *me = NULL;
int slotID;

DBG("Original contents at address: 0x%08x\n with size %d bytes\n", (unsigned long) buffer, size);

/* Allocate a contiguous memory region to host the ME*/
me = kmalloc(size, GFP_KERNEL);
me = kzalloc(size, GFP_KERNEL);
BUG_ON(!me);

memcpy(me, buffer, size);
val = kzalloc(sizeof(int), GFP_KERNEL);
BUG_ON(!val);

memcpy(me, buffer, size);

/* Now, the virtual address can be converted to the physical one in the
* soo_hypercall() function */

soo_hypercall(AVZ_INJECT_ME, me, &slotID, &size);
soo_hypercall(AVZ_INJECT_ME, me, val, NULL);
slotID = *val;

kfree(me);

kfree(val);

return slotID;
}

Expand Down
15 changes: 11 additions & 4 deletions linux/linux/soo/core/me_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@

int get_ME_state(unsigned int ME_slotID)
{
int val;
int *val;
int state;

val = ME_slotID;
val = kzalloc(sizeof(int), GFP_KERNEL);
BUG_ON(!val);

soo_hypercall(AVZ_GET_ME_STATE, NULL, &val, NULL);
*val = ME_slotID;

return val;
soo_hypercall(AVZ_GET_ME_STATE, NULL, val, NULL);
state = *val;

kfree(val);

return state;
}

/*
Expand Down
15 changes: 9 additions & 6 deletions linux/linux/soo/kernel/hypervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@

void avz_ME_unpause(domid_t domain_id, addr_t vbstore_pfn)
{
struct domctl op;
struct domctl *op;

lprintk("Trying to unpause ME domain %d...", domain_id);
op = kzalloc(sizeof(struct domctl), GFP_KERNEL);
BUG_ON(!op);

op.cmd = DOMCTL_unpauseME;
lprintk("Trying to unpause ME domain %d...", domain_id);

op.domain = domain_id;
op->cmd = DOMCTL_unpauseME;

op->domain = domain_id;

op.u.unpause_ME.vbstore_pfn = vbstore_pfn;
op->u.unpause_ME.vbstore_pfn = vbstore_pfn;

avz_hypercall(__HYPERVISOR_domctl, (long) &op, 0 ,0 ,0);
avz_hypercall(__HYPERVISOR_domctl, virt_to_phys(op), 0 ,0 ,0);
}

#if defined(CONFIG_SOO) && !defined(CONFIG_LINUXVIRT)
Expand Down

0 comments on commit 3c391dc

Please sign in to comment.