On Thu, Dec 3, 2015 at 9:08 AM, Barret Rhoden <[email protected]> wrote:
> +
> + if (x86_hwtf_is_partial(tf)) {
> + swap_gs();
> + } else {
> + write_msr(MSR_GS_BASE, (uint64_t)tf->tf_gsbase);
> + write_msr(MSR_FS_BASE, (uint64_t)tf->tf_fsbase);
> + }
>
This might deserve a static inline, given it's repeated sometime below.
> diff --git a/kern/arch/x86/ros/trapframe64.h
> b/kern/arch/x86/ros/trapframe64.h
> index eb209ddd717d..af2de4cfe886 100644
> --- a/kern/arch/x86/ros/trapframe64.h
> +++ b/kern/arch/x86/ros/trapframe64.h
> @@ -23,20 +23,20 @@ struct hw_trapframe {
> uint64_t tf_r14;
> uint64_t tf_r15;
> uint32_t tf_trapno;
> - uint32_t tf_padding5;
> + uint32_t tf_padding5; /* used in trap reflection */
> /* below here defined by x86 hardware (error code optional) */
> uint32_t tf_err;
> - uint32_t tf_padding4;
> + uint32_t tf_padding4; /* used in trap reflection */
> uint64_t tf_rip;
> uint16_t tf_cs;
> - uint16_t tf_padding3;
> + uint16_t tf_padding3; /* used in trap reflection */
> uint32_t tf_padding2;
> uint64_t tf_rflags;
> /* unlike 32 bit, SS:RSP is always pushed, even when not changing
> rings */
> uint64_t tf_rsp;
> uint16_t tf_ss;
> uint16_t tf_padding1;
> - uint32_t tf_padding0;
> + uint32_t tf_padding0; /* used for partial contexts */
>
Why not give these "padding" a name which tells their use?
+/* Partial contexts for HW and SW TFs have the user's gs in
> MSR_KERNEL_GS_BASE.
> + * The kernel's gs is loaded into gs. We need to put the kernel's gs into
> + * KERNEL_GS_BASE so the core is ready to run another full context, save
> the
> + * user's {GS,FS}_BASE into their TF so it can run on another core, and
> keep GS
> + * loaded with the current GS (the kernel's). */
> +static inline void x86_finalize_hwtf(struct hw_trapframe *tf)
> +{
> + tf->tf_gsbase = read_msr(MSR_KERNEL_GS_BASE);
> + write_msr(MSR_KERNEL_GS_BASE, read_msr(MSR_GS_BASE));
> + tf->tf_fsbase = read_msr(MSR_FS_BASE);
> + x86_hwtf_clear_partial(tf);
> +}
> +
> +static inline void x86_finalize_swtf(struct sw_trapframe *tf)
> +{
> + tf->tf_gsbase = read_msr(MSR_KERNEL_GS_BASE);
> + write_msr(MSR_KERNEL_GS_BASE, read_msr(MSR_GS_BASE));
> + tf->tf_fsbase = read_msr(MSR_FS_BASE);
> + x86_swtf_clear_partial(tf);
> +}
>
>
--
You received this message because you are subscribed to the Google Groups
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.