<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>144680</bug_id>
          
          <creation_ts>2015-05-06 03:05:13 -0700</creation_ts>
          <short_desc>[JSC] Erratum (843419) in Cortex-A53</short_desc>
          <delta_ts>2015-05-12 01:17:01 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>108645</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Gabor Loki">loki</reporter>
          <assigned_to name="Gabor Loki">loki</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>msaboff</cc>
    
    <cc>ossy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1092123</commentid>
    <comment_count>0</comment_count>
    <who name="Gabor Loki">loki</who>
    <bug_when>2015-05-06 03:05:13 -0700</bug_when>
    <thetext>If there is a load or store instruction at a page boundary which uses the result of an ADRP instruction as a base it might access an incorrect address. There is a second variant of this if the base register is written by an instruction immediately after an ADRP to the same register, might also cause incorrect address access.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1092124</commentid>
    <comment_count>1</comment_count>
    <who name="Gabor Loki">loki</who>
    <bug_when>2015-05-06 03:06:39 -0700</bug_when>
    <thetext>Although the adrp instruction is never used from ARM64Assembler.h, it is possible to add a simple workaround for this.

I will upload a patch soon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1092125</commentid>
    <comment_count>2</comment_count>
      <attachid>252464</attachid>
    <who name="Gabor Loki">loki</who>
    <bug_when>2015-05-06 03:12:59 -0700</bug_when>
    <thetext>Created attachment 252464
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1092789</commentid>
    <comment_count>3</comment_count>
      <attachid>252464</attachid>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2015-05-07 15:24:00 -0700</bug_when>
    <thetext>Comment on attachment 252464
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=252464&amp;action=review

&gt; Source/JavaScriptCore/assembler/ARM64Assembler.h:3668
&gt; +        nop();

Why this third nop?  I thought that the bug was an issue only for a dependent instruction at the page boundary.  The check looks for the page boundary and inserts two nop&apos;s that should take care of the problem, making the last nop unnecessary.

&gt; Source/JavaScriptCore/assembler/ARM64Assembler.h:3670
&gt; +    ALWAYS_INLINE void nopCortexA53Fix843419()
&gt; +    {
&gt; +#if CPU(ARM64_CORTEXA53)
&gt; +        if (UNLIKELY((m_buffer.codeSize() &amp; 0xFF8) == 0xFF8)) {
&gt; +            nop();
&gt; +            nop();
&gt; +        }
&gt; +        nop();
&gt; +#endif
&gt; +    }

This nop padding needs to happen at link time.  I don&apos;t think we have any guarantees that the page offset at assemble time will be the same after we link.  Even if we did, there is some code compaction that can happen at link time, primarily due to branch type specialization.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1093120</commentid>
    <comment_count>4</comment_count>
    <who name="Gabor Loki">loki</who>
    <bug_when>2015-05-08 01:49:15 -0700</bug_when>
    <thetext>There are two cases:
1) If the ADRP is near to the page boundary (last two instruction) you will need more than two instructions between the ADRP and the load or store.
2) If the ADRP is followed by an instruction which writes the result register you will need an addition register.

So, there is no unnecessary nops.

&gt; This nop padding needs to happen at link time.  I don&apos;t think we have any guarantees that the page offset at assemble time will be the same after we link.
&gt; Even if we did, there is some code compaction that can happen at link time, primarily due to branch type specialization.

Sad to hear that. It was a long time when I last touched the JSC.

I am sure that the appropriate fix will be to check all the conditions which cause the issue, but it surely slow down the code generation - because the load and store instructions are very frequent. If we do these checks as a later pass after code generation (link time), the effect to the performance will be the same.

I think the most easiest way to fix this - which might not influence the performance much - is to generate three nops after ADRP.

How does it sound?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1093744</commentid>
    <comment_count>5</comment_count>
      <attachid>252858</attachid>
    <who name="Gabor Loki">loki</who>
    <bug_when>2015-05-11 06:22:55 -0700</bug_when>
    <thetext>Created attachment 252858
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1093748</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2015-05-11 07:08:40 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; There are two cases:
&gt; 1) If the ADRP is near to the page boundary (last two instruction) you will
&gt; need more than two instructions between the ADRP and the load or store.
&gt; 2) If the ADRP is followed by an instruction which writes the result
&gt; register you will need an addition register.
&gt; 
&gt; So, there is no unnecessary nops.
&gt; 
&gt; &gt; This nop padding needs to happen at link time.  I don&apos;t think we have any guarantees that the page offset at assemble time will be the same after we link.
&gt; &gt; Even if we did, there is some code compaction that can happen at link time, primarily due to branch type specialization.
&gt; 
&gt; Sad to hear that. It was a long time when I last touched the JSC.
&gt; 
&gt; I am sure that the appropriate fix will be to check all the conditions which
&gt; cause the issue, but it surely slow down the code generation - because the
&gt; load and store instructions are very frequent. If we do these checks as a
&gt; later pass after code generation (link time), the effect to the performance
&gt; will be the same.
&gt; 
&gt; I think the most easiest way to fix this - which might not influence the
&gt; performance much - is to generate three nops after ADRP.
&gt; 
&gt; How does it sound?

Sounds fine.

As a heads up, there has been some discussion to change the current movz/movk/movk absolute address materialization to adrp/add.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1093749</commentid>
    <comment_count>7</comment_count>
      <attachid>252858</attachid>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2015-05-11 07:09:02 -0700</bug_when>
    <thetext>Comment on attachment 252858
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1094112</commentid>
    <comment_count>8</comment_count>
      <attachid>252858</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-05-12 01:16:54 -0700</bug_when>
    <thetext>Comment on attachment 252858
Patch

Clearing flags on attachment: 252858

Committed r184170: &lt;http://trac.webkit.org/changeset/184170&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1094113</commentid>
    <comment_count>9</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-05-12 01:17:01 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>252464</attachid>
            <date>2015-05-06 03:12:59 -0700</date>
            <delta_ts>2015-05-11 06:22:50 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-144680-20150506121141.patch</filename>
            <type>text/plain</type>
            <size>1990</size>
            <attacher name="Gabor Loki">loki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTgzODY0CmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCAz
MTk3NDgyNjgzZDNkMDg5NjE0NjhkZjVmZTk1ZTc0YzBhMjIxZWE5Li44OTAyNzU3YzUzNWE3MDdh
OTZhYTI1MzJjOGJmZDJkM2M1N2EzZTk2IDEwMDY0NAotLS0gYS9Tb3VyY2UvSmF2YVNjcmlwdENv
cmUvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwxNyBAQAorMj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jxMaW5rUmVjb3JkLCAwLCBVbnNhZmVWZWN0b3JPdmVyZmxv
dz4gbV9qdW1wc1RvTGluazsKICAgICBpbnQgbV9pbmRleE9mTGFzdFdhdGNocG9pbnQ7Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>252858</attachid>
            <date>2015-05-11 06:22:55 -0700</date>
            <delta_ts>2015-05-12 01:16:54 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-144680-20150511152131.patch</filename>
            <type>text/plain</type>
            <size>1906</size>
            <attacher name="Gabor Loki">loki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTgzODY0CmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCAz
MTk3NDgyNjgzZDNkMDg5NjE0NjhkZjVmZTk1ZTc0YzBhMjIxZWE5Li4zOGY1YTg4YTdlYzI1Yzcy
MTJiZGJjNjZmM2U3ZDZkODdjMDQyMTFiIDEwMDY0NAotLS0gYS9Tb3VyY2UvSmF2YVNjcmlwdENv
cmUvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwxNyBAQAorMjAxNS0wNS0xMSAgR2Fib3IgTG9raSAgPGxva2lAd2Via2l0Lm9yZz4KKwor
ICAgICAgICBXb3JrYXJvdW5kIGZvciBDb3J0ZXgtQTUzIGVycmF0dW0gODQzNDE5CisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xNDQ2ODAKKworICAgICAg
ICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBUaGlzIHBhdGNoIGlzIGFi
b3V0IHRvIGdpdmUgc2ltcGxlIHdvcmthcm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nNldCA+PiAxMiwgcmQpKTsKKyAgICAgICAgbm9wQ29ydGV4QTUz
Rml4ODQzNDE5KCk7CiAgICAgfQogCiAgICAgdGVtcGxhdGU8aW50IGRhdGFzaXplLCBTZXRGbGFn
cyBzZXRGbGFncyA9IERvbnRTZXRGbGFncz4KQEAgLTM2NTUsNiArMzY1NiwxNyBAQCBwcml2YXRl
OgogI2VuZGlmCiAgICAgfQogCisgICAgLy8gV29ya2Fyb3VuZCBmb3IgQ29ydGV4LUE1MyBlcnJh
dHVtICg4NDM0MTkpLiBFbWl0IGV4dHJhIG5vcHMgdG8gYXZvaWQKKyAgICAvLyB3cm9uZyBhZGRy
ZXNzIGFjY2VzcyBhZnRlciBBRFJQIGluc3RydWN0aW9uLgorICAgIEFMV0FZU19JTkxJTkUgdm9p
ZCBub3BDb3J0ZXhBNTNGaXg4NDM0MTkoKQorICAgIHsKKyNpZiBDUFUoQVJNNjRfQ09SVEVYQTUz
KQorICAgICAgICBub3AoKTsKKyAgICAgICAgbm9wKCk7CisgICAgICAgIG5vcCgpOworI2VuZGlm
CisgICAgfQorCiAgICAgQXNzZW1ibGVyQnVmZmVyIG1fYnVmZmVyOwogICAgIFZlY3RvcjxMaW5r
UmVjb3JkLCAwLCBVbnNhZmVWZWN0b3JPdmVyZmxvdz4gbV9qdW1wc1RvTGluazsKICAgICBpbnQg
bV9pbmRleE9mTGFzdFdhdGNocG9pbnQ7Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>