-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[AArch64] Correctly pad out service request stubs when relocating. #8056
Conversation
@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; | ||
} | ||
} |
There was a problem hiding this comment.
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;
}();
There was a problem hiding this comment.
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++; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spurious parens.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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);
}
There was a problem hiding this 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.
There was a problem hiding this 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++; |
There was a problem hiding this comment.
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) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
srcAddrBegin = addr; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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);
}
@dave-estes has updated the pull request. View: changes, changes since last import |
There was a problem hiding this 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.
There was a problem hiding this 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.
No description provided.