From: He Sheng hesheng@wxiat.com
Sunway inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5G7NL
--------------------------------
The user_fpsimd_state struct has been defined to hold fpu state which is also held in thread_struct. To reuse this struct, this patch makes a little change to user_fpsimd_state, then replace struct context_fpregs and fpcr of thread_struct.
This patch also moves definition of task_pt_regs and mm_segment_t to appropriate headers to avoid compile errors.
Signed-off-by: He Sheng hesheng@wxiat.com
Signed-off-by: Gu Zitao guzitao@wxiat.com --- arch/sw_64/include/asm/processor.h | 45 +-------- arch/sw_64/include/asm/ptrace.h | 4 - arch/sw_64/include/asm/thread_info.h | 5 + arch/sw_64/include/uapi/asm/ptrace.h | 8 +- arch/sw_64/kernel/asm-offsets.c | 67 +++++++------- arch/sw_64/kernel/fpu.S | 134 +++++++++++++-------------- arch/sw_64/kernel/process.c | 2 +- arch/sw_64/kernel/ptrace.c | 51 +++------- arch/sw_64/kernel/signal.c | 13 +-- arch/sw_64/kvm/entry.S | 40 ++++---- 10 files changed, 155 insertions(+), 214 deletions(-)
diff --git a/arch/sw_64/include/asm/processor.h b/arch/sw_64/include/asm/processor.h index 67d3b4368987..08e8cc8e5428 100644 --- a/arch/sw_64/include/asm/processor.h +++ b/arch/sw_64/include/asm/processor.h @@ -9,6 +9,10 @@ #define _ASM_SW64_PROCESSOR_H
#include <linux/personality.h> /* for ADDR_LIMIT_32BIT */ +#include <asm/ptrace.h> + +#define task_pt_regs(task) \ + ((struct pt_regs *) (task_stack_page(task) + 2 * PAGE_SIZE) - 1)
/* * Returns current instruction pointer ("program counter"). @@ -37,47 +41,8 @@ #define TASK_UNMAPPED_BASE \ ((current->personality & ADDR_LIMIT_32BIT) ? 0x40000000 : UNMAPPED_BASE)
-typedef struct { - unsigned long seg; -} mm_segment_t; - -struct context_fpregs { - unsigned long f0[4]; - unsigned long f1[4]; - unsigned long f2[4]; - unsigned long f3[4]; - unsigned long f4[4]; - unsigned long f5[4]; - unsigned long f6[4]; - unsigned long f7[4]; - unsigned long f8[4]; - unsigned long f9[4]; - unsigned long f10[4]; - unsigned long f11[4]; - unsigned long f12[4]; - unsigned long f13[4]; - unsigned long f14[4]; - unsigned long f15[4]; - unsigned long f16[4]; - unsigned long f17[4]; - unsigned long f18[4]; - unsigned long f19[4]; - unsigned long f20[4]; - unsigned long f21[4]; - unsigned long f22[4]; - unsigned long f23[4]; - unsigned long f24[4]; - unsigned long f25[4]; - unsigned long f26[4]; - unsigned long f27[4]; - unsigned long f28[4]; - unsigned long f29[4]; - unsigned long f30[4]; -} __aligned(32); /* 256 bits aligned for simd */ - struct thread_struct { - struct context_fpregs ctx_fp; - unsigned long fpcr; + struct user_fpsimd_state fpstate; /* Callee-saved registers */ unsigned long ra; unsigned long s[7]; /* s0 ~ s6 */ diff --git a/arch/sw_64/include/asm/ptrace.h b/arch/sw_64/include/asm/ptrace.h index 85f7a47fdee3..ac9943015663 100644 --- a/arch/sw_64/include/asm/ptrace.h +++ b/arch/sw_64/include/asm/ptrace.h @@ -3,10 +3,8 @@ #define _ASM_SW64_PTRACE_H
#include <uapi/asm/ptrace.h> -#include <linux/sched/task_stack.h> #include <asm/hmcall.h> #include <asm/thread_info.h> -#include <asm/processor.h> #include <asm/page.h>
/* @@ -65,8 +63,6 @@ struct pt_regs { #define kernel_stack_pointer(regs) (((regs->ps) >> 4) & (TASK_SIZE - 1)) #define instruction_pointer_set(regs, val) ((regs)->pc = val)
-#define task_pt_regs(task) \ - ((struct pt_regs *) (task_stack_page(task) + 2 * PAGE_SIZE) - 1)
#define current_pt_regs() \ ((struct pt_regs *) ((char *)current_thread_info() + 2 * PAGE_SIZE) - 1) diff --git a/arch/sw_64/include/asm/thread_info.h b/arch/sw_64/include/asm/thread_info.h index cffb09fc6262..33b95f815448 100644 --- a/arch/sw_64/include/asm/thread_info.h +++ b/arch/sw_64/include/asm/thread_info.h @@ -9,6 +9,11 @@ #include <asm/types.h> #include <asm/sysinfo.h>
+typedef struct { + unsigned long seg; +} mm_segment_t; + + struct pcb_struct { unsigned long ksp; unsigned long usp; diff --git a/arch/sw_64/include/uapi/asm/ptrace.h b/arch/sw_64/include/uapi/asm/ptrace.h index 1169d87c4b9c..a45b10b8914a 100644 --- a/arch/sw_64/include/uapi/asm/ptrace.h +++ b/arch/sw_64/include/uapi/asm/ptrace.h @@ -11,9 +11,15 @@ struct user_pt_regs { __u64 pstate; };
+/* 256 bits aligned for simd */ +struct fpreg { + __u64 v[4] __attribute__((aligned(32))); +}; + struct user_fpsimd_state { - __u64 vregs[124]; + struct fpreg fp[31]; __u64 fpcr; + __u64 __reserved[3]; };
/* PTRACE_ATTACH is 16 */ diff --git a/arch/sw_64/kernel/asm-offsets.c b/arch/sw_64/kernel/asm-offsets.c index 5dc59346996f..0c7e1e26eb05 100644 --- a/arch/sw_64/kernel/asm-offsets.c +++ b/arch/sw_64/kernel/asm-offsets.c @@ -178,40 +178,39 @@ void foo(void) DEFINE(HOST_INT_R16, offsetof(struct host_int_args, r16)); BLANK();
- DEFINE(TASK_THREAD, offsetof(struct task_struct, thread)); - DEFINE(THREAD_CTX_FP, offsetof(struct thread_struct, ctx_fp)); - DEFINE(THREAD_FPCR, offsetof(struct thread_struct, fpcr)); - DEFINE(CTX_FP_F0, offsetof(struct context_fpregs, f0)); - DEFINE(CTX_FP_F1, offsetof(struct context_fpregs, f1)); - DEFINE(CTX_FP_F2, offsetof(struct context_fpregs, f2)); - DEFINE(CTX_FP_F3, offsetof(struct context_fpregs, f3)); - DEFINE(CTX_FP_F4, offsetof(struct context_fpregs, f4)); - DEFINE(CTX_FP_F5, offsetof(struct context_fpregs, f5)); - DEFINE(CTX_FP_F6, offsetof(struct context_fpregs, f6)); - DEFINE(CTX_FP_F7, offsetof(struct context_fpregs, f7)); - DEFINE(CTX_FP_F8, offsetof(struct context_fpregs, f8)); - DEFINE(CTX_FP_F9, offsetof(struct context_fpregs, f9)); - DEFINE(CTX_FP_F10, offsetof(struct context_fpregs, f10)); - DEFINE(CTX_FP_F11, offsetof(struct context_fpregs, f11)); - DEFINE(CTX_FP_F12, offsetof(struct context_fpregs, f12)); - DEFINE(CTX_FP_F13, offsetof(struct context_fpregs, f13)); - DEFINE(CTX_FP_F14, offsetof(struct context_fpregs, f14)); - DEFINE(CTX_FP_F15, offsetof(struct context_fpregs, f15)); - DEFINE(CTX_FP_F16, offsetof(struct context_fpregs, f16)); - DEFINE(CTX_FP_F17, offsetof(struct context_fpregs, f17)); - DEFINE(CTX_FP_F18, offsetof(struct context_fpregs, f18)); - DEFINE(CTX_FP_F19, offsetof(struct context_fpregs, f19)); - DEFINE(CTX_FP_F20, offsetof(struct context_fpregs, f20)); - DEFINE(CTX_FP_F21, offsetof(struct context_fpregs, f21)); - DEFINE(CTX_FP_F22, offsetof(struct context_fpregs, f22)); - DEFINE(CTX_FP_F23, offsetof(struct context_fpregs, f23)); - DEFINE(CTX_FP_F24, offsetof(struct context_fpregs, f24)); - DEFINE(CTX_FP_F25, offsetof(struct context_fpregs, f25)); - DEFINE(CTX_FP_F26, offsetof(struct context_fpregs, f26)); - DEFINE(CTX_FP_F27, offsetof(struct context_fpregs, f27)); - DEFINE(CTX_FP_F28, offsetof(struct context_fpregs, f28)); - DEFINE(CTX_FP_F29, offsetof(struct context_fpregs, f29)); - DEFINE(CTX_FP_F30, offsetof(struct context_fpregs, f30)); + OFFSET(TASK_THREAD, task_struct, thread); + OFFSET(TASK_THREAD_F0, task_struct, thread.fpstate.fp[0]); + OFFSET(TASK_THREAD_F1, task_struct, thread.fpstate.fp[1]); + OFFSET(TASK_THREAD_F2, task_struct, thread.fpstate.fp[2]); + OFFSET(TASK_THREAD_F3, task_struct, thread.fpstate.fp[3]); + OFFSET(TASK_THREAD_F4, task_struct, thread.fpstate.fp[4]); + OFFSET(TASK_THREAD_F5, task_struct, thread.fpstate.fp[5]); + OFFSET(TASK_THREAD_F6, task_struct, thread.fpstate.fp[6]); + OFFSET(TASK_THREAD_F7, task_struct, thread.fpstate.fp[7]); + OFFSET(TASK_THREAD_F8, task_struct, thread.fpstate.fp[8]); + OFFSET(TASK_THREAD_F9, task_struct, thread.fpstate.fp[9]); + OFFSET(TASK_THREAD_F10, task_struct, thread.fpstate.fp[10]); + OFFSET(TASK_THREAD_F11, task_struct, thread.fpstate.fp[11]); + OFFSET(TASK_THREAD_F12, task_struct, thread.fpstate.fp[12]); + OFFSET(TASK_THREAD_F13, task_struct, thread.fpstate.fp[13]); + OFFSET(TASK_THREAD_F14, task_struct, thread.fpstate.fp[14]); + OFFSET(TASK_THREAD_F15, task_struct, thread.fpstate.fp[15]); + OFFSET(TASK_THREAD_F16, task_struct, thread.fpstate.fp[16]); + OFFSET(TASK_THREAD_F17, task_struct, thread.fpstate.fp[17]); + OFFSET(TASK_THREAD_F18, task_struct, thread.fpstate.fp[18]); + OFFSET(TASK_THREAD_F19, task_struct, thread.fpstate.fp[19]); + OFFSET(TASK_THREAD_F20, task_struct, thread.fpstate.fp[20]); + OFFSET(TASK_THREAD_F21, task_struct, thread.fpstate.fp[21]); + OFFSET(TASK_THREAD_F22, task_struct, thread.fpstate.fp[22]); + OFFSET(TASK_THREAD_F23, task_struct, thread.fpstate.fp[23]); + OFFSET(TASK_THREAD_F24, task_struct, thread.fpstate.fp[24]); + OFFSET(TASK_THREAD_F25, task_struct, thread.fpstate.fp[25]); + OFFSET(TASK_THREAD_F26, task_struct, thread.fpstate.fp[26]); + OFFSET(TASK_THREAD_F27, task_struct, thread.fpstate.fp[27]); + OFFSET(TASK_THREAD_F28, task_struct, thread.fpstate.fp[28]); + OFFSET(TASK_THREAD_F29, task_struct, thread.fpstate.fp[29]); + OFFSET(TASK_THREAD_F30, task_struct, thread.fpstate.fp[30]); + OFFSET(TASK_THREAD_FPCR, task_struct, thread.fpstate.fpcr); BLANK(); OFFSET(TASK_THREAD_RA, task_struct, thread.ra); OFFSET(TASK_THREAD_S0, task_struct, thread.s[0]); diff --git a/arch/sw_64/kernel/fpu.S b/arch/sw_64/kernel/fpu.S index 25dcf4740525..3cb3bfab08e8 100644 --- a/arch/sw_64/kernel/fpu.S +++ b/arch/sw_64/kernel/fpu.S @@ -8,49 +8,46 @@ .set noat ENTRY(__fpstate_save) /* a0: prev task */ - ldi a0, TASK_THREAD(a0) - ldi t0, THREAD_CTX_FP(a0) - vstd $f0, CTX_FP_F0(t0) - vstd $f1, CTX_FP_F1(t0) - vstd $f2, CTX_FP_F2(t0) - vstd $f3, CTX_FP_F3(t0) - vstd $f4, CTX_FP_F4(t0) - vstd $f5, CTX_FP_F5(t0) - vstd $f6, CTX_FP_F6(t0) - vstd $f7, CTX_FP_F7(t0) - vstd $f8, CTX_FP_F8(t0) - vstd $f9, CTX_FP_F9(t0) - vstd $f10, CTX_FP_F10(t0) - vstd $f11, CTX_FP_F11(t0) - vstd $f12, CTX_FP_F12(t0) - vstd $f13, CTX_FP_F13(t0) - vstd $f14, CTX_FP_F14(t0) - vstd $f15, CTX_FP_F15(t0) - vstd $f16, CTX_FP_F16(t0) - vstd $f17, CTX_FP_F17(t0) - vstd $f18, CTX_FP_F18(t0) - vstd $f19, CTX_FP_F19(t0) - vstd $f20, CTX_FP_F20(t0) - vstd $f21, CTX_FP_F21(t0) - vstd $f22, CTX_FP_F22(t0) - vstd $f23, CTX_FP_F23(t0) - vstd $f24, CTX_FP_F24(t0) - vstd $f25, CTX_FP_F25(t0) - vstd $f26, CTX_FP_F26(t0) - vstd $f27, CTX_FP_F27(t0) + vstd $f0, TASK_THREAD_F0(a0) + vstd $f1, TASK_THREAD_F1(a0) + vstd $f2, TASK_THREAD_F2(a0) + vstd $f3, TASK_THREAD_F3(a0) + vstd $f4, TASK_THREAD_F4(a0) + vstd $f5, TASK_THREAD_F5(a0) + vstd $f6, TASK_THREAD_F6(a0) + vstd $f7, TASK_THREAD_F7(a0) + vstd $f8, TASK_THREAD_F8(a0) + vstd $f9, TASK_THREAD_F9(a0) + vstd $f10, TASK_THREAD_F10(a0) + vstd $f11, TASK_THREAD_F11(a0) + vstd $f12, TASK_THREAD_F12(a0) + vstd $f13, TASK_THREAD_F13(a0) + vstd $f14, TASK_THREAD_F14(a0) + vstd $f15, TASK_THREAD_F15(a0) + vstd $f16, TASK_THREAD_F16(a0) + vstd $f17, TASK_THREAD_F17(a0) + vstd $f18, TASK_THREAD_F18(a0) + vstd $f19, TASK_THREAD_F19(a0) + vstd $f20, TASK_THREAD_F20(a0) + vstd $f21, TASK_THREAD_F21(a0) + vstd $f22, TASK_THREAD_F22(a0) + vstd $f23, TASK_THREAD_F23(a0) + vstd $f24, TASK_THREAD_F24(a0) + vstd $f25, TASK_THREAD_F25(a0) + vstd $f26, TASK_THREAD_F26(a0) + vstd $f27, TASK_THREAD_F27(a0) rfpcr $f0 - vstd $f28, CTX_FP_F28(t0) - vstd $f29, CTX_FP_F29(t0) - vstd $f30, CTX_FP_F30(t0) - fstd $f0, THREAD_FPCR(a0) - vldd $f0, CTX_FP_F0(t0) + vstd $f28, TASK_THREAD_F28(a0) + vstd $f29, TASK_THREAD_F29(a0) + vstd $f30, TASK_THREAD_F30(a0) + fstd $f0, TASK_THREAD_FPCR(a0) + vldd $f0, TASK_THREAD_F0(a0) ret END(__fpstate_save)
ENTRY(__fpstate_restore) /* a0: next task */ - ldi a0, TASK_THREAD(a0) - fldd $f0, THREAD_FPCR(a0) + fldd $f0, TASK_THREAD_FPCR(a0) wfpcr $f0 fimovd $f0, t1 and t1, 0x3, t1 @@ -70,37 +67,36 @@ $setfpec_1: $setfpec_2: setfpec2 $setfpec_over: - ldi t0, THREAD_CTX_FP(a0) - vldd $f0, CTX_FP_F0(t0) - vldd $f1, CTX_FP_F1(t0) - vldd $f2, CTX_FP_F2(t0) - vldd $f3, CTX_FP_F3(t0) - vldd $f4, CTX_FP_F4(t0) - vldd $f5, CTX_FP_F5(t0) - vldd $f6, CTX_FP_F6(t0) - vldd $f7, CTX_FP_F7(t0) - vldd $f8, CTX_FP_F8(t0) - vldd $f9, CTX_FP_F9(t0) - vldd $f10, CTX_FP_F10(t0) - vldd $f11, CTX_FP_F11(t0) - vldd $f12, CTX_FP_F12(t0) - vldd $f13, CTX_FP_F13(t0) - vldd $f14, CTX_FP_F14(t0) - vldd $f15, CTX_FP_F15(t0) - vldd $f16, CTX_FP_F16(t0) - vldd $f17, CTX_FP_F17(t0) - vldd $f18, CTX_FP_F18(t0) - vldd $f19, CTX_FP_F19(t0) - vldd $f20, CTX_FP_F20(t0) - vldd $f21, CTX_FP_F21(t0) - vldd $f22, CTX_FP_F22(t0) - vldd $f23, CTX_FP_F23(t0) - vldd $f24, CTX_FP_F24(t0) - vldd $f25, CTX_FP_F25(t0) - vldd $f26, CTX_FP_F26(t0) - vldd $f27, CTX_FP_F27(t0) - vldd $f28, CTX_FP_F28(t0) - vldd $f29, CTX_FP_F29(t0) - vldd $f30, CTX_FP_F30(t0) + vldd $f0, TASK_THREAD_F0(a0) + vldd $f1, TASK_THREAD_F1(a0) + vldd $f2, TASK_THREAD_F2(a0) + vldd $f3, TASK_THREAD_F3(a0) + vldd $f4, TASK_THREAD_F4(a0) + vldd $f5, TASK_THREAD_F5(a0) + vldd $f6, TASK_THREAD_F6(a0) + vldd $f7, TASK_THREAD_F7(a0) + vldd $f8, TASK_THREAD_F8(a0) + vldd $f9, TASK_THREAD_F9(a0) + vldd $f10, TASK_THREAD_F10(a0) + vldd $f11, TASK_THREAD_F11(a0) + vldd $f12, TASK_THREAD_F12(a0) + vldd $f13, TASK_THREAD_F13(a0) + vldd $f14, TASK_THREAD_F14(a0) + vldd $f15, TASK_THREAD_F15(a0) + vldd $f16, TASK_THREAD_F16(a0) + vldd $f17, TASK_THREAD_F17(a0) + vldd $f18, TASK_THREAD_F18(a0) + vldd $f19, TASK_THREAD_F19(a0) + vldd $f20, TASK_THREAD_F20(a0) + vldd $f21, TASK_THREAD_F21(a0) + vldd $f22, TASK_THREAD_F22(a0) + vldd $f23, TASK_THREAD_F23(a0) + vldd $f24, TASK_THREAD_F24(a0) + vldd $f25, TASK_THREAD_F25(a0) + vldd $f26, TASK_THREAD_F26(a0) + vldd $f27, TASK_THREAD_F27(a0) + vldd $f28, TASK_THREAD_F28(a0) + vldd $f29, TASK_THREAD_F29(a0) + vldd $f30, TASK_THREAD_F30(a0) ret END(__fpstate_restore) diff --git a/arch/sw_64/kernel/process.c b/arch/sw_64/kernel/process.c index 6b5f0f3a8345..308675d29c04 100644 --- a/arch/sw_64/kernel/process.c +++ b/arch/sw_64/kernel/process.c @@ -256,7 +256,7 @@ EXPORT_SYMBOL(dump_elf_task); int dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task) { - memcpy(dest, &task->thread.ctx_fp, 32 * 8); + memcpy(dest, &task->thread.fpstate, 32 * 8); return 1; } EXPORT_SYMBOL(dump_elf_task_fp); diff --git a/arch/sw_64/kernel/ptrace.c b/arch/sw_64/kernel/ptrace.c index 94fba3569781..bdbd0d97a130 100644 --- a/arch/sw_64/kernel/ptrace.c +++ b/arch/sw_64/kernel/ptrace.c @@ -9,6 +9,7 @@ #include <linux/audit.h> #include <linux/regset.h> #include <linux/elf.h> +#include <linux/sched/task_stack.h>
#include <asm/reg.h> #include <asm/asm-offsets.h> @@ -55,9 +56,6 @@ enum { REG_GP = 29 };
-#define FP_REG(fp_regno, vector_regno) \ - (fp_regno * 32 + vector_regno * 8) - #define R(x) ((size_t) &((struct pt_regs *)0)->x)
short regoffsets[32] = { @@ -91,8 +89,8 @@ static unsigned long zero; static unsigned long * get_reg_addr(struct task_struct *task, unsigned long regno) { - unsigned long *addr; - int fp_regno, vector_regno; + void *addr; + int fno, vno;
switch (regno) { case USP: @@ -108,9 +106,8 @@ get_reg_addr(struct task_struct *task, unsigned long regno) addr = (void *)task_pt_regs(task) + regoffsets[regno]; break; case FPREG_BASE ... FPREG_END: - fp_regno = regno - FPREG_BASE; - vector_regno = 0; - addr = (void *)((unsigned long)&task->thread.ctx_fp + FP_REG(fp_regno, vector_regno)); + fno = regno - FPREG_BASE; + addr = &task->thread.fpstate.fp[fno].v[0]; break; case VECREG_BASE ... VECREG_END: /* @@ -121,12 +118,12 @@ get_reg_addr(struct task_struct *task, unsigned long regno) addr = &zero; break; } - fp_regno = (regno - VECREG_BASE) & 0x1f; - vector_regno = 1 + ((regno - VECREG_BASE) >> 5); - addr = (void *)((unsigned long)&task->thread.ctx_fp + FP_REG(fp_regno, vector_regno)); + fno = (regno - VECREG_BASE) & 0x1f; + vno = 1 + ((regno - VECREG_BASE) >> 5); + addr = &task->thread.fpstate.fp[fno].v[vno]; break; case FPCR: - addr = (void *)&task->thread.fpcr; + addr = &task->thread.fpstate.fpcr; break; case PC: addr = (void *)task_pt_regs(task) + PT_REGS_PC; @@ -322,17 +319,9 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset, struct membuf to) { - int ret; - struct user_fpsimd_state uregs; - - memcpy(uregs.vregs, &target->thread.ctx_fp, - sizeof(struct context_fpregs)); - - uregs.fpcr = target->thread.fpcr; - - ret = membuf_write(&to, &uregs, sizeof(uregs));
- return ret; + return membuf_write(&to, &target->thread.fpstate, + sizeof(struct user_fpsimd_state)); }
static int fpr_set(struct task_struct *target, @@ -340,21 +329,9 @@ static int fpr_set(struct task_struct *target, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { - int ret; - struct user_fpsimd_state uregs; - - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, - &uregs, 0, sizeof(uregs)); - - if (ret) - return ret; - - memcpy(&target->thread.ctx_fp, uregs.vregs, - sizeof(struct context_fpregs)); - - target->thread.fpcr = uregs.fpcr; - - return ret; + return user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.fpstate, 0, + sizeof(struct user_fpsimd_state)); }
enum sw64_regset { diff --git a/arch/sw_64/kernel/signal.c b/arch/sw_64/kernel/signal.c index 887326812624..6a6203ccb04f 100644 --- a/arch/sw_64/kernel/signal.c +++ b/arch/sw_64/kernel/signal.c @@ -100,9 +100,10 @@ restore_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs) err |= __get_user(usp, sc->sc_regs+30); wrusp(usp); /* simd-fp */ - err |= __copy_from_user(¤t->thread.ctx_fp, - &sc->sc_fpregs, sizeof(struct context_fpregs)); - err |= __get_user(current->thread.fpcr, &sc->sc_fpcr); + err |= __copy_from_user(¤t->thread.fpstate, &sc->sc_fpregs, + offsetof(struct user_fpsimd_state, fpcr)); + err |= __get_user(current->thread.fpstate.fpcr, &sc->sc_fpcr); + if (likely(!err)) __fpstate_restore(current);
@@ -230,9 +231,9 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, err |= __put_user(0, sc->sc_regs+31); /* simd-fp */ __fpstate_save(current); - err |= __copy_to_user(&sc->sc_fpregs, - ¤t->thread.ctx_fp, sizeof(struct context_fpregs)); - err |= __put_user(current->thread.fpcr, &sc->sc_fpcr); + err |= __copy_to_user(&sc->sc_fpregs, ¤t->thread.fpstate, + offsetof(struct user_fpsimd_state, fpcr)); + err |= __put_user(current->thread.fpstate.fpcr, &sc->sc_fpcr);
err |= __put_user(regs->trap_a0, &sc->sc_traparg_a0); err |= __put_user(regs->trap_a1, &sc->sc_traparg_a1); diff --git a/arch/sw_64/kvm/entry.S b/arch/sw_64/kvm/entry.S index 1e089da5378e..0c02b68ee7d0 100644 --- a/arch/sw_64/kvm/entry.S +++ b/arch/sw_64/kvm/entry.S @@ -15,18 +15,16 @@ ENTRY(__sw64_vcpu_run)
/* save host fpregs */ ldl $1, TI_TASK($8) - ldi $1, TASK_THREAD($1) rfpcr $f0 - fstd $f0, THREAD_FPCR($1) - ldi $1, THREAD_CTX_FP($1) - vstd $f2, CTX_FP_F2($1) - vstd $f3, CTX_FP_F3($1) - vstd $f4, CTX_FP_F4($1) - vstd $f5, CTX_FP_F5($1) - vstd $f6, CTX_FP_F6($1) - vstd $f7, CTX_FP_F7($1) - vstd $f8, CTX_FP_F8($1) - vstd $f9, CTX_FP_F9($1) + fstd $f0, TASK_THREAD_FPCR($1) + vstd $f2, TASK_THREAD_F2($1) + vstd $f3, TASK_THREAD_F3($1) + vstd $f4, TASK_THREAD_F4($1) + vstd $f5, TASK_THREAD_F5($1) + vstd $f6, TASK_THREAD_F6($1) + vstd $f7, TASK_THREAD_F7($1) + vstd $f8, TASK_THREAD_F8($1) + vstd $f9, TASK_THREAD_F9($1)
ldi sp, -VCPU_RET_SIZE(sp) /* r16 = guest kvm_vcpu_arch.vcb struct pointer */ @@ -213,8 +211,7 @@ $g_setfpec_over: bic sp, $8, $8 /* restore host fpregs */ ldl $1, TI_TASK($8) - ldi $1, TASK_THREAD($1) - fldd $f0, THREAD_FPCR($1) + fldd $f0, TASK_THREAD_FPCR($1) wfpcr $f0 fimovd $f0, $2 and $2, 0x3, $2 @@ -234,15 +231,14 @@ $setfpec_1: $setfpec_2: setfpec2 $setfpec_over: - ldi $1, THREAD_CTX_FP($1) - vldd $f2, CTX_FP_F2($1) - vldd $f3, CTX_FP_F3($1) - vldd $f4, CTX_FP_F4($1) - vldd $f5, CTX_FP_F5($1) - vldd $f6, CTX_FP_F6($1) - vldd $f7, CTX_FP_F7($1) - vldd $f8, CTX_FP_F8($1) - vldd $f9, CTX_FP_F9($1) + vldd $f2, TASK_THREAD_F2($1) + vldd $f3, TASK_THREAD_F3($1) + vldd $f4, TASK_THREAD_F4($1) + vldd $f5, TASK_THREAD_F5($1) + vldd $f6, TASK_THREAD_F6($1) + vldd $f7, TASK_THREAD_F7($1) + vldd $f8, TASK_THREAD_F8($1) + vldd $f9, TASK_THREAD_F9($1)
/* if $0 > 0, handle hcall */ bgt $0, $ret_to