Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Mar 2004 18:55:24 -0800
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        Nate Lawson <nate@root.org>
Cc:        current@freebsd.org
Subject:   Re: bug in vm_contig.c? [was: Re: ACPI crash with recent changes]
Message-ID:  <20040305025524.GA601@dhcp01.pn.xcllnt.net>
In-Reply-To: <20040304161108.U26303@root.org>
References:  <20040304025223.GA622@dhcp01.pn.xcllnt.net> <20040304161108.U26303@root.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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
@@ -230,7 +230,7 @@
                        }
                }
                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@xcllnt.net



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040305025524.GA601>