All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.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 v3 19/20] xen/riscv: add support of page lookup by GFN
Date: Fri, 22 Aug 2025 10:39:53 +0200	[thread overview]
Message-ID: <205d50ff-5a7c-41b2-a72f-932f0a7cb4e1@gmail.com> (raw)
In-Reply-To: <f7f81e65-5c85-4e30-a68b-01cdcf51dc07@suse.com>

[-- Attachment #1: Type: text/plain, Size: 2239 bytes --]


On 8/11/25 3:25 PM, Jan Beulich wrote:
>> + * The page_order will correspond to the order of the mapping in the page
>> + * table (i.e it could be a superpage).
>> + *
>> + * If the entry is not present, INVALID_MFN will be returned and the
>> + * page_order will be set according to the order of the invalid range.
>> + *
>> + * valid will contain the value of bit[0] (e.g valid bit) of the
>> + * entry.
>> + */
>> +static mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn,
>> +                           p2m_type_t *t,
>> +                           unsigned int *page_order,
>> +                           bool *valid)
>> +{
>> +    unsigned int level = 0;
>> +    pte_t entry, *table;
>> +    int rc;
>> +    mfn_t mfn = INVALID_MFN;
>> +    DECLARE_OFFSETS(offsets, gfn_to_gaddr(gfn));
>> +
>> +    ASSERT(p2m_is_locked(p2m));
>> +    BUILD_BUG_ON(XEN_PT_LEVEL_MAP_MASK(0) != PAGE_MASK);
> What function-wide property is this check about? Even when moved ...
>
>> +    if ( valid )
>> +        *valid = false;
>> +
>> +    /* XXX: Check if the mapping is lower than the mapped gfn */
> (Nested: What is this about?)
>
>> +    /* This gfn is higher than the highest the p2m map currently holds */
>> +    if ( gfn_x(gfn) > gfn_x(p2m->max_mapped_gfn) )
>> +    {
>> +        for ( level = P2M_ROOT_LEVEL; level; level-- )
>> +            if ( (gfn_x(gfn) & (XEN_PT_LEVEL_MASK(level) >> PAGE_SHIFT)) >
> ... into the more narrow scope where another XEN_PT_LEVEL_MASK() exists I
> can't really spot what the check is to guard against.

Missed to answer in my prev. reply to this and noticed that only during
start of reworking it.

I think it makes sense to update the comment above if condition, this is needed
to find the highest possible order by checking the base of the block mapping
is greater than the max mapped gfn as it is mentioned in the description of the
function, if the entry is not present, the function will return the order of
the invalid range.

I expect that probably it makes sense to do something similar for ->lowest_mapped_gfn
and it is a reason why /* XXX: ... */ comment exist.

~ Oleksii

>
>> +                 gfn_x(p2m->max_mapped_gfn) )
>> +                break;
>> +
>> +        goto out;
>> +    }

[-- Attachment #2: Type: text/html, Size: 3286 bytes --]

  parent reply	other threads:[~2025-08-22  8:40 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31 15:57 [PATCH v3 00/20] xen/riscv: introduce p2m functionality Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 01/20] xen/riscv: implement sbi_remote_hfence_gvma() Oleksii Kurochko
2025-08-04 13:52   ` Jan Beulich
2025-08-05 14:45     ` Oleksii Kurochko
2025-08-05 15:01       ` Jan Beulich
2025-07-31 15:58 ` [PATCH v3 02/20] xen/riscv: introduce sbi_remote_hfence_gvma_vmid() Oleksii Kurochko
2025-08-04 13:55   ` Jan Beulich
2025-08-05 14:57     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 03/20] xen/riscv: introduce VMID allocation and manegement Oleksii Kurochko
2025-08-04 15:19   ` Jan Beulich
2025-08-06 11:33     ` Oleksii Kurochko
2025-08-06 12:05       ` Jan Beulich
2025-08-06 16:24         ` Oleksii Kurochko
2025-08-06 16:50           ` Demi Marie Obenour
2025-08-07  8:43             ` Oleksii Kurochko
2025-08-07 10:11           ` Jan Beulich
2025-08-07 14:45             ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 04/20] xen/riscv: introduce things necessary for p2m initialization Oleksii Kurochko
2025-08-04 15:53   ` Jan Beulich
2025-08-06 11:43     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 05/20] xen/riscv: construct the P2M pages pool for guests Oleksii Kurochko
2025-08-04 15:58   ` Jan Beulich
2025-08-05 10:40   ` Jan Beulich
2025-08-06 12:01     ` Oleksii Kurochko
2025-08-06 12:07       ` Jan Beulich
2025-07-31 15:58 ` [PATCH v3 06/20] xen/riscv: add root page table allocation Oleksii Kurochko
2025-08-05 10:37   ` Jan Beulich
2025-08-07 12:00     ` Oleksii Kurochko
2025-08-07 15:30       ` Jan Beulich
2025-08-07 15:59         ` Oleksii Kurochko
2025-08-07 16:03           ` Jan Beulich
2025-08-05 10:43   ` Jan Beulich
2025-08-07 13:35     ` Oleksii Kurochko
2025-08-07 15:57       ` Jan Beulich
2025-08-08  9:14         ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 07/20] xen/riscv: introduce pte_{set,get}_mfn() Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 08/20] xen/riscv: add new p2m types and helper macros for type classification Oleksii Kurochko
2025-08-04 14:16   ` Jan Beulich
2025-08-07 15:41     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 09/20] xen/dom0less: abstract Arm-specific p2m type name for device MMIO mappings Oleksii Kurochko
2025-08-04 14:11   ` Jan Beulich
2025-08-07 15:23     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 10/20] xen/riscv: introduce page_{get,set}_xenheap_gfn() Oleksii Kurochko
2025-08-05 14:11   ` Jan Beulich
2025-08-08  9:16     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 11/20] xen/riscv: implement function to map memory in guest p2m Oleksii Kurochko
2025-08-05 15:20   ` Jan Beulich
2025-08-08 13:46     ` Oleksii Kurochko
2025-08-11  7:28       ` Jan Beulich
2025-08-11  9:29         ` Oleksii Kurochko
2025-08-11  9:35           ` Jan Beulich
2025-07-31 15:58 ` [PATCH v3 12/20] xen/riscv: implement p2m_set_range() Oleksii Kurochko
2025-08-05 16:04   ` Jan Beulich
2025-08-15  9:52     ` Oleksii Kurochko
2025-08-15 12:50       ` Jan Beulich
2025-08-18 11:03         ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 13/20] xen/riscv: Implement p2m_free_subtree() and related helpers Oleksii Kurochko
2025-08-06 15:55   ` Jan Beulich
2025-08-14 15:09     ` Oleksii Kurochko
2025-08-14 15:17       ` Jan Beulich
2025-08-18  8:22         ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 14/20] xen/riscv: Implement p2m_pte_from_mfn() and support PBMT configuration Oleksii Kurochko
2025-08-11 11:36   ` Jan Beulich
2025-08-11 14:44     ` Oleksii Kurochko
2025-08-11 15:11       ` Jan Beulich
2025-07-31 15:58 ` [PATCH v3 15/20] xen/riscv: implement p2m_next_level() Oleksii Kurochko
2025-08-11 11:44   ` Jan Beulich
2025-07-31 15:58 ` [PATCH v3 16/20] xen/riscv: Implement superpage splitting for p2m mappings Oleksii Kurochko
2025-08-11 11:59   ` Jan Beulich
2025-08-11 15:19     ` Oleksii Kurochko
2025-08-11 15:47       ` Jan Beulich
2025-07-31 15:58 ` [PATCH v3 17/20] xen/riscv: implement put_page() Oleksii Kurochko
2025-08-11 12:43   ` Jan Beulich
2025-08-11 15:32     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 18/20] xen/riscv: implement mfn_valid() and page reference, ownership handling helpers Oleksii Kurochko
2025-08-11 12:50   ` Jan Beulich
2025-08-11 15:34     ` Oleksii Kurochko
2025-07-31 15:58 ` [PATCH v3 19/20] xen/riscv: add support of page lookup by GFN Oleksii Kurochko
2025-08-11 13:25   ` Jan Beulich
2025-08-12 11:42     ` Oleksii Kurochko
2025-08-22  8:39     ` Oleksii Kurochko [this message]
2025-07-31 15:58 ` [PATCH v3 20/20] xen/riscv: introduce metadata table to store P2M type Oleksii Kurochko
2025-08-11 15:44   ` Jan Beulich
2025-08-12 14:52     ` 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=205d50ff-5a7c-41b2-a72f-932f0a7cb4e1@gmail.com \
    --to=oleksii.kurochko@gmail.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=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.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.