ia64/xen-unstable

changeset 2258:8346a7a9c1e1

bitkeeper revision 1.1159.32.5 (4121d149RRDPS-silekwHOodPcrI6w)

First cut of grant-table public interface.
author kaf24@scramble.cl.cam.ac.uk
date Tue Aug 17 09:35:05 2004 +0000 (2004-08-17)
parents bb91ba552d34
children a7d13ecf88c5 8a90852f79d1
files .rootkeys xen/include/hypervisor-ifs/grant_table.h
line diff
     1.1 --- a/.rootkeys	Mon Aug 16 18:08:51 2004 +0000
     1.2 +++ b/.rootkeys	Tue Aug 17 09:35:05 2004 +0000
     1.3 @@ -687,6 +687,7 @@ 404f1bc68SXxmv0zQpXBWGrCzSyp8w xen/inclu
     1.4  404f1bc7IwU-qnH8mJeVu0YsNGMrcw xen/include/hypervisor-ifs/arch-x86_64.h
     1.5  3ddb79c2PMeWTK86y4C3F4MzHw4A1g xen/include/hypervisor-ifs/dom0_ops.h
     1.6  403cd194j2pyLqXD8FJ-ukvZzkPenw xen/include/hypervisor-ifs/event_channel.h
     1.7 +4121d149udGfSUGhn3k1ECz0bM31nQ xen/include/hypervisor-ifs/grant_table.h
     1.8  3ddb79c25UE59iu4JJcbRalx95mvcg xen/include/hypervisor-ifs/hypervisor-if.h
     1.9  40f5623bqoi4GEoBiiUc6TZk1HjsMg xen/include/hypervisor-ifs/io/blkif.h
    1.10  40dc4076pVeE1kEEWzcUaNZin65kCA xen/include/hypervisor-ifs/io/domain_controller.h
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/include/hypervisor-ifs/grant_table.h	Tue Aug 17 09:35:05 2004 +0000
     2.3 @@ -0,0 +1,89 @@
     2.4 +/******************************************************************************
     2.5 + * grant_table.h
     2.6 + * 
     2.7 + * Interface for granting foreign access to page frames, and receiving
     2.8 + * page-ownership transfers.
     2.9 + * 
    2.10 + * Copyright (c) 2004, K A Fraser
    2.11 + * 
    2.12 + * Some rough guidelines on accessing and updating grant-table entries
    2.13 + * in a concurreny-safe manner. For more information, Linux contains a
    2.14 + * reference implementation for guest OSes (arch/xen/kernel/grant_table.c).
    2.15 + * 
    2.16 + * NB. WMB is a no-op on current-generation x86 processors.
    2.17 + * 
    2.18 + * Introducing a valid entry into the grant table:
    2.19 + *  1. Write ent->domid.
    2.20 + *  2. Write ent->frame (to zero if installing GTF_accept_transfer).
    2.21 + *  3. Write memory barrier (WMB).
    2.22 + *  4. Write ent->flags, inc. valid type.
    2.23 + * 
    2.24 + * Removing an unused GTF_permit_access entry:
    2.25 + *  1. flags = ent->flags.
    2.26 + *  2. Observe that !(flags & (GTF_reading|GTF_writing)).
    2.27 + *  3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
    2.28 + *  4. WMB.
    2.29 + * 
    2.30 + * Removing an unused GTF_accept_transfer entry:
    2.31 + *  1. Clear ent->flags.
    2.32 + *  2. WMB.
    2.33 + * 
    2.34 + * Changing a GTF_permit_access from writable to read-only:
    2.35 + *  Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing.
    2.36 + * 
    2.37 + * Changing a GTF_permit_access from read-only to writable:
    2.38 + *  Use SMP-safe bit-setting instruction.
    2.39 + */
    2.40 +
    2.41 +#ifndef __HYPERVISOR_IFS_GRANT_TABLE_H__
    2.42 +#define __HYPERVISOR_IFS_GRANT_TABLE_H__
    2.43 +
    2.44 +/*
    2.45 + * A grant table comprises a packed array of grant entries in one or more
    2.46 + * page frames shared between Xen and a guest.
    2.47 + * [XEN]: This field is written by Xen and read by the sharing guest.
    2.48 + * [GST]: This field is written by the guest and read by Xen.
    2.49 + */
    2.50 +typedef struct {
    2.51 +    /* GTF_xxx: various type and flag information.  [XEN,GST] */
    2.52 +    u16     flags;      /* 0 */
    2.53 +    /* The domain being granted foreign privileges. [GST] */
    2.54 +    domid_t domid;      /* 2 */
    2.55 +    /*
    2.56 +     * GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
    2.57 +     * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
    2.58 +     */
    2.59 +    u32     frame;      /* 4 */
    2.60 +} PACKED grant_entry_t; /* 8 bytes */
    2.61 +
    2.62 +/*
    2.63 + * Reference to a grant entry in a specified domain's grant table.
    2.64 + */
    2.65 +typedef u16 grant_ref_t;
    2.66 +
    2.67 +/*
    2.68 + * Type of grant entry.
    2.69 + *  GTF_invalid: This grant entry grants no privileges.
    2.70 + *  GTF_permit_access: Allow @domid to map/access @frame.
    2.71 + *  GTF_accept_transfer: Allow @domid to transfer ownership of one page frame
    2.72 + *                       to this guest. Xen writes the page number to @frame.
    2.73 + */
    2.74 +#define GTF_invalid         (0<<0)
    2.75 +#define GTF_permit_access   (1<<0)
    2.76 +#define GTF_accept_transfer (2<<0)
    2.77 +#define GTF_type_mask       (3<<0)
    2.78 +
    2.79 +/*
    2.80 + * Subflags for GTF_permit_access.
    2.81 + *  GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST]
    2.82 + *  GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN]
    2.83 + *  GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN]
    2.84 + */
    2.85 +#define _GTF_readonly       (2)
    2.86 +#define GTF_readonly        (1<<_GTF_readonly)
    2.87 +#define _GTF_reading        (3)
    2.88 +#define GTF_reading         (1<<_GTF_inuse)
    2.89 +#define _GTF_writing        (4)
    2.90 +#define GTF_writing         (1<<_GTF_inuse)
    2.91 +
    2.92 +#endif /* __HYPERVISOR_IFS_GRANT_TABLE_H__ */