From nobody Sat May 4 22:22:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1557749058; cv=none; d=zoho.com; s=zohoarc; b=Ga5VdMFohsquJ3u4BmYxapumOs1sOiTMK7MPqzGZ87xCMff7gHIp0XkMtnTuEw12fTaBWLsV6oP9m0KqoLG77xq4DTD4T9irpJbsQMLtLfuPZyYr28kQhqWX5alLdt9aE6k6oEu4TNNfkQ6Ozy3NeAkpzwp5t1SSNtGXngZj9fE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557749058; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RRxHfRV+Nkj7T9UQbflCHFwgeYBhi6zGD4PURH16caQ=; b=RB7h8Dv2hednhFPIucHG8sy6sVx52ICCfrrl71LO2EzC3zkK2jAaWWSjwALAdpmimLA+PjcQeT2X1nsGtdPNp3JmpQ/E68FHEzVlkLrT/HTaKoBVbekFF0w/0ZNb7PigNBCLRFcq0fRSPmBKR67gWUPZf2Tf7ITVyN2i5DNx9rc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557749058701990.8222745739887; Mon, 13 May 2019 05:04:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:55906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ9gl-0008Vs-Ms for importer@patchew.org; Mon, 13 May 2019 08:04:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ9aN-0003WC-CS for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ9aM-0001Qy-AO for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:39 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37797) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQ9aM-0001QU-40 for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:38 -0400 Received: by mail-wm1-x342.google.com with SMTP id 7so7385814wmo.2 for ; Mon, 13 May 2019 04:57:38 -0700 (PDT) Received: from localhost.localdomain ([37.142.144.27]) by smtp.gmail.com with ESMTPSA id z5sm5238554wmi.34.2019.05.13.04.57.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 04:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RRxHfRV+Nkj7T9UQbflCHFwgeYBhi6zGD4PURH16caQ=; b=ObM3p8NR3XUkME4KrKzX97ce3DeISoRGewIytawGsJiDu4HKVFKzigLi7Cm9vTBhkt qSCxrxvt8sy3qCFkXjK1vUmBedn1XSRIrnmqTuP2tTWQ3Spm71KcMcXRgjSxGAWklVd5 FW/V94XZL+X8Kf7QUjLEid6mBjNClJexcwN5yXvYxLWkIaGxjiEDty7vF8HpUZJP8v5p bCk0OFgsDrhHFX/u2XjbeFn09aiVbozGG5tReIZEb+f7/APT4wuuJvNzvY90YOnTIYCr Hd83C6kjcTtHZXTNPNePb4rQyOn/lEvD8eczM47THeg2Oua0fmF1IL5bacCBSEpK/l+Z /syA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RRxHfRV+Nkj7T9UQbflCHFwgeYBhi6zGD4PURH16caQ=; b=U9gfegPP2EMs4CqQyA/o4hbs9mXk1w7HFcV2vBW4F++BZ1VgFMWSQJwliZQzRHXVTL QdgEqV5/WfQjLuOktruheQQ7Z2JYhfyS1y5RE4j9e/z4RpdyfiDbo6Rx5KJvspw1syrM hGYe4clYz8NkBFh+MkoQJQ9nK8n/HGcbIFYbgGcaw2Vw9acVXunrExnT6OWgYoCy2c1o kf1Srn2+9BZXL+lvxpFNrISD4/9yVObKtogj7jrZruq9nJVLR1YfBwT4gSmesX/VdJfE XsOcNDrDuzZQ3tGN2cim3fdHMcndUEmnywCrOGlbmWtGhpuAG8/OEsKIZYSQ6Hlhc0VJ HDpg== X-Gm-Message-State: APjAAAW9P9y4haYAV/Qya+aEwiB7lKXoC5+bYAnubfVLbFasEEX9A5w1 XChggL7fdvU3F6TKd/2kNvVL7jjF X-Google-Smtp-Source: APXvYqyIoIvrqoIw2lGEZ5Hzf26BKPmk0OkIINBe6lgaodB/JeMZr5jBWnVXlc+4VZ6f1XvGRStvdQ== X-Received: by 2002:a7b:cb81:: with SMTP id m1mr16295012wmi.9.1557748656762; Mon, 13 May 2019 04:57:36 -0700 (PDT) From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:57:29 +0300 Message-Id: <20190513115731.17588-2-marcel.apfelbaum@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513115731.17588-1-marcel.apfelbaum@gmail.com> References: <20190513115731.17588-1-marcel.apfelbaum@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH V3 1/3] hw/display/ramfb: fix guest memory un-mapping 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: , Cc: alex.williamson@redhat.com, kraxel@redhat.com, hqm03ster@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Hou Qiming Pulled back the `qemu_create_displaysurface_guestmem` function to create the display surface so that the guest memory gets properly unmapped. Signed-off-by: HOU Qiming [rename the new functions and use QEMU coding style] Signed-off-by: Marcel Apfelbaum --- hw/display/ramfb.c | 51 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c index 25c8ad7c25..1955b048dd 100644 --- a/hw/display/ramfb.c +++ b/hw/display/ramfb.c @@ -32,33 +32,58 @@ struct RAMFBState { struct RAMFBCfg cfg; }; =20 +static void ramfb_unmap_display_surface(pixman_image_t *image, void *unuse= d) +{ + void *data =3D pixman_image_get_data(image); + uint32_t size =3D pixman_image_get_stride(image) * + pixman_image_get_height(image); + cpu_physical_memory_unmap(data, size, 0, 0); +} + +static DisplaySurface *ramfb_create_display_surface(int width, int height, + pixman_format_code_t f= ormat, + int linesize, uint64_t= addr) +{ + DisplaySurface *surface; + hwaddr size; + void *data; + + if (linesize =3D=3D 0) { + linesize =3D width * PIXMAN_FORMAT_BPP(format) / 8; + } + + size =3D (hwaddr)linesize * height; + data =3D cpu_physical_memory_map(addr, &size, 0); + if (size !=3D (hwaddr)linesize * height) { + cpu_physical_memory_unmap(data, size, 0, 0); + return NULL; + } + + surface =3D qemu_create_displaysurface_from(width, height, + format, linesize, data); + pixman_image_set_destroy_function(surface->image, + ramfb_unmap_display_surface, NULL); + + return surface; +} + static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len) { RAMFBState *s =3D dev; - void *framebuffer; uint32_t fourcc, format; - hwaddr stride, addr, length; + hwaddr stride, addr; =20 s->width =3D be32_to_cpu(s->cfg.width); s->height =3D be32_to_cpu(s->cfg.height); stride =3D be32_to_cpu(s->cfg.stride); fourcc =3D be32_to_cpu(s->cfg.fourcc); addr =3D be64_to_cpu(s->cfg.addr); - length =3D stride * s->height; format =3D qemu_drm_format_to_pixman(fourcc); =20 fprintf(stderr, "%s: %dx%d @ 0x%" PRIx64 "\n", __func__, s->width, s->height, addr); - framebuffer =3D address_space_map(&address_space_memory, - addr, &length, false, - MEMTXATTRS_UNSPECIFIED); - if (!framebuffer || length < stride * s->height) { - s->width =3D 0; - s->height =3D 0; - return; - } - s->ds =3D qemu_create_displaysurface_from(s->width, s->height, - format, stride, framebuffer); + s->ds =3D ramfb_create_display_surface(s->width, s->height, + format, stride, addr); } =20 void ramfb_display_update(QemuConsole *con, RAMFBState *s) --=20 2.17.1 From nobody Sat May 4 22:22:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1557748785; cv=none; d=zoho.com; s=zohoarc; b=etqBgP8XVJp6snAJVvtaOzEi5mVfBjreFO7Iaw+5qQUHLKym07KRjOqRRcYp2t9kl/gSnL6Q2FOi3Jkg68IqybMnLHXZYBqbojVtLndKxi5dy/CzR2QbCH0u0IzbUhOQpKG53XqKsfhOdRxNnvn2xuLegAZ7Q97ZARrUGIKqBEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557748785; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Nnd8FYZPm/MLulz3Akv9891/p6EUv5PIMcaH5c6XG9k=; b=GPdS1znhHl6pj0hLPHO7BHaUYO69/AsfZ5v9nu4Dui+Wwz71Xd0z5xTLiKjIfO2ngyEt7A6IyHMU1b07g3eYI705YnP7/axvbWJrFFCY59zDVfGgDAorvgzlcUTz6ToVXdD13UfXvIRlfTba/rVQJMbts9JKidUtlgcbQQHzhrI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557748785143680.2162045720137; Mon, 13 May 2019 04:59:45 -0700 (PDT) Received: from localhost ([127.0.0.1]:55708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ9cL-0004hp-PH for importer@patchew.org; Mon, 13 May 2019 07:59:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ9aO-0003XL-UB for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ9aN-0001Ry-T8 for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:40 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36593) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQ9aN-0001RL-Mn for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:39 -0400 Received: by mail-wr1-x444.google.com with SMTP id o4so14949734wra.3 for ; Mon, 13 May 2019 04:57:39 -0700 (PDT) Received: from localhost.localdomain ([37.142.144.27]) by smtp.gmail.com with ESMTPSA id z5sm5238554wmi.34.2019.05.13.04.57.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 04:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Nnd8FYZPm/MLulz3Akv9891/p6EUv5PIMcaH5c6XG9k=; b=bYUJE4JPlOZnPo0KYhnqkF9fn+yBVwhdAcRerhGa9IAAYMEyxgdAq1ZhuPDwxZqyH6 f85SHsvGvt+V0zG44R9A1CyrGeS6knlshZr0dl384JgPp3EU8t+V9+ilK/71yyt17ovo 1oZo6StGYsSjuLlC3ZzDOtl9ZUkYj662/vYkige9ANiTySc9vclXxbpFRNVlNO6hwf6B ZV7onw8X4b64PkKKL49QZSb4rSGdUwoaUEelkluicFEbUvrHMgJfwnpEP8sB4FGYntf3 qwrSEpdrTsWByEsbtpYbsp4rgQRROZsxKNIEntYwkb3Yn4dPJnGClPfj8ygtlo8X93gK xAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Nnd8FYZPm/MLulz3Akv9891/p6EUv5PIMcaH5c6XG9k=; b=dfCHyWZepWbOWVf8Y4xiau5VGbClaySehQjaFoUBbvGpLlc1EUy5vcALPTxFOAMH8E ZQ4axDXNtaUqnLJ9hQ40zla/Inv54pOXcgE8mQJ4Q8VIfbH4jD6LnwnWoZ6ZwHVuledr QEhynbtnAO5evTJdLiIP+Pa62wCTC/cqCRZYTefK5aVRNumHYpnoZWq/OGkX1s/ufHXQ YRHQdVOT8oXMN4tgK1UhBQrE6lpi4U9GANAUoInsvbmuIOqiDoLHtS46RlwYgPY+Yz9X bFZ2b78T5kGbRmS1BewDWVdESsDUoMplXZJL3a6H7AnRDp24DS3k5M3GeZITTNea5kC/ xo9g== X-Gm-Message-State: APjAAAWlm58GQXgkI932Ol5RCT4IAGItT0QRH8f0s9WoGl6QA3xT7MaX KqzVQcTY4tLu0OhEj0bVNdBvV+Ef X-Google-Smtp-Source: APXvYqwZiOmKbkkNsp/7A+fQ/jMH4LL2MS5zEwSCV0rHlGrgvyrTZjQnn4+DqKir17z6lP+a9xhxaQ== X-Received: by 2002:a5d:4f88:: with SMTP id d8mr2847906wru.34.1557748658455; Mon, 13 May 2019 04:57:38 -0700 (PDT) From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:57:30 +0300 Message-Id: <20190513115731.17588-3-marcel.apfelbaum@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513115731.17588-1-marcel.apfelbaum@gmail.com> References: <20190513115731.17588-1-marcel.apfelbaum@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH V3 2/3] hw/display/ramfb: lock guest resolution after it's set 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: , Cc: alex.williamson@redhat.com, kraxel@redhat.com, hqm03ster@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Hou Qiming Only allow one resolution change per guest boot, which prevents a crash when the guest writes garbage to the configuration space (e.g. when rebooting). Signed-off-by: HOU Qiming [fixed malformed patch] Signed-off-by: Marcel Apfelbaum --- hw/display/ramfb.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c index 1955b048dd..0fe79aa856 100644 --- a/hw/display/ramfb.c +++ b/hw/display/ramfb.c @@ -30,6 +30,7 @@ struct RAMFBState { DisplaySurface *ds; uint32_t width, height; struct RAMFBCfg cfg; + bool locked; }; =20 static void ramfb_unmap_display_surface(pixman_image_t *image, void *unuse= d) @@ -70,18 +71,25 @@ static DisplaySurface *ramfb_create_display_surface(int= width, int height, static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len) { RAMFBState *s =3D dev; - uint32_t fourcc, format; + uint32_t fourcc, format, width, height; hwaddr stride, addr; =20 - s->width =3D be32_to_cpu(s->cfg.width); - s->height =3D be32_to_cpu(s->cfg.height); + width =3D be32_to_cpu(s->cfg.width); + height =3D be32_to_cpu(s->cfg.height); stride =3D be32_to_cpu(s->cfg.stride); fourcc =3D be32_to_cpu(s->cfg.fourcc); addr =3D be64_to_cpu(s->cfg.addr); format =3D qemu_drm_format_to_pixman(fourcc); =20 fprintf(stderr, "%s: %dx%d @ 0x%" PRIx64 "\n", __func__, - s->width, s->height, addr); + width, height, addr); + if (s->locked) { + fprintf(stderr, "%s: resolution locked, change rejected\n", __func= __); + return; + } + s->locked =3D true; + s->width =3D width; + s->height =3D height; s->ds =3D ramfb_create_display_surface(s->width, s->height, format, stride, addr); } @@ -101,6 +109,13 @@ void ramfb_display_update(QemuConsole *con, RAMFBState= *s) dpy_gfx_update_full(con); } =20 +static void ramfb_reset(void *opaque) +{ + RAMFBState *s =3D (RAMFBState *)opaque; + s->locked =3D false; + memset(&s->cfg, 0, sizeof(s->cfg)); +} + RAMFBState *ramfb_setup(Error **errp) { FWCfgState *fw_cfg =3D fw_cfg_find(); @@ -113,9 +128,12 @@ RAMFBState *ramfb_setup(Error **errp) =20 s =3D g_new0(RAMFBState, 1); =20 + s->locked =3D false; + rom_add_vga("vgabios-ramfb.bin"); fw_cfg_add_file_callback(fw_cfg, "etc/ramfb", NULL, ramfb_fw_cfg_write, s, &s->cfg, sizeof(s->cfg), false); + qemu_register_reset(ramfb_reset, s); return s; } --=20 2.17.1 From nobody Sat May 4 22:22:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1557748971; cv=none; d=zoho.com; s=zohoarc; b=cTtGil9aW88o1K6Ut2za533PsZstzb/3wy8XF2ixwp++vywmUXbVGs/8OtbqprS6/VfXV8SnWLnbmdyPMpCZL/yVuWf5+/7QZ1alpn5qV5MLGfRGovVvJhTsZYdaYlXu29PhK6r6IFT7pfQKbVGxhxFNLwsH9jcqADAwzg4PGwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557748971; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Cb6ypY+QVCjZPXzcsPv+3xj/2MSR1UVyWcvLGS9tb9s=; b=hhdPdj7AC0OTQm3gNdq9kiDXswAMj/V32vWSiDMQekbD0eH6x77bd9y/xLGF2bDrQYjtoRnjSBRHIw2rx3z+yoJgYS3loP6465bfsLfknXPTfUq7eeNOhZOP/GlxRdIoAmMSDJU30SBIVUjKgLiJf+1xxt3Y9xqcyCJW5VIbygI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557748971240620.8799699701489; Mon, 13 May 2019 05:02:51 -0700 (PDT) Received: from localhost ([127.0.0.1]:55774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ9fM-0007UW-53 for importer@patchew.org; Mon, 13 May 2019 08:02:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ9aQ-0003Yn-FX for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ9aP-0001So-98 for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:42 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:45886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQ9aP-0001SF-2P for qemu-devel@nongnu.org; Mon, 13 May 2019 07:57:41 -0400 Received: by mail-wr1-x443.google.com with SMTP id b18so4953261wrq.12 for ; Mon, 13 May 2019 04:57:40 -0700 (PDT) Received: from localhost.localdomain ([37.142.144.27]) by smtp.gmail.com with ESMTPSA id z5sm5238554wmi.34.2019.05.13.04.57.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 04:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cb6ypY+QVCjZPXzcsPv+3xj/2MSR1UVyWcvLGS9tb9s=; b=b+bdhhH1pgI1LdW9aezyT+xGnySlMx4o8eETBpGD/dN4TlvjOHgBmerRYPp+QV+kUN ekwslQArVwfQjkmFDXGpFDGvI1Qt3+p2U8OZuDMN6JlAn0AW8t46nVEnH+R1fPwhodRm 07ESRsTbVBPpb1vPKdGatVvTcu3w8xedcY5GFG4mawaiidErQ+DnxCQlW1weacF6K2wo t6XHg0dXEb1e99XvkjkKLioUvBdI9GCeEKJWakUxps3TVMVRF/wafg61whLr5FQ5Tfst RhR63q7IyUuU1uwmqAVqBpu5pg0I0gy5d0fnCf459tu5BSxLEki+WnMpAb5zsTEg0fdc E1BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cb6ypY+QVCjZPXzcsPv+3xj/2MSR1UVyWcvLGS9tb9s=; b=uTVxnHtTF8pUiU0okJmpVU6Cx9T/SuyoiEBqCQjegMAbcvV/NRfXdPMTx4gGAG1Lmj dDnSg2MoSJjfbGRy2HA/Md5mgw8Nt/+afdKTYrIsvu9soE3o9/7GINptoE/tyhJn2yC1 GxiB7pa8nqen3OnfKmADrThyJHexywDM49Bzmt2asCOS0gUg7Fl8lmzcXl5VST9QGwJ0 HBewCwg2QDJuGyTPXz0D17FzexOGLkbyr3o3i3QemL9RfFoNcrrx+Rwk3ui1HEn7YpVh rLlhLunze3NJBNLPvzqTph9HDnxhZD77kLt53RtAMINiIfCpuysy57Zub0XyQcc3e2Sn 8mSA== X-Gm-Message-State: APjAAAVTUI3GfGmzd6dQhIyQb2jXvfJQnkwuWJ64plyqIgRW7KLuuGI2 uoXV+n954nFPdq6vANclK62H+3DE X-Google-Smtp-Source: APXvYqy/jP/gflelwq2PBs5IonjeRzkA6p0agrevW21QoogKb1FfJyoOY18MGQg/9QrZbiUY5rTk6g== X-Received: by 2002:a5d:5701:: with SMTP id a1mr17843450wrv.52.1557748659876; Mon, 13 May 2019 04:57:39 -0700 (PDT) From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:57:31 +0300 Message-Id: <20190513115731.17588-4-marcel.apfelbaum@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513115731.17588-1-marcel.apfelbaum@gmail.com> References: <20190513115731.17588-1-marcel.apfelbaum@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH V3 3/3] hw/display/ramfb: initialize fw-config space with xres/ yres 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: , Cc: alex.williamson@redhat.com, kraxel@redhat.com, hqm03ster@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Hou Qiming If xres / yres were specified in QEMU command line, write them as an initial resolution to the fw-config space on guest reset, which a later BIOS / OVMF patch can take advantage of. Signed-off-by: HOU Qiming [fixed malformed patch] Signed-off-by: Marcel Apfelbaum --- hw/display/ramfb-standalone.c | 12 +++++++++++- hw/display/ramfb.c | 16 +++++++++++++++- hw/vfio/display.c | 4 ++-- include/hw/display/ramfb.h | 2 +- stubs/ramfb.c | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/hw/display/ramfb-standalone.c b/hw/display/ramfb-standalone.c index da3229a1f6..6441449e7b 100644 --- a/hw/display/ramfb-standalone.c +++ b/hw/display/ramfb-standalone.c @@ -1,6 +1,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/loader.h" +#include "hw/isa/isa.h" #include "hw/display/ramfb.h" #include "ui/console.h" #include "sysemu/sysemu.h" @@ -11,6 +12,8 @@ typedef struct RAMFBStandaloneState { SysBusDevice parent_obj; QemuConsole *con; RAMFBState *state; + uint32_t xres; + uint32_t yres; } RAMFBStandaloneState; =20 static void display_update_wrapper(void *dev) @@ -33,15 +36,22 @@ static void ramfb_realizefn(DeviceState *dev, Error **e= rrp) RAMFBStandaloneState *ramfb =3D RAMFB(dev); =20 ramfb->con =3D graphic_console_init(dev, 0, &wrapper_ops, dev); - ramfb->state =3D ramfb_setup(errp); + ramfb->state =3D ramfb_setup(dev, errp); } =20 +static Property ramfb_properties[] =3D { + DEFINE_PROP_UINT32("xres", RAMFBStandaloneState, xres, 0), + DEFINE_PROP_UINT32("yres", RAMFBStandaloneState, yres, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static void ramfb_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); dc->realize =3D ramfb_realizefn; + dc->props =3D ramfb_properties; dc->desc =3D "ram framebuffer standalone device"; dc->user_creatable =3D true; } diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c index 0fe79aa856..b4eb283ef8 100644 --- a/hw/display/ramfb.c +++ b/hw/display/ramfb.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/option.h" #include "hw/loader.h" #include "hw/display/ramfb.h" #include "ui/console.h" @@ -29,6 +30,7 @@ struct QEMU_PACKED RAMFBCfg { struct RAMFBState { DisplaySurface *ds; uint32_t width, height; + uint32_t starting_width, starting_height; struct RAMFBCfg cfg; bool locked; }; @@ -114,9 +116,11 @@ static void ramfb_reset(void *opaque) RAMFBState *s =3D (RAMFBState *)opaque; s->locked =3D false; memset(&s->cfg, 0, sizeof(s->cfg)); + s->cfg.width =3D s->starting_width; + s->cfg.height =3D s->starting_height; } =20 -RAMFBState *ramfb_setup(Error **errp) +RAMFBState *ramfb_setup(DeviceState* dev, Error **errp) { FWCfgState *fw_cfg =3D fw_cfg_find(); RAMFBState *s; @@ -128,6 +132,16 @@ RAMFBState *ramfb_setup(Error **errp) =20 s =3D g_new0(RAMFBState, 1); =20 + const char *s_fb_width =3D qemu_opt_get(dev->opts, "xres"); + const char *s_fb_height =3D qemu_opt_get(dev->opts, "yres"); + if (s_fb_width) { + s->cfg.width =3D atoi(s_fb_width); + s->starting_width =3D s->cfg.width; + } + if (s_fb_height) { + s->cfg.height =3D atoi(s_fb_height); + s->starting_height =3D s->cfg.height; + } s->locked =3D false; =20 rom_add_vga("vgabios-ramfb.bin"); diff --git a/hw/vfio/display.c b/hw/vfio/display.c index a3d9c8f5be..2c2d3e5b71 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -352,7 +352,7 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev= , Error **errp) &vfio_display_dmabuf_ops, vdev); if (vdev->enable_ramfb) { - vdev->dpy->ramfb =3D ramfb_setup(errp); + vdev->dpy->ramfb =3D ramfb_setup(DEVICE(vdev), errp); } vfio_display_edid_init(vdev); return 0; @@ -478,7 +478,7 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev= , Error **errp) &vfio_display_region_ops, vdev); if (vdev->enable_ramfb) { - vdev->dpy->ramfb =3D ramfb_setup(errp); + vdev->dpy->ramfb =3D ramfb_setup(DEVICE(vdev), errp); } return 0; } diff --git a/include/hw/display/ramfb.h b/include/hw/display/ramfb.h index b33a2c467b..f6c2de93b2 100644 --- a/include/hw/display/ramfb.h +++ b/include/hw/display/ramfb.h @@ -4,7 +4,7 @@ /* ramfb.c */ typedef struct RAMFBState RAMFBState; void ramfb_display_update(QemuConsole *con, RAMFBState *s); -RAMFBState *ramfb_setup(Error **errp); +RAMFBState *ramfb_setup(DeviceState *dev, Error **errp); =20 /* ramfb-standalone.c */ #define TYPE_RAMFB_DEVICE "ramfb" diff --git a/stubs/ramfb.c b/stubs/ramfb.c index 48143f3354..0799093a5d 100644 --- a/stubs/ramfb.c +++ b/stubs/ramfb.c @@ -6,7 +6,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s) { } =20 -RAMFBState *ramfb_setup(Error **errp) +RAMFBState *ramfb_setup(DeviceState* dev, Error **errp) { error_setg(errp, "ramfb support not available"); return NULL; --=20 2.17.1