uti: rename x86-specific 'fs' to 'tls' + arm implem

Note: the original fujitsu implementation didn't rename the various
save_fs function/desc to save_tls for some reason, might as well go all
the way though...

Change-Id: Ic362c15c8b320c4d258d2ead8c5fd4eafd9d0ae9
Fujitsu: POSTK_DEBUG_ARCH_DEP_91
This commit is contained in:
Shiratori, Takehiro
2019-03-12 14:35:27 +09:00
committed by Masamichi Takagi
parent 8356ef6c96
commit c32edff2bb
8 changed files with 79 additions and 46 deletions

View File

@@ -145,14 +145,13 @@ out:
void *
get_user_sp(void)
{
/* TODO; skeleton for UTI */
return NULL;
return (void *)current_pt_regs()->sp;
}
void
set_user_sp(void *usp)
{
/* TODO; skeleton for UTI */
current_pt_regs()->sp = (unsigned long)usp;
}
struct trans_uctx {
@@ -163,22 +162,44 @@ struct trans_uctx {
};
void
restore_fs(unsigned long fs)
restore_tls(unsigned long addr)
{
/* TODO; skeleton for UTI */
const unsigned long tpidrro = 0;
asm volatile(
" msr tpidr_el0, %0\n"
" msr tpidrro_el0, %1"
: : "r" (addr), "r" (tpidrro));
}
void
save_fs_ctx(void *ctx)
save_tls_ctx(void __user *ctx)
{
/* TODO; skeleton for UTI */
struct trans_uctx __user *tctx = ctx;
unsigned long baseaddr;
asm volatile(
" mrs %0, tpidr_el0"
: "=r" (baseaddr));
if (copy_to_user(&tctx->tls_baseaddr, &baseaddr,
sizeof(tctx->tls_baseaddr))) {
pr_err("%s: copy_to_user failed.\n", __func__);
return;
}
}
unsigned long
get_fs_ctx(void *ctx)
get_tls_ctx(void __user *ctx)
{
/* TODO; skeleton for UTI */
return 0;
struct trans_uctx __user *tctx = ctx;
struct trans_uctx kctx;
if (copy_from_user(&kctx, tctx, sizeof(struct trans_uctx))) {
pr_err("%s: copy_from_user failed.\n", __func__);
return 0;
}
return kctx.tls_baseaddr;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
@@ -294,7 +315,7 @@ out:
* Context register save/load is done on Linux (get from current_pt_regs).
* Do TLS save/load and register host_thread with ioctl.
*/
long arch_switch_ctx(struct uti_save_fs_desc *desc)
long arch_switch_ctx(struct uti_switch_ctx_desc *desc)
{
int rc = 0;
struct trans_uctx *__user rctx = NULL;
@@ -318,7 +339,7 @@ long arch_switch_ctx(struct uti_save_fs_desc *desc)
rc = -EFAULT;
goto out;
}
restore_fs(get_fs_ctx(rctx));
restore_tls(get_tls_ctx(rctx));
out:
return rc;

View File

@@ -261,25 +261,35 @@ struct trans_uctx {
};
void
restore_fs(unsigned long fs)
restore_tls(unsigned long addr)
{
wrmsrl(MSR_FS_BASE, fs);
wrmsrl(MSR_FS_BASE, addr);
}
void
save_fs_ctx(void *ctx)
save_tls_ctx(void __user *ctx)
{
struct trans_uctx *tctx = ctx;
struct trans_uctx __user *tctx = ctx;
struct trans_uctx kctx;
rdmsrl(MSR_FS_BASE, tctx->fs);
if (copy_from_user(&kctx, tctx, sizeof(struct trans_uctx))) {
pr_err("%s: copy_from_user failed.\n", __func__);
return;
}
rdmsrl(MSR_FS_BASE, kctx.fs);
}
unsigned long
get_fs_ctx(void *ctx)
get_tls_ctx(void __user *ctx)
{
struct trans_uctx *tctx = ctx;
struct trans_uctx __user *tctx = ctx;
struct trans_uctx kctx;
return tctx->fs;
if (copy_from_user(&kctx, tctx, sizeof(struct trans_uctx))) {
pr_err("%s: copy_from_user failed.\n", __func__);
return 0;
}
return kctx.fs;
}
unsigned long
@@ -370,9 +380,9 @@ static inline bool pte_is_write_combined(pte_t pte)
/*
* The assembler switch_ctx is save/load registers in the context.
* Do FS save/load and register host_thread with ioctl.
* Do TLS save/load and register host_thread with ioctl.
*/
long arch_switch_ctx(struct uti_save_fs_desc *desc)
long arch_switch_ctx(struct uti_switch_ctx_desc *desc)
{
return 0;
}