From nobody Tue Apr 15 14:50:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535106386294187.4644976396819; Fri, 24 Aug 2018 03:26:26 -0700 (PDT) Received: from localhost ([::1]:40963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ft9IK-0000mX-AB for importer@patchew.org; Fri, 24 Aug 2018 06:26:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ft8UR-0007qK-Kp for qemu-devel@nongnu.org; Fri, 24 Aug 2018 05:34:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ft8UQ-0004t5-KH for qemu-devel@nongnu.org; Fri, 24 Aug 2018 05:34:47 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:44906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ft8UQ-0004sY-8t for qemu-devel@nongnu.org; Fri, 24 Aug 2018 05:34:46 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1ft8UP-0006iK-Ay for qemu-devel@nongnu.org; Fri, 24 Aug 2018 10:34:45 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 24 Aug 2018 10:33:42 +0100 Message-Id: <20180824093343.11346-52-peter.maydell@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180824093343.11346-1-peter.maydell@linaro.org> References: <20180824093343.11346-1-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 51/52] hw/display/bcm2835_fb: Validate bcm2835_fb_mbox_push() config X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Refactor bcm2835_fb_mbox_push() to work by calling bcm2835_fb_validate_config() and bcm2835_fb_reconfigure(), so that config set this way is also validated. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20180814144436.679-9-peter.maydell@linaro.org --- hw/display/bcm2835_fb.c | 63 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c index 3edb8b5cfcb..d534d00a65f 100644 --- a/hw/display/bcm2835_fb.c +++ b/hw/display/bcm2835_fb.c @@ -248,38 +248,6 @@ void bcm2835_fb_validate_config(BCM2835FBConfig *confi= g) } } =20 -static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value) -{ - uint32_t pitch; - uint32_t size; - - value &=3D ~0xf; - - s->lock =3D true; - - s->config.xres =3D ldl_le_phys(&s->dma_as, value); - s->config.yres =3D ldl_le_phys(&s->dma_as, value + 4); - s->config.xres_virtual =3D ldl_le_phys(&s->dma_as, value + 8); - s->config.yres_virtual =3D ldl_le_phys(&s->dma_as, value + 12); - s->config.bpp =3D ldl_le_phys(&s->dma_as, value + 20); - s->config.xoffset =3D ldl_le_phys(&s->dma_as, value + 24); - s->config.yoffset =3D ldl_le_phys(&s->dma_as, value + 28); - - s->config.base =3D s->vcram_base | (value & 0xc0000000); - s->config.base +=3D BCM2835_FB_OFFSET; - - pitch =3D bcm2835_fb_get_pitch(&s->config); - size =3D bcm2835_fb_get_size(&s->config); - - stl_le_phys(&s->dma_as, value + 16, pitch); - stl_le_phys(&s->dma_as, value + 32, s->config.base); - stl_le_phys(&s->dma_as, value + 36, size); - - s->invalidate =3D true; - qemu_console_resize(s->con, s->config.xres, s->config.yres); - s->lock =3D false; -} - void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig) { s->lock =3D true; @@ -291,6 +259,37 @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835= FBConfig *newconfig) s->lock =3D false; } =20 +static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value) +{ + uint32_t pitch; + uint32_t size; + BCM2835FBConfig newconf; + + value &=3D ~0xf; + + newconf.xres =3D ldl_le_phys(&s->dma_as, value); + newconf.yres =3D ldl_le_phys(&s->dma_as, value + 4); + newconf.xres_virtual =3D ldl_le_phys(&s->dma_as, value + 8); + newconf.yres_virtual =3D ldl_le_phys(&s->dma_as, value + 12); + newconf.bpp =3D ldl_le_phys(&s->dma_as, value + 20); + newconf.xoffset =3D ldl_le_phys(&s->dma_as, value + 24); + newconf.yoffset =3D ldl_le_phys(&s->dma_as, value + 28); + + newconf.base =3D s->vcram_base | (value & 0xc0000000); + newconf.base +=3D BCM2835_FB_OFFSET; + + bcm2835_fb_validate_config(&newconf); + + pitch =3D bcm2835_fb_get_pitch(&newconf); + size =3D bcm2835_fb_get_size(&newconf); + + stl_le_phys(&s->dma_as, value + 16, pitch); + stl_le_phys(&s->dma_as, value + 32, newconf.base); + stl_le_phys(&s->dma_as, value + 36, size); + + bcm2835_fb_reconfigure(s, &newconf); +} + static uint64_t bcm2835_fb_read(void *opaque, hwaddr offset, unsigned size) { BCM2835FBState *s =3D opaque; --=20 2.18.0