qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Romero <gustavo.romero@linaro.org>
To: "Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org, alex.bennee@linaro.org
Cc: peter.maydell@linaro.org
Subject: Re: [PATCH v3 4/4] tests/tcg/aarch64: Extend MTE gdbstub tests to system mode
Date: Thu, 29 Aug 2024 17:13:14 -0300	[thread overview]
Message-ID: <f5b66bb8-bf39-40f6-e641-64ddcfd6ac13@linaro.org> (raw)
In-Reply-To: <65e4c975-83f9-4d9b-a8aa-37d9543afac7@linaro.org>

Hi Richard,

On 8/28/24 9:43 PM, Richard Henderson wrote:
> On 8/28/24 04:01, Gustavo Romero wrote:
>>   SECTIONS
>>   {
>> -    /* virt machine, RAM starts at 1gb */
>> +    /* Skip first 1 GiB on virt machine: RAM starts at 1 GiB. */
>>       . = (1 << 30);
> 
> Better is to use
> 
> MEMORY {
>    RAM (rwx) : ORIGIN = 1 << 30, LENGTH = 16M
> }
> 
> (or whatever minimum length seems reasonable).
> 
> Since there is only one memory region, it will be used by default and no further markup is required.
> 
>> +    /* Align text to first 2 MiB. */
>> +    . = ALIGN(0 * 2M);
> 
> This is pointless, of course: ALIGN(0) does nothing.
> 
>> @@ -19,12 +21,12 @@ SECTIONS
>>           *(.bss)
>>       }
>>       /*
>> -     * Align the MTE page to the next 2mb boundary (i.e., the third 2mb chunk
>> -     * starting from 1gb) by setting the address for symbol 'mte_page', which is
>> -     * used in boot.S to setup the PTE and in the mte.S test as the address that
>> -     * the MTE instructions operate on.
>> +     * Align the MTE page to the next 2 MiB boundary (i.e., the third 2 MiB
>> +     * chunk starting from 1 GiB) by setting the address for symbol 'mte_page',
>> +     * which is used in boot.S to setup the PTE and in the mte.S test as the
>> +     * address that the MTE instructions operate on.
>>        */
>> -    mte_page = ALIGN(1 << 22);
>> +    mte_page = ALIGN(2 * 2M);
> 
> This does not do what you think it does.
> It aligns to the next 4M boundary, not the next 2M boundary.

I see now. This works because by chance ALIGN(2M) == ALIGN(4M).

So, using the 'M' suffix, I understand this is correct (and works):

(diff against the my patch)

index 46f1092522..823d47f7e7 100644
--- a/tests/tcg/aarch64/system/kernel.ld
+++ b/tests/tcg/aarch64/system/kernel.ld
@@ -11,7 +11,7 @@ SECTIONS
          *(.rodata)
      }
      /* align r/w section to next 2mb */
-    . = ALIGN(1 << 21);
+    . = ALIGN(2M);
      .data : {
          *(.data)
      }
@@ -24,7 +24,7 @@ SECTIONS
       * used in boot.S to setup the PTE and in the mte.S test as the address that
       * the MTE instructions operate on.
       */
-    mte_page = ALIGN(1 << 22);
+    mte_page = ALIGN(2M);
      /DISCARD/ : {
          *(.ARM.attributes)
      }

   1 .text         00001e60  0000000040001000  0000000040001000  00011000  2**12
   4 .data         00012000  0000000040200000  0000000040200000  00020000  2**12
0000000040400000 g       .data	0000000000000000 mte_page


I was not able to make the MEMORY command work. I tried:

index 46f1092522..dc39518a16 100644
--- a/tests/tcg/aarch64/system/kernel.ld
+++ b/tests/tcg/aarch64/system/kernel.ld
@@ -1,9 +1,13 @@
  ENTRY(__start)
  
+MEMORY
+{
+    ram (rwx) : ORIGIN = 1 << 30, LENGTH = 16M
+}
+
  SECTIONS
  {
      /* virt machine, RAM starts at 1gb */
-    . = (1 << 30);
      .text : {
          *(.text)
      }
@@ -11,7 +15,7 @@ SECTIONS
          *(.rodata)
      }
      /* align r/w section to next 2mb */
-    . = ALIGN(1 << 21);
+    . = ALIGN(2M);
      .data : {
          *(.data)
      }
@@ -24,7 +28,7 @@ SECTIONS
       * used in boot.S to setup the PTE and in the mte.S test as the address that
       * the MTE instructions operate on.
       */
-    mte_page = ALIGN(1 << 22);
+    mte_page = ((1 << 30) + 4M);
      /DISCARD/ : {
          *(.ARM.attributes)
      }

But it didn't work because data section is placed in the wrong place:

   1 .text         00001e60  0000000040001000  0000000040001000  00011000  2**12
   4 .data         00012000  0000000040003000  0000000040003000  00013000  2**12
0000000040400000 g       *ABS*	0000000000000000 mte_page

Do you know why?

I also had to use 'mte_page = ((1 << 30) + 4M);' for the mte_page symbol because
the current location (.) seems to reset to zero for the sections, hence if I do:

+    mte_page = ALIGN(2M);

I get:

0000000040200000 g       .data	0000000000000000 mte_page


Cheers,
Gustavo


  reply	other threads:[~2024-08-29 20:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-25 14:52 [PATCH v3 0/4] gdbstub: Add support for MTE in system mode Gustavo Romero
2024-08-25 14:52 ` [PATCH v3 1/4] gdbstub: Use specific MMU index when probing MTE addresses Gustavo Romero
2024-08-25 14:52 ` [PATCH v3 2/4] gdbstub: Add support for MTE in system mode Gustavo Romero
2024-08-25 14:52 ` [PATCH v3 3/4] tests/guest-debug: Support passing arguments to the GDB test script Gustavo Romero
2024-09-06 13:49   ` Alex Bennée
2024-08-25 14:52 ` [PATCH v3 4/4] tests/tcg/aarch64: Extend MTE gdbstub tests to system mode Gustavo Romero
2024-08-26  6:10   ` Philippe Mathieu-Daudé
2024-08-27 12:42     ` Gustavo Romero
2024-08-27 18:01       ` Gustavo Romero
2024-08-29  0:43         ` Richard Henderson
2024-08-29 20:13           ` Gustavo Romero [this message]
2024-08-29 22:16             ` Richard Henderson
2024-08-30 22:35               ` Gustavo Romero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5b66bb8-bf39-40f6-e641-64ddcfd6ac13@linaro.org \
    --to=gustavo.romero@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).