linux-kernel-test/arch/i386/kernel
Zachary Amsden f2f30ebca6 [PATCH] x86: introduce a write acessor for updating the current LDT
Introduce a write acessor for updating the current LDT.  This is required
for hypervisors like Xen that do not allow LDT pages to be directly
written.

Testing - here's a fun little LDT test that can be trivially modified to
test limits as well.

/*
 * Copyright (c) 2005, Zachary Amsden (zach@vmware.com)
 * This is licensed under the GPL.
 */

#include <stdio.h>
#include <signal.h>
#include <asm/ldt.h>
#include <asm/segment.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
#define __KERNEL__
#include <asm/page.h>

void main(void)
{
        struct user_desc desc;
        char *code;
        unsigned long long tsc;

        code = (char *)mmap(0, 8192, PROT_EXEC|PROT_READ|PROT_WRITE,
                                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        desc.entry_number = 0;
        desc.base_addr = code;
        desc.limit = 1;
        desc.seg_32bit = 1;
        desc.contents = MODIFY_LDT_CONTENTS_CODE;
        desc.read_exec_only = 0;
        desc.limit_in_pages = 1;
        desc.seg_not_present = 0;
        desc.useable = 1;
        if (modify_ldt(1, &desc, sizeof(desc)) != 0) {
                perror("modify_ldt");
        }
        printf("code base is 0x%08x\n", (unsigned)code);
        code[0x0ffe] = 0x0f;  /* rdtsc */
        code[0x0fff] = 0x31;
        code[0x1000] = 0xcb;  /* lret */
        __asm__ __volatile("lcall $7,$0xffe" : "=A" (tsc));
        printf("TSC is 0x%016llx\n", tsc);
}

Signed-off-by: Zachary Amsden <zach@vmware.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-05 00:06:13 -07:00
..
acpi [PATCH] x86: sutomatically enable bigsmp when we have more than 8 CPUs 2005-09-05 00:06:10 -07:00
cpu [PATCH] x86: more asm cleanups 2005-09-05 00:06:12 -07:00
timers [PATCH] hpet: use read_timer_tsc only when CPU has TSC 2005-09-05 00:06:09 -07:00
apic.c [PATCH] x86: Remove obsolete get_cpu_vendor call 2005-08-18 12:53:59 -07:00
apm.c [PATCH] APM: Remove redundant call to set_cpus_allowed 2005-07-26 14:35:45 -07:00
asm-offsets.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
bootflag.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
cpuid.c [PATCH] class: convert arch/* to use the new class api instead of class_simple 2005-06-20 15:15:09 -07:00
crash.c [PATCH] x86: more asm cleanups 2005-09-05 00:06:12 -07:00
dmi_scan.c [PATCH] dmi: spring cleanup 2005-06-25 16:24:28 -07:00
doublefault.c [PATCH] i386: inline assembler: cleanup and encapsulate descriptor and task register management 2005-09-05 00:06:11 -07:00
early_printk.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
efi_stub.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
efi.c [PATCH] i386: inline assembler: cleanup and encapsulate descriptor and task register management 2005-09-05 00:06:11 -07:00
entry.S [PATCH] uml: fix syscall table by including $(SUBARCH)'s one, for i386 2005-05-01 08:58:55 -07:00
head.S [PATCH] kdump: Save parameter segment in protected mode (x86) 2005-09-05 00:06:09 -07:00
i386_ksyms.c [PATCH] Remove i386_ksyms.c, almost. 2005-06-23 09:45:11 -07:00
i387.c x86: make restore_fpu() use alternative assembler instructions 2005-07-22 16:06:16 -04:00
i8259.c [PATCH] kexec: x86: i8259 shutdown: disable interrupts 2005-06-25 16:24:46 -07:00
init_task.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
io_apic.c [PATCH] x86: i8253/i8259A lock cleanup 2005-06-30 08:45:10 -07:00
ioport.c [PATCH] x86: make IOPL explicit 2005-09-05 00:06:12 -07:00
irq.c [PATCH] cpu state clean after hot remove 2005-06-25 16:24:30 -07:00
kprobes.c [PATCH] kprobes: fix namespace problem and sparc64 build 2005-07-05 19:19:00 -07:00
ldt.c [PATCH] x86: introduce a write acessor for updating the current LDT 2005-09-05 00:06:13 -07:00
machine_kexec.c [PATCH] x86: more asm cleanups 2005-09-05 00:06:12 -07:00
Makefile [PATCH] kexec: x86 kexec core 2005-06-25 16:24:49 -07:00
mca.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
microcode.c [PATCH] i386: cleanup serialize msr 2005-09-05 00:06:11 -07:00
module.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mpparse.c [PATCH] x86: sutomatically enable bigsmp when we have more than 8 CPUs 2005-09-05 00:06:10 -07:00
msr.c [PATCH] x86: more asm cleanups 2005-09-05 00:06:12 -07:00
nmi.c [PATCH] Mobil Pentium 4 HT and the NMI 2005-08-19 18:44:56 -07:00
numaq.c [PATCH] re-disable TSC on NUMAQ 2005-07-28 21:46:05 -07:00
pci-dma.c [PATCH] Remove i386_ksyms.c, almost. 2005-06-23 09:45:11 -07:00
process.c [PATCH] x86: make IOPL explicit 2005-09-05 00:06:12 -07:00
ptrace.c [PATCH] xen: x86: Rename usermode macro 2005-06-23 09:45:14 -07:00
quirks.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
reboot_fixups.c [PATCH] x86 reboot: Add reboot fixup for gx1/cs5530a 2005-05-01 08:58:49 -07:00
reboot.c [PATCH] i386: inline assembler: cleanup and encapsulate descriptor and task register management 2005-09-05 00:06:11 -07:00
relocate_kernel.S [PATCH] kexec: x86 kexec core 2005-06-25 16:24:49 -07:00
scx200.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
semaphore.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
setup.c [PATCH] x86: sutomatically enable bigsmp when we have more than 8 CPUs 2005-09-05 00:06:10 -07:00
sigframe.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
signal.c [PATCH] x86: privilege cleanup 2005-09-05 00:06:12 -07:00
smp.c [PATCH] i386: inline asm cleanup 2005-09-05 00:06:11 -07:00
smpboot.c [PATCH] mostly_read data section 2005-07-07 18:23:46 -07:00
srat.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
summit.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sys_i386.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
syscall_table.S [PATCH] remove sys_set_zone_reclaim() 2005-08-01 10:03:56 -07:00
sysenter.c [PATCH] sep initializing rework 2005-06-25 16:24:29 -07:00
time_hpet.c [PATCH] CPU hotplug: fix hpet sectioning 2005-06-25 16:24:28 -07:00
time.c [PATCH] mostly_read data section 2005-07-07 18:23:46 -07:00
trampoline.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
traps.c [PATCH] x86: privilege cleanup 2005-09-05 00:06:12 -07:00
vm86.c [PATCH] i386: inline assembler: cleanup and encapsulate descriptor and task register management 2005-09-05 00:06:11 -07:00
vmlinux.lds.S [PATCH] mostly_read data section 2005-07-07 18:23:46 -07:00
vsyscall-int80.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vsyscall-note.S [PATCH] i386 vDSO: add PT_NOTE segment 2005-04-16 15:24:48 -07:00
vsyscall-sigreturn.S [PATCH] i386: clean up vDSO alignment padding 2005-09-05 00:06:10 -07:00
vsyscall-sysenter.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vsyscall.lds.S [PATCH] i386 vDSO: add PT_NOTE segment 2005-04-16 15:24:48 -07:00
vsyscall.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00