ia64/xen-unstable

changeset 13300:e5f24d5f71ac

Enable compatibility mode operation for HYPERVISOR_set_trap_table and
HYPERVISOR_set_gdt.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Fri Jan 05 17:34:34 2007 +0000 (2007-01-05)
parents ac55ec633422
children c2a82e026497
files xen/arch/x86/x86_64/compat/entry.S xen/arch/x86/x86_64/compat/mm.c xen/arch/x86/x86_64/compat/traps.c
line diff
     1.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:33 2007 +0000
     1.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:34 2007 +0000
     1.3 @@ -278,8 +278,6 @@ CFIX14:
     1.4  
     1.5  .section .rodata, "a", @progbits
     1.6  
     1.7 -#define compat_set_trap_table domain_crash_synchronous
     1.8 -#define compat_set_gdt domain_crash_synchronous
     1.9  #define compat_platform_op domain_crash_synchronous
    1.10  #define compat_multicall domain_crash_synchronous
    1.11  #define compat_set_timer_op domain_crash_synchronous
     2.1 --- a/xen/arch/x86/x86_64/compat/mm.c	Fri Jan 05 17:34:33 2007 +0000
     2.2 +++ b/xen/arch/x86/x86_64/compat/mm.c	Fri Jan 05 17:34:34 2007 +0000
     2.3 @@ -4,6 +4,39 @@
     2.4  #include <compat/memory.h>
     2.5  #include <compat/xen.h>
     2.6  
     2.7 +int compat_set_gdt(XEN_GUEST_HANDLE(uint) frame_list, unsigned int entries)
     2.8 +{
     2.9 +    unsigned int i, nr_pages = (entries + 511) / 512;
    2.10 +    unsigned long frames[16];
    2.11 +    long ret;
    2.12 +
    2.13 +    /* Rechecked in set_gdt, but ensures a sane limit for copy_from_user(). */
    2.14 +    if ( entries > FIRST_RESERVED_GDT_ENTRY )
    2.15 +        return -EINVAL;
    2.16 +
    2.17 +    if ( !guest_handle_okay(frame_list, nr_pages) )
    2.18 +        return -EFAULT;
    2.19 +
    2.20 +    for ( i = 0; i < nr_pages; ++i )
    2.21 +    {
    2.22 +        unsigned int frame;
    2.23 +
    2.24 +        if ( __copy_from_guest(&frame, frame_list, 1) )
    2.25 +            return -EFAULT;
    2.26 +        frames[i] = frame;
    2.27 +        guest_handle_add_offset(frame_list, 1);
    2.28 +    }
    2.29 +
    2.30 +    LOCK_BIGLOCK(current->domain);
    2.31 +
    2.32 +    if ( (ret = set_gdt(current, frames, entries)) == 0 )
    2.33 +        local_flush_tlb();
    2.34 +
    2.35 +    UNLOCK_BIGLOCK(current->domain);
    2.36 +
    2.37 +    return ret;
    2.38 +}
    2.39 +
    2.40  int compat_update_descriptor(u32 pa_lo, u32 pa_hi, u32 desc_lo, u32 desc_hi)
    2.41  {
    2.42      return do_update_descriptor(pa_lo | ((u64)pa_hi << 32),
     3.1 --- a/xen/arch/x86/x86_64/compat/traps.c	Fri Jan 05 17:34:33 2007 +0000
     3.2 +++ b/xen/arch/x86/x86_64/compat/traps.c	Fri Jan 05 17:34:34 2007 +0000
     3.3 @@ -1,6 +1,8 @@
     3.4  #ifdef CONFIG_COMPAT
     3.5  
     3.6 +#include <xen/event.h>
     3.7  #include <compat/callback.h>
     3.8 +#include <compat/arch-x86_32.h>
     3.9  
    3.10  void compat_show_guest_stack(struct cpu_user_regs *regs, int debug_stack_lines)
    3.11  {
    3.12 @@ -252,6 +254,49 @@ long compat_set_callbacks(unsigned long 
    3.13      return 0;
    3.14  }
    3.15  
    3.16 +DEFINE_XEN_GUEST_HANDLE(trap_info_compat_t);
    3.17 +
    3.18 +int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
    3.19 +{
    3.20 +    struct compat_trap_info cur;
    3.21 +    struct trap_info *dst = current->arch.guest_context.trap_ctxt;
    3.22 +    long rc = 0;
    3.23 +
    3.24 +    /* If no table is presented then clear the entire virtual IDT. */
    3.25 +    if ( guest_handle_is_null(traps) )
    3.26 +    {
    3.27 +        memset(dst, 0, 256 * sizeof(*dst));
    3.28 +        return 0;
    3.29 +    }
    3.30 +
    3.31 +    for ( ; ; )
    3.32 +    {
    3.33 +        if ( hypercall_preempt_check() )
    3.34 +        {
    3.35 +            rc = hypercall_create_continuation(
    3.36 +                __HYPERVISOR_set_trap_table, "h", traps);
    3.37 +            break;
    3.38 +        }
    3.39 +
    3.40 +        if ( copy_from_guest(&cur, traps, 1) )
    3.41 +        {
    3.42 +            rc = -EFAULT;
    3.43 +            break;
    3.44 +        }
    3.45 +
    3.46 +        if ( cur.address == 0 )
    3.47 +            break;
    3.48 +
    3.49 +        fixup_guest_code_selector(current->domain, cur.cs);
    3.50 +
    3.51 +        XLAT_trap_info(dst + cur.vector, &cur);
    3.52 +
    3.53 +        guest_handle_add_offset(traps, 1);
    3.54 +    }
    3.55 +
    3.56 +    return rc;
    3.57 +}
    3.58 +
    3.59  #endif /* CONFIG_COMPAT */
    3.60  
    3.61  static void hypercall_page_initialise_ring1_kernel(void *hypercall_page)