From: kaf24@scramble.cl.cam.ac.uk Date: Wed, 2 Jun 2004 14:04:13 +0000 (+0000) Subject: bitkeeper revision 1.927 (40bdde5d1ZXH3mH4b7gbCihjzISvAg) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~18194 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=137cf1e1e3b56f74d76e17cc07e23d749eeaab46;p=xen.git bitkeeper revision 1.927 (40bdde5d1ZXH3mH4b7gbCihjzISvAg) Interface cleanups. --- diff --git a/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h b/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h index e660a0438d..80055a5062 100644 --- a/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h +++ b/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h @@ -7,6 +7,16 @@ #ifndef __HYPERVISOR_IF_I386_H__ #define __HYPERVISOR_IF_I386_H__ +/* + * Pointers and other address fields inside interface structures are padded to + * 64 bits. This means that field alignments aren't different between 32- and + * 64-bit architectures. + */ +/* NB. Multi-level macro ensures __LINE__ is expanded before concatenation. */ +#define __MEMORY_PADDING(_X) u32 __pad_ ## _X +#define _MEMORY_PADDING(_X) __MEMORY_PADDING(_X) +#define MEMORY_PADDING _MEMORY_PADDING(__LINE__) + /* * SEGMENT DESCRIPTOR TABLES */ @@ -55,6 +65,10 @@ #ifndef __ASSEMBLY__ +/* NB. Both the following are 32 bits each. */ +typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */ +typedef unsigned long cpureg_t; /* Full-sized register. */ + /* * Send an array of these to HYPERVISOR_set_trap_table() */ @@ -62,13 +76,12 @@ #define TI_GET_IF(_ti) ((_ti)->flags & 4) #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl)) #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2)) -typedef struct trap_info_st -{ - unsigned char vector; /* exception vector */ - unsigned char flags; /* 0-3: privilege level; 4: clear event enable? */ - unsigned short cs; /* code selector */ - unsigned long address; /* code address */ -} trap_info_t; +typedef struct { + u8 vector; /* 0: exception vector */ + u8 flags; /* 1: 0-3: privilege level; 4: clear event enable? */ + u16 cs; /* 2: code selector */ + memory_t address; /* 4: code address */ +} PACKED trap_info_t; /* 8 bytes */ typedef struct { @@ -89,19 +102,18 @@ typedef struct unsigned long eflags; unsigned long esp; unsigned long ss; -} execution_context_t; +} PACKED execution_context_t; typedef struct { - unsigned long tsc_bits; /* 32 bits read from the CPU's TSC. */ - unsigned int tsc_bitshift; /* 'tsc_bits' uses N:N+31 of TSC. */ -} tsc_timestamp_t; + u32 tsc_bits; /* 0: 32 bits read from the CPU's TSC. */ + u32 tsc_bitshift; /* 4: 'tsc_bits' uses N:N+31 of TSC. */ +} PACKED tsc_timestamp_t; /* 8 bytes */ /* * The following is all CPU context. Note that the i387_ctxt block is filled * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used. */ -typedef struct full_execution_context_st -{ +typedef struct { #define ECF_I387_VALID (1<<0) unsigned long flags; execution_context_t cpu_ctxt; /* User-level CPU registers */ @@ -117,7 +129,7 @@ typedef struct full_execution_context_st unsigned long event_callback_eip; unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ unsigned long failsafe_callback_eip; -} full_execution_context_t; +} PACKED full_execution_context_t; #define ARCH_HAS_FAST_TRAP diff --git a/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h b/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h index 12cc5f6b1c..9eb578b781 100644 --- a/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h +++ b/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h @@ -7,6 +7,9 @@ #ifndef __HYPERVISOR_IF_X86_64_H__ #define __HYPERVISOR_IF_X86_64_H__ +/* Pointers are naturally 64 bits in this architecture; no padding needed. */ +#define MEMORY_PADDING() ((void)0) + /* * SEGMENT DESCRIPTOR TABLES */ @@ -53,6 +56,10 @@ #ifndef __ASSEMBLY__ +/* NB. Both the following are 64 bits each. */ +typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */ +typedef unsigned long cpureg_t; /* Full-sized register. */ + /* * Send an array of these to HYPERVISOR_set_trap_table() */ @@ -60,13 +67,13 @@ #define TI_GET_IF(_ti) ((_ti)->flags & 4) #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl)) #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2)) -typedef struct trap_info_st -{ - unsigned char vector; /* exception vector */ - unsigned char flags; /* 0-3: privilege level; 4: clear event enable? */ - unsigned short cs; /* code selector */ - unsigned long address; /* code address */ -} trap_info_t; +typedef struct { + u8 vector; /* 0: exception vector */ + u8 flags; /* 1: 0-3: privilege level; 4: clear event enable? */ + u16 cs; /* 2: code selector */ + u32 __pad; /* 4 */ + memory_t address; /* 8: code address */ +} PACKED trap_info_t; /* 16 bytes */ typedef struct { @@ -90,19 +97,22 @@ typedef struct unsigned long eflags; unsigned long rsp; unsigned long ss; -} execution_context_t; +} PACKED execution_context_t; +/* + * NB. This may become a 64-bit count with no shift. If this happens then the + * structure size will still be 8 bytes, so no other alignments will change. + */ typedef struct { - unsigned long tsc_bits; /* 32 bits read from the CPU's TSC. */ - unsigned int tsc_bitshift; /* 'tsc_bits' uses N:N+31 of TSC. */ -} tsc_timestamp_t; + u32 tsc_bits; /* 0: 32 bits read from the CPU's TSC. */ + u32 tsc_bitshift; /* 4: 'tsc_bits' uses N:N+31 of TSC. */ +} PACKED tsc_timestamp_t; /* 8 bytes */ /* * The following is all CPU context. Note that the i387_ctxt block is filled * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used. */ -typedef struct full_execution_context_st -{ +typedef struct { #define ECF_I387_VALID (1<<0) unsigned long flags; execution_context_t cpu_ctxt; /* User-level CPU registers */ @@ -117,7 +127,7 @@ typedef struct full_execution_context_st unsigned long event_callback_eip; unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ unsigned long failsafe_callback_eip; -} full_execution_context_t; +} PACKED full_execution_context_t; #endif /* !__ASSEMBLY__ */ diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index 6273878d16..d5de8a8a85 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -3,7 +3,8 @@ * * Process command requests from domain-0 guest OS. * - * Copyright (c) 2002-2003, K A Fraser, B Dragovic + * Copyright (c) 2002-2003, B Dragovic + * Copyright (c) 2002-2004, K Fraser */ @@ -18,22 +19,24 @@ * This makes sure that old versions of dom0 tools will stop working in a * well-defined way (rather than crashing the machine, for instance). */ -#define DOM0_INTERFACE_VERSION 0xAAAA000C +#define DOM0_INTERFACE_VERSION 0xAAAA000D #define MAX_DOMAIN_NAME 16 /************************************************************************/ #define DOM0_GETMEMLIST 2 -typedef struct dom0_getmemlist_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - unsigned long max_pfns; - void *buffer; + domid_t domain; /* 0 */ + memory_t max_pfns; /* 8 */ + MEMORY_PADDING; + void *buffer; /* 16 */ + MEMORY_PADDING; /* OUT variables. */ - unsigned long num_pfns; -} dom0_getmemlist_t; + memory_t num_pfns; /* 24 */ + MEMORY_PADDING; +} PACKED dom0_getmemlist_t; /* 32 bytes */ #define DOM0_SCHEDCTL 6 /* struct sched_ctl_cmd is from sched-ctl.h */ @@ -44,110 +47,117 @@ typedef struct sched_ctl_cmd dom0_schedctl_t; typedef struct sched_adjdom_cmd dom0_adjustdom_t; #define DOM0_CREATEDOMAIN 8 -typedef struct dom0_createdomain_st -{ +typedef struct { /* IN parameters. */ - unsigned int memory_kb; - char name[MAX_DOMAIN_NAME]; - int cpu; + memory_t memory_kb; /* 0 */ + MEMORY_PADDING; + u8 name[MAX_DOMAIN_NAME]; /* 8 */ + u32 cpu; /* 24 */ + u32 __pad; /* 28 */ /* OUT parameters. */ - domid_t domain; -} dom0_createdomain_t; + domid_t domain; /* 32 */ +} PACKED dom0_createdomain_t; /* 40 bytes */ #define DOM0_DESTROYDOMAIN 9 -typedef struct dom0_destroydomain_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - int force; -} dom0_destroydomain_t; + domid_t domain; /* 0 */ + u32 force; /* 8 */ +} PACKED dom0_destroydomain_t; /* 12 bytes */ #define DOM0_STARTDOMAIN 10 -typedef struct dom0_startdomain_st -{ +typedef struct { /* IN parameters. */ - domid_t domain; -} dom0_startdomain_t; + domid_t domain; /* 0 */ +} PACKED dom0_startdomain_t; /* 8 bytes */ #define DOM0_STOPDOMAIN 11 -typedef struct dom0_stopdomain_st -{ +typedef struct { /* IN parameters. */ - domid_t domain; + domid_t domain; /* 0 */ /* hack to indicate that you want to wait for other domain -- replace with proper sychronous stop soon! */ - int sync; -} dom0_stopdomain_t; + u32 sync; /* 8 */ +} PACKED dom0_stopdomain_t; /* 12 bytes */ #define DOM0_GETDOMAININFO 12 -typedef struct dom0_getdomaininfo_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - full_execution_context_t *ctxt; + domid_t domain; /* 0 */ + full_execution_context_t *ctxt; /* 8 */ + MEMORY_PADDING; /* OUT variables. */ - char name[MAX_DOMAIN_NAME]; - int processor; - int has_cpu; + char name[MAX_DOMAIN_NAME]; /* 16 */ + u32 processor; /* 32 */ + u32 has_cpu; /* 36 */ #define DOMSTATE_ACTIVE 0 #define DOMSTATE_STOPPED 1 - int state; - int hyp_events; - unsigned int tot_pages, max_pages; - long long cpu_time; - unsigned long shared_info_frame; /* MFN of shared_info struct */ -} dom0_getdomaininfo_t; + u32 state; /* 40 */ + u32 hyp_events; /* 44 */ + u32 tot_pages; /* 48 */ + u32 max_pages; /* 52 */ + u64 cpu_time; /* 56 */ + memory_t shared_info_frame; /* 64: MFN of shared_info struct */ + MEMORY_PADDING; +} PACKED dom0_getdomaininfo_t; /* 72 bytes */ #define DOM0_BUILDDOMAIN 13 -typedef struct dom0_builddomain_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - unsigned int num_vifs; + domid_t domain; /* 0 */ + u32 num_vifs;/* 8 */ + u32 __pad; /* 12 */ /* IN/OUT parameters */ - full_execution_context_t *ctxt; -} dom0_builddomain_t; + full_execution_context_t *ctxt; /* 16 */ + MEMORY_PADDING; +} PACKED dom0_builddomain_t; /* 24 bytes */ #define DOM0_IOPL 14 -typedef struct dom0_iopl_st -{ - domid_t domain; - unsigned int iopl; -} dom0_iopl_t; +typedef struct { + domid_t domain; /* 0 */ + u32 iopl; /* 8 */ +} PACKED dom0_iopl_t; /* 12 bytes */ #define DOM0_MSR 15 -typedef struct dom0_msr_st -{ +typedef struct { /* IN variables. */ - int write, cpu_mask, msr; - unsigned int in1, in2; + u32 write; /* 0 */ + u32 cpu_mask; /* 4 */ + u32 msr; /* 8 */ + u32 in1; /* 12 */ + u32 in2; /* 16 */ /* OUT variables. */ - unsigned int out1, out2; -} dom0_msr_t; + u32 out1; /* 20 */ + u32 out2; /* 24 */ +} PACKED dom0_msr_t; /* 28 bytes */ #define DOM0_DEBUG 16 -typedef struct dom0_debug_st -{ +typedef struct { /* IN variables. */ - char opcode; - domid_t domain; - int in1, in2, in3, in4; + domid_t domain; /* 0 */ + u8 opcode; /* 8 */ + u8 __pad0, __pad1, __pad2; + u32 in1; /* 12 */ + u32 in2; /* 16 */ + u32 in3; /* 20 */ + u32 in4; /* 24 */ /* OUT variables. */ - unsigned int status; - int out1, out2; -} dom0_debug_t; + u32 status; /* 28 */ + u32 out1; /* 32 */ + u32 out2; /* 36 */ +} PACKED dom0_debug_t; /* 40 bytes */ /* * Set clock such that it would read after 00:00:00 UTC, * 1 January, 1970 if the current system time was . */ #define DOM0_SETTIME 17 -typedef struct dom0_settime_st -{ +typedef struct { /* IN variables. */ - unsigned long secs, usecs; - u64 system_time; -} dom0_settime_t; + u32 secs; /* 0 */ + u32 usecs; /* 4 */ + u64 system_time; /* 8 */ +} PACKED dom0_settime_t; /* 16 bytes */ #define DOM0_GETPAGEFRAMEINFO 18 #define NOTAB 0 /* normal page */ @@ -157,85 +167,82 @@ typedef struct dom0_settime_st #define L4TAB (4<<28) #define XTAB (0xf<<28) /* invalid page */ #define LTAB_MASK XTAB -typedef struct dom0_getpageframeinfo_st -{ +typedef struct { /* IN variables. */ - unsigned long pfn; /* Machine page frame number to query. */ - domid_t domain; /* To which domain does the frame belong? */ + memory_t pfn; /* 0: Machine page frame number to query. */ + MEMORY_PADDING; + domid_t domain; /* 8: To which domain does the frame belong? */ /* OUT variables. */ /* Is the page PINNED to a type? */ - unsigned long type; /* see above type defs */ -} dom0_getpageframeinfo_t; - + u32 type; /* 16: see above type defs */ +} PACKED dom0_getpageframeinfo_t; /* 20 bytes */ /* * Read console content from Xen buffer ring. */ - #define DOM0_READCONSOLE 19 -typedef struct dom0_readconsole_st -{ - unsigned long str; - unsigned int count; - unsigned int cmd; -} dom0_readconsole_t; +typedef struct { + memory_t str; /* 0 */ + MEMORY_PADDING; + u32 count; /* 8 */ + u32 cmd; /* 12 */ +} PACKED dom0_readconsole_t; /* 16 bytes */ /* * Pin Domain to a particular CPU (use -1 to unpin) */ #define DOM0_PINCPUDOMAIN 20 -typedef struct dom0_pincpudomain_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - int cpu; /* -1 implies unpin */ -} dom0_pincpudomain_t; + domid_t domain; /* 0 */ + s32 cpu; /* 8: -1 implies unpin */ +} PACKED dom0_pincpudomain_t; /* 12 bytes */ /* Get trace buffers physical base pointer */ #define DOM0_GETTBUFS 21 -typedef struct dom0_gettbufs_st -{ - /* OUT variables */ - unsigned long phys_addr; /* location of the trace buffers */ - unsigned long size; /* size of each trace buffer, in bytes */ -} dom0_gettbufs_t; +typedef struct { + /* OUT variables */ + memory_t phys_addr; /* 0: location of the trace buffers */ + MEMORY_PADDING; + u32 size; /* 8: size of each trace buffer, in bytes */ +} PACKED dom0_gettbufs_t; /* 12 bytes */ /* * Get physical information about the host machine */ #define DOM0_PHYSINFO 22 -typedef struct dom0_physinfo_st -{ - int ht_per_core; - int cores; - unsigned long cpu_khz; - unsigned long total_pages; - unsigned long free_pages; -} dom0_physinfo_t; +typedef struct { + u32 ht_per_core; /* 0 */ + u32 cores; /* 4 */ + u32 cpu_khz; /* 8 */ + u32 __pad; /* 12 */ + memory_t total_pages; /* 16 */ + MEMORY_PADDING; + memory_t free_pages; /* 24 */ + MEMORY_PADDING; +} PACKED dom0_physinfo_t; /* 32 bytes */ /* * Allow a domain access to a physical PCI device */ #define DOM0_PCIDEV_ACCESS 23 -typedef struct dom0_pcidev_access_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - int bus; - int dev; - int func; - int enable; -} dom0_pcidev_access_t; + domid_t domain; /* 0 */ + u32 bus; /* 8 */ + u32 dev; /* 12 */ + u32 func; /* 16 */ + u32 enable; /* 20 */ +} PACKED dom0_pcidev_access_t; /* 24 bytes */ /* * Get the ID of the current scheduler. */ #define DOM0_SCHED_ID 24 -typedef struct dom0_sched_id_st -{ +typedef struct { /* OUT variable */ - int sched_id; -} dom0_sched_id_t; + u32 sched_id; /* 0 */ +} PACKED dom0_sched_id_t; /* 4 bytes */ /* * Control shadow pagetables operation @@ -249,87 +256,88 @@ typedef struct dom0_sched_id_st #define DOM0_SHADOW_CONTROL_OP_CLEAN 11 #define DOM0_SHADOW_CONTROL_OP_PEEK 12 #define DOM0_SHADOW_CONTROL_OP_CLEAN2 13 -typedef struct dom0_shadow_control_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - int op; - unsigned long *dirty_bitmap; // pointe to mlocked buffer - /* IN/OUT variables */ - unsigned long pages; // size of buffer, updated with actual size - /* OUT varaibles */ - unsigned long fault_count; - unsigned long dirty_count; -} dom0_shadow_control_t; + domid_t domain; /* 0 */ + u32 op; /* 8 */ + u32 __pad; /* 12 */ + unsigned long *dirty_bitmap; /* 16: pointer to locked buffer */ + MEMORY_PADDING; + /* IN/OUT variables. */ + memory_t pages; /* 24: size of buffer, updated with actual size */ + MEMORY_PADDING; + /* OUT variables. */ + memory_t fault_count; /* 32 */ + MEMORY_PADDING; + memory_t dirty_count; /* 40 */ + MEMORY_PADDING; +} PACKED dom0_shadow_control_t; /* 48 bytes */ #define DOM0_SETDOMAINNAME 26 -typedef struct dom0_setdomainname_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - char name[MAX_DOMAIN_NAME]; -} dom0_setdomainname_t; + domid_t domain; /* 0 */ + char name[MAX_DOMAIN_NAME]; /* 8 */ +} PACKED dom0_setdomainname_t; /* 24 bytes */ #define DOM0_SETDOMAININITIALMEM 27 -typedef struct dom0_setdomaininitialmem_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - unsigned int initial_memkb; /* use before domain is built */ -} dom0_setdomaininitialmem_t; + domid_t domain; /* 0 */ + memory_t initial_memkb; /* 8 */ + MEMORY_PADDING; +} PACKED dom0_setdomaininitialmem_t; /* 16 bytes */ #define DOM0_SETDOMAINMAXMEM 28 -typedef struct dom0_setdomainmaxmem_st -{ +typedef struct { /* IN variables. */ - domid_t domain; - unsigned int max_memkb; -} dom0_setdomainmaxmem_t; + domid_t domain; /* 0 */ + memory_t max_memkb; /* 8 */ + MEMORY_PADDING; +} PACKED dom0_setdomainmaxmem_t; /* 16 bytes */ #define DOM0_GETPAGEFRAMEINFO2 29 /* batched interface */ -typedef struct dom0_getpageframeinfo2_st -{ +typedef struct { /* IN variables. */ - domid_t domain; /* To which domain do frames belong? */ - int num; + domid_t domain; /* 0 */ + memory_t num; /* 8 */ + MEMORY_PADDING; /* IN/OUT variables. */ - unsigned long *array; -} dom0_getpageframeinfo2_t; - - -typedef struct dom0_op_st -{ - unsigned long cmd; - unsigned long interface_version; /* DOM0_INTERFACE_VERSION */ - union - { - unsigned long dummy[4]; - dom0_createdomain_t createdomain; - dom0_startdomain_t startdomain; - dom0_stopdomain_t stopdomain; - dom0_destroydomain_t destroydomain; - dom0_getmemlist_t getmemlist; - dom0_schedctl_t schedctl; - dom0_adjustdom_t adjustdom; - dom0_builddomain_t builddomain; - dom0_getdomaininfo_t getdomaininfo; - dom0_getpageframeinfo_t getpageframeinfo; - dom0_iopl_t iopl; - dom0_msr_t msr; - dom0_debug_t debug; - dom0_settime_t settime; - dom0_readconsole_t readconsole; - dom0_pincpudomain_t pincpudomain; - dom0_gettbufs_t gettbufs; - dom0_physinfo_t physinfo; - dom0_pcidev_access_t pcidev_access; - dom0_sched_id_t sched_id; - dom0_shadow_control_t shadow_control; - dom0_setdomainname_t setdomainname; + unsigned long *array; /* 16 */ + MEMORY_PADDING; +} PACKED dom0_getpageframeinfo2_t; /* 24 bytes */ + +typedef struct { + u32 cmd; /* 0 */ + u32 interface_version; /* 4 */ /* DOM0_INTERFACE_VERSION */ + union { /* 8 */ + u32 dummy[14]; /* 56 bytes */ + dom0_createdomain_t createdomain; + dom0_startdomain_t startdomain; + dom0_stopdomain_t stopdomain; + dom0_destroydomain_t destroydomain; + dom0_getmemlist_t getmemlist; + dom0_schedctl_t schedctl; + dom0_adjustdom_t adjustdom; + dom0_builddomain_t builddomain; + dom0_getdomaininfo_t getdomaininfo; + dom0_getpageframeinfo_t getpageframeinfo; + dom0_iopl_t iopl; + dom0_msr_t msr; + dom0_debug_t debug; + dom0_settime_t settime; + dom0_readconsole_t readconsole; + dom0_pincpudomain_t pincpudomain; + dom0_gettbufs_t gettbufs; + dom0_physinfo_t physinfo; + dom0_pcidev_access_t pcidev_access; + dom0_sched_id_t sched_id; + dom0_shadow_control_t shadow_control; + dom0_setdomainname_t setdomainname; dom0_setdomaininitialmem_t setdomaininitialmem; - dom0_setdomainmaxmem_t setdomainmaxmem; + dom0_setdomainmaxmem_t setdomainmaxmem; dom0_getpageframeinfo2_t getpageframeinfo2; - } u; -} dom0_op_t; + } PACKED u; +} PACKED dom0_op_t; /* 64 bytes */ #endif /* __DOM0_OPS_H__ */ diff --git a/xen/include/hypervisor-ifs/event_channel.h b/xen/include/hypervisor-ifs/event_channel.h index 20095c91a3..1c84fb3c22 100644 --- a/xen/include/hypervisor-ifs/event_channel.h +++ b/xen/include/hypervisor-ifs/event_channel.h @@ -17,13 +17,12 @@ * 3. and are only supplied if the op succeeds. */ #define EVTCHNOP_bind_interdomain 0 -typedef struct evtchn_bind_interdomain -{ +typedef struct { /* IN parameters. */ - domid_t dom1, dom2; + domid_t dom1, dom2; /* 0, 8 */ /* OUT parameters. */ - int port1, port2; -} evtchn_bind_interdomain_t; + u32 port1, port2; /* 16, 20 */ +} PACKED evtchn_bind_interdomain_t; /* 24 bytes */ /* * EVTCHNOP_bind_virq: Bind a local event channel to IRQ . @@ -31,13 +30,12 @@ typedef struct evtchn_bind_interdomain * 1. A virtual IRQ may be bound to at most one event channel per domain. */ #define EVTCHNOP_bind_virq 1 -typedef struct evtchn_bind_virq -{ +typedef struct { /* IN parameters. */ - int virq; + u32 virq; /* 0 */ /* OUT parameters. */ - int port; -} evtchn_bind_virq_t; + u32 port; /* 4 */ +} PACKED evtchn_bind_virq_t; /* 8 bytes */ /* * EVTCHNOP_bind_pirq: Bind a local event channel to IRQ . @@ -46,15 +44,14 @@ typedef struct evtchn_bind_virq * 2. Only a sufficiently-privileged domain may bind to a physical IRQ. */ #define EVTCHNOP_bind_pirq 2 -typedef struct evtchn_bind_pirq -{ +typedef struct { /* IN parameters. */ - int pirq; + u32 pirq; /* 0 */ #define BIND_PIRQ__WILL_SHARE 1 - unsigned int flags; /* BIND_PIRQ__* */ + u32 flags; /* BIND_PIRQ__* */ /* 4 */ /* OUT parameters. */ - int port; -} evtchn_bind_pirq_t; + u32 port; /* 8 */ +} PACKED evtchn_bind_pirq_t; /* 12 bytes */ /* * EVTCHNOP_close: Close the communication channel which has an endpoint at @@ -65,25 +62,23 @@ typedef struct evtchn_bind_pirq * for which is not DOMID_SELF. */ #define EVTCHNOP_close 3 -typedef struct evtchn_close -{ +typedef struct { /* IN parameters. */ - domid_t dom; - int port; + domid_t dom; /* 0 */ + u32 port; /* 8 */ /* No OUT parameters. */ -} evtchn_close_t; +} PACKED evtchn_close_t; /* 12 bytes */ /* * EVTCHNOP_send: Send an event to the remote end of the channel whose local * endpoint is . */ #define EVTCHNOP_send 4 -typedef struct evtchn_send -{ +typedef struct { /* IN parameters. */ - int local_port; + u32 local_port; /* 0 */ /* No OUT parameters. */ -} evtchn_send_t; +} PACKED evtchn_send_t; /* 4 bytes */ /* * EVTCHNOP_status: Get the current status of the communication channel which @@ -94,40 +89,39 @@ typedef struct evtchn_send * channel for which is not DOMID_SELF. */ #define EVTCHNOP_status 5 -typedef struct evtchn_status -{ +typedef struct { /* IN parameters */ - domid_t dom; - int port; + domid_t dom; /* 0 */ + u32 port; /* 8 */ /* OUT parameters */ #define EVTCHNSTAT_closed 0 /* Chennel is not in use. */ #define EVTCHNSTAT_unbound 1 /* Channel is not bound to a source. */ #define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */ #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */ #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */ - int status; + u32 status; /* 12 */ union { - int __none; /* EVTCHNSTAT_closed, EVTCHNSTAT_unbound */ struct { - domid_t dom; - int port; - } interdomain; /* EVTCHNSTAT_interdomain */ - int pirq; /* EVTCHNSTAT_pirq */ - int virq; /* EVTCHNSTAT_virq */ - } u; -} evtchn_status_t; + domid_t dom; /* 16 */ + u32 port; /* 24 */ + } PACKED interdomain; /* EVTCHNSTAT_interdomain */ + u32 pirq; /* EVTCHNSTAT_pirq */ /* 16 */ + u32 virq; /* EVTCHNSTAT_virq */ /* 16 */ + } PACKED u; +} PACKED evtchn_status_t; /* 28 bytes */ -typedef struct evtchn_op -{ - int cmd; /* EVTCHNOP_* */ - union { +typedef struct { + u32 cmd; /* EVTCHNOP_* */ /* 0 */ + u32 __reserved; /* 4 */ + union { /* 8 */ evtchn_bind_interdomain_t bind_interdomain; evtchn_bind_virq_t bind_virq; evtchn_bind_pirq_t bind_pirq; evtchn_close_t close; evtchn_send_t send; evtchn_status_t status; - } u; -} evtchn_op_t; + u8 __dummy[32]; + } PACKED u; +} PACKED evtchn_op_t; /* 40 bytes */ #endif /* __HYPERVISOR_IFS__EVENT_CHANNEL_H__ */ diff --git a/xen/include/hypervisor-ifs/hypervisor-if.h b/xen/include/hypervisor-ifs/hypervisor-if.h index 57b9dff13f..66b06ae1d6 100644 --- a/xen/include/hypervisor-ifs/hypervisor-if.h +++ b/xen/include/hypervisor-ifs/hypervisor-if.h @@ -7,6 +7,9 @@ #ifndef __HYPERVISOR_IF_H__ #define __HYPERVISOR_IF_H__ +/* GCC-specific way to pack structure definitions (no implicit padding). */ +#define PACKED __attribute__ ((packed)) + #include "arch/hypervisor-if.h" /* @@ -197,21 +200,24 @@ typedef u64 domid_t; #include "block.h" /* - * Send an array of these to HYPERVISOR_mmu_update() + * Send an array of these to HYPERVISOR_mmu_update(). + * NB. The fields are natural pointer/address size for this architecture. */ typedef struct { - unsigned long ptr, val; /* *ptr = val */ -} mmu_update_t; + memory_t ptr; /* Machine address of PTE. */ + memory_t val; /* New contents of PTE. */ +} PACKED mmu_update_t; /* - * Send an array of these to HYPERVISOR_multicall() + * Send an array of these to HYPERVISOR_multicall(). + * NB. The fields are natural register size for this architecture. */ typedef struct { - unsigned long op; - unsigned long args[7]; -} multicall_entry_t; + cpureg_t op; + cpureg_t args[7]; +} PACKED multicall_entry_t; /* Event channel endpoints per domain. */ #define NR_EVENT_CHANNELS 1024 @@ -258,7 +264,7 @@ typedef struct shared_info_st u8 evtchn_upcall_pending; u8 evtchn_upcall_mask; u8 pad0, pad1; - } vcpu_data[MAX_VIRT_CPUS]; + } PACKED vcpu_data[MAX_VIRT_CPUS]; /* 0 */ /* * A domain can have up to 1024 "event channels" on which it can send @@ -295,16 +301,16 @@ typedef struct shared_info_st * 32-bit selector to be set. Each bit in the selector covers a 32-bit * word in the PENDING bitfield array. */ - u32 evtchn_pending[32]; - u32 evtchn_pending_sel; - u32 evtchn_exception[32]; - u32 evtchn_mask[32]; + u32 evtchn_pending[32]; /* 4 */ + u32 evtchn_pending_sel; /* 132 */ + u32 evtchn_exception[32]; /* 136 */ + u32 evtchn_mask[32]; /* 264 */ /* * Time: The following abstractions are exposed: System Time, Clock Time, * Domain Virtual Time. Domains can access Cycle counter time directly. */ - u64 cpu_freq; /* CPU frequency (Hz). */ + u64 cpu_freq; /* 392: CPU frequency (Hz). */ /* * The following values are updated periodically (and not necessarily @@ -313,12 +319,12 @@ typedef struct shared_info_st * incremented immediately after. See the Xen-specific Linux code for an * example of how to read these values safely (arch/xen/kernel/time.c). */ - unsigned long time_version1; /* A version number for info below. */ - unsigned long time_version2; /* A version number for info below. */ + u32 time_version1; /* 400 */ + u32 time_version2; /* 404 */ tsc_timestamp_t tsc_timestamp; /* TSC at last update of time vals. */ u64 system_time; /* Time, in nanosecs, since boot. */ - unsigned long wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ - unsigned long wc_usec; /* Usecs 00:00:00 UTC, Jan 1, 1970. */ + u32 wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ + u32 wc_usec; /* Usecs 00:00:00 UTC, Jan 1, 1970. */ u64 domain_time; /* Domain virtual time, in nanosecs. */ /* @@ -326,8 +332,8 @@ typedef struct shared_info_st * Allow a domain to specify a timeout value in system time and * domain virtual time. */ - u64 wall_timeout; - u64 domain_timeout; + u64 wall_timeout; /* 440 */ + u64 domain_timeout; /* 448 */ /* * The index structures are all stored here for convenience. The rings @@ -339,7 +345,7 @@ typedef struct shared_info_st execution_context_t execution_context; -} shared_info_t; +} PACKED shared_info_t; /* * Start-of-day memory layout for the initial domain (DOM0): diff --git a/xen/include/hypervisor-ifs/physdev.h b/xen/include/hypervisor-ifs/physdev.h index 50372bf2be..4e1aa135d3 100644 --- a/xen/include/hypervisor-ifs/physdev.h +++ b/xen/include/hypervisor-ifs/physdev.h @@ -20,60 +20,61 @@ /* Read from PCI configuration space. */ typedef struct { /* IN */ - int bus; - int dev; - int func; - int reg; - int len; + u32 bus; /* 0 */ + u32 dev; /* 4 */ + u32 func; /* 8 */ + u32 reg; /* 12 */ + u32 len; /* 16 */ /* OUT */ - u32 value; -} physdevop_pci_cfgreg_read_t; + u32 value; /* 20 */ +} PACKED physdevop_pci_cfgreg_read_t; /* 24 bytes */ /* Write to PCI configuration space. */ typedef struct { /* IN */ - int bus; - int dev; - int func; - int reg; - int len; - u32 value; -} physdevop_pci_cfgreg_write_t; + u32 bus; /* 0 */ + u32 dev; /* 4 */ + u32 func; /* 8 */ + u32 reg; /* 12 */ + u32 len; /* 16 */ + u32 value; /* 20 */ +} PACKED physdevop_pci_cfgreg_write_t; /* 24 bytes */ /* Do final initialisation of a PCI device (e.g., last-moment IRQ routing). */ typedef struct { /* IN */ - int bus; - int dev; - int func; -} physdevop_pci_initialise_device_t; + u32 bus; /* 0 */ + u32 dev; /* 4 */ + u32 func; /* 8 */ +} PACKED physdevop_pci_initialise_device_t; /* 12 bytes */ /* Find the root buses for subsequent scanning. */ typedef struct { /* OUT */ - u32 busmask[256/32]; -} physdevop_pci_probe_root_buses_t; + u32 busmask[256/32]; /* 0 */ +} PACKED physdevop_pci_probe_root_buses_t; /* 32 bytes */ typedef struct { /* IN */ - int irq; + u32 irq; /* 0 */ /* OUT */ /* Need to call PHYSDEVOP_IRQ_UNMASK_NOTIFY when the IRQ has been serviced? */ #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY (1<<0) - unsigned long flags; -} physdevop_irq_status_query_t; + u32 flags; /* 4 */ +} PACKED physdevop_irq_status_query_t; /* 8 bytes */ typedef struct _physdev_op_st { - unsigned long cmd; - union - { + u32 cmd; /* 0 */ + u32 __pad; /* 4 */ + union { /* 8 */ physdevop_pci_cfgreg_read_t pci_cfgreg_read; physdevop_pci_cfgreg_write_t pci_cfgreg_write; physdevop_pci_initialise_device_t pci_initialise_device; physdevop_pci_probe_root_buses_t pci_probe_root_buses; physdevop_irq_status_query_t irq_status_query; - } u; -} physdev_op_t; + u8 __dummy[32]; + } PACKED u; +} PACKED physdev_op_t; /* 40 bytes */ #endif /* __HYPERVISOR_IFS_PHYSDEV_H__ */ diff --git a/xen/include/hypervisor-ifs/sched_ctl.h b/xen/include/hypervisor-ifs/sched_ctl.h index cdf682963a..641ad2c192 100644 --- a/xen/include/hypervisor-ifs/sched_ctl.h +++ b/xen/include/hypervisor-ifs/sched_ctl.h @@ -23,49 +23,45 @@ */ struct sched_ctl_cmd { - unsigned int sched_id; - int direction; /* are we getting or putting settings? */ - - union - { + u32 sched_id; /* 0 */ + u32 direction; /* 4 */ + union { /* 8 */ struct bvt_ctl { /* IN variables. */ - unsigned long ctx_allow; /* context switch allowance */ - } bvt; + u32 ctx_allow; /* 8: context switch allowance */ + } PACKED bvt; struct rrobin_ctl { /* IN variables */ - u64 slice; /* round robin time slice */ - } rrobin; - } u; -}; + u64 slice; /* 8: round robin time slice */ + } PACKED rrobin; + } PACKED u; +} PACKED; /* 16 bytes */ struct sched_adjdom_cmd { - unsigned int sched_id; - domid_t domain; - int direction; /* are we getting or putting settings? */ - - union - { + u32 sched_id; /* 0 */ + u32 direction; /* 4 */ + domid_t domain; /* 8 */ + union { /* 16 */ struct bvt_adjdom { - unsigned long mcu_adv; /* mcu advance: inverse of weight */ - unsigned long warp; /* time warp */ - unsigned long warpl; /* warp limit */ - unsigned long warpu; /* unwarp time requirement */ - } bvt; + u32 mcu_adv; /* 16: mcu advance: inverse of weight */ + u32 warp; /* 20: time warp */ + u32 warpl; /* 24: warp limit */ + u32 warpu; /* 28: unwarp time requirement */ + } PACKED bvt; struct atropos_adjdom { - u64 nat_period; - u64 nat_slice; - u64 latency; - int xtratime; - } atropos; - } u; -}; + u64 nat_period; /* 16 */ + u64 nat_slice; /* 24 */ + u64 latency; /* 32 */ + u32 xtratime; /* 36 */ + } PACKED atropos; + } PACKED u; +} PACKED; /* 40 bytes */ #endif /* __SCHED_CTL_H__ */ diff --git a/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/blkif.h b/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/blkif.h index 0a90744c59..1024629ea7 100644 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/blkif.h +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/blkif/blkif.h @@ -27,17 +27,17 @@ #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 typedef struct { - u8 operation; /* BLKIF_OP_??? */ - u8 nr_segments; /* number of segments */ - blkif_vdev_t device; /* only for read/write requests */ - unsigned long id; /* private guest value, echoed in resp */ + u8 operation; /* 0: BLKIF_OP_??? */ + u8 nr_segments; /* 1: number of segments */ + blkif_vdev_t device; /* 2: only for read/write requests */ + unsigned long id; /* 4: private guest value, echoed in resp */ blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */ /* @f_a_s[2:0]=last_sect ; @f_a_s[5:3]=first_sect ; @f_a_s[:12]=frame. */ /* @first_sect: first sector in frame to transfer (inclusive). */ /* @last_sect: last sector in frame to transfer (inclusive). */ /* @frame: machine page frame number. */ unsigned long frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST]; -} blkif_request_t; +} PACKED blkif_request_t; #define blkif_first_sect(_fas) (((_fas)>>3)&7) #define blkif_last_sect(_fas) ((_fas)&7) @@ -46,7 +46,7 @@ typedef struct { unsigned long id; /* copied from request */ u8 operation; /* copied from request */ s16 status; /* BLKIF_RSP_??? */ -} blkif_response_t; +} PACKED blkif_response_t; #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */ #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */ @@ -55,7 +55,7 @@ typedef struct { * We use a special capitalised type name because it is _essential_ that all * arithmetic on indexes is done on an integer type of the correct size. */ -typedef unsigned int BLKIF_RING_IDX; +typedef u32 BLKIF_RING_IDX; /* * Ring indexes are 'free running'. That is, they are not stored modulo the @@ -65,13 +65,13 @@ typedef unsigned int BLKIF_RING_IDX; #define MASK_BLKIF_IDX(_i) ((_i)&(BLKIF_RING_SIZE-1)) typedef struct { - BLKIF_RING_IDX req_prod; /* Request producer. Updated by front-end. */ - BLKIF_RING_IDX resp_prod; /* Response producer. Updated by back-end. */ - union { + BLKIF_RING_IDX req_prod; /* 0: Request producer. Updated by front-end. */ + BLKIF_RING_IDX resp_prod; /* 4: Response producer. Updated by back-end. */ + union { /* 8 */ blkif_request_t req; blkif_response_t resp; - } ring[BLKIF_RING_SIZE]; -} blkif_ring_t; + } PACKED ring[BLKIF_RING_SIZE]; +} PACKED blkif_ring_t; /* @@ -107,9 +107,9 @@ typedef struct { #define VDISK_VIRTUAL(_x) ((_x) & VDISK_FLAG_VIRT) typedef struct { - blkif_sector_t capacity; /* Size in terms of 512-byte sectors. */ - blkif_vdev_t device; /* Device number (opaque 16 bit value). */ - u16 info; /* Device type and flags (VDISK_*). */ -} vdisk_t; + blkif_sector_t capacity; /* 0: Size in terms of 512-byte sectors. */ + blkif_vdev_t device; /* 8: Device number (opaque 16 bit value). */ + u16 info; /* 10: Device type and flags (VDISK_*). */ +} PACKED vdisk_t; /* 12 bytes */ #endif /* __SHARED_BLKIF_H__ */ diff --git a/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c b/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c index 33e1fde912..7068d89035 100644 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/backend/main.c @@ -16,11 +16,11 @@ static void netif_page_release(struct page *page); static void make_tx_response(netif_t *netif, u16 id, s8 st); -static int make_rx_response(netif_t *netif, - u16 id, - s8 st, - netif_addr_t addr, - u16 size); +static int make_rx_response(netif_t *netif, + u16 id, + s8 st, + memory_t addr, + u16 size); static void net_tx_action(unsigned long unused); static DECLARE_TASKLET(net_tx_tasklet, net_tx_action, 0); @@ -682,11 +682,11 @@ static void make_tx_response(netif_t *netif, notify_via_evtchn(netif->evtchn); } -static int make_rx_response(netif_t *netif, - u16 id, - s8 st, - netif_addr_t addr, - u16 size) +static int make_rx_response(netif_t *netif, + u16 id, + s8 st, + memory_t addr, + u16 size) { NET_RING_IDX i = netif->rx_resp_prod; netif_rx_response_t *resp; diff --git a/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/netif.h b/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/netif.h index 68251420ef..098b292612 100644 --- a/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/netif.h +++ b/xenolinux-2.4.26-sparse/arch/xen/drivers/netif/netif.h @@ -9,34 +9,35 @@ #ifndef __SHARED_NETIF_H__ #define __SHARED_NETIF_H__ -typedef unsigned long netif_addr_t; - typedef struct { - netif_addr_t addr; /* Machine address of packet. */ - u16 id; /* Echoed in response message. */ - u16 size; /* Packet size in bytes. */ -} netif_tx_request_t; + memory_t addr; /* 0: Machine address of packet. */ + MEMORY_PADDING; + u16 id; /* 8: Echoed in response message. */ + u16 size; /* 10: Packet size in bytes. */ +} PACKED netif_tx_request_t; /* 12 bytes */ typedef struct { - u16 id; - s8 status; -} netif_tx_response_t; + u16 id; /* 0 */ + s8 status; /* 2 */ + u8 __pad; /* 3 */ +} PACKED netif_tx_response_t; /* 4 bytes */ typedef struct { - u16 id; /* Echoed in response message. */ -} netif_rx_request_t; + u16 id; /* 0: Echoed in response message. */ +} PACKED netif_rx_request_t; /* 2 bytes */ typedef struct { - netif_addr_t addr; /* Machine address of packet. */ - u16 id; - s16 status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */ -} netif_rx_response_t; + memory_t addr; /* 0: Machine address of packet. */ + MEMORY_PADDING; + u16 id; /* 8: */ + s16 status; /* 10: -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */ +} PACKED netif_rx_response_t; /* 12 bytes */ /* * We use a special capitalised type name because it is _essential_ that all * arithmetic on indexes is done on an integer type of the correct size. */ -typedef unsigned int NETIF_RING_IDX; +typedef u32 NETIF_RING_IDX; /* * Ring indexes are 'free running'. That is, they are not stored modulo the @@ -51,29 +52,33 @@ typedef unsigned int NETIF_RING_IDX; /* This structure must fit in a memory page. */ typedef struct { - union { - netif_tx_request_t req; - netif_tx_response_t resp; - } ring[NETIF_TX_RING_SIZE]; /* * Frontend places packets into ring at tx_req_prod. * Frontend receives event when tx_resp_prod passes tx_event. */ - NETIF_RING_IDX req_prod, resp_prod, event; -} netif_tx_interface_t; + NETIF_RING_IDX req_prod; /* 0 */ + NETIF_RING_IDX resp_prod; /* 4 */ + NETIF_RING_IDX event; /* 8 */ + union { /* 12 */ + netif_tx_request_t req; + netif_tx_response_t resp; + } PACKED ring[NETIF_TX_RING_SIZE]; +} PACKED netif_tx_interface_t; /* This structure must fit in a memory page. */ typedef struct { - union { - netif_rx_request_t req; - netif_rx_response_t resp; - } ring[NETIF_RX_RING_SIZE]; /* * Frontend places empty buffers into ring at rx_req_prod. * Frontend receives event when rx_resp_prod passes rx_event. */ - NETIF_RING_IDX req_prod, resp_prod, event; -} netif_rx_interface_t; + NETIF_RING_IDX req_prod; /* 0 */ + NETIF_RING_IDX resp_prod; /* 4 */ + NETIF_RING_IDX event; /* 8 */ + union { /* 12 */ + netif_rx_request_t req; + netif_rx_response_t resp; + } PACKED ring[NETIF_RX_RING_SIZE]; +} PACKED netif_rx_interface_t; /* Descriptor status values */ #define NETIF_RSP_DROPPED -2