Re: [PATCH v2 02/10] mini-os: sort and sanitize e820 memory map

2021-12-20 Thread Juergen Gross

On 21.12.21 00:17, Samuel Thibault wrote:

Juergen Gross, le lun. 20 déc. 2021 17:07:08 +0100, a ecrit:

+static void e820_sanitize(void)
+{
+int i;
+unsigned long end, start;
+
+/* Sanitize memory map in current form. */
+e820_process_entries();
+
+/* Adjust map entries to page boundaries. */
+for ( i = 0; i < e820_entries; i++ )
+{
+start = e820_map[i].addr;
+end = start + e820_map[i].size;
+if ( (1U << e820_map[i].type) & E820_NARROW )
+{
+if ( start & (PAGE_SIZE - 1) )
+{
+start = round_pgup(start);
+e820_insert_entry_at(i, start - PAGE_SIZE, PAGE_SIZE,
+ E820_TMP_RESERVED);
+i++;
+}
+if ( end & (PAGE_SIZE - 1) )
+{
+end = round_pgdown(end);
+e820_insert_entry_at(i, end, PAGE_SIZE, E820_TMP_RESERVED);


Rather i+1 so it's most probably already sorted?


Ah, yes, good catch.



Apart from that,

Reviewed-by: Samuel Thibault 


Thanks,


Juergen



OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [PATCH v2 02/10] mini-os: sort and sanitize e820 memory map

2021-12-20 Thread Samuel Thibault
Juergen Gross, le lun. 20 déc. 2021 17:07:08 +0100, a ecrit:
> +static void e820_sanitize(void)
> +{
> +int i;
> +unsigned long end, start;
> +
> +/* Sanitize memory map in current form. */
> +e820_process_entries();
> +
> +/* Adjust map entries to page boundaries. */
> +for ( i = 0; i < e820_entries; i++ )
> +{
> +start = e820_map[i].addr;
> +end = start + e820_map[i].size;
> +if ( (1U << e820_map[i].type) & E820_NARROW )
> +{
> +if ( start & (PAGE_SIZE - 1) )
> +{
> +start = round_pgup(start);
> +e820_insert_entry_at(i, start - PAGE_SIZE, PAGE_SIZE,
> + E820_TMP_RESERVED);
> +i++;
> +}
> +if ( end & (PAGE_SIZE - 1) )
> +{
> +end = round_pgdown(end);
> +e820_insert_entry_at(i, end, PAGE_SIZE, E820_TMP_RESERVED);

Rather i+1 so it's most probably already sorted?

Apart from that,

Reviewed-by: Samuel Thibault 

Samuel