[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Port ACM code to new Xen byteorder macros.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1170089212 0
# Node ID 699656fb1d0ba5cb507e0128e2a23099c580c14c
# Parent  647c06ba0b49ea05672ec8a4baa152445050d316
Port ACM code to new Xen byteorder macros.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/acm/acm_chinesewall_hooks.c             |   44 +++++------
 xen/acm/acm_core.c                          |   36 ++-------
 xen/acm/acm_policy.c                        |  106 ++++++++++++++--------------
 xen/acm/acm_simple_type_enforcement_hooks.c |   34 ++++----
 xen/include/acm/acm_endian.h                |   52 ++-----------
 5 files changed, 111 insertions(+), 161 deletions(-)

diff -r 647c06ba0b49 -r 699656fb1d0b xen/acm/acm_chinesewall_hooks.c
--- a/xen/acm/acm_chinesewall_hooks.c   Mon Jan 29 16:04:43 2007 +0000
+++ b/xen/acm/acm_chinesewall_hooks.c   Mon Jan 29 16:46:52 2007 +0000
@@ -132,26 +132,26 @@ static int chwall_dump_policy(u8 * buf, 
     if (buf_size < sizeof(struct acm_chwall_policy_buffer))
         return -EINVAL;
 
-    chwall_buf->chwall_max_types = htonl(chwall_bin_pol.max_types);
-    chwall_buf->chwall_max_ssidrefs = htonl(chwall_bin_pol.max_ssidrefs);
-    chwall_buf->policy_code = htonl(ACM_CHINESE_WALL_POLICY);
+    chwall_buf->chwall_max_types = cpu_to_be32(chwall_bin_pol.max_types);
+    chwall_buf->chwall_max_ssidrefs = cpu_to_be32(chwall_bin_pol.max_ssidrefs);
+    chwall_buf->policy_code = cpu_to_be32(ACM_CHINESE_WALL_POLICY);
     chwall_buf->chwall_ssid_offset =
-        htonl(sizeof(struct acm_chwall_policy_buffer));
+        cpu_to_be32(sizeof(struct acm_chwall_policy_buffer));
     chwall_buf->chwall_max_conflictsets =
-        htonl(chwall_bin_pol.max_conflictsets);
+        cpu_to_be32(chwall_bin_pol.max_conflictsets);
     chwall_buf->chwall_conflict_sets_offset =
-        htonl(ntohl(chwall_buf->chwall_ssid_offset) +
+        cpu_to_be32(be32_to_cpu(chwall_buf->chwall_ssid_offset) +
               sizeof(domaintype_t) * chwall_bin_pol.max_ssidrefs *
               chwall_bin_pol.max_types);
     chwall_buf->chwall_running_types_offset =
-        htonl(ntohl(chwall_buf->chwall_conflict_sets_offset) +
+        cpu_to_be32(be32_to_cpu(chwall_buf->chwall_conflict_sets_offset) +
               sizeof(domaintype_t) * chwall_bin_pol.max_conflictsets *
               chwall_bin_pol.max_types);
     chwall_buf->chwall_conflict_aggregate_offset =
-        htonl(ntohl(chwall_buf->chwall_running_types_offset) +
+        cpu_to_be32(be32_to_cpu(chwall_buf->chwall_running_types_offset) +
               sizeof(domaintype_t) * chwall_bin_pol.max_types);
 
-    ret = ntohl(chwall_buf->chwall_conflict_aggregate_offset) +
+    ret = be32_to_cpu(chwall_buf->chwall_conflict_aggregate_offset) +
         sizeof(domaintype_t) * chwall_bin_pol.max_types;
 
     ret = (ret + 7) & ~7;
@@ -160,21 +160,21 @@ static int chwall_dump_policy(u8 * buf, 
         return -EINVAL;
 
     /* now copy buffers over */
-    arrcpy16((u16 *) (buf + ntohl(chwall_buf->chwall_ssid_offset)),
+    arrcpy16((u16 *) (buf + be32_to_cpu(chwall_buf->chwall_ssid_offset)),
              chwall_bin_pol.ssidrefs,
              chwall_bin_pol.max_ssidrefs * chwall_bin_pol.max_types);
 
     arrcpy16((u16 *) (buf +
-                      ntohl(chwall_buf->chwall_conflict_sets_offset)),
+                      be32_to_cpu(chwall_buf->chwall_conflict_sets_offset)),
              chwall_bin_pol.conflict_sets,
              chwall_bin_pol.max_conflictsets * chwall_bin_pol.max_types);
 
     arrcpy16((u16 *) (buf +
-                      ntohl(chwall_buf->chwall_running_types_offset)),
+                      be32_to_cpu(chwall_buf->chwall_running_types_offset)),
              chwall_bin_pol.running_types, chwall_bin_pol.max_types);
 
     arrcpy16((u16 *) (buf +
-                      ntohl(chwall_buf->chwall_conflict_aggregate_offset)),
+                      
be32_to_cpu(chwall_buf->chwall_conflict_aggregate_offset)),
              chwall_bin_pol.conflict_aggregate_set,
              chwall_bin_pol.max_types);
     return ret;
@@ -267,20 +267,20 @@ static int chwall_set_policy(u8 * buf, u
         return -EINVAL;
 
     /* rewrite the policy due to endianess */
-    chwall_buf->policy_code = ntohl(chwall_buf->policy_code);
-    chwall_buf->policy_version = ntohl(chwall_buf->policy_version);
-    chwall_buf->chwall_max_types = ntohl(chwall_buf->chwall_max_types);
+    chwall_buf->policy_code = be32_to_cpu(chwall_buf->policy_code);
+    chwall_buf->policy_version = be32_to_cpu(chwall_buf->policy_version);
+    chwall_buf->chwall_max_types = be32_to_cpu(chwall_buf->chwall_max_types);
     chwall_buf->chwall_max_ssidrefs =
-        ntohl(chwall_buf->chwall_max_ssidrefs);
+        be32_to_cpu(chwall_buf->chwall_max_ssidrefs);
     chwall_buf->chwall_max_conflictsets =
-        ntohl(chwall_buf->chwall_max_conflictsets);
-    chwall_buf->chwall_ssid_offset = ntohl(chwall_buf->chwall_ssid_offset);
+        be32_to_cpu(chwall_buf->chwall_max_conflictsets);
+    chwall_buf->chwall_ssid_offset = 
be32_to_cpu(chwall_buf->chwall_ssid_offset);
     chwall_buf->chwall_conflict_sets_offset =
-        ntohl(chwall_buf->chwall_conflict_sets_offset);
+        be32_to_cpu(chwall_buf->chwall_conflict_sets_offset);
     chwall_buf->chwall_running_types_offset =
-        ntohl(chwall_buf->chwall_running_types_offset);
+        be32_to_cpu(chwall_buf->chwall_running_types_offset);
     chwall_buf->chwall_conflict_aggregate_offset =
-        ntohl(chwall_buf->chwall_conflict_aggregate_offset);
+        be32_to_cpu(chwall_buf->chwall_conflict_aggregate_offset);
 
     /* policy type and version checks */
     if ((chwall_buf->policy_code != ACM_CHINESE_WALL_POLICY) ||
diff -r 647c06ba0b49 -r 699656fb1d0b xen/acm/acm_core.c
--- a/xen/acm/acm_core.c        Mon Jan 29 16:04:43 2007 +0000
+++ b/xen/acm/acm_core.c        Mon Jan 29 16:46:52 2007 +0000
@@ -62,36 +62,18 @@ struct acm_binary_policy acm_bin_pol;
 /* acm binary policy lock */
 DEFINE_RWLOCK(acm_bin_pol_rwlock);
 
-/* until we have endian support in Xen, we discover it at runtime */
-u8 little_endian = 1;
-void
-acm_set_endian(void)
-{
-    u32 test = 1;
-    if (*((u8 *)&test) == 1)
-    {
-        printkd("ACM module running in LITTLE ENDIAN.\n");
-        little_endian = 1;
-    }
-    else
-    {
-        printkd("ACM module running in BIG ENDIAN.\n");
-        little_endian = 0;
-    }
-}
-
-int
-acm_set_policy_reference(u8 * buf, u32 buf_size)
+int
+acm_set_policy_reference(u8 *buf, u32 buf_size)
 {
     struct acm_policy_reference_buffer *pr = (struct 
acm_policy_reference_buffer *)buf;
-    acm_bin_pol.policy_reference_name = (char *)xmalloc_array(u8, 
ntohl(pr->len));
+    acm_bin_pol.policy_reference_name = (char *)xmalloc_array(u8, 
be32_to_cpu(pr->len));
 
     if (!acm_bin_pol.policy_reference_name)
         return -ENOMEM;
 
     strlcpy(acm_bin_pol.policy_reference_name,
             (char *)(buf + sizeof(struct acm_policy_reference_buffer)),
-            ntohl(pr->len));
+            be32_to_cpu(pr->len));
     printk("%s: Activating policy %s\n", __func__,
            acm_bin_pol.policy_reference_name);
     return 0;
@@ -108,10 +90,10 @@ acm_dump_policy_reference(u8 *buf, u32 b
         return -EINVAL;
 
     memset(buf, 0, ret);
-    pr_buf->len = htonl(strlen(acm_bin_pol.policy_reference_name) + 1); /* 
including stringend '\0' */
+    pr_buf->len = cpu_to_be32(strlen(acm_bin_pol.policy_reference_name) + 1); 
/* including stringend '\0' */
     strlcpy((char *)(buf + sizeof(struct acm_policy_reference_buffer)),
             acm_bin_pol.policy_reference_name,
-            ntohl(pr_buf->len));
+            be32_to_cpu(pr_buf->len));
     return ret;
 }
 
@@ -202,7 +184,7 @@ acm_is_policy(char *buf, unsigned long l
         return 0;
 
     pol = (struct acm_policy_buffer *)buf;
-    return ntohl(pol->magic) == ACM_MAGIC;
+    return be32_to_cpu(pol->magic) == ACM_MAGIC;
 }
 
 
@@ -217,7 +199,7 @@ acm_setup(char *policy_start,
         return rc;
 
     pol = (struct acm_policy_buffer *)policy_start;
-    if (ntohl(pol->magic) != ACM_MAGIC)
+    if (be32_to_cpu(pol->magic) != ACM_MAGIC)
         return rc;
 
     rc = do_acm_set_policy((void *)policy_start, (u32)policy_len);
@@ -240,8 +222,6 @@ acm_init(char *policy_start,
          unsigned long policy_len)
 {
     int ret = ACM_OK;
-
-    acm_set_endian();
 
     /* first try to load the boot policy (uses its own locks) */
     acm_setup(policy_start, policy_len);
diff -r 647c06ba0b49 -r 699656fb1d0b xen/acm/acm_policy.c
--- a/xen/acm/acm_policy.c      Mon Jan 29 16:04:43 2007 +0000
+++ b/xen/acm/acm_policy.c      Mon Jan 29 16:46:52 2007 +0000
@@ -63,9 +63,9 @@ do_acm_set_policy(void *buf, u32 buf_siz
 {
     struct acm_policy_buffer *pol = (struct acm_policy_buffer *)buf;
     /* some sanity checking */
-    if ((ntohl(pol->magic) != ACM_MAGIC) ||
-        (buf_size != ntohl(pol->len)) ||
-        (ntohl(pol->policy_version) != ACM_POLICY_VERSION))
+    if ((be32_to_cpu(pol->magic) != ACM_MAGIC) ||
+        (buf_size != be32_to_cpu(pol->len)) ||
+        (be32_to_cpu(pol->policy_version) != ACM_POLICY_VERSION))
     {
         printk("%s: ERROR in Magic, Version, or buf size.\n", __func__);
         goto error_free;
@@ -73,8 +73,8 @@ do_acm_set_policy(void *buf, u32 buf_siz
 
     if (acm_active_security_policy == ACM_POLICY_UNDEFINED) {
         /* setup the policy with the boot policy */
-        if (acm_init_binary_policy((ntohl(pol->secondary_policy_code) << 4) |
-                                   ntohl(pol->primary_policy_code))) {
+        if (acm_init_binary_policy((be32_to_cpu(pol->secondary_policy_code) << 
4) |
+                                   be32_to_cpu(pol->primary_policy_code))) {
             goto error_free;
         }
         acm_active_security_policy =
@@ -82,8 +82,8 @@ do_acm_set_policy(void *buf, u32 buf_siz
     }
 
     /* once acm_active_security_policy is set, it cannot be changed */
-    if ((ntohl(pol->primary_policy_code) != acm_bin_pol.primary_policy_code) ||
-        (ntohl(pol->secondary_policy_code) != 
acm_bin_pol.secondary_policy_code))
+    if ((be32_to_cpu(pol->primary_policy_code) != 
acm_bin_pol.primary_policy_code) ||
+        (be32_to_cpu(pol->secondary_policy_code) != 
acm_bin_pol.secondary_policy_code))
     {
         printkd("%s: Wrong policy type in boot policy!\n", __func__);
         goto error_free;
@@ -93,21 +93,21 @@ do_acm_set_policy(void *buf, u32 buf_siz
     write_lock(&acm_bin_pol_rwlock);
 
     /* set label reference name */
-    if (acm_set_policy_reference(buf + ntohl(pol->policy_reference_offset),
-                                 ntohl(pol->primary_buffer_offset) -
-                                 ntohl(pol->policy_reference_offset)))
+    if (acm_set_policy_reference(buf + 
be32_to_cpu(pol->policy_reference_offset),
+                                 be32_to_cpu(pol->primary_buffer_offset) -
+                                 be32_to_cpu(pol->policy_reference_offset)))
         goto error_lock_free;
 
     /* set primary policy data */
-    if (acm_primary_ops->set_binary_policy(buf + 
ntohl(pol->primary_buffer_offset),
-                                           ntohl(pol->secondary_buffer_offset) 
-
-                                           ntohl(pol->primary_buffer_offset)))
+    if (acm_primary_ops->set_binary_policy(buf + 
be32_to_cpu(pol->primary_buffer_offset),
+                                           
be32_to_cpu(pol->secondary_buffer_offset) -
+                                           
be32_to_cpu(pol->primary_buffer_offset)))
         goto error_lock_free;
 
     /* set secondary policy data */
-    if (acm_secondary_ops->set_binary_policy(buf + 
ntohl(pol->secondary_buffer_offset),
-                                             ntohl(pol->len) - 
-                                             
ntohl(pol->secondary_buffer_offset)))
+    if (acm_secondary_ops->set_binary_policy(buf + 
be32_to_cpu(pol->secondary_buffer_offset),
+                                             be32_to_cpu(pol->len) - 
+                                             
be32_to_cpu(pol->secondary_buffer_offset)))
         goto error_lock_free;
 
     write_unlock(&acm_bin_pol_rwlock);
@@ -136,38 +136,38 @@ acm_get_policy(XEN_GUEST_HANDLE(void) bu
     read_lock(&acm_bin_pol_rwlock);
 
     bin_pol = (struct acm_policy_buffer *)policy_buffer;
-    bin_pol->magic = htonl(ACM_MAGIC);
-    bin_pol->primary_policy_code = htonl(acm_bin_pol.primary_policy_code);
-    bin_pol->secondary_policy_code = htonl(acm_bin_pol.secondary_policy_code);
-
-    bin_pol->len = htonl(sizeof(struct acm_policy_buffer));
-    bin_pol->policy_reference_offset = htonl(ntohl(bin_pol->len));
-    bin_pol->primary_buffer_offset = htonl(ntohl(bin_pol->len));
-    bin_pol->secondary_buffer_offset = htonl(ntohl(bin_pol->len));
+    bin_pol->magic = cpu_to_be32(ACM_MAGIC);
+    bin_pol->primary_policy_code = 
cpu_to_be32(acm_bin_pol.primary_policy_code);
+    bin_pol->secondary_policy_code = 
cpu_to_be32(acm_bin_pol.secondary_policy_code);
+
+    bin_pol->len = cpu_to_be32(sizeof(struct acm_policy_buffer));
+    bin_pol->policy_reference_offset = cpu_to_be32(be32_to_cpu(bin_pol->len));
+    bin_pol->primary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len));
+    bin_pol->secondary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len));
      
-    ret = acm_dump_policy_reference(policy_buffer + 
ntohl(bin_pol->policy_reference_offset),
-                                    buf_size - 
ntohl(bin_pol->policy_reference_offset));
-    if (ret < 0)
-        goto error_free_unlock;
-
-    bin_pol->len = htonl(ntohl(bin_pol->len) + ret);
-    bin_pol->primary_buffer_offset = htonl(ntohl(bin_pol->len));
-
-    ret = acm_primary_ops->dump_binary_policy (policy_buffer + 
ntohl(bin_pol->primary_buffer_offset),
-                                               buf_size - 
ntohl(bin_pol->primary_buffer_offset));
-    if (ret < 0)
-        goto error_free_unlock;
-
-    bin_pol->len = htonl(ntohl(bin_pol->len) + ret);
-    bin_pol->secondary_buffer_offset = htonl(ntohl(bin_pol->len));
-
-    ret = acm_secondary_ops->dump_binary_policy(policy_buffer + 
ntohl(bin_pol->secondary_buffer_offset),
-                                                buf_size - 
ntohl(bin_pol->secondary_buffer_offset));
-    if (ret < 0)
-        goto error_free_unlock;
-
-    bin_pol->len = htonl(ntohl(bin_pol->len) + ret);
-    if (copy_to_guest(buf, policy_buffer, ntohl(bin_pol->len)))
+    ret = acm_dump_policy_reference(policy_buffer + 
be32_to_cpu(bin_pol->policy_reference_offset),
+                                    buf_size - 
be32_to_cpu(bin_pol->policy_reference_offset));
+    if (ret < 0)
+        goto error_free_unlock;
+
+    bin_pol->len = cpu_to_be32(be32_to_cpu(bin_pol->len) + ret);
+    bin_pol->primary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len));
+
+    ret = acm_primary_ops->dump_binary_policy (policy_buffer + 
be32_to_cpu(bin_pol->primary_buffer_offset),
+                                               buf_size - 
be32_to_cpu(bin_pol->primary_buffer_offset));
+    if (ret < 0)
+        goto error_free_unlock;
+
+    bin_pol->len = cpu_to_be32(be32_to_cpu(bin_pol->len) + ret);
+    bin_pol->secondary_buffer_offset = cpu_to_be32(be32_to_cpu(bin_pol->len));
+
+    ret = acm_secondary_ops->dump_binary_policy(policy_buffer + 
be32_to_cpu(bin_pol->secondary_buffer_offset),
+                                                buf_size - 
be32_to_cpu(bin_pol->secondary_buffer_offset));
+    if (ret < 0)
+        goto error_free_unlock;
+
+    bin_pol->len = cpu_to_be32(be32_to_cpu(bin_pol->len) + ret);
+    if (copy_to_guest(buf, policy_buffer, be32_to_cpu(bin_pol->len)))
         goto error_free_unlock;
 
     read_unlock(&acm_bin_pol_rwlock);
@@ -204,12 +204,12 @@ acm_dump_statistics(XEN_GUEST_HANDLE(voi
     if (len2 < 0)
         goto error_lock_free;
 
-    acm_stats.magic = htonl(ACM_MAGIC);
-    acm_stats.primary_policy_code = htonl(acm_bin_pol.primary_policy_code);
-    acm_stats.secondary_policy_code = htonl(acm_bin_pol.secondary_policy_code);
-    acm_stats.primary_stats_offset = htonl(sizeof(struct acm_stats_buffer));
-    acm_stats.secondary_stats_offset = htonl(sizeof(struct acm_stats_buffer) + 
len1);
-    acm_stats.len = htonl(sizeof(struct acm_stats_buffer) + len1 + len2);
+    acm_stats.magic = cpu_to_be32(ACM_MAGIC);
+    acm_stats.primary_policy_code = 
cpu_to_be32(acm_bin_pol.primary_policy_code);
+    acm_stats.secondary_policy_code = 
cpu_to_be32(acm_bin_pol.secondary_policy_code);
+    acm_stats.primary_stats_offset = cpu_to_be32(sizeof(struct 
acm_stats_buffer));
+    acm_stats.secondary_stats_offset = cpu_to_be32(sizeof(struct 
acm_stats_buffer) + len1);
+    acm_stats.len = cpu_to_be32(sizeof(struct acm_stats_buffer) + len1 + len2);
 
     memcpy(stats_buffer, &acm_stats, sizeof(struct acm_stats_buffer));
 
diff -r 647c06ba0b49 -r 699656fb1d0b xen/acm/acm_simple_type_enforcement_hooks.c
--- a/xen/acm/acm_simple_type_enforcement_hooks.c       Mon Jan 29 16:04:43 
2007 +0000
+++ b/xen/acm/acm_simple_type_enforcement_hooks.c       Mon Jan 29 16:46:52 
2007 +0000
@@ -143,11 +143,11 @@ ste_dump_policy(u8 *buf, u32 buf_size) {
     if (buf_size < sizeof(struct acm_ste_policy_buffer))
         return -EINVAL;
 
-    ste_buf->ste_max_types = htonl(ste_bin_pol.max_types);
-    ste_buf->ste_max_ssidrefs = htonl(ste_bin_pol.max_ssidrefs);
-    ste_buf->policy_code = htonl(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY);
-    ste_buf->ste_ssid_offset = htonl(sizeof(struct acm_ste_policy_buffer));
-    ret = ntohl(ste_buf->ste_ssid_offset) +
+    ste_buf->ste_max_types = cpu_to_be32(ste_bin_pol.max_types);
+    ste_buf->ste_max_ssidrefs = cpu_to_be32(ste_bin_pol.max_ssidrefs);
+    ste_buf->policy_code = cpu_to_be32(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY);
+    ste_buf->ste_ssid_offset = cpu_to_be32(sizeof(struct 
acm_ste_policy_buffer));
+    ret = be32_to_cpu(ste_buf->ste_ssid_offset) +
         sizeof(domaintype_t)*ste_bin_pol.max_ssidrefs*ste_bin_pol.max_types;
 
     ret = (ret + 7) & ~7;
@@ -156,7 +156,7 @@ ste_dump_policy(u8 *buf, u32 buf_size) {
         return -EINVAL;
 
     /* now copy buffer over */
-    arrcpy(buf + ntohl(ste_buf->ste_ssid_offset),
+    arrcpy(buf + be32_to_cpu(ste_buf->ste_ssid_offset),
            ste_bin_pol.ssidrefs,
            sizeof(domaintype_t),
            ste_bin_pol.max_ssidrefs*ste_bin_pol.max_types);
@@ -287,11 +287,11 @@ ste_set_policy(u8 *buf, u32 buf_size)
         return -EINVAL;
 
     /* Convert endianess of policy */
-    ste_buf->policy_code = ntohl(ste_buf->policy_code);
-    ste_buf->policy_version = ntohl(ste_buf->policy_version);
-    ste_buf->ste_max_types = ntohl(ste_buf->ste_max_types);
-    ste_buf->ste_max_ssidrefs = ntohl(ste_buf->ste_max_ssidrefs);
-    ste_buf->ste_ssid_offset = ntohl(ste_buf->ste_ssid_offset);
+    ste_buf->policy_code = be32_to_cpu(ste_buf->policy_code);
+    ste_buf->policy_version = be32_to_cpu(ste_buf->policy_version);
+    ste_buf->ste_max_types = be32_to_cpu(ste_buf->ste_max_types);
+    ste_buf->ste_max_ssidrefs = be32_to_cpu(ste_buf->ste_max_ssidrefs);
+    ste_buf->ste_ssid_offset = be32_to_cpu(ste_buf->ste_ssid_offset);
 
     /* policy type and version checks */
     if ((ste_buf->policy_code != ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY) ||
@@ -348,12 +348,12 @@ ste_dump_stats(u8 *buf, u16 buf_len)
     struct acm_ste_stats_buffer stats;
 
     /* now send the hook counts to user space */
-    stats.ec_eval_count = htonl(atomic_read(&ste_bin_pol.ec_eval_count));
-    stats.gt_eval_count = htonl(atomic_read(&ste_bin_pol.gt_eval_count));
-    stats.ec_denied_count = htonl(atomic_read(&ste_bin_pol.ec_denied_count));
-    stats.gt_denied_count = htonl(atomic_read(&ste_bin_pol.gt_denied_count));
-    stats.ec_cachehit_count = 
htonl(atomic_read(&ste_bin_pol.ec_cachehit_count));
-    stats.gt_cachehit_count = 
htonl(atomic_read(&ste_bin_pol.gt_cachehit_count));
+    stats.ec_eval_count = cpu_to_be32(atomic_read(&ste_bin_pol.ec_eval_count));
+    stats.gt_eval_count = cpu_to_be32(atomic_read(&ste_bin_pol.gt_eval_count));
+    stats.ec_denied_count = 
cpu_to_be32(atomic_read(&ste_bin_pol.ec_denied_count));
+    stats.gt_denied_count = 
cpu_to_be32(atomic_read(&ste_bin_pol.gt_denied_count));
+    stats.ec_cachehit_count = 
cpu_to_be32(atomic_read(&ste_bin_pol.ec_cachehit_count));
+    stats.gt_cachehit_count = 
cpu_to_be32(atomic_read(&ste_bin_pol.gt_cachehit_count));
 
     if (buf_len < sizeof(struct acm_ste_stats_buffer))
         return -ENOMEM;
diff -r 647c06ba0b49 -r 699656fb1d0b xen/include/acm/acm_endian.h
--- a/xen/include/acm/acm_endian.h      Mon Jan 29 16:04:43 2007 +0000
+++ b/xen/include/acm/acm_endian.h      Mon Jan 29 16:46:52 2007 +0000
@@ -22,57 +22,27 @@
 #ifndef _ACM_ENDIAN_H
 #define _ACM_ENDIAN_H
 
-/* don't use these functions in performance critical sections! */
-
-/* set during initialization by testing */
-extern u8 little_endian;
-
-static inline u32 ntohl(u32 x) 
-{
-    if (little_endian)
-        return 
-            ( (((x) >> 24) & 0xff      )| 
-              (((x) >>  8) & 0xff00    )| 
-              (((x) <<  8) & 0xff0000  )|
-              (((x) << 24) & 0xff000000) );
-    else
-        return x;
-}
-
-static inline u16 ntohs(u16 x) 
-{
-    if (little_endian)
-        return 
-            ( (((x) >> 8) & 0xff   )|
-              (((x) << 8) & 0xff00 ) );
-    else
-        return x;
-}
-
-#define htonl(x) ntohl(x)
-#define htons(x) ntohs(x)
+#include <asm/byteorder.h>
 
 static inline void arrcpy16(u16 *dest, const u16 *src, size_t n)
 {
-    unsigned int i = 0;
-    while (i < n) {
-        dest[i] = htons(src[i]);
-        i++;
-    }
+    unsigned int i;
+    for ( i = 0; i < n; i++ )
+        dest[i] = cpu_to_be16(src[i]);
 }
 
 static inline void arrcpy32(u32 *dest, const u32 *src, size_t n)
 {
-    unsigned int i = 0;
-    while (i < n) {
-        dest[i] = htonl(src[i]);
-        i++;
-    }
+    unsigned int i;
+    for ( i = 0; i < n; i++ )
+        dest[i] = cpu_to_be32(src[i]);
 }
 
-static inline void arrcpy(void *dest, const void *src, unsigned int elsize, 
size_t n)
+static inline void arrcpy(
+    void *dest, const void *src, unsigned int elsize, size_t n)
 {
-    switch (elsize) {
+    switch ( elsize )
+    {
     case sizeof(u16):
         arrcpy16((u16 *)dest, (u16 *)src, n);
         break;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.