Re: bug in vm_contig.c? [was: Re: ACPI crash with recent changes]

From: Marcel Moolenaar <marcel_at_xcllnt.net>
Date: Thu, 4 Mar 2004 18:55:24 -0800
On Thu, Mar 04, 2004 at 04:16:20PM -0800, Nate Lawson wrote:
> Try reverting these two changes.  This is not an ACPI problem.  The fact
> that ACPI needs to allocate some memory early on in the boot for its sleep
> code is what triggers this bug.
> 
>    src/sys/vm/vm_contig.c:1.31
>    src/sys/vm/vm_page.c:1.277
> 
> http://docs.freebsd.org/cgi/getmsg.cgi?fetch=326708+0+current/cvs-src
> 
> I think the bug is the loop accessing i - 1 right from the start.  It may
> be correct to do:  for (i = start + 1; ...
> But I don't know this section of the code.

Yes, start can be and is 0 at that moment. Hence, i can be 0 and i - 1
can be fatal. Initializing the loop with start + 1 fixes the problem.
To be precise, we're talking about:

Index: vm_contig.c
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_contig.c,v
retrieving revision 1.31
diff -u -r1.31 vm_contig.c
--- vm_contig.c 2 Mar 2004 08:25:58 -0000       1.31
+++ vm_contig.c 5 Mar 2004 02:41:38 -0000
_at__at_ -230,7 +230,7 _at__at_
                        }
                }
                mtx_lock_spin(&vm_page_queue_free_mtx);
-               for (i = start; i < (start + size / PAGE_SIZE); i++) {
+               for (i = start + 1; i < (start + size / PAGE_SIZE); i++) {
                        pqtype = pga[i].queue - pga[i].pc;
                        if ((VM_PAGE_TO_PHYS(&pga[i]) !=
                            (VM_PAGE_TO_PHYS(&pga[i - 1]) + PAGE_SIZE)) ||

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel_at_xcllnt.net
Received on Thu Mar 04 2004 - 17:55:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:46 UTC