On Mon, Dec 18, 2017 at 12:43:06PM +0100, Thomas Gleixner wrote:

>  arch/x86/include/asm/desc.h           |    2 ++
>  arch/x86/kernel/ldt.c                 |    7 ++++++-
>  tools/testing/selftests/x86/ldt_gdt.c |    3 +--
>  3 files changed, 9 insertions(+), 3 deletions(-)
> 
> --- a/arch/x86/include/asm/desc.h
> +++ b/arch/x86/include/asm/desc.h
> @@ -20,6 +20,8 @@ static inline void fill_ldt(struct desc_
>  
>       desc->type              = (info->read_exec_only ^ 1) << 1;
>       desc->type             |= info->contents << 2;
> +     /* Set the ACCESS bit so it can be mapped RO */
> +     desc->type             |= 1;
>  
>       desc->s                 = 1;
>       desc->dpl               = 0x3;


--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -93,17 +93,10 @@ static void set_tls_desc(struct task_str
        cpu = get_cpu();
 
        while (n-- > 0) {
-               if (LDT_empty(info) || LDT_zero(info)) {
+               if (LDT_empty(info) || LDT_zero(info))
                        memset(desc, 0, sizeof(*desc));
-               } else {
+               else
                        fill_ldt(desc, info);
-
-                       /*
-                        * Always set the accessed bit so that the CPU
-                        * doesn't try to write to the (read-only) GDT.
-                        */
-                       desc->type |= 1;
-               }
                ++info;
                ++desc;
        }

Reply via email to