Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AArch64] Correctly pad out service request stubs when relocating. #8056

Conversation

dave-estes-QCOM
Copy link
Contributor

No description provided.

@dave-estes-QCOM
Copy link
Contributor Author

@mxw, this addresses an issue where service request stubs were changing size during relocation. Theoretically the other platforms can have the same problem arise. It's probably not worth implementing this, though an assert might be prudent if there isn't one already.

srcAddrBegin = addr;
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this reads a bit better as a

auto const srcAddrBegin = [&] {
  for (auto addr : env.meta.reusedStubs) {
    if ((srcAddr >= addr) && (srcAddr < (addr + svcreq::stub_size()))) {
      return addr;
    }
  }
  return nullptr;
}();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

while (src->Mask(ExceptionMask) == BRK) {
src = src->NextInstruction();
env.rewrites.insert(src);
srcCount++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we count the first one that we handle before this loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcCount and destCount are both set to 1 in the loop in relocateImpl() when the instruction is copied. Then these helper functions either leave it alone, rewrite that instruction, or extend that instruction. They update srcCount and destCount accordingly.

}

// Pad out the remainder of the dest service request stub
auto const destAddrBegin = (srcAddrBegin == env.start) ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious parens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.


// Pad out the remainder of the dest service request stub
auto const destAddrBegin = (srcAddrBegin == env.start) ?
destStart : env.rel.adjustedAddressAfter(srcAddrBegin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is destStart != env.rel.adjustedAddressAfter(srcAddrBegin) if srcAddrBegin == env.start?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, because of the way the relocation mapping works, the first instruction does not get a mapping. This is behavior that I picked up from the other backends. The following is a snipped from relocateImpl() at line 679 of this version of the file:

   if (srcAddr == env.start) {
     /*
      * For the start of the range, we only want to overwrite the "after"
      * address (since the "before" address could belong to the previous
      * tracelet, which could be being relocated to a completely different
      * address. recordRange will do that for us, so just make sure we
      * have the right address setup.
      */
     destStart = destAddr;
   } else {
    env.rel.recordAddress(srcAddr, destAddr, 0);
   }

Copy link
Contributor

@hhvm-bot hhvm-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxw has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor Author

@dave-estes-QCOM dave-estes-QCOM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will push a commit addressing the changes shortly.

while (src->Mask(ExceptionMask) == BRK) {
src = src->NextInstruction();
env.rewrites.insert(src);
srcCount++;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcCount and destCount are both set to 1 in the loop in relocateImpl() when the instruction is copied. Then these helper functions either leave it alone, rewrite that instruction, or extend that instruction. They update srcCount and destCount accordingly.

}

// Pad out the remainder of the dest service request stub
auto const destAddrBegin = (srcAddrBegin == env.start) ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

srcAddrBegin = addr;
break;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.


// Pad out the remainder of the dest service request stub
auto const destAddrBegin = (srcAddrBegin == env.start) ?
destStart : env.rel.adjustedAddressAfter(srcAddrBegin);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, because of the way the relocation mapping works, the first instruction does not get a mapping. This is behavior that I picked up from the other backends. The following is a snipped from relocateImpl() at line 679 of this version of the file:

   if (srcAddr == env.start) {
     /*
      * For the start of the range, we only want to overwrite the "after"
      * address (since the "before" address could belong to the previous
      * tracelet, which could be being relocated to a completely different
      * address. recordRange will do that for us, so just make sure we
      * have the right address setup.
      */
     destStart = destAddr;
   } else {
    env.rel.recordAddress(srcAddr, destAddr, 0);
   }

@facebook-github-bot
Copy link
Contributor

@dave-estes has updated the pull request. View: changes, changes since last import

Copy link
Contributor

@hhvm-bot hhvm-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxw has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@hhvm-bot hhvm-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxw is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@hhvm-bot hhvm-bot closed this in f0dd917 Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants