Commit 64dcfe6b84d4104d93e4baf2b5a0b3e7f2e4cc30

Authored by Serban Constantinescu
Committed by Greg Kroah-Hartman
1 parent eecddef594

staging: android: binder: fix binder interface for 64bit compat layer

The changes in this patch will fix the binder interface for use on 64bit
machines and stand as the base of the 64bit compat support. The changes
apply to the structures that are passed between the kernel and
userspace.

Most of the  changes applied mirror the change to struct binder_version
where there is no need for a 64bit wide protocol_version(on 64bit
machines). The change inlines with the existing 32bit userspace(the
structure has the same size) and simplifies the compat layer such that
the same handler can service the BINDER_VERSION ioctl.

Other changes make use of kernel types as well as user-exportable ones
and fix format specifier issues.

The changes do not affect existing 32bit ABI.

Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Acked-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 2 changed files with 16 additions and 16 deletions Side-by-side Diff

drivers/staging/android/binder.c
... ... @@ -1272,7 +1272,7 @@
1272 1272 case BINDER_TYPE_WEAK_HANDLE: {
1273 1273 struct binder_ref *ref = binder_get_ref(proc, fp->handle);
1274 1274 if (ref == NULL) {
1275   - pr_err("transaction release %d bad handle %ld\n",
  1275 + pr_err("transaction release %d bad handle %d\n",
1276 1276 debug_id, fp->handle);
1277 1277 break;
1278 1278 }
1279 1279  
... ... @@ -1284,13 +1284,13 @@
1284 1284  
1285 1285 case BINDER_TYPE_FD:
1286 1286 binder_debug(BINDER_DEBUG_TRANSACTION,
1287   - " fd %ld\n", fp->handle);
  1287 + " fd %d\n", fp->handle);
1288 1288 if (failed_at)
1289 1289 task_close_fd(proc, fp->handle);
1290 1290 break;
1291 1291  
1292 1292 default:
1293   - pr_err("transaction release %d bad object type %lx\n",
  1293 + pr_err("transaction release %d bad object type %x\n",
1294 1294 debug_id, fp->type);
1295 1295 break;
1296 1296 }
... ... @@ -1548,7 +1548,7 @@
1548 1548 case BINDER_TYPE_WEAK_HANDLE: {
1549 1549 struct binder_ref *ref = binder_get_ref(proc, fp->handle);
1550 1550 if (ref == NULL) {
1551   - binder_user_error("%d:%d got transaction with invalid handle, %ld\n",
  1551 + binder_user_error("%d:%d got transaction with invalid handle, %d\n",
1552 1552 proc->pid,
1553 1553 thread->pid, fp->handle);
1554 1554 return_error = BR_FAILED_REPLY;
1555 1555  
... ... @@ -1591,13 +1591,13 @@
1591 1591  
1592 1592 if (reply) {
1593 1593 if (!(in_reply_to->flags & TF_ACCEPT_FDS)) {
1594   - binder_user_error("%d:%d got reply with fd, %ld, but target does not allow fds\n",
  1594 + binder_user_error("%d:%d got reply with fd, %d, but target does not allow fds\n",
1595 1595 proc->pid, thread->pid, fp->handle);
1596 1596 return_error = BR_FAILED_REPLY;
1597 1597 goto err_fd_not_allowed;
1598 1598 }
1599 1599 } else if (!target_node->accept_fds) {
1600   - binder_user_error("%d:%d got transaction with fd, %ld, but target does not allow fds\n",
  1600 + binder_user_error("%d:%d got transaction with fd, %d, but target does not allow fds\n",
1601 1601 proc->pid, thread->pid, fp->handle);
1602 1602 return_error = BR_FAILED_REPLY;
1603 1603 goto err_fd_not_allowed;
... ... @@ -1605,7 +1605,7 @@
1605 1605  
1606 1606 file = fget(fp->handle);
1607 1607 if (file == NULL) {
1608   - binder_user_error("%d:%d got transaction with invalid fd, %ld\n",
  1608 + binder_user_error("%d:%d got transaction with invalid fd, %d\n",
1609 1609 proc->pid, thread->pid, fp->handle);
1610 1610 return_error = BR_FAILED_REPLY;
1611 1611 goto err_fget_failed;
1612 1612  
... ... @@ -1619,13 +1619,13 @@
1619 1619 task_fd_install(target_proc, target_fd, file);
1620 1620 trace_binder_transaction_fd(t, fp->handle, target_fd);
1621 1621 binder_debug(BINDER_DEBUG_TRANSACTION,
1622   - " fd %ld -> %d\n", fp->handle, target_fd);
  1622 + " fd %d -> %d\n", fp->handle, target_fd);
1623 1623 /* TODO: fput? */
1624 1624 fp->handle = target_fd;
1625 1625 } break;
1626 1626  
1627 1627 default:
1628   - binder_user_error("%d:%d got transaction with invalid object type, %lx\n",
  1628 + binder_user_error("%d:%d got transaction with invalid object type, %x\n",
1629 1629 proc->pid, thread->pid, fp->type);
1630 1630 return_error = BR_FAILED_REPLY;
1631 1631 goto err_bad_object_type;
... ... @@ -2579,7 +2579,7 @@
2579 2579 goto err;
2580 2580 }
2581 2581 binder_debug(BINDER_DEBUG_READ_WRITE,
2582   - "%d:%d write %zd at %08lx, read %zd at %08lx\n",
  2582 + "%d:%d write %zd at %016lx, read %zd at %016lx\n",
2583 2583 proc->pid, thread->pid, bwr.write_size,
2584 2584 bwr.write_buffer, bwr.read_size, bwr.read_buffer);
2585 2585  
drivers/staging/android/binder.h
... ... @@ -48,13 +48,13 @@
48 48 */
49 49 struct flat_binder_object {
50 50 /* 8 bytes for large_flat_header. */
51   - unsigned long type;
52   - unsigned long flags;
  51 + __u32 type;
  52 + __u32 flags;
53 53  
54 54 /* 8 bytes of data. */
55 55 union {
56 56 void __user *binder; /* local object */
57   - signed long handle; /* remote object */
  57 + __u32 handle; /* remote object */
58 58 };
59 59  
60 60 /* extra data associated with local object */
... ... @@ -78,7 +78,7 @@
78 78 /* Use with BINDER_VERSION, driver fills in fields. */
79 79 struct binder_version {
80 80 /* driver protocol version -- increment with incompatible change */
81   - signed long protocol_version;
  81 + __s32 protocol_version;
82 82 };
83 83  
84 84 /* This is the current protocol version. */
... ... @@ -119,7 +119,7 @@
119 119 * identifying the target and contents of the transaction.
120 120 */
121 121 union {
122   - size_t handle; /* target descriptor of command transaction */
  122 + __u32 handle; /* target descriptor of command transaction */
123 123 void *ptr; /* target descriptor of return transaction */
124 124 } target;
125 125 void *cookie; /* target object cookie */
... ... @@ -154,7 +154,7 @@
154 154  
155 155 struct binder_pri_desc {
156 156 __s32 priority;
157   - __s32 desc;
  157 + __u32 desc;
158 158 };
159 159  
160 160 struct binder_pri_ptr_cookie {