qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Gustavo Romero" <gustavo.romero@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: Fri, 30 Aug 2024 08:16:43 +1000	[thread overview]
Message-ID: <58dbf60e-9f37-498e-80d1-19ed25d8b91f@linaro.org> (raw)
In-Reply-To: <f5b66bb8-bf39-40f6-e641-64ddcfd6ac13@linaro.org>

On 8/30/24 06:13, Gustavo Romero wrote:
>    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?

This is where using '.' gets tricky.
For .data to be in the correct place, we need to place the ALIGN on .data:

   .data : ALIGN(2M) {
      ...
   }

> 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

Right.  That's a consequence of not placing the symbol within a section for layout.

I suppose all this is a bit academic. The current method using '.' is sufficient, but it 
feels slapdash.

Thinking about this more, the proper way to use MEMORY is to describe the page tables that 
we're setting up:

MEMORY {
   TXT (rx) : ORIGIN = 1 << 30, LENGTH = 2M
   DAT (rw) : ORIGIN = (1 << 30) + 2M, LENGTH = 2M
   TAG (rw) : ORIGIN = (1 << 30) + 4M, LENGTH = 2M
}

SECTIONS {
   .text : {
     *(.text)
     *(.rodata)
   } >TXT
   .data : {
     *(.data)
     *(.bss)
   } >DAT
   .tag : {
     mte_page = .
   } >TAG
}

Or something close to that.


r~


  reply	other threads:[~2024-08-29 22:17 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
2024-08-29 22:16             ` Richard Henderson [this message]
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=58dbf60e-9f37-498e-80d1-19ed25d8b91f@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=gustavo.romero@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.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).