All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Vallejo <agarciav@amd.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Jason Andryuk" <jason.andryuk@amd.com>,
	"Xenia Ragiadakou" <xenia.ragiadakou@amd.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Julien Grall" <julien@xen.org>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	xen-devel@lists.xenproject.org,
	"consulting@bugseng.com" <consulting@bugseng.com>
Subject: Re: [PATCH v3 08/16] x86/hyperlaunch: Add helpers to locate multiboot modules
Date: Tue, 15 Apr 2025 12:30:08 +0100	[thread overview]
Message-ID: <D976F4QPLMB9.2AZGDR11JD5OI@amd.com> (raw)
In-Reply-To: <ea28d057-5fd5-4cc2-8833-5427015a4190@suse.com>

On Tue Apr 15, 2025 at 7:05 AM BST, Jan Beulich wrote:
> On 14.04.2025 20:01, Alejandro Vallejo wrote:
>> On Mon Apr 14, 2025 at 4:05 PM BST, Jan Beulich wrote:
>>> On 14.04.2025 15:37, Alejandro Vallejo wrote:
>>>> On Thu Apr 10, 2025 at 11:42 AM BST, Jan Beulich wrote:
>>>>> On 08.04.2025 18:07, Alejandro Vallejo wrote:
>>>>>> +/*
>>>>>> + * Locate a multiboot module given its node offset in the FDT.
>>>>>> + *
>>>>>> + * The module location may be given via either FDT property:
>>>>>> + *     * reg = <address, size>
>>>>>> + *         * Mutates `bi` to append the module.
>>>>>> + *     * module-index = <idx>
>>>>>> + *         * Leaves `bi` unchanged.
>>>>>> + *
>>>>>> + * @param fdt           Pointer to the full FDT.
>>>>>> + * @param node          Offset for the module node.
>>>>>> + * @param address_cells Number of 4-octet cells that make up an "address".
>>>>>> + * @param size_cells    Number of 4-octet cells that make up a "size".
>>>>>> + * @param bi[inout]     Xen's representation of the boot parameters.
>>>>>> + * @return              -EINVAL on malformed nodes, otherwise
>>>>>> + *                      index inside `bi->mods`
>>>>>> + */
>>>>>> +int __init fdt_read_multiboot_module(const void *fdt, int node,
>>>>>> +                                     int address_cells, int size_cells,
>>>>>> +                                     struct boot_info *bi)
>>>>>
>>>>> Functions without callers and non-static ones without declarations are
>>>>> disliked by Misra.
>>>>
>>>> Can't do much about it if I want them to stand alone in a single patch.
>>>> Otherwise the following ones become quite unwieldy to look at. All I can
>>>> say is that this function becomes static and with a caller on the next
>>>> patch.
>>>
>>> Which means you need to touch this again anyway. Perhaps we need a Misra
>>> deviation for __maybe_unused functions / data, in which case you could
>>> use that here and strip it along with making the function static. Cc-ing
>>> Bugseng folks.
>> 
>> It's a transient violation, sure. Do we care about transient MISRA
>> violations though? I understand the importance of bisectability, but
>> AUIU MISRA compliance matters to the extent that that the tip is
>> compliant rather than the intermediate steps?
>
> Thing is that quite a few rules are blocking now. I haven't checked whether
> the one here (already) is; if it isn't, we can't exclude it will be by the
> time this patch is committed. If then the next patch isn't committed
> together with it, we'd face a CI failure.
>
>> Another option would be to fold them this patch and the next together
>> after both get their R-by. As I said, I assumed you'd rather see them in
>> isolation for purposes of review.
>
> As it looks it's all plain code additions, so reviewability would merely
> mildly suffer from patch size. But afaict there would be no loss of clarity.
>
>>>>>> +    /* Otherwise location given as a `reg` property. */
>>>>>> +    prop = fdt_get_property(fdt, node, "reg", NULL);
>>>>>> +
>>>>>> +    if ( !prop )
>>>>>> +    {
>>>>>> +        printk("  No location for multiboot,module\n");
>>>>>> +        return -EINVAL;
>>>>>> +    }
>>>>>> +    if ( fdt_get_property(fdt, node, "module-index", NULL) )
>>>>>> +    {
>>>>>> +        printk("  Location of multiboot,module defined multiple times\n");
>>>>>> +        return -EINVAL;
>>>>>> +    }
>>>>>> +
>>>>>> +    ret = read_fdt_prop_as_reg(prop, address_cells, size_cells, &addr, &size);
>>>>>> +
>>>>>> +    if ( ret < 0 )
>>>>>> +    {
>>>>>> +        printk("  Failed reading reg for multiboot,module\n");
>>>>>> +        return -EINVAL;
>>>>>> +    }
>>>>>> +
>>>>>> +    idx = bi->nr_modules + 1;
>>>>>
>>>>> This at least looks like an off-by-one. If the addition of 1 is really
>>>>> intended, I think it needs commenting on.
>>>>
>>>> Seems to be, yes. The underlying array is a bit bizarre. It's sizes as
>>>> MAX_NR_BOOTMODS + 1, with the first one being the DTB itself. I guess
>>>> the intent was to take it into account, but bi->nr_modules is
>>>> initialised to the number of multiboot modules, so it SHOULD be already
>>>> taking it into account.
>>>>
>>>> Also, the logic for bounds checking seems... off (because of the + 1 I
>>>> mentioned before). Or at least confusing, so I've moved to using
>>>> ARRAY_SIZE(bi->mods) rather than explicitly comparing against
>>>> MAX_NR_BOOTMODS.
>>>>
>>>> The array is MAX_NR_BOOTMODS + 1 in length, so it's just more cognitive
>>>> load than I'm comfortable with.
>>>
>>> If I'm not mistaken the +1 is inherited from the modules array we had in
>>> the past, where we wanted 1 extra slot for Xen itself. Hence before you
>>> move to using ARRAY_SIZE() everywhere it needs to really be clear what
>>> the +1 here is used for.
>> 
>> Ew.  Ok, just looked at the code in multiboot_fill_boot_info and indeed
>> the arrangement is for all multiboot modules to be in front, and Xen to
>> be appended. But bi->nr_modules only lists multiboot modules, so
>> increasing that value is therefore not enough (or
>> next_boot_module_index() would fail).
>> 
>> I need to have a proper read on how this is all stitched together.  I
>> may simply swap BOOTMOD_XEN with the next entry on append. Though my
>> preference would be to _not_ have Xen as part of the module list to
>> begin with. Before boot_info that was probably a place as good as any,
>> but this would be much better off in a dedicated field.
>> 
>> I don't see much in terms of usage though. Why is it being added at all?
>
> For hyperlaunch I fear it's you who needs to answer this question. For
> pre-hyperlaunch it's (primarily?) for consider_modules(), iirc. See two
> of the three comments ahead of its non-recursive invocations.
>
> Jan

There's no specific need for it on hyperlaunch AFAIK. Fixing
consider_modules to not require Xen being on the list of modules is easy
enough on both arm and x86 (it's a matter of passing the boot_info in
full rather than array + size), but I fear there may be more instances of
such checks.

I'll let it be for the time being and take a mental note to untangle
it later on. For this I'll simply ensure the append logic maintains Xen
at the back, as a sentinel of sorts for the module list, and document
that behaviour in the boot_info itself.

Cheers,
Alejandro


  reply	other threads:[~2025-04-15 11:30 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 16:07 [PATCH v3 00/16] Hyperlaunch device tree for dom0 Alejandro Vallejo
2025-04-08 16:07 ` [PATCH v3 01/16] x86/boot: introduce boot domain Alejandro Vallejo
2025-04-09  6:24   ` Jan Beulich
2025-04-09 10:28     ` Alejandro Vallejo
2025-04-10 13:13       ` Daniel P. Smith
2025-04-10 20:56         ` Jason Andryuk
2025-04-10 13:09     ` Daniel P. Smith
2025-04-10 15:01       ` Jan Beulich
2025-04-10 20:56         ` Jason Andryuk
2025-04-16 13:02           ` Daniel P. Smith
2025-04-16 13:33             ` Jan Beulich
2025-04-16 14:00               ` Daniel P. Smith
2025-04-16 14:06                 ` Jan Beulich
2025-04-16 15:01                   ` Daniel P. Smith
2025-04-08 16:07 ` [PATCH v3 02/16] x86/boot: introduce domid field to struct boot_domain Alejandro Vallejo
2025-04-09  6:34   ` Jan Beulich
2025-04-09 10:33     ` Alejandro Vallejo
2025-04-10 16:18       ` Jason Andryuk
2025-04-08 16:07 ` [PATCH v3 03/16] x86/boot: add cmdline " Alejandro Vallejo
2025-04-09  6:48   ` Jan Beulich
2025-04-09 11:11     ` Alejandro Vallejo
2025-04-09 11:28       ` Alejandro Vallejo
2025-04-09 14:13         ` Jan Beulich
2025-04-09 14:00       ` Jan Beulich
2025-04-09 21:05   ` Denis Mukhin
2025-04-10 12:02     ` Alejandro Vallejo
2025-04-08 16:07 ` [PATCH v3 04/16] kconfig: introduce option to independently enable libfdt Alejandro Vallejo
2025-04-09 18:57   ` Denis Mukhin
2025-04-10 12:05     ` Alejandro Vallejo
2025-04-10  9:04   ` Jan Beulich
2025-04-10 12:04     ` Alejandro Vallejo
2025-04-08 16:07 ` [PATCH v3 05/16] kconfig: introduce domain builder config option Alejandro Vallejo
2025-04-10  9:08   ` Jan Beulich
2025-04-10 12:52     ` Alejandro Vallejo
2025-04-10 12:57       ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 06/16] x86/hyperlaunch: introduce the domain builder Alejandro Vallejo
2025-04-09 18:53   ` Denis Mukhin
2025-04-10  7:49     ` Jan Beulich
2025-04-10 13:01     ` Alejandro Vallejo
2025-04-10  9:39   ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 07/16] x86/hyperlaunch: initial support for hyperlaunch device tree Alejandro Vallejo
2025-04-10 10:10   ` Jan Beulich
2025-04-10 14:50     ` Alejandro Vallejo
2025-04-08 16:07 ` [PATCH v3 08/16] x86/hyperlaunch: Add helpers to locate multiboot modules Alejandro Vallejo
2025-04-10 10:42   ` Jan Beulich
2025-04-14 13:37     ` Alejandro Vallejo
2025-04-14 15:05       ` Jan Beulich
2025-04-14 18:01         ` Alejandro Vallejo
2025-04-15  6:05           ` Jan Beulich
2025-04-15 11:30             ` Alejandro Vallejo [this message]
2025-04-16 16:55             ` Nicola Vetrini
2025-04-17 11:50               ` Alejandro Vallejo
2025-04-14 19:09         ` Nicola Vetrini
2025-04-08 16:07 ` [PATCH v3 09/16] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Alejandro Vallejo
2025-04-09 21:24   ` Denis Mukhin
2025-04-14 13:56     ` Alejandro Vallejo
2025-04-10 10:58   ` Jan Beulich
2025-04-14 13:58     ` Alejandro Vallejo
2025-04-08 16:07 ` [PATCH v3 10/16] x86/hyperlaunch: obtain cmdline from device tree Alejandro Vallejo
2025-04-09 22:04   ` Denis Mukhin
2025-04-14 14:54     ` Alejandro Vallejo
2025-04-10 11:12   ` Jan Beulich
2025-04-14 14:23     ` Alejandro Vallejo
2025-04-14 15:09       ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 11/16] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Alejandro Vallejo
2025-04-09 22:07   ` Denis Mukhin
2025-04-14 15:03     ` Alejandro Vallejo
2025-04-10 11:34   ` Jan Beulich
2025-04-14 17:06     ` Alejandro Vallejo
2025-04-14 17:27       ` Alejandro Vallejo
2025-04-15  6:17         ` Jan Beulich
2025-04-15 11:59           ` Alejandro Vallejo
2025-04-15 14:11             ` Jan Beulich
2025-04-16 13:19             ` Daniel P. Smith
2025-04-15  6:12       ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 12/16] x86/hyperlaunch: add domain id parsing to domain config Alejandro Vallejo
2025-04-09 22:15   ` Denis Mukhin
2025-04-14 18:07     ` Alejandro Vallejo
2025-04-15  0:28       ` Stefano Stabellini
2025-04-15  6:21       ` Jan Beulich
2025-04-15 11:37         ` Alejandro Vallejo
2025-04-15 14:13           ` Jan Beulich
2025-04-10 11:49   ` Jan Beulich
2025-04-14 18:35     ` Alejandro Vallejo
2025-04-15  6:27       ` Jan Beulich
2025-04-15 12:05         ` Alejandro Vallejo
2025-04-15 14:16           ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 13/16] x86/hyperlaunch: specify dom0 mode with device tree Alejandro Vallejo
2025-04-09 22:24   ` Denis Mukhin
2025-04-10 11:55     ` Jan Beulich
2025-04-14 18:45     ` Alejandro Vallejo
2025-04-10 11:57   ` Jan Beulich
2025-04-16 13:32     ` Daniel P. Smith
2025-04-16 13:38       ` Jan Beulich
2025-04-16 14:09         ` Daniel P. Smith
2025-04-16 14:24           ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 14/16] x86/hyperlaunch: add memory parsing to domain config Alejandro Vallejo
2025-04-09 22:29   ` Denis Mukhin
2025-04-14 18:49     ` Alejandro Vallejo
2025-04-10 12:03   ` Jan Beulich
2025-04-14 18:59     ` Alejandro Vallejo
2025-04-16 13:37     ` Daniel P. Smith
2025-04-16 13:41       ` Jan Beulich
2025-04-16 14:12         ` Daniel P. Smith
2025-04-16 14:27           ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 15/16] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Alejandro Vallejo
2025-04-09 22:33   ` Denis Mukhin
2025-04-14 19:07     ` Alejandro Vallejo
2025-04-10 12:08   ` Jan Beulich
2025-04-14 19:12     ` Alejandro Vallejo
2025-04-16 13:42     ` Daniel P. Smith
2025-04-16 13:54       ` Alejandro Vallejo
2025-04-16 14:16         ` Daniel P. Smith
2025-04-16 13:54       ` Jan Beulich
2025-04-16 14:19         ` Daniel P. Smith
2025-04-16 14:31           ` Jan Beulich
2025-04-08 16:07 ` [PATCH v3 16/16] x86/hyperlaunch: add capabilities to boot domain Alejandro Vallejo
2025-04-09 22:39   ` Denis Mukhin
2025-04-14 19:17     ` Alejandro Vallejo
2025-04-10 12:18   ` Jan Beulich
2025-04-10 12:18   ` Jan Beulich
2025-04-14 19:31     ` Alejandro Vallejo
2025-04-15  6:38       ` Jan Beulich
2025-04-15 12:22         ` Alejandro Vallejo
2025-04-15 14:20           ` Jan Beulich
2025-04-09  6:29 ` [PATCH v3 00/16] Hyperlaunch device tree for dom0 Jan Beulich
2025-04-09 10:19   ` Alejandro Vallejo
2025-04-09 10:39     ` Alejandro Vallejo

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=D976F4QPLMB9.2AZGDR11JD5OI@amd.com \
    --to=agarciav@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=consulting@bugseng.com \
    --cc=jason.andryuk@amd.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 \
    --cc=xenia.ragiadakou@amd.com \
    /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.