Skip to content

Commit

Permalink
resourcecoordinator: support 10.14 hosts with 10.15 SDK
Browse files Browse the repository at this point in the history
The size of a structure changed between 10.14 and 10.15 in such a way
that the 10.15 structure can't be passed directly to a 10.14 host
over mach IPC. Deal with that by using the compatible prefix of the
structure.

Bug: 1023913
Change-Id: Ic2d5091f5e720097182436f42d94df6bf9a92fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1967436
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#724732}
  • Loading branch information
Elly Fong-Jones authored and Commit Bot committed Dec 13, 2019
1 parent 7f90048 commit 614ac67
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,34 @@ struct ChromeTaskVMInfo {
#else
using ChromeTaskVMInfo = task_vm_info;
#endif // MAC_OS_X_VERSION_10_11
mach_msg_type_number_t ChromeTaskVMInfoCount =
sizeof(ChromeTaskVMInfo) / sizeof(natural_t);

// Don't simply use sizeof(task_vm_info) / sizeof(natural_t):
// In the 10.15 SDK, this structure is 87 32-bit words long, and in
// mach_types.defs:
//
// type task_info_t = array[*:87] of integer_t;
//
// However in the 10.14 SDK, this structure is 42 32-bit words, and in
// mach_types.defs:
//
// type task_info_t = array[*:52] of integer_t;
//
// As a result, the 10.15 SDK's task_vm_info won't fit inside the 10.14 SDK's
// task_info_t, so the *rest of the system* (on 10.14 and earlier) can't handle
// calls that request the full 10.15 structure. We have to request a prefix of
// it that 10.14 and earlier can handle by limiting the length we request. The
// rest of the fields just get ignored, but we don't use them anyway.

constexpr mach_msg_type_number_t ChromeTaskVMInfoCount =
TASK_VM_INFO_REV2_COUNT;

// The count field is in units of natural_t, which is the machine's word size
// (64 bits on all modern machines), but the task_info_t array is in units of
// integer_t, which is 32 bits.
constexpr mach_msg_type_number_t MAX_MIG_SIZE_FOR_1014 =
52 / (sizeof(natural_t) / sizeof(integer_t));
static_assert(ChromeTaskVMInfoCount <= MAX_MIG_SIZE_FOR_1014,
"task_vm_info must be small enough for 10.14 MIG interfaces");

using VMRegion = mojom::VmRegion;

Expand Down

0 comments on commit 614ac67

Please sign in to comment.