mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: zach@vmware.com
To: akpm@osdl.org, chrisl@vmware.com, chrisw@osdl.org, hpa@zytor.com,
	Keir.Fraser@cl.cam.ac.uk, linux-kernel@vger.kernel.org,
	m+Ian.Pratt@cl.cam.ac.uk, mbligh@mbligh.org, pratap@vmware.com,
	virtualization@lists.osdl.org, zach@vmware.com,
	zwane@arm.linux.org.uk
Subject: [PATCH 13/14] i386 / Introduce hypervisor ldt hooks
Date: Wed, 10 Aug 2005 21:58:21 -0700	[thread overview]
Message-ID: <200508110458.j7B4wLq9019627@zach-dev.vmware.com> (raw)

Add hooks that the hypervisor can use to establish writable and non-writable
pages for LDT pages.  I made these parallel the page flags as defined in
include/linux/page-flags.h, since the flag mechanism is very similar to the
hypercall page flagging, and extended easily later to include PT, PD, PDP,
GDT, etc.

Patch-against: 2.6.13-rc5-mm1
Patch-keys: i386 ldt paravirt xen
Signed-off-by: Zachary Amsden <zach@vmware.com>
Index: linux-2.6.13/arch/i386/kernel/ldt.c
===================================================================
--- linux-2.6.13.orig/arch/i386/kernel/ldt.c	2005-08-10 17:06:52.000000000 -0700
+++ linux-2.6.13/arch/i386/kernel/ldt.c	2005-08-10 17:11:38.000000000 -0700
@@ -18,6 +18,7 @@
 #include <asm/system.h>
 #include <asm/ldt.h>
 #include <asm/desc.h>
+#include <mach_pgalloc.h>
 
 #ifdef CONFIG_SMP /* avoids "defined but not used" warning */
 static void flush_ldt(void *null)
@@ -59,16 +60,19 @@
 #ifdef CONFIG_SMP
 		cpumask_t mask;
 		preempt_disable();
+		SetPagesLDT(pc->ldt, (pc->size * LDT_ENTRY_SIZE) / PAGE_SIZE);
 		load_LDT(pc);
 		mask = cpumask_of_cpu(smp_processor_id());
 		if (!cpus_equal(current->mm->cpu_vm_mask, mask))
 			smp_call_function(flush_ldt, NULL, 1, 1);
 		preempt_enable();
 #else
+		SetPagesLDT(pc->ldt, (pc->size * LDT_ENTRY_SIZE) / PAGE_SIZE);
 		load_LDT(pc);
 #endif
 	}
 	if (oldsize) {
+		ClearPagesLDT(oldldt, (oldsize * LDT_ENTRY_SIZE) / PAGE_SIZE);
 		if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
 			vfree(oldldt);
 		else
@@ -83,8 +87,10 @@
 
 	down(&old->sem);
 	err = alloc_ldt(new, 0, old->size, 0);
-	if (!err)
+	if (!err) {
 		memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
+		SetPagesLDT(new->ldt, (new->size * LDT_ENTRY_SIZE) / PAGE_SIZE);
+	}
 	up(&old->sem);
 	return err;
 }
@@ -93,6 +99,7 @@
 {
 	if (mm == current->active_mm)
 		clear_LDT();
+	ClearPagesLDT(mm->context.ldt, (mm->context.size * LDT_ENTRY_SIZE) / PAGE_SIZE);
 	if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
 		vfree(mm->context.ldt);
 	else
Index: linux-2.6.13/include/asm-i386/mach-default/mach_pgalloc.h
===================================================================
--- linux-2.6.13.orig/include/asm-i386/mach-default/mach_pgalloc.h	2005-08-10 17:11:38.000000000 -0700
+++ linux-2.6.13/include/asm-i386/mach-default/mach_pgalloc.h	2005-08-10 17:11:38.000000000 -0700
@@ -0,0 +1,7 @@
+#ifndef __ASM_MACH_PGALLOC_H
+#define __ASM_MACH_PGALLOC_H
+
+#define SetPagesLDT(_va, _pages)
+#define ClearPagesLDT(_va, _pages)
+
+#endif

                 reply	other threads:[~2005-08-11  4:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200508110458.j7B4wLq9019627@zach-dev.vmware.com \
    --to=zach@vmware.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=akpm@osdl.org \
    --cc=chrisl@vmware.com \
    --cc=chrisw@osdl.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m+Ian.Pratt@cl.cam.ac.uk \
    --cc=mbligh@mbligh.org \
    --cc=pratap@vmware.com \
    --cc=virtualization@lists.osdl.org \
    --cc=zwane@arm.linux.org.uk \
    /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

all inboxes | Powered by JetHome®