From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Julien Grall <julien.grall@arm.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
Stefano Stabellini <stefanos@xilinx.com>
Subject: Re: [Xen-devel] [PATCH v5 3/7] xen/arm: keep track of reserved-memory regions
Date: Tue, 13 Aug 2019 15:14:06 +0000 [thread overview]
Message-ID: <87a7cdgksi.fsf@epam.com> (raw)
In-Reply-To: <75f9a42a-f691-2cf2-b9e8-289c05f66286@arm.com>
Hi Julien,
Julien Grall writes:
> Hi,
>
> On 8/13/19 3:23 PM, Volodymyr Babchuk wrote:
>>
>> Stefano Stabellini writes:
>>
>>> As we parse the device tree in Xen, keep track of the reserved-memory
>>> regions as they need special treatment (follow-up patches will make use
>>> of the stored information.)
>>>
>>> Reuse process_memory_node to add reserved-memory regions to the
>>> bootinfo.reserved_mem array.
>>>
>>> Refuse to continue once we reach the max number of reserved memory
>>> regions to avoid accidentally mapping any portions of them into a VM.
>>>
>>> Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
>>>
>>> ---
>>> Changes in v5:
>>> - remove unneeded cast
>>> - remove unneeded strlen check
>>> - don't pass address_cells, size_cells, depth to device_tree_for_each_node
>>>
>>> Changes in v4:
>>> - depth + 1 in process_reserved_memory_node
>>> - pass address_cells and size_cells to device_tree_for_each_node
>>> - pass struct meminfo * instead of a boolean to process_memory_node
>>> - improve in-code comment
>>> - use a separate process_reserved_memory_node (separate from
>>> process_memory_node) function wrapper to have different error handling
>>>
>>> Changes in v3:
>>> - match only /reserved-memory
>>> - put the warning back in place for reg not present on a normal memory
>>> region
>>> - refuse to continue once we reach the max number of reserved memory
>>> regions
>>>
>>> Changes in v2:
>>> - call process_memory_node from process_reserved_memory_node to avoid
>>> duplication
>>> ---
>>> xen/arch/arm/bootfdt.c | 41 +++++++++++++++++++++++++++++++------
>>> xen/include/asm-arm/setup.h | 1 +
>>> 2 files changed, 36 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
>>> index 590b14304c..0b0e22a3d0 100644
>>> --- a/xen/arch/arm/bootfdt.c
>>> +++ b/xen/arch/arm/bootfdt.c
>>> @@ -136,6 +136,7 @@ static int __init process_memory_node(const void *fdt, int node,
>>> const __be32 *cell;
>>> paddr_t start, size;
>>> u32 reg_cells = address_cells + size_cells;
>>> + struct meminfo *mem = data;
>>>
>>> if ( address_cells < 1 || size_cells < 1 )
>>> return -ENOENT;
>>> @@ -147,21 +148,46 @@ static int __init process_memory_node(const void *fdt, int node,
>>> cell = (const __be32 *)prop->data;
>>> banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32));
>>>
>>> - for ( i = 0; i < banks && bootinfo.mem.nr_banks < NR_MEM_BANKS; i++ )
>>> + for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
>> What is logic behind the second part of the loop condition?
>>
>> You know that if (banks > NR_MEM_BANKS) then you will exit with error. Do
>> you really need to iterate over loop in this case?
>
> Well, the error is ignored in the case of memory banks. So iterating
> over the first banks allows you to fill up bootinfo with as much as
> possible as RAM. The rest of the RAM will not be used by Xen.
Fair enough.
>>
>>> {
>>> device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
>>> if ( !size )
>>> continue;
>>> - bootinfo.mem.bank[bootinfo.mem.nr_banks].start = start;
>>> - bootinfo.mem.bank[bootinfo.mem.nr_banks].size = size;
>>> - bootinfo.mem.nr_banks++;
>>> + mem->bank[mem->nr_banks].start = start;
>>> + mem->bank[mem->nr_banks].size = size;
>>> + mem->nr_banks++;
>>> }
>>>
>>> - if ( bootinfo.mem.nr_banks == NR_MEM_BANKS )
>>> + if ( mem->nr_banks == NR_MEM_BANKS )
>> Looks like you have the same off-by-one error, as in previous patch.
>> I can see that it was there earlier. But it is good time to fix it.
>
> I don't think there was an off-by-one error before this series. So
> what do you mean?
I explained this in patch #2. Imagine that NR_MEM_BANKS = 1 and you have
one memory node in the dtb. You'll fill the first element of the array
and mem->nr_banks will become 1. This is absolutely normal. But check
above will fail, which is not right.
--
Volodymyr Babchuk at EPAM
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-08-13 15:14 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 22:28 [Xen-devel] [PATCH v5 0/7] reserved-memory in dom0 Stefano Stabellini
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 1/7] xen/arm: pass node to device_tree_for_each_node Stefano Stabellini
2019-08-13 13:45 ` Volodymyr Babchuk
2019-08-14 22:12 ` Stefano Stabellini
2019-08-13 17:25 ` Julien Grall
2019-08-14 22:11 ` Stefano Stabellini
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 2/7] xen/arm: make process_memory_node a device_tree_node_func Stefano Stabellini
2019-08-13 14:14 ` Volodymyr Babchuk
2019-08-14 22:35 ` Stefano Stabellini
2019-08-15 9:12 ` Julien Grall
2019-08-15 11:20 ` Volodymyr Babchuk
2019-08-15 11:24 ` Julien Grall
2019-08-15 11:29 ` Julien Grall
2019-08-15 12:14 ` Volodymyr Babchuk
2019-08-15 12:33 ` Julien Grall
2019-08-15 13:51 ` Volodymyr Babchuk
2019-08-15 14:15 ` Julien Grall
2019-08-13 17:37 ` Julien Grall
2019-08-14 22:54 ` Stefano Stabellini
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 3/7] xen/arm: keep track of reserved-memory regions Stefano Stabellini
2019-08-13 14:23 ` Volodymyr Babchuk
2019-08-13 14:46 ` Julien Grall
2019-08-13 15:14 ` Volodymyr Babchuk [this message]
2019-08-13 15:15 ` Julien Grall
2019-08-13 15:39 ` Volodymyr Babchuk
2019-08-14 12:48 ` Julien Grall
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 4/7] xen/arm: early_print_info print reserved_mem Stefano Stabellini
2019-08-13 14:28 ` Volodymyr Babchuk
2019-08-13 14:47 ` Julien Grall
2019-08-14 22:21 ` Stefano Stabellini
2019-08-14 12:52 ` Julien Grall
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 5/7] xen/arm: handle reserved-memory in consider_modules and dt_unreserved_regions Stefano Stabellini
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 6/7] xen/arm: don't iomem_permit_access for reserved-memory regions Stefano Stabellini
2019-08-13 14:34 ` Volodymyr Babchuk
2019-08-13 14:55 ` Julien Grall
2019-08-14 22:40 ` Stefano Stabellini
2019-08-15 9:15 ` Julien Grall
2019-08-12 22:28 ` [Xen-devel] [PATCH v5 7/7] xen/arm: add reserved-memory regions to the dom0 memory node Stefano Stabellini
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=87a7cdgksi.fsf@epam.com \
--to=volodymyr_babchuk@epam.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=stefanos@xilinx.com \
--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.