debuggers.hg
changeset 13704:699656fb1d0b
Port ACM code to new Xen byteorder macros.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Mon Jan 29 16:46:52 2007 +0000 (2007-01-29) |
parents | 647c06ba0b49 |
children | 44eb80f50725 |
files | xen/acm/acm_chinesewall_hooks.c xen/acm/acm_core.c xen/acm/acm_policy.c xen/acm/acm_simple_type_enforcement_hooks.c xen/include/acm/acm_endian.h |
line diff
1.1 --- a/xen/acm/acm_chinesewall_hooks.c Mon Jan 29 16:04:43 2007 +0000 1.2 +++ b/xen/acm/acm_chinesewall_hooks.c Mon Jan 29 16:46:52 2007 +0000 1.3 @@ -132,26 +132,26 @@ static int chwall_dump_policy(u8 * buf, 1.4 if (buf_size < sizeof(struct acm_chwall_policy_buffer)) 1.5 return -EINVAL; 1.6 1.7 - chwall_buf->chwall_max_types = htonl(chwall_bin_pol.max_types); 1.8 - chwall_buf->chwall_max_ssidrefs = htonl(chwall_bin_pol.max_ssidrefs); 1.9 - chwall_buf->policy_code = htonl(ACM_CHINESE_WALL_POLICY); 1.10 + chwall_buf->chwall_max_types = cpu_to_be32(chwall_bin_pol.max_types); 1.11 + chwall_buf->chwall_max_ssidrefs = cpu_to_be32(chwall_bin_pol.max_ssidrefs); 1.12 + chwall_buf->policy_code = cpu_to_be32(ACM_CHINESE_WALL_POLICY); 1.13 chwall_buf->chwall_ssid_offset = 1.14 - htonl(sizeof(struct acm_chwall_policy_buffer)); 1.15 + cpu_to_be32(sizeof(struct acm_chwall_policy_buffer)); 1.16 chwall_buf->chwall_max_conflictsets = 1.17 - htonl(chwall_bin_pol.max_conflictsets); 1.18 + cpu_to_be32(chwall_bin_pol.max_conflictsets); 1.19 chwall_buf->chwall_conflict_sets_offset = 1.20 - htonl(ntohl(chwall_buf->chwall_ssid_offset) + 1.21 + cpu_to_be32(be32_to_cpu(chwall_buf->chwall_ssid_offset) + 1.22 sizeof(domaintype_t) * chwall_bin_pol.max_ssidrefs * 1.23 chwall_bin_pol.max_types); 1.24 chwall_buf->chwall_running_types_offset = 1.25 - htonl(ntohl(chwall_buf->chwall_conflict_sets_offset) + 1.26 + cpu_to_be32(be32_to_cpu(chwall_buf->chwall_conflict_sets_offset) + 1.27 sizeof(domaintype_t) * chwall_bin_pol.max_conflictsets * 1.28 chwall_bin_pol.max_types); 1.29 chwall_buf->chwall_conflict_aggregate_offset = 1.30 - htonl(ntohl(chwall_buf->chwall_running_types_offset) + 1.31 + cpu_to_be32(be32_to_cpu(chwall_buf->chwall_running_types_offset) + 1.32 sizeof(domaintype_t) * chwall_bin_pol.max_types); 1.33 1.34 - ret = ntohl(chwall_buf->chwall_conflict_aggregate_offset) + 1.35 + ret = be32_to_cpu(chwall_buf->chwall_conflict_aggregate_offset) + 1.36 sizeof(domaintype_t) * chwall_bin_pol.max_types; 1.37 1.38 ret = (ret + 7) & ~7; 1.39 @@ -160,21 +160,21 @@ static int chwall_dump_policy(u8 * buf, 1.40 return -EINVAL; 1.41 1.42 /* now copy buffers over */ 1.43 - arrcpy16((u16 *) (buf + ntohl(chwall_buf->chwall_ssid_offset)), 1.44 + arrcpy16((u16 *) (buf + be32_to_cpu(chwall_buf->chwall_ssid_offset)), 1.45 chwall_bin_pol.ssidrefs, 1.46 chwall_bin_pol.max_ssidrefs * chwall_bin_pol.max_types); 1.47 1.48 arrcpy16((u16 *) (buf + 1.49 - ntohl(chwall_buf->chwall_conflict_sets_offset)), 1.50 + be32_to_cpu(chwall_buf->chwall_conflict_sets_offset)), 1.51 chwall_bin_pol.conflict_sets, 1.52 chwall_bin_pol.max_conflictsets * chwall_bin_pol.max_types); 1.53 1.54 arrcpy16((u16 *) (buf + 1.55 - ntohl(chwall_buf->chwall_running_types_offset)), 1.56 + be32_to_cpu(chwall_buf->chwall_running_types_offset)), 1.57 chwall_bin_pol.running_types, chwall_bin_pol.max_types); 1.58 1.59 arrcpy16((u16 *) (buf + 1.60 - ntohl(chwall_buf->chwall_conflict_aggregate_offset)), 1.61 + be32_to_cpu(chwall_buf->chwall_conflict_aggregate_offset)), 1.62 chwall_bin_pol.conflict_aggregate_set, 1.63 chwall_bin_pol.max_types); 1.64 return ret; 1.65 @@ -267,20 +267,20 @@ static int chwall_set_policy(u8 * buf, u 1.66 return -EINVAL; 1.67 1.68 /* rewrite the policy due to endianess */ 1.69 - chwall_buf->policy_code = ntohl(chwall_buf->policy_code); 1.70 - chwall_buf->policy_version = ntohl(chwall_buf->policy_version); 1.71 - chwall_buf->chwall_max_types = ntohl(chwall_buf->chwall_max_types); 1.72 + chwall_buf->policy_code = be32_to_cpu(chwall_buf->policy_code); 1.73 + chwall_buf->policy_version = be32_to_cpu(chwall_buf->policy_version); 1.74 + chwall_buf->chwall_max_types = be32_to_cpu(chwall_buf->chwall_max_types); 1.75 chwall_buf->chwall_max_ssidrefs = 1.76 - ntohl(chwall_buf->chwall_max_ssidrefs); 1.77 + be32_to_cpu(chwall_buf->chwall_max_ssidrefs); 1.78 chwall_buf->chwall_max_conflictsets = 1.79 - ntohl(chwall_buf->chwall_max_conflictsets); 1.80 - chwall_buf->chwall_ssid_offset = ntohl(chwall_buf->chwall_ssid_offset); 1.81 + be32_to_cpu(chwall_buf->chwall_max_conflictsets); 1.82 + chwall_buf->chwall_ssid_offset = be32_to_cpu(chwall_buf->chwall_ssid_offset); 1.83 chwall_buf->chwall_conflict_sets_offset = 1.84 - ntohl(chwall_buf->chwall_conflict_sets_offset); 1.85 + be32_to_cpu(chwall_buf->chwall_conflict_sets_offset); 1.86 chwall_buf->chwall_running_types_offset = 1.87 - ntohl(chwall_buf->chwall_running_types_offset); 1.88 + be32_to_cpu(chwall_buf->chwall_running_types_offset); 1.89 chwall_buf->chwall_conflict_aggregate_offset = 1.90 - ntohl(chwall_buf->chwall_conflict_aggregate_offset); 1.91 + be32_to_cpu(chwall_buf->chwall_conflict_aggregate_offset); 1.92 1.93 /* policy type and version checks */ 1.94 if ((chwall_buf->policy_code != ACM_CHINESE_WALL_POLICY) ||
2.1 --- a/xen/acm/acm_core.c Mon Jan 29 16:04:43 2007 +0000 2.2 +++ b/xen/acm/acm_core.c Mon Jan 29 16:46:52 2007 +0000 2.3 @@ -62,36 +62,18 @@ struct acm_binary_policy acm_bin_pol; 2.4 /* acm binary policy lock */ 2.5 DEFINE_RWLOCK(acm_bin_pol_rwlock); 2.6 2.7 -/* until we have endian support in Xen, we discover it at runtime */ 2.8 -u8 little_endian = 1; 2.9 -void 2.10 -acm_set_endian(void) 2.11 -{ 2.12 - u32 test = 1; 2.13 - if (*((u8 *)&test) == 1) 2.14 - { 2.15 - printkd("ACM module running in LITTLE ENDIAN.\n"); 2.16 - little_endian = 1; 2.17 - } 2.18 - else 2.19 - { 2.20 - printkd("ACM module running in BIG ENDIAN.\n"); 2.21 - little_endian = 0; 2.22 - } 2.23 -} 2.24 - 2.25 int 2.26 -acm_set_policy_reference(u8 * buf, u32 buf_size) 2.27 +acm_set_policy_reference(u8 *buf, u32 buf_size) 2.28 { 2.29 struct acm_policy_reference_buffer *pr = (struct acm_policy_reference_buffer *)buf; 2.30 - acm_bin_pol.policy_reference_name = (char *)xmalloc_array(u8, ntohl(pr->len)); 2.31 + acm_bin_pol.policy_reference_name = (char *)xmalloc_array(u8, be32_to_cpu(pr->len)); 2.32 2.33 if (!acm_bin_pol.policy_reference_name) 2.34 return -ENOMEM; 2.35 2.36 strlcpy(acm_bin_pol.policy_reference_name, 2.37 (char *)(buf + sizeof(struct acm_policy_reference_buffer)), 2.38 - ntohl(pr->len)); 2.39 + be32_to_cpu(pr->len)); 2.40 printk("%s: Activating policy %s\n", __func__, 2.41 acm_bin_pol.policy_reference_name); 2.42 return 0; 2.43 @@ -108,10 +90,10 @@ acm_dump_policy_reference(u8 *buf, u32 b 2.44 return -EINVAL; 2.45 2.46 memset(buf, 0, ret); 2.47 - pr_buf->len = htonl(strlen(acm_bin_pol.policy_reference_name) + 1); /* including stringend '\0' */ 2.48 + pr_buf->len = cpu_to_be32(strlen(acm_bin_pol.policy_reference_name) + 1); /* including stringend '\0' */ 2.49 strlcpy((char *)(buf + sizeof(struct acm_policy_reference_buffer)), 2.50 acm_bin_pol.policy_reference_name, 2.51 - ntohl(pr_buf->len)); 2.52 + be32_to_cpu(pr_buf->len)); 2.53 return ret; 2.54 } 2.55 2.56 @@ -202,7 +184,7 @@ acm_is_policy(char *buf, unsigned long l 2.57 return 0; 2.58 2.59 pol = (struct acm_policy_buffer *)buf; 2.60 - return ntohl(pol->magic) == ACM_MAGIC; 2.61 + return be32_to_cpu(pol->magic) == ACM_MAGIC; 2.62 } 2.63 2.64 2.65 @@ -217,7 +199,7 @@ acm_setup(char *policy_start, 2.66 return rc; 2.67 2.68 pol = (struct acm_policy_buffer *)policy_start; 2.69 - if (ntohl(pol->magic) != ACM_MAGIC) 2.70 + if (be32_to_cpu(pol->magic) != ACM_MAGIC) 2.71 return rc; 2.72 2.73 rc = do_acm_set_policy((void *)policy_start, (u32)policy_len); 2.74 @@ -241,8 +223,6 @@ acm_init(char *policy_start, 2.75 { 2.76 int ret = ACM_OK; 2.77 2.78 - acm_set_endian(); 2.79 - 2.80 /* first try to load the boot policy (uses its own locks) */ 2.81 acm_setup(policy_start, policy_len); 2.82
3.1 --- a/xen/acm/acm_policy.c Mon Jan 29 16:04:43 2007 +0000 3.2 +++ b/xen/acm/acm_policy.c Mon Jan 29 16:46:52 2007 +0000 3.3 @@ -63,9 +63,9 @@ do_acm_set_policy(void *buf, u32 buf_siz 3.4 { 3.5 struct acm_policy_buffer *pol = (struct acm_policy_buffer *)buf; 3.6 /* some sanity checking */ 3.7 - if ((ntohl(pol->magic) != ACM_MAGIC) || 3.8 - (buf_size != ntohl(pol->len)) || 3.9 - (ntohl(pol->policy_version) != ACM_POLICY_VERSION)) 3.10 + if ((be32_to_cpu(pol->magic) != ACM_MAGIC) || 3.11 + (buf_size != be32_to_cpu(pol->len)) || 3.12 + (be32_to_cpu(pol->policy_version) != ACM_POLICY_VERSION)) 3.13 { 3.14 printk("%s: ERROR in Magic, Version, or buf size.\n", __func__); 3.15 goto error_free; 3.16 @@ -73,8 +73,8 @@ do_acm_set_policy(void *buf, u32 buf_siz 3.17 3.18 if (acm_active_security_policy == ACM_POLICY_UNDEFINED) { 3.19 /* setup the policy with the boot policy */ 3.20 - if (acm_init_binary_policy((ntohl(pol->secondary_policy_code) << 4) | 3.21 - ntohl(pol->primary_policy_code))) { 3.22 + if (acm_init_binary_policy((be32_to_cpu(pol->secondary_policy_code) << 4) | 3.23 + be32_to_cpu(pol->primary_policy_code))) { 3.24 goto error_free; 3.25 } 3.26 acm_active_security_policy = 3.27 @@ -82,8 +82,8 @@ do_acm_set_policy(void *buf, u32 buf_siz 3.28 } 3.29 3.30 /* once acm_active_security_policy is set, it cannot be changed */ 3.31 - if ((ntohl(pol->primary_policy_code) != acm_bin_pol.primary_policy_code) || 3.32 - (ntohl(pol->secondary_policy_code) != acm_bin_pol.secondary_policy_code)) 3.33 + if ((be32_to_cpu(pol->primary_policy_code) != acm_bin_pol.primary_policy_code) || 3.34 + (be32_to_cpu(pol->secondary_policy_code) != acm_bin_pol.secondary_policy_code)) 3.35 { 3.36 printkd("%s: Wrong policy type in boot policy!\n", __func__); 3.37 goto error_free; 3.38 @@ -93,21 +93,21 @@ do_acm_set_policy(void *buf, u32 buf_siz 3.39 write_lock(&acm_bin_pol_rwlock); 3.40 3.41 /* set label reference name */ 3.42 - if (acm_set_policy_reference(buf + ntohl(pol->policy_reference_offset), 3.43 - ntohl(pol->primary_buffer_offset) - 3.44 - ntohl(pol->policy_reference_offset))) 3.45 + if (acm_set_policy_reference(buf + be32_to_cpu(pol->policy_reference_offset), 3.46 + be32_to_cpu(pol->primary_buffer_offset) - 3.47 + be32_to_cpu(pol->policy_reference_offset))) 3.48 goto error_lock_free; 3.49 3.50 /* set primary policy data */ 3.51 - if (acm_primary_ops->set_binary_policy(buf + ntohl(pol->primary_buffer_offset), 3.52 - ntohl(pol->secondary_buffer_offset) - 3.53 - ntohl(pol->primary_buffer_offset))) 3.54 + if (acm_primary_ops->set_binary_policy(buf + be32_to_cpu(pol->primary_buffer_offset), 3.55 + be32_to_cpu(pol->secondary_buffer_offset) - 3.56 + be32_to_cpu(pol->primary_buffer_offset))) 3.57 goto error_lock_free; 3.58 3.59 /* set secondary policy data */ 3.60 - if (acm_secondary_ops->set_binary_policy(buf + ntohl(pol->secondary_buffer_offset), 3.61 - ntohl(pol->len) - 3.62 - ntohl(pol->secondary_buffer_offset))) 3.63 + if (acm_secondary_ops->set_binary_policy(buf + be32_to_cpu(pol->secondary_buffer_offset), 3.64 + be32_to_cpu(pol->len) - 3.65 + be32_to_cpu(pol->secondary_buffer_offset))) 3.66 goto error_lock_free; 3.67 3.68 write_unlock(&acm_bin_pol_rwlock); 3.69 @@ -136,38 +136,38 @@ acm_get_policy(XEN_GUEST_HANDLE(void) bu 3.70 read_lock(&acm_bin_pol_rwlock); 3.71 3.72 bin_pol = (struct acm_policy_buffer *)policy_buffer; 3.73 - bin_pol->magic = htonl(ACM_MAGIC); 3.74 - bin_pol->primary_policy_code = htonl(acm_bin_pol.primary_policy_code); 3.75 - bin_pol->secondary_policy_code = htonl(acm_bin_pol.secondary_policy_code); 3.76 + bin_pol->magic = cpu_to_be32(ACM_MAGIC); 3.77 + bin_pol->primary_policy_code = cpu_to_be32(acm_bin_pol.primary_policy_code); 3.78 + bin_pol->secondary_policy_code = cpu_to_be32(acm_bin_pol.secondary_policy_code); 3.79 3.80 - bin_pol->len = htonl(sizeof(struct acm_policy_buffer)); 3.81 - bin_pol->policy_reference_offset = htonl(ntohl(bin_pol->len)); 3.82 - bin_pol->primary_buffer_offset = htonl(ntohl(bin_pol->len)); 3.83 - bin_pol->secondary_buffer_offset = htonl(ntohl(bin_pol->len)); 3.84 + bin_pol->len = cpu_to_be32(sizeof(struct acm_policy_buffer)); 3.85 + bin_pol->policy_reference_offset = cpu_to_be32(be32_to_cpu(bin_pol->len)); 3.86 + bin_pol->primary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len)); 3.87 + bin_pol->secondary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len)); 3.88 3.89 - ret = acm_dump_policy_reference(policy_buffer + ntohl(bin_pol->policy_reference_offset), 3.90 - buf_size - ntohl(bin_pol->policy_reference_offset)); 3.91 + ret = acm_dump_policy_reference(policy_buffer + be32_to_cpu(bin_pol->policy_reference_offset), 3.92 + buf_size - be32_to_cpu(bin_pol->policy_reference_offset)); 3.93 if (ret < 0) 3.94 goto error_free_unlock; 3.95 3.96 - bin_pol->len = htonl(ntohl(bin_pol->len) + ret); 3.97 - bin_pol->primary_buffer_offset = htonl(ntohl(bin_pol->len)); 3.98 + bin_pol->len = cpu_to_be32(be32_to_cpu(bin_pol->len) + ret); 3.99 + bin_pol->primary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len)); 3.100 3.101 - ret = acm_primary_ops->dump_binary_policy (policy_buffer + ntohl(bin_pol->primary_buffer_offset), 3.102 - buf_size - ntohl(bin_pol->primary_buffer_offset)); 3.103 + ret = acm_primary_ops->dump_binary_policy (policy_buffer + be32_to_cpu(bin_pol->primary_buffer_offset), 3.104 + buf_size - be32_to_cpu(bin_pol->primary_buffer_offset)); 3.105 if (ret < 0) 3.106 goto error_free_unlock; 3.107 3.108 - bin_pol->len = htonl(ntohl(bin_pol->len) + ret); 3.109 - bin_pol->secondary_buffer_offset = htonl(ntohl(bin_pol->len)); 3.110 + bin_pol->len = cpu_to_be32(be32_to_cpu(bin_pol->len) + ret); 3.111 + bin_pol->secondary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len)); 3.112 3.113 - ret = acm_secondary_ops->dump_binary_policy(policy_buffer + ntohl(bin_pol->secondary_buffer_offset), 3.114 - buf_size - ntohl(bin_pol->secondary_buffer_offset)); 3.115 + ret = acm_secondary_ops->dump_binary_policy(policy_buffer + be32_to_cpu(bin_pol->secondary_buffer_offset), 3.116 + buf_size - be32_to_cpu(bin_pol->secondary_buffer_offset)); 3.117 if (ret < 0) 3.118 goto error_free_unlock; 3.119 3.120 - bin_pol->len = htonl(ntohl(bin_pol->len) + ret); 3.121 - if (copy_to_guest(buf, policy_buffer, ntohl(bin_pol->len))) 3.122 + bin_pol->len = cpu_to_be32(be32_to_cpu(bin_pol->len) + ret); 3.123 + if (copy_to_guest(buf, policy_buffer, be32_to_cpu(bin_pol->len))) 3.124 goto error_free_unlock; 3.125 3.126 read_unlock(&acm_bin_pol_rwlock); 3.127 @@ -204,12 +204,12 @@ acm_dump_statistics(XEN_GUEST_HANDLE(voi 3.128 if (len2 < 0) 3.129 goto error_lock_free; 3.130 3.131 - acm_stats.magic = htonl(ACM_MAGIC); 3.132 - acm_stats.primary_policy_code = htonl(acm_bin_pol.primary_policy_code); 3.133 - acm_stats.secondary_policy_code = htonl(acm_bin_pol.secondary_policy_code); 3.134 - acm_stats.primary_stats_offset = htonl(sizeof(struct acm_stats_buffer)); 3.135 - acm_stats.secondary_stats_offset = htonl(sizeof(struct acm_stats_buffer) + len1); 3.136 - acm_stats.len = htonl(sizeof(struct acm_stats_buffer) + len1 + len2); 3.137 + acm_stats.magic = cpu_to_be32(ACM_MAGIC); 3.138 + acm_stats.primary_policy_code = cpu_to_be32(acm_bin_pol.primary_policy_code); 3.139 + acm_stats.secondary_policy_code = cpu_to_be32(acm_bin_pol.secondary_policy_code); 3.140 + acm_stats.primary_stats_offset = cpu_to_be32(sizeof(struct acm_stats_buffer)); 3.141 + acm_stats.secondary_stats_offset = cpu_to_be32(sizeof(struct acm_stats_buffer) + len1); 3.142 + acm_stats.len = cpu_to_be32(sizeof(struct acm_stats_buffer) + len1 + len2); 3.143 3.144 memcpy(stats_buffer, &acm_stats, sizeof(struct acm_stats_buffer)); 3.145
4.1 --- a/xen/acm/acm_simple_type_enforcement_hooks.c Mon Jan 29 16:04:43 2007 +0000 4.2 +++ b/xen/acm/acm_simple_type_enforcement_hooks.c Mon Jan 29 16:46:52 2007 +0000 4.3 @@ -143,11 +143,11 @@ ste_dump_policy(u8 *buf, u32 buf_size) { 4.4 if (buf_size < sizeof(struct acm_ste_policy_buffer)) 4.5 return -EINVAL; 4.6 4.7 - ste_buf->ste_max_types = htonl(ste_bin_pol.max_types); 4.8 - ste_buf->ste_max_ssidrefs = htonl(ste_bin_pol.max_ssidrefs); 4.9 - ste_buf->policy_code = htonl(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY); 4.10 - ste_buf->ste_ssid_offset = htonl(sizeof(struct acm_ste_policy_buffer)); 4.11 - ret = ntohl(ste_buf->ste_ssid_offset) + 4.12 + ste_buf->ste_max_types = cpu_to_be32(ste_bin_pol.max_types); 4.13 + ste_buf->ste_max_ssidrefs = cpu_to_be32(ste_bin_pol.max_ssidrefs); 4.14 + ste_buf->policy_code = cpu_to_be32(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY); 4.15 + ste_buf->ste_ssid_offset = cpu_to_be32(sizeof(struct acm_ste_policy_buffer)); 4.16 + ret = be32_to_cpu(ste_buf->ste_ssid_offset) + 4.17 sizeof(domaintype_t)*ste_bin_pol.max_ssidrefs*ste_bin_pol.max_types; 4.18 4.19 ret = (ret + 7) & ~7; 4.20 @@ -156,7 +156,7 @@ ste_dump_policy(u8 *buf, u32 buf_size) { 4.21 return -EINVAL; 4.22 4.23 /* now copy buffer over */ 4.24 - arrcpy(buf + ntohl(ste_buf->ste_ssid_offset), 4.25 + arrcpy(buf + be32_to_cpu(ste_buf->ste_ssid_offset), 4.26 ste_bin_pol.ssidrefs, 4.27 sizeof(domaintype_t), 4.28 ste_bin_pol.max_ssidrefs*ste_bin_pol.max_types); 4.29 @@ -287,11 +287,11 @@ ste_set_policy(u8 *buf, u32 buf_size) 4.30 return -EINVAL; 4.31 4.32 /* Convert endianess of policy */ 4.33 - ste_buf->policy_code = ntohl(ste_buf->policy_code); 4.34 - ste_buf->policy_version = ntohl(ste_buf->policy_version); 4.35 - ste_buf->ste_max_types = ntohl(ste_buf->ste_max_types); 4.36 - ste_buf->ste_max_ssidrefs = ntohl(ste_buf->ste_max_ssidrefs); 4.37 - ste_buf->ste_ssid_offset = ntohl(ste_buf->ste_ssid_offset); 4.38 + ste_buf->policy_code = be32_to_cpu(ste_buf->policy_code); 4.39 + ste_buf->policy_version = be32_to_cpu(ste_buf->policy_version); 4.40 + ste_buf->ste_max_types = be32_to_cpu(ste_buf->ste_max_types); 4.41 + ste_buf->ste_max_ssidrefs = be32_to_cpu(ste_buf->ste_max_ssidrefs); 4.42 + ste_buf->ste_ssid_offset = be32_to_cpu(ste_buf->ste_ssid_offset); 4.43 4.44 /* policy type and version checks */ 4.45 if ((ste_buf->policy_code != ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY) || 4.46 @@ -348,12 +348,12 @@ ste_dump_stats(u8 *buf, u16 buf_len) 4.47 struct acm_ste_stats_buffer stats; 4.48 4.49 /* now send the hook counts to user space */ 4.50 - stats.ec_eval_count = htonl(atomic_read(&ste_bin_pol.ec_eval_count)); 4.51 - stats.gt_eval_count = htonl(atomic_read(&ste_bin_pol.gt_eval_count)); 4.52 - stats.ec_denied_count = htonl(atomic_read(&ste_bin_pol.ec_denied_count)); 4.53 - stats.gt_denied_count = htonl(atomic_read(&ste_bin_pol.gt_denied_count)); 4.54 - stats.ec_cachehit_count = htonl(atomic_read(&ste_bin_pol.ec_cachehit_count)); 4.55 - stats.gt_cachehit_count = htonl(atomic_read(&ste_bin_pol.gt_cachehit_count)); 4.56 + stats.ec_eval_count = cpu_to_be32(atomic_read(&ste_bin_pol.ec_eval_count)); 4.57 + stats.gt_eval_count = cpu_to_be32(atomic_read(&ste_bin_pol.gt_eval_count)); 4.58 + stats.ec_denied_count = cpu_to_be32(atomic_read(&ste_bin_pol.ec_denied_count)); 4.59 + stats.gt_denied_count = cpu_to_be32(atomic_read(&ste_bin_pol.gt_denied_count)); 4.60 + stats.ec_cachehit_count = cpu_to_be32(atomic_read(&ste_bin_pol.ec_cachehit_count)); 4.61 + stats.gt_cachehit_count = cpu_to_be32(atomic_read(&ste_bin_pol.gt_cachehit_count)); 4.62 4.63 if (buf_len < sizeof(struct acm_ste_stats_buffer)) 4.64 return -ENOMEM;
5.1 --- a/xen/include/acm/acm_endian.h Mon Jan 29 16:04:43 2007 +0000 5.2 +++ b/xen/include/acm/acm_endian.h Mon Jan 29 16:46:52 2007 +0000 5.3 @@ -22,57 +22,27 @@ 5.4 #ifndef _ACM_ENDIAN_H 5.5 #define _ACM_ENDIAN_H 5.6 5.7 -/* don't use these functions in performance critical sections! */ 5.8 - 5.9 -/* set during initialization by testing */ 5.10 -extern u8 little_endian; 5.11 - 5.12 -static inline u32 ntohl(u32 x) 5.13 -{ 5.14 - if (little_endian) 5.15 - return 5.16 - ( (((x) >> 24) & 0xff )| 5.17 - (((x) >> 8) & 0xff00 )| 5.18 - (((x) << 8) & 0xff0000 )| 5.19 - (((x) << 24) & 0xff000000) ); 5.20 - else 5.21 - return x; 5.22 -} 5.23 - 5.24 -static inline u16 ntohs(u16 x) 5.25 -{ 5.26 - if (little_endian) 5.27 - return 5.28 - ( (((x) >> 8) & 0xff )| 5.29 - (((x) << 8) & 0xff00 ) ); 5.30 - else 5.31 - return x; 5.32 -} 5.33 - 5.34 -#define htonl(x) ntohl(x) 5.35 -#define htons(x) ntohs(x) 5.36 +#include <asm/byteorder.h> 5.37 5.38 static inline void arrcpy16(u16 *dest, const u16 *src, size_t n) 5.39 { 5.40 - unsigned int i = 0; 5.41 - while (i < n) { 5.42 - dest[i] = htons(src[i]); 5.43 - i++; 5.44 - } 5.45 + unsigned int i; 5.46 + for ( i = 0; i < n; i++ ) 5.47 + dest[i] = cpu_to_be16(src[i]); 5.48 } 5.49 5.50 static inline void arrcpy32(u32 *dest, const u32 *src, size_t n) 5.51 { 5.52 - unsigned int i = 0; 5.53 - while (i < n) { 5.54 - dest[i] = htonl(src[i]); 5.55 - i++; 5.56 - } 5.57 + unsigned int i; 5.58 + for ( i = 0; i < n; i++ ) 5.59 + dest[i] = cpu_to_be32(src[i]); 5.60 } 5.61 5.62 -static inline void arrcpy(void *dest, const void *src, unsigned int elsize, size_t n) 5.63 +static inline void arrcpy( 5.64 + void *dest, const void *src, unsigned int elsize, size_t n) 5.65 { 5.66 - switch (elsize) { 5.67 + switch ( elsize ) 5.68 + { 5.69 case sizeof(u16): 5.70 arrcpy16((u16 *)dest, (u16 *)src, n); 5.71 break;