[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 1/2] x86_64: Fix updating fsgs base on context switch
From: |
Samuel Thibault |
Subject: |
Re: [RFC PATCH 1/2] x86_64: Fix updating fsgs base on context switch |
Date: |
Fri, 12 May 2023 00:51:45 +0200 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Applied, thanks!
Sergey Bugaev, le jeu. 11 mai 2023 16:58:43 +0300, a ecrit:
> Commit 31dd30a94a682955c3c9e2f42252b4a07687067a "add setting gs/fsbase"
> added the code to set fs and gs bases on context_switch. However, this
> was only being done when switching context via the explicit
> switch_context() method, but not in other cases where the context is
> switched, such as with call_continuation().
>
> Instead, put setting fsgs base into switch_ktss(), where it will be
> called in all cases.
> ---
> i386/i386/pcb.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c
> index 8a9e3bf4..a5efb9a8 100644
> --- a/i386/i386/pcb.c
> +++ b/i386/i386/pcb.c
> @@ -223,6 +223,11 @@ void switch_ktss(pcb_t pcb)
> pcb->ims.user_gdt, sizeof pcb->ims.user_gdt);
> #endif /* MACH_PV_DESCRIPTORS */
>
> +#if defined(__x86_64__) && !defined(USER32)
> + wrmsr(MSR_REG_FSBASE, pcb->iss.fsbase);
> + wrmsr(MSR_REG_GSBASE, pcb->iss.gsbase);
> +#endif
> +
> db_load_context(pcb);
>
> /*
> @@ -373,10 +378,6 @@ thread_t switch_context(
> * Load the rest of the user state for the new thread
> */
> switch_ktss(new->pcb);
> -#if defined(__x86_64__) && !defined(USER32)
> - wrmsr(MSR_REG_FSBASE, new->pcb->iss.fsbase);
> - wrmsr(MSR_REG_GSBASE, new->pcb->iss.gsbase);
> -#endif
> return Switch_context(old, continuation, new);
> }
>
> --
> 2.40.1
>
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.