From owner-freebsd-x11@FreeBSD.ORG Thu Jan 1 21:34:55 2015 Return-Path: Delivered-To: freebsd-x11@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 927AD604; Thu, 1 Jan 2015 21:34:55 +0000 (UTC) Received: from mail-wg0-x235.google.com (mail-wg0-x235.google.com [IPv6:2a00:1450:400c:c00::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 32097F79; Thu, 1 Jan 2015 21:34:55 +0000 (UTC) Received: by mail-wg0-f53.google.com with SMTP id x13so5652251wgg.12; Thu, 01 Jan 2015 13:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=OxUvvoJDvrgopbpJ2FzKVsAWtnYAe0dFOCIc2FW971U=; b=qN1tz2clorO45TdgZX5+O7usvTNwMvcsd030ZjNdfEnbJdMbTqfb8yP8TYti6DPL8C nvUG/KOChmcF+U5P8IQ4JdM9Zi7r4xCJBFagP+EtAzTa5nPg9z2CRckgKOXGlNgKN4Q3 cku9l8ZFfLjhJHzizPPZiZemG9wmpZJyPWHsGEB5sm6IfeIX89rjXNOUIRULoWjc/SGy MySbGcz6Im0N8MDpdX+R26hSNznw8bg1LR76JjPeRxYaGI1x/NSdEj/cGcDqD++SGx9q 9IfNGn7kAmIlGhAdW20s3SzKubMPnk+ya2IIVJjWAapp1PsCoarcueTM/RVB3WBZJRG6 z+Lw== MIME-Version: 1.0 X-Received: by 10.194.5.37 with SMTP id p5mr21546962wjp.20.1420148093461; Thu, 01 Jan 2015 13:34:53 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.195 with HTTP; Thu, 1 Jan 2015 13:34:53 -0800 (PST) In-Reply-To: <20150101192219.GA46601@voyager> References: <20150101192219.GA46601@voyager> Date: Thu, 1 Jan 2015 13:34:53 -0800 X-Google-Sender-Auth: jWolSM7QIqYpgu_y285v0p9hmmY Message-ID: Subject: Re: [PATCH] Fixing panic in vt_fb_blank() if fb_size is not a multiple of fb_stride From: Adrian Chadd To: Andre Albsmeier Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-hackers@freebsd.org" , freebsd-x11@freebsd.org X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jan 2015 21:34:55 -0000 oh cool! Would you mind filing a PR? This is a pretty nifty find, good work! (https://bugs.freebsd.org/submit/) -adrian On 1 January 2015 at 11:22, Andre Albsmeier wrote: > [Crossposting to -hackers and -x11 as this is vt and i915kms related] > > I can reliably crash an older notebook (Fujitsu E8310) with Intel > graphics (GM965) by loading i915kms after having booted but only > if vt(4) is used instead of old syscons. > > Reason for the crash is a page fault in vt_fb_blank() which is > in /sys/dev/vt/hw/fb/vt_fb.c: > > #7 0xc08c929e in bcopy () at /src/src-9/sys/i386/i386/support.s:198 > #8 0xc08d93e0 in memmove (dest=0xedfd3c00, src=0xeda30000, n=5632) at /src/src-9/sys/libkern/memmove.c:36 > #9 0xc053fac7 in vt_fb_mem_copy (sc=0xc6919500, offset_to=5913600, offset_from=0, size=5632) at /src/src-9/sys/dev/fb/fbd.c:205 > #10 0xc060370e in vt_fb_blank (vd=0xc09c3c40, color=) at /src/src-9/sys/dev/vt/hw/fb/vt_fb.c:179 > #11 0xc0603b10 in vt_fb_init (vd=0xc09c3c40) at /src/src-9/sys/dev/vt/hw/fb/vt_fb.c:306 > #12 0xc06098db in vt_allocate (drv=0xc09c3b80, softc=0xc6919500) at /src/src-9/sys/dev/vt/vt_core.c:1970 > > in vt_fb_blank() we find: > > for (o = info->fb_stride; o < info->fb_size; o += info->fb_stride) { > info->copy(info, o, 0, info->fb_stride); > } > > fb_size gets calculated in intelfb_create() which is in > /sys/dev/drm2/i915/intel_fb.c as > > size = mode_cmd.pitches[0] * mode_cmd.height; > size = roundup2(size, PAGE_SIZE); > > with fb_stride being the result of > > mode_cmd.pitches[0] = roundup2( (mode_cmd.width * ((sizes->surface_bpp + 7) / 8), 64); > > So with my funky resolution of 1400 x 1050 @32bit we get > > fb_stride = 5632 > fb_size = 5914624 > > We see that fb_stride won't fit into fb_size in whole numbers > (5914624 / 5632 = 1050.18181818181818181818) so this is why > the loop runs beyond fb_size and gives a page fault. > > I am now using this modified loop in vt_fb_blank() which does > not try to run to the end of the fb by replacing > > info->fb_size > > by > > info->fb_height * info->fb_stride > > for (o = info->fb_stride; o < info->fb_height * info->fb_stride; o += info->fb_stride) { > info->copy(info, o, 0, info->fb_stride); > } > > All this is on 9.3-STABLE. I have no idea if this is the correct > solution but at least I can use vt instead of sc on this notebook. > > -Andre > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"