From: Glauber de Oliveira Costa <gcosta@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, glommer@gmail.com, tglx@linutronix.de,
mingo@elte.hu, ehabkost@redhat.com, jeremy@goop.org,
avi@qumranet.com, anthony@codemonkey.ws,
virtualization@lists.linux-foundation.org, rusty@rustcorp.com.au,
ak@suse.de, chrisw@sous-sol.org, rostedt@goodmis.org,
hpa@zytor.com, zach@vmware.com, roland@redhat.com,
Glauber de Oliveira Costa <gcosta@redhat.com>
Subject: [PATCH 14/19] unify non-paravirt parts of desc.h
Date: Thu, 13 Dec 2007 00:01:47 -0200 [thread overview]
Message-ID: <11975113821418-git-send-email-gcosta@redhat.com> (raw)
In-Reply-To: <11975113771692-git-send-email-gcosta@redhat.com>
This patch unifies the non-paravirt part of desc_{32,64}.h into
desc.h. Most of it, is simply common code, that is moved to
the shared header. The only exception is the set_ldt_desc in desc_64.h,
which is changed - included its name - to accomodate for the way
the ldt is set up in i386.
Also, constant definitions used in desc_32.h are moved to desc_defs.h
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
---
include/asm-x86/desc.h | 87 ++++++++++++++++++++++++++++++++++++++
include/asm-x86/desc_32.h | 66 ----------------------------
include/asm-x86/desc_64.h | 64 ++++-----------------------
include/asm-x86/mmu_context_64.h | 4 +-
4 files changed, 99 insertions(+), 122 deletions(-)
Index: linux-2.6-x86/include/asm-x86/desc.h
===================================================================
--- linux-2.6-x86.orig/include/asm-x86/desc.h
+++ linux-2.6-x86/include/asm-x86/desc.h
@@ -4,6 +4,7 @@
#ifndef __ASSEMBLY__
#include <asm/desc_defs.h>
#include <asm/ldt.h>
+#include <asm/mmu.h>
static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
{
@@ -23,7 +24,8 @@ static inline void fill_ldt(struct desc_
desc->base2 = (info->base_addr & 0xff000000) >> 24;
}
-#endif
+extern struct desc_ptr idt_descr;
+extern gate_desc idt_table[];
#ifdef CONFIG_X86_32
# include "desc_32.h"
@@ -31,4 +33,65 @@ static inline void fill_ldt(struct desc_
# include "desc_64.h"
#endif
+#define _LDT_empty(info) (\
+ (info)->base_addr == 0 && \
+ (info)->limit == 0 && \
+ (info)->contents == 0 && \
+ (info)->read_exec_only == 1 && \
+ (info)->seg_32bit == 0 && \
+ (info)->limit_in_pages == 0 && \
+ (info)->seg_not_present == 1 && \
+ (info)->useable == 0)
+
+#ifdef CONFIG_X86_64
+#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0))
+#else
+#define LDT_empty(info) (_LDT_empty(info))
+#endif
+
+static inline void clear_LDT(void)
+{
+ set_ldt(NULL, 0);
+}
+
+/*
+ * load one particular LDT into the current CPU
+ */
+static inline void load_LDT_nolock(mm_context_t *pc)
+{
+ set_ldt(pc->ldt, pc->size);
+}
+
+static inline void load_LDT(mm_context_t *pc)
+{
+ preempt_disable();
+ load_LDT_nolock(pc);
+ preempt_enable();
+}
+
+#else
+/*
+ * GET_DESC_BASE reads the descriptor base of the specified segment.
+ *
+ * Args:
+ * idx - descriptor index
+ * gdt - GDT pointer
+ * base - 32bit register to which the base will be written
+ * lo_w - lo word of the "base" register
+ * lo_b - lo byte of the "base" register
+ * hi_b - hi byte of the low word of the "base" register
+ *
+ * Example:
+ * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
+ * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
+ */
+#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
+ movb idx*8+4(gdt), lo_b; \
+ movb idx*8+7(gdt), hi_b; \
+ shll $16, base; \
+ movw idx*8+2(gdt), lo_w;
+
+
+#endif /* __ASSEMBLY__ */
+
#endif
Index: linux-2.6-x86/include/asm-x86/desc_32.h
===================================================================
--- linux-2.6-x86.orig/include/asm-x86/desc_32.h
+++ linux-2.6-x86/include/asm-x86/desc_32.h
@@ -11,8 +11,6 @@
#include <linux/smp.h>
#include <linux/percpu.h>
-#include <asm/mmu.h>
-
struct gdt_page
{
struct desc_struct gdt[GDT_ENTRIES];
@@ -24,8 +22,6 @@ static inline struct desc_struct *get_cp
return per_cpu(gdt_page, cpu).gdt;
}
-extern struct desc_ptr idt_descr;
-extern gate_desc idt_table[];
extern void set_intr_gate(unsigned int irq, void * addr);
static inline void pack_descriptor(struct desc_struct *desc,
@@ -172,36 +168,6 @@ static inline void __set_tss_desc(unsign
#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
-#define LDT_empty(info) (\
- (info)->base_addr == 0 && \
- (info)->limit == 0 && \
- (info)->contents == 0 && \
- (info)->read_exec_only == 1 && \
- (info)->seg_32bit == 0 && \
- (info)->limit_in_pages == 0 && \
- (info)->seg_not_present == 1 && \
- (info)->useable == 0 )
-
-static inline void clear_LDT(void)
-{
- set_ldt(NULL, 0);
-}
-
-/*
- * load one particular LDT into the current CPU
- */
-static inline void load_LDT_nolock(mm_context_t *pc)
-{
- set_ldt(pc->ldt, pc->size);
-}
-
-static inline void load_LDT(mm_context_t *pc)
-{
- preempt_disable();
- load_LDT_nolock(pc);
- preempt_enable();
-}
-
static inline unsigned long get_desc_base(unsigned long *desc)
{
unsigned long base;
@@ -210,30 +176,6 @@ static inline unsigned long get_desc_bas
(desc[1] & 0xff000000);
return base;
}
-
-#else /* __ASSEMBLY__ */
-
-/*
- * GET_DESC_BASE reads the descriptor base of the specified segment.
- *
- * Args:
- * idx - descriptor index
- * gdt - GDT pointer
- * base - 32bit register to which the base will be written
- * lo_w - lo word of the "base" register
- * lo_b - lo byte of the "base" register
- * hi_b - hi byte of the low word of the "base" register
- *
- * Example:
- * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
- * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
- */
-#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
- movb idx*8+4(gdt), lo_b; \
- movb idx*8+7(gdt), hi_b; \
- shll $16, base; \
- movw idx*8+2(gdt), lo_w;
-
#endif /* !__ASSEMBLY__ */
#endif
Index: linux-2.6-x86/include/asm-x86/desc_64.h
===================================================================
--- linux-2.6-x86.orig/include/asm-x86/desc_64.h
+++ linux-2.6-x86/include/asm-x86/desc_64.h
@@ -9,16 +9,13 @@
#include <linux/string.h>
#include <linux/smp.h>
-#include <asm/desc_defs.h>
#include <asm/segment.h>
-#include <asm/mmu.h>
extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
#define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8))
#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
-#define clear_LDT() asm volatile("lldt %w0"::"r" (0))
static inline unsigned long __store_tr(void)
{
@@ -30,7 +27,6 @@ static inline unsigned long __store_tr(v
#define store_tr(tr) (tr) = __store_tr()
-extern gate_desc idt_table[];
extern struct desc_ptr cpu_gdt_descr[];
static inline void write_ldt_entry(struct desc_struct *ldt,
@@ -138,23 +134,19 @@ static inline void set_tss_desc(unsigned
IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
}
-static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
+static inline void set_ldt(void *addr, int entries)
{
- set_tssldt_descriptor(&get_cpu_gdt_table(cpu)[GDT_ENTRY_LDT],
- (unsigned long)addr, DESC_LDT, size * 8 - 1);
+ if (likely(entries == 0))
+ __asm__ __volatile__("lldt %w0"::"q" (0));
+ else {
+ unsigned cpu = smp_processor_id();
+
+ set_tssldt_descriptor(&get_cpu_gdt_table(cpu)[GDT_ENTRY_LDT],
+ (unsigned long)addr, DESC_LDT, entries * 8 - 1);
+ __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
+ }
}
-#define LDT_empty(info) (\
- (info)->base_addr == 0 && \
- (info)->limit == 0 && \
- (info)->contents == 0 && \
- (info)->read_exec_only == 1 && \
- (info)->seg_32bit == 0 && \
- (info)->limit_in_pages == 0 && \
- (info)->seg_not_present == 1 && \
- (info)->useable == 0 && \
- (info)->lm == 0)
-
static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
{
unsigned int i;
@@ -164,32 +156,6 @@ static inline void load_TLS(struct threa
gdt[i] = t->tls_array[i];
}
-/*
- * load one particular LDT into the current CPU
- */
-static inline void load_LDT_nolock(mm_context_t *pc, int cpu)
-{
- int count = pc->size;
-
- if (likely(!count)) {
- clear_LDT();
- return;
- }
-
- set_ldt_desc(cpu, pc->ldt, count);
- load_LDT_desc();
-}
-
-static inline void load_LDT(mm_context_t *pc)
-{
- int cpu = get_cpu();
-
- load_LDT_nolock(pc, cpu);
- put_cpu();
-}
-
-extern struct desc_ptr idt_descr;
-
static inline unsigned long get_desc_base(const void *ptr)
{
const u32 *desc = ptr;
@@ -199,7 +165,6 @@ static inline unsigned long get_desc_bas
(desc[1] & 0xff000000);
return base;
}
-
#endif /* !__ASSEMBLY__ */
#endif
Index: linux-2.6-x86/include/asm-x86/mmu_context_64.h
===================================================================
--- linux-2.6-x86.orig/include/asm-x86/mmu_context_64.h
+++ linux-2.6-x86/include/asm-x86/mmu_context_64.h
@@ -43,7 +43,7 @@ static inline void switch_mm(struct mm_s
load_cr3(next->pgd);
if (unlikely(next->context.ldt != prev->context.ldt))
- load_LDT_nolock(&next->context, cpu);
+ load_LDT_nolock(&next->context);
}
#ifdef CONFIG_SMP
else {
@@ -56,7 +56,7 @@ static inline void switch_mm(struct mm_s
* to make sure to use no freed page tables.
*/
load_cr3(next->pgd);
- load_LDT_nolock(&next->context, cpu);
+ load_LDT_nolock(&next->context);
}
}
#endif
next prev parent reply other threads:[~2007-12-13 4:52 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-06 16:16 [PATCH 0/19] desc_struct integration Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 1/19] unify desc_struct Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 2/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 3/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 4/19] removed unused variable Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 5/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 6/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 7/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 8/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 9/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 10/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 11/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 12/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 13/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 14/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 15/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 16/19] provide tss_desc Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-06 16:16 ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-06 19:24 ` [PATCH 1/19] unify desc_struct Jeremy Fitzhardinge
2007-12-06 19:37 ` Glauber de Oliveira Costa
2007-12-06 20:54 ` Andi Kleen
2007-12-06 21:20 ` Glauber de Oliveira Costa
2007-12-06 22:03 ` Jeremy Fitzhardinge
2007-12-12 12:53 ` [PATCH 0/19] desc_struct integration Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 01/19] unify desc_struct Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 02/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 03/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 04/19] removed unused variable Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 05/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 06/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 07/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 08/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 09/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 10/19] provide tss_desc Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 11/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 12/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 13/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-12 12:53 ` [PATCH 14/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-12 12:54 ` [PATCH 15/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-12 12:54 ` [PATCH 16/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-12 12:54 ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-12 12:54 ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-12 12:54 ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-12 17:56 ` [PATCH 09/19] introduce fill_ldt Ingo Molnar
2007-12-12 17:20 ` [PATCH 0/19] desc_struct integration Ingo Molnar
2007-12-12 18:11 ` Ingo Molnar
2007-12-12 18:20 ` Ingo Molnar
2007-12-12 18:27 ` Glauber de Oliveira Costa
2007-12-12 18:33 ` Ingo Molnar
2007-12-12 19:05 ` Glauber de Oliveira Costa
2007-12-12 18:34 ` Ingo Molnar
2007-12-12 23:39 ` H. Peter Anvin
2007-12-13 2:01 ` [PATCH 0/19 - v3] " Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 01/19] unify desc_struct Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 02/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 03/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 04/19] removed unused variable Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 05/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 06/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 07/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 08/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 09/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 10/19] provide tss_desc Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 11/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 12/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 13/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-13 2:01 ` Glauber de Oliveira Costa [this message]
2007-12-13 2:01 ` [PATCH 15/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 16/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-13 2:01 ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-13 12:46 ` Andi Kleen
2007-12-13 14:50 ` Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 0/19 -v4] desc_struct integration Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 01/19] unify desc_struct Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 02/19] unify struct desc_ptr Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 03/19] change gdt acessor macro name Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 04/19] removed unused variable Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 05/19] introduce gate_desc type Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 06/19] change write_idt_entry signature Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 07/19] introduce ldt_desc type Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 08/19] modify write_ldt function Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 09/19] introduce fill_ldt Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 10/19] provide tss_desc Glauber de Oliveira Costa
2007-12-13 13:57 ` [PATCH 11/19] change write_gdt_entry signature Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 12/19] change write_ldt_entry signature Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 13/19] move constants to desc_defs.h Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 14/19] unify non-paravirt parts of desc.h Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 15/19] use the same data type for tls_array Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 16/19] modify get_desc_base Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 17/19] unify paravirt pieces of descriptor handling Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 18/19] move _set_gate and its users to a common location Glauber de Oliveira Costa
2007-12-13 13:58 ` [PATCH 19/19] unify set_tss_desc Glauber de Oliveira Costa
2007-12-22 2:07 ` [PATCH 18/19] move _set_gate and its users to a common location Ingo Molnar
2007-12-13 16:47 ` [PATCH 0/19 -v4] desc_struct integration Ingo Molnar
2007-12-13 17:06 ` Glauber de Oliveira Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11975113821418-git-send-email-gcosta@redhat.com \
--to=gcosta@redhat.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=anthony@codemonkey.ws \
--cc=avi@qumranet.com \
--cc=chrisw@sous-sol.org \
--cc=ehabkost@redhat.com \
--cc=glommer@gmail.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux-foundation.org \
--cc=zach@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).