git: 9front

Download patch

ref: b972c1f514548a57adbcde2207d1ae48e41c4f5f
parent: 07f197cec0247d18891bbd5a243b36cd2806b0f0
author: qwx <qwx@sciops.net>
date: Sat May 25 22:02:29 EDT 2024

devsegment: don't use ulong as negative index

len is ulong, hence &l[-len] makes no sense.
&l[-(uintptr)len] and l - len are correct.

igfx uses a fixed segment to extend its memory when stolen memory is
insufficient for the requested mode.  this caused segment allocation
to always fail since no page in the loop would fall within the range.
modesetting then fails but the bottom of the screen stays garbled.

--- a/sys/src/9/port/devsegment.c
+++ b/sys/src/9/port/devsegment.c
@@ -492,7 +492,7 @@
 		h = t = nil;
 		f = &palloc.head;
 		while((p = *f) != nil){
-			if(p > &l[-len] && p <= l){
+			if(p > l-len && p <= l){
 				*f = p->next;
 				if((p->next = h) == nil)
 					t = p;
@@ -514,7 +514,7 @@
 		palloc.freecount -= i;
 		unlock(&palloc);
 
-		p = &l[-len];
+		p = l-len;
 		do {
 			p++;
 			p->ref = 1;
--