code: plan9front

Download patch

ref: ded308e5762d26ed79d26d540dfba8d336f20390
parent: 8a2efea90ce8ced888e0138b9f33e7f6179ae949
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;