All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Cc: "Alistair Francis" <alistair.francis@wdc.com>,
	"Bob Eshleman" <bobbyeshleman@gmail.com>,
	"Connor Davis" <connojdavis@gmail.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v1 2/3] xen/riscv: update defintion of vmap_to_mfn()
Date: Mon, 27 Jan 2025 11:09:05 +0100	[thread overview]
Message-ID: <2bf6ef11-fb4e-40ef-b258-dd9314cba791@suse.com> (raw)
In-Reply-To: <bf85f6987c2a2f3374ad47fc0bf1513d69372b1f.1737391102.git.oleksii.kurochko@gmail.com>

On 20.01.2025 17:54, Oleksii Kurochko wrote:
> vmap_to_mfn() uses virt_to_maddr(), which is designed to work with VA from
> either the direct map region or Xen's linkage region (XEN_VIRT_START).
> An assertion will occur if it is used with other regions, in particular for
> the VMAP region.
> 
> Since RISC-V lacks a hardware feature to request the MMU to translate a VA to
> a PA (as Arm does, for example), software page table walking (pt_walk()) is
> used for the VMAP region to obtain the PA.
> 
> Fixes: 7db8d2bd9b ("xen/riscv: add minimal stuff to mm.h to build full Xen")
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/arch/riscv/include/asm/mm.h
> +++ b/xen/arch/riscv/include/asm/mm.h
> @@ -25,7 +25,7 @@ paddr_t pt_walk(vaddr_t va);
>  #define gaddr_to_gfn(ga)    _gfn(paddr_to_pfn(ga))
>  #define mfn_to_maddr(mfn)   pfn_to_paddr(mfn_x(mfn))
>  #define maddr_to_mfn(ma)    _mfn(paddr_to_pfn(ma))
> -#define vmap_to_mfn(va)     maddr_to_mfn(virt_to_maddr((vaddr_t)(va)))
> +#define vmap_to_mfn(va)     maddr_to_mfn(pt_walk((vaddr_t)(va)))

With this being the first use of pt_walk(), I wonder whether the function might
better return mfn_t (and simply ignore the low 12 bits of Vthe incoming VA; see
my respective comment on the earlier patch). After all it is quite natural for
a page table walk to return a page frame number, not a physical address.

Jan


  reply	other threads:[~2025-01-27 10:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20 16:54 [PATCH for 4.20? v1 0/3] Fixes for vmap_to_mfn() and pt_mapping_level Oleksii Kurochko
2025-01-20 16:54 ` [PATCH v1 1/3] xen/riscv: implement software page table walking Oleksii Kurochko
2025-01-27 10:06   ` Jan Beulich
2025-01-27 12:29     ` Oleksii Kurochko
2025-01-27 12:57       ` Jan Beulich
2025-01-27 17:22         ` Oleksii Kurochko
2025-01-27 17:41           ` Oleksii Kurochko
2025-01-28  8:07             ` Jan Beulich
2025-01-28  8:14           ` Jan Beulich
2025-01-29 13:12             ` Oleksii Kurochko
2025-01-29 14:01               ` Jan Beulich
2025-01-29 15:34                 ` Oleksii Kurochko
2025-01-20 16:54 ` [PATCH v1 2/3] xen/riscv: update defintion of vmap_to_mfn() Oleksii Kurochko
2025-01-27 10:09   ` Jan Beulich [this message]
2025-01-27 12:32     ` Oleksii Kurochko
2025-01-20 16:54 ` [PATCH v1 3/3] xen/riscv: update mfn calculation in pt_mapping_level() Oleksii Kurochko
2025-01-27 10:24   ` Jan Beulich
2025-01-27 12:51     ` Oleksii Kurochko

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=2bf6ef11-fb4e-40ef-b258-dd9314cba791@suse.com \
    --to=jbeulich@suse.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bobbyeshleman@gmail.com \
    --cc=connojdavis@gmail.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=oleksii.kurochko@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 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.