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

8248238: Implementation: JEP 388: Windows AArch64 Support #301

Closed
wants to merge 5 commits into from

Conversation

rnkovacs
Copy link
Contributor

@rnkovacs rnkovacs commented Aug 30, 2021

Main commit of the Windows/AArch64 port.

Also fixes JDK-8272181 by adding src/hotspot/os_cpu/windows_aarch64/pauth_windows_aarch64.inline.hpp, which is needed for a successful Windows-AArch64 build.

Depends on #274 and #299.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issues

  • JDK-8248238: Implementation: JEP 388: Windows AArch64 Support
  • JDK-8272181: Windows-AArch64:Backport fix of Backtracing broken on PAC enabled systems

Reviewers

Contributors

  • Monica Beckwith <mbeckwit@openjdk.org>
  • Ludovic Henry <luhenry@openjdk.org>
  • Bernhard Urban-Forster <burban@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk11u-dev pull/301/head:pull/301
$ git checkout pull/301

Update a local copy of the PR:
$ git checkout pull/301
$ git pull https://git.openjdk.java.net/jdk11u-dev pull/301/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 301

View PR using the GUI difftool:
$ git pr show -t 301

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk11u-dev/pull/301.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 30, 2021

👋 Welcome back rnkovacs! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title Backport 9604ee82690f89320614b37bfef4178abc869777 8248238: Implementation: JEP 388: Windows AArch64 Support Aug 30, 2021
@openjdk
Copy link

openjdk bot commented Aug 30, 2021

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added the backport label Aug 30, 2021
@rnkovacs
Copy link
Contributor Author

/contributor add Monica Beckwith mbeckwit@openjdk.org
/contributor add Ludovic Henry luhenry@openjdk.org
/contributor add Bernhard Urban-Forster burban@openjdk.org

@openjdk
Copy link

openjdk bot commented Aug 30, 2021

@rnkovacs
Contributor Monica Beckwith <mbeckwit@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Aug 30, 2021

@rnkovacs
Contributor Ludovic Henry <luhenry@openjdk.org> successfully added.

@rnkovacs
Copy link
Contributor Author

/issue add 8272181

@openjdk
Copy link

openjdk bot commented Aug 30, 2021

@rnkovacs
Contributor Bernhard Urban-Forster <burban@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Aug 30, 2021

@rnkovacs
Adding additional issue to issue list: 8272181: Windows-AArch64:Backport fix of Backtracing broken on PAC enabled systems``.

@rnkovacs rnkovacs marked this pull request as ready for review August 30, 2021 08:29
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 30, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 30, 2021

@RealCLanger
Copy link
Contributor

Hi @rnkovacs, can you split these into separate, dependent Pull requests?
E.g. #274 as first in the row. Then, open another PR in favor of #299 that has branch pr/274 as target. And then the 3 commits included in this one also as separate PRs, targeting the appropriate predecessor PR?

@rnkovacs
Copy link
Contributor Author

Hi @RealCLanger, I attempted to do that but apparently failed - I forgot to change the target branch. Do I need to close #299 and this one and open completely new PRs?

@rnkovacs rnkovacs changed the base branch from master to pr/299 August 30, 2021 09:10
@rnkovacs
Copy link
Contributor Author

Seems like I could do the change on the GUI. Could you please check if it's correct now?

@RealCLanger
Copy link
Contributor

Seems like I could do the change on the GUI. Could you please check if it's correct now?

Yes, I think this looks good now, thanks.

@VladimirKempik
Copy link

VladimirKempik commented Sep 2, 2021

One question, about R18 exclusion part.
In the light of recent issues with r18 being finally used by OS for its own needs ( since macos12b6), I have made some tests. ( more about issues here https://youtrack.jetbrains.com/issue/JBR-3715)
I took part of this PR which belongs to R18 usage elimination and applied it to zulu11 ( reverting older version of patch first which wasn't working with C2 compiled code)
This fixed zulu11 under macos12b6 and I was happy about that.
However I have noticed one strange thing
I did this:
bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -jar demo/jfc/J2Ddemo/J2Ddemo.jar > output.log
then this:
cat output.log | grep x18 | grep -v 0x18
and found some usage of x18:
0x000000010bcafc80: stp x18, x19, [sp, #144]
0x000000010bcb0b60: stp x18, x19, [sp, #144]
0x000000010bcb1590: stp x18, x19, [sp, #144]
0x000000010bcb2470: stp x18, x19, [sp, #144]
0x000000010bcb3dd0: stp x18, x19, [sp, #144]
0x000000010bcb4cd0: stp x18, x19, [sp, #144]
0x000000010bcb5ae0: stp x18, x19, [sp, #144]

it's just reading of x18, not writing, however it might indicate something is still missing there.
this doesn't happen on jdk17ea

Could you try to replicate this result with win-arm64 build of jdk11 ( make sure to put hsdis in there)

@VladimirKempik
Copy link

VladimirKempik commented Sep 2, 2021

An example, it's always in Stub Code
[Exception Handler]
[Stub Code]
0x0000000109fe4340: adrp x8, 0x0000000109b39000
; {no_reloc}
0x0000000109fe4344: add x8, x8, #0x580
0x0000000109fe4348: blr x8
0x0000000109fe434c: stp x0, x1, [sp, #-256]!
0x0000000109fe4350: stp x2, x3, [sp, #16]
0x0000000109fe4354: stp x4, x5, [sp, #32]
0x0000000109fe4358: stp x6, x7, [sp, #48]
0x0000000109fe435c: stp x8, x9, [sp, #64]
0x0000000109fe4360: stp x10, x11, [sp, #80]
0x0000000109fe4364: stp x12, x13, [sp, #96]
0x0000000109fe4368: stp x14, x15, [sp, #112]
0x0000000109fe436c: stp x16, x17, [sp, #128]
0x0000000109fe4370: stp x18, x19, [sp, #144]
0x0000000109fe4374: stp x20, x21, [sp, #160]
0x0000000109fe4378: stp x22, x23, [sp, #176]
0x0000000109fe437c: stp x24, x25, [sp, #192]
0x0000000109fe4380: stp x26, x27, [sp, #208]

@VladimirKempik
Copy link

So it's
void MacroAssembler::stop(const char* msg) {
address ip = pc();
pusha();
movptr(c_rarg0, (uintptr_t)(address)msg);
movptr(c_rarg1, (uintptr_t)(address)ip);
mov(c_rarg2, sp);
mov(c_rarg3, CAST_FROM_FN_PTR(address, MacroAssembler::debug64));
blr(c_rarg3);
hlt(0);
}
where pusha is :

void MacroAssembler::pusha() {
push(0x7fffffff, sp);
}

where push is:

// Push lots of registers in the bit set supplied. Don't push sp.
// Return the number of words pushed
int MacroAssembler::push(unsigned int bitset, Register stack) {
int words_pushed = 0;

// Scan bitset to accumulate register pairs
unsigned char regs[32];
int count = 0;
for (int reg = 0; reg <= 30; reg++) {
if (1 & bitset)
regs[count++] = reg;
bitset >>= 1;
}
...

@theRealAph could you please suggest, do we need to change the mask in pusha for win-arm64/mac-arm64 to not save r18 by pusha ?

@theRealAph
Copy link
Contributor

Yes, exartly.

It could be:

push(RegSet::range(r0, r29) R18_RESERVED_ONLY(-r18_tls), sp);

Copy link

@VladimirKempik VladimirKempik left a comment

Choose a reason for hiding this comment

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

Yes, exartly.

It could be:

push(RegSet::range(r0, r29) R18_RESERVED_ONLY(-r18_tls), sp);

But it should probably be done here
https://github.com/openjdk/jdk11u-dev/pull/301/files#diff-0f4150a9c607ccd590bf256daa800c0276144682a92bc6bdced5e8bc1bb81f3aR2548

ah, you were probably talking about pusha(), I initially thought it was about call_clobbered_registers()

void MacroAssembler::push_call_clobbered_registers() {
int step = 4 * wordSize;
push(RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2), sp);
push(call_clobbered_registers() - RegSet::of(rscratch1, rscratch2), sp);

Choose a reason for hiding this comment

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

is it right to substract rscratch1/2 twice, fist in call_clobbered_registers, then here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not exactly wrong. The readability of the code seems to have suffered in translation.

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the actual change make to development head, this is a misapplied patch. To match head, this should be:

RegSet MacroAssembler::call_clobbered_registers() {
  RegSet regs = RegSet::range(r0, r17) - RegSet::of(rscratch1, rscratch2);
#ifndef R18_RESERVED
  regs += r18_tls;
#endif
  return regs;
}
void MacroAssembler::push_call_clobbered_registers() {
  int step = 4 * wordSize;
  push(call_clobbered_registers(), sp);

Strictly speaking it should also push rscratch1 and rscratch2 - they are call clobbered - but we don't care because any macro can trash rscratch1 and rscratch2, so there's no point saving and restoring them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this @VladimirKempik.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@theRealAph you're right about push_call_clobbered_registers(), but I think call_clobbered_registers() is actually fine the way it is. The register named r18_tls on tip has been renamed to r18_reserved in this backport.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks to me like the only real issue here is warn(). stop() doesn't restore the registers, so that's fine. We do want to see all the registers in a register dump. It would be better if pusha() were left as it is, but popa() did not clobber r18.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this concern is addressed by openjdk/jdk#5828. Are you okay with leaving this patch as-is and backporting that soon after?

Copy link
Contributor

Choose a reason for hiding this comment

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

The register named r18_tls on tip has been renamed to r18_reserved in this backport.

Why has it been renamed r18_reserved ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out I was missing some history & context on this - it was r18_reserved originally, but there was a partial rewrite to r18_tls that I finished in the wrong direction. @lewurm's testing the fix, then I'll update.

@lewurm
Copy link
Member

lewurm commented Oct 1, 2021

[...] where pusha is :

void MacroAssembler::pusha() { push(0x7fffffff, sp); }

[...]

Nice catch!

I'm not sure if this should go as part of this PR. The same problem exists in jdk-tip and therefore should be addressed there first:
https://github.com/openjdk/jdk/blob/c05dc268acaf87236f30cf700ea3ac778e3b20e5/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L1859-L1865

On jdk-tip there is only one usage left in the template interpreter generator: https://github.com/openjdk/jdk/blob/c05dc268acaf87236f30cf700ea3ac778e3b20e5/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp#L1400-L1404

Seems like the code path is uncommon, but we should still fix it imho.

What do you think?

@VladimirKempik
Copy link

Since this PR is kind of stuck, can we get R18 patch out of it and push it under separate PR ? this will make macos-aarch64 port not dependent on win-aarch64 anymore

@mo-beck
Copy link

mo-beck commented Nov 26, 2021

Thank you all for your thoroughness, support, guidance, and perseverance throughout.

@VladimirKempik
Copy link

Could you /reviewer credit me too? Thanks

@rnkovacs
Copy link
Contributor Author

/reviewer credit @VladimirKempik
/reviewer credit @magicus

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

@rnkovacs Reviewer vkempik has already made an authenticated review of this PR, and does not need to be credited manually.

@rnkovacs
Copy link
Contributor Author

Could you /reviewer credit me too? Thanks

Sorry I thought you are. It seems like it picks up people who actually approve the PR.

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

@rnkovacs Reviewer ihse has already made an authenticated review of this PR, and does not need to be credited manually.

@theRealAph
Copy link
Contributor

Could you /reviewer credit me too? Thanks

Sorry I thought you are. It seems like it picks up people who actually approve the PR.

I'm looking at the OpenJDK census, and vkempik seems to be a committer, not a reviewer. It would be quite wrong for us to record a non-reviewer as a reviewer.

@rnkovacs
Copy link
Contributor Author

I'm looking at the OpenJDK census, and vkempik seems to be a committer, not a reviewer. It would be quite wrong for us to record a non-reviewer as a reviewer.

Should I remove @lewurm and @mo-beck from the reviewers then? The tooling itself seems to be confused about GH reviews from people with and without Reviewer status, as they got added automatically.

@rnkovacs
Copy link
Contributor Author

/reviewer remove burban
/reviewer remove mbeckwit

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

@rnkovacs There are no manually specified reviewers associated with this pull request.
Current credited reviewers are:

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

@rnkovacs There are no manually specified reviewers associated with this pull request.
Current credited reviewers are:

@rnkovacs
Copy link
Contributor Author

I cannot do any meaningful modifications to the reviewer list.

Could someone please sponsor the change?

@RealCLanger
Copy link
Contributor

Could you /reviewer credit me too? Thanks

Sorry I thought you are. It seems like it picks up people who actually approve the PR.

I'm looking at the OpenJDK census, and vkempik seems to be a committer, not a reviewer. It would be quite wrong for us to record a non-reviewer as a reviewer.

No, everybody who reviews a PR (marks the PR as reviewed) and has a census entry will be credited as a reviewer by Skara. But only if somebody is a project Reviewer - by census role - this will be an authoritative review, allowing the author to merge a PR. And I also think that's right, anybody who spent time and effort to review a particular change should also be credited, no matter of project role.

@RealCLanger
Copy link
Contributor

RealCLanger commented Nov 26, 2021

I cannot do any meaningful modifications to the reviewer list.

Could someone please sponsor the change?

OK, I hope @VladimirKempik and @magicus will be credited correctly, but they should. The preliminary commit message in the commit above is hopefully misleading. So:
/sponsor

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

Going to push as commit 7bdb8ac.
Since your change was applied there have been 53 commits pushed to the master branch:

  • 19a1969: 8274773: [TESTBUG] UnsafeIntrinsicsTest intermittently fails on weak memory model platform
  • e59323f: 8277224: sun.security.pkcs.PKCS9Attributes.toString() throws NPE
  • 48b5a6a: 8277815: Fix mistakes in legal header backports
  • 87c04f2: 8211801: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[A-E]
  • 84a3397: 8211905: Remove multiple casts for EM06 file
  • 91c6420: 8211131: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/[G-I]*
  • 0b8e1b1: 8211261: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/[A-G]*
  • a7f1b72: 8210984: [TESTBUG] hs203t003 fails with "# ERROR: hs203t003.cpp, 218: NSK_CPP_STUB2 ( ResumeThread, jvmti, thread)"
  • 6d1c3c6: 8210689: Remove the multi-line old C style for string literals
  • 9a1fce0: 8210726: Fix up a few minor nits forgotten by JDK-8210665
  • ... and 43 more: https://git.openjdk.java.net/jdk11u-dev/compare/2221f37d096c3657d9ab503ab5b3d671e1ae53f8...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 26, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 26, 2021
@openjdk
Copy link

openjdk bot commented Nov 26, 2021

@RealCLanger @rnkovacs Pushed as commit 7bdb8ac.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@RealCLanger
Copy link
Contributor

OK, I hope @VladimirKempik and @magicus will be credited correctly, but they should. The preliminary commit message in the commit above is hopefully misleading.

Hm, my hope was wrong, I'm sorry, @VladimirKempik. I now think you would have had to approve the PR in GitHub once again...

@rnkovacs
Copy link
Contributor Author

Thanks so much, @RealCLanger!

@brianjstafford
Copy link

brianjstafford commented Nov 26, 2021

Thank you to all the contributors and reviewers who have helped with this PR. It's very much appreciated!

@theRealAph
Copy link
Contributor

No, everybody who reviews a PR (marks the PR as reviewed) and has a census entry will be credited as a reviewer by Skara. But only if somebody is a project Reviewer - by census role - this will be an authoritative review, allowing the author to merge a PR. And I also think that's right, anybody who spent time and effort to review a particular change should also be credited, no matter of project role.

Yes, I get that, but it's a trap for all contributors: if you go to "Reviewers" at the top of the page you just see a list. I've got nothing against credit where it's due, but this workflow looks rather error prone.

@mo-beck
Copy link

mo-beck commented Nov 29, 2021

I agree with @RealCLanger. The original work was done by 3 contributors, so I think it is appreciable (and should be encouraged) if any of the original contributors spent their time reviewing the backport, and hence they should be listed as reviewers (despite their project status). Similarly, @VladimirKempik and @magicus spent their time and effort helping out with the original work and the backport as well. For some reason, I don't see them both in the reviewer for the backport and I don't see any of their code comments when I click on their review comments icon in the top right area. So maybe @VladimirKempik and @magicus would need to manually mark this backport as reviewed to get the credit. Thanks for having this discussion.

Could you /reviewer credit me too? Thanks

Sorry I thought you are. It seems like it picks up people who actually approve the PR.

I'm looking at the OpenJDK census, and vkempik seems to be a committer, not a reviewer. It would be quite wrong for us to record a non-reviewer as a reviewer.

No, everybody who reviews a PR (marks the PR as reviewed) and has a census entry will be credited as a reviewer by Skara. But only if somebody is a project Reviewer - by census role - this will be an authoritative review, allowing the author to merge a PR. And I also think that's right, anybody who spent time and effort to review a particular change should also be credited, no matter of project role.

@VladimirKempik
Copy link

probably it's github issue, the link that says %Username% left review comments is not working anymore for me and magicus
an example https://github.com/openjdk/jdk11u-dev/pull/301/files/f7f50ab7bdaa0c6f893d0e0874de25a83b7d2edd
So I can't mark those comments as fixed and "approve" button is nowhere to be found.

@theRealAph
Copy link
Contributor

I agree with @RealCLanger. The original work was done by 3 contributors, so I think it is appreciable (and should be encouraged) if any of the original contributors spent their time reviewing the backport, and hence they should be listed as reviewers (despite their project status).

Sure, it's a joint contribution, and all authors should be credited.

Similarly, @VladimirKempik and @magicus spent their time and effort helping out with the original work and the backport as well. For some reason, I don't see them both in the reviewer for the backport and I don't see any of their code comments when I click on their review comments icon in the top right area. So maybe @VladimirKempik and @magicus would need to manually mark this backport as reviewed to get the credit. Thanks for having this discussion.

Fair enough, but that's about acquiring brownie points, whereas I'm talking about processes.

The purpose of a review tick is to mark a change as reviewed, and we need Reviewers to do that. However, the list of "Reviewers" at the top right of this page doesn't indicate which ones are Reviewers. Thankfully, Skara does provide the information we need (in the Reviewers section at the top of the discussion) so we have what we need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
10 participants