Skip to content
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

msm8939: huawei-kiwi: add lk1st #449

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/msm_shared/include/scm.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ typedef struct {
uint32_t x4; /* Param3 */
uint32_t x5[10]; /* Indirect parameter list */
uint32_t atomic; /* To indicate if its standard or fast call */
uint32_t hvc; /* Make a hypervisor call instead */
} scmcall_arg;

/* Return value for the SCM call:
Expand Down
50 changes: 48 additions & 2 deletions platform/msm_shared/scm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,12 @@ void scm_elexec_call(paddr_t kernel_entry, paddr_t dtb_offset)
scm_arg.x2 = (uint32_t ) &param;
scm_arg.x3 = sizeof(el1_system_param);

/* First try a hypervisor call to jump to EL2 if supported */
scm_arg.hvc = true;
scm_call2(&scm_arg, NULL);

dprintf(INFO, "Falling back to SCM call\n");
scm_arg.hvc = false;
Comment on lines +1080 to +1085
Copy link
Member

Choose a reason for hiding this comment

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

This will crash on platforms that don't have hyp partition (or otherwise don't allow unknown hvc calls) so we didn't include el2 support until now, pending changes in qhypstub. Unfortunately neither me nor @stephan-gh had time to fix this yet...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'd prefer not re-introducing this to the new branch. It's cleaner to change this in qhypstub.

scm_call2(&scm_arg, NULL);
}

Expand Down Expand Up @@ -1223,6 +1229,43 @@ static uint32_t scm_call_a32(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3,
return r0;
}

static uint32_t hvc_call_a32(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, uint32_t x4, uint32_t x5, scmcall_ret *ret)
{
register uint32_t r0 __asm__("r0") = x0;
register uint32_t r1 __asm__("r1") = x1;
register uint32_t r2 __asm__("r2") = x2;
register uint32_t r3 __asm__("r3") = x3;
register uint32_t r4 __asm__("r4") = x4;
register uint32_t r5 __asm__("r5") = x5;

do {
__asm__ volatile(
__asmeq("%0", "r0")
__asmeq("%1", "r1")
__asmeq("%2", "r2")
__asmeq("%3", "r3")
__asmeq("%4", "r0")
__asmeq("%5", "r1")
__asmeq("%6", "r2")
__asmeq("%7", "r3")
__asmeq("%8", "r4")
__asmeq("%9", "r5")
".cpu cortex-a7\n"
"hvc #0 @ switch to hypervisor\n"
: "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3)
: "r" (r0), "r" (r1), "r" (r2), "r" (r3), "r" (r4), "r" (r5));
} while(r0 == 1);

if (ret)
{
ret->x1 = r1;
ret->x2 = r2;
ret->x3 = r3;
}

return r0;
}

uint32_t scm_call2(scmcall_arg *arg, scmcall_ret *ret)
{
uint32_t *indir_arg = NULL;
Expand All @@ -1246,11 +1289,14 @@ uint32_t scm_call2(scmcall_arg *arg, scmcall_ret *ret)
x5 = (addr_t) indir_arg;
}

rc = scm_call_a32(arg->x0, arg->x1, arg->x2, arg->x3, arg->x4, x5, ret);
if (arg->hvc)
rc = hvc_call_a32(arg->x0, arg->x1, arg->x2, arg->x3, arg->x4, x5, ret);
else
rc = scm_call_a32(arg->x0, arg->x1, arg->x2, arg->x3, arg->x4, x5, ret);

if (rc)
{
dprintf(CRITICAL, "SCM call: 0x%x failed with :%x\n", arg->x0, rc);
dprintf(CRITICAL, "%s call: 0x%x failed with :%x\n", arg->hvc ? "HVC" : "SCM", arg->x0, rc);
return rc;
}

Expand Down