All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
To: Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	<qemu-riscv@nongnu.org>, <qemu-devel@nongnu.org>,
	 Stefan Huber <stefan.huber@oth-regensburg.de>
Cc: Bin Meng <bin.meng@windriver.com>,
	Konrad Schwarz <konrad.schwarz@siemens.com>
Subject: Re: [PATCH] target/riscv: Fix incorrect PTE merge in walk_pte
Date: Mon, 4 Apr 2022 19:22:36 +0200	[thread overview]
Message-ID: <8ec43086-62e6-bc4e-2a65-5a2943a679b4@oth-regensburg.de> (raw)
In-Reply-To: <20220401122248.2792180-1-ralf.ramsauer@oth-regensburg.de>



On 01/04/2022 14:22, Ralf Ramsauer wrote:
> Two non-subsequent PTEs can be mapped to subsequent paddrs. In this
> case, walk_pte will erroneously merge them.
> 
> Enforce the split up, by tracking the virtual base address.
> 
> Let's say we have the mapping:
> 0x81200000 -> 0x89623000 (4K)
> 0x8120f000 -> 0x89624000 (4K)
> 
> Before, walk_pte would have shown:
> 
> vaddr            paddr            size             attr
> ---------------- ---------------- ---------------- -------
> 0000000081200000 0000000089623000 0000000000002000 rwxu-ad
> 
> as it only checks for subsequent paddrs. With this patch, it becomes:
> 
> vaddr            paddr            size             attr
> ---------------- ---------------- ---------------- -------
> 0000000081200000 0000000089623000 0000000000001000 rwxu-ad
> 000000008120f000 0000000089624000 0000000000001000 rwxu-ad
> 
> Signed-off-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
> ---
>   target/riscv/monitor.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
> index 7efb4b62c1..60e3edd0ad 100644
> --- a/target/riscv/monitor.c
> +++ b/target/riscv/monitor.c
> @@ -84,6 +84,7 @@ static void walk_pte(Monitor *mon, hwaddr base, target_ulong start,
>   {
>       hwaddr pte_addr;
>       hwaddr paddr;
> +    target_ulong last_start = -1;
>       target_ulong pgsize;
>       target_ulong pte;
>       int ptshift;
> @@ -116,13 +117,15 @@ static void walk_pte(Monitor *mon, hwaddr base, target_ulong start,
>                    * contiguous mapped block details.
>                    */
>                   if ((*last_attr != attr) ||
> -                    (*last_paddr + *last_size != paddr)) {
> +                    (*last_paddr + *last_size != paddr) ||
> +                    (last_start + *last_size != start)) {
>                       print_pte(mon, va_bits, *vbase, *pbase,
>                                 *last_paddr + *last_size - *pbase, *last_attr);
>   
>                       *vbase = start;
>                       *pbase = paddr;
>                       *last_attr = attr;
> +                    last_start = start;
>                   }

Yikes, there's a small bug in my patch that I failed to see:
last_addr = start should be outside the curly brackets, otherwise it 
will rip up too much regions.

I'll return with a V2.

Thanks
   Ralf

>   
>                   *last_paddr = paddr;


  parent reply	other threads:[~2022-04-04 17:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01 12:22 [PATCH] target/riscv: Fix incorrect PTE merge in walk_pte Ralf Ramsauer
2022-04-01 12:22 ` Ralf Ramsauer
2022-04-01 13:14 ` Richard Henderson
2022-04-04 17:22 ` Ralf Ramsauer [this message]
2022-04-04 17:34 ` [PATCH v2] " Ralf Ramsauer
2022-04-04 17:34   ` Ralf Ramsauer
2022-04-12  4:53   ` Alistair Francis
2022-04-12  4:53     ` Alistair Francis
2022-04-22  2:53   ` Bin Meng
2022-04-22  2:53     ` Bin Meng
2022-04-22  2:54     ` Bin Meng
2022-04-22  2:54       ` Bin Meng
2022-04-22 11:37       ` [EXT] " Ralf Ramsauer
2022-04-22 11:37         ` Ralf Ramsauer
2022-04-22 23:08         ` Alistair Francis
2022-04-22 23:08           ` Alistair Francis
2022-04-23 21:59           ` [PATCH v3] " Ralf Ramsauer
2022-04-23 21:59             ` Ralf Ramsauer
2022-04-24  1:20             ` Bin Meng
2022-04-24  1:20               ` Bin Meng
2022-04-26  0:16             ` Alistair Francis
2022-04-26  0:16               ` Alistair Francis
2022-04-27 23:52             ` Alistair Francis
2022-04-27 23:52               ` Alistair Francis
2022-04-28  0:13             ` Alistair Francis
2022-04-28  0:13               ` Alistair Francis

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=8ec43086-62e6-bc4e-2a65-5a2943a679b4@oth-regensburg.de \
    --to=ralf.ramsauer@oth-regensburg.de \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=konrad.schwarz@siemens.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=stefan.huber@oth-regensburg.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.