Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2726385ybf; Mon, 2 Mar 2020 14:22:26 -0800 (PST) X-Google-Smtp-Source: ADFU+vuPoUqfJXGhA8CValYpVSDQbiJakz3xl/T6MUtUfgW3NTMkS6DfsuN11bfFS2dHC4FrLyg8 X-Received: by 2002:a54:468a:: with SMTP id k10mr458249oic.3.1583187746251; Mon, 02 Mar 2020 14:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583187746; cv=none; d=google.com; s=arc-20160816; b=Qz7MZhpFryOxNjUPlGF3eNfCW7OuqtI0Se3o/e/LHkfNz94oF6rarBoNv6zaBl8t4S tyCO/Ox3YrWLdM3qCuSqISfkAG2365cYpc/f3EU9GPI28r+etpcSw3IU42drF+EEPoV4 EWGF/oTvxS7kpgrzk3T9EkSHOL5PtYTj5GolQnKuFAP96TOSfsfgE73utBUe3LCpYf6S 8V1NzyZX5UIspJvhvCGXDSSGYB7D2TlO9w2osbjxa72pg5I1hmrylmmAijnqQ2+XiiMg a68ozFFZhqZ3tV+WBZJmYOBBRsM2rsH9X5TK62U/QBBjj51TL74yGi3IGUeuJpsljQBH pa9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=H/ZXePw08jIq7OBB1YUZ7Aye4n93ozY+7PwFaAkmQrs=; b=LHPcyWxHmJnuJdBcBUfD+ZBlGaf1baGPxh9sHFqt+Ls3fUId05TsYfxjKRwaSHNVJ7 Mz1MYkDWxue+bq6GYxT7ZSSNumyyR01evDJX16fm/maTxdV3XgLMy6FJJW+nZgsl3iVI cAj6zKb8d6AliL/eI0wIkQBHT8FKVtYyfcqMFtuBLRDzKs/9HpmaNLoY9O+ZHR5YZ+IT Qblf4nE+8VDgROhrFCAE+0b6eBIb7lwEEYI4l0il7farZNv0WuRsRkS94h0g5pSGgeuP 3pzgka3OGgkgETRY2Sa6gQMf0xEMrUIbZ+AO4xOTIBf1ZsYHZj9JnWkC4kdAh3iw0nVO 6soA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e0zMyqz+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si4397829otr.94.2020.03.02.14.22.13; Mon, 02 Mar 2020 14:22:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e0zMyqz+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbgCBWVl (ORCPT + 99 others); Mon, 2 Mar 2020 17:21:41 -0500 Received: from mail-vk1-f195.google.com ([209.85.221.195]:35578 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbgCBWVk (ORCPT ); Mon, 2 Mar 2020 17:21:40 -0500 Received: by mail-vk1-f195.google.com with SMTP id r5so319175vkf.2 for ; Mon, 02 Mar 2020 14:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H/ZXePw08jIq7OBB1YUZ7Aye4n93ozY+7PwFaAkmQrs=; b=e0zMyqz+F+6zRjoWtD/mmEgf34GKDHSCQlnC/uFR2APNtgaNTLYdn/QIN8teuoIAIM rff9jQj/X45gNaRymYGKIMomIBf61QRu0cSWCxImAgLP2bGNh7kxVBOw9RxTu3c/ObV9 w6VlRCQMySed3qvqkTtidujVwrsaEQIQO2ye2MqYmi/E97frP8ZV4KBO/a6zgm7b5gDy fi7YE9kwimD1YdzUI/ow0fLyrYA4zPh63n6XoJUb7TrsyOTHqtwjnkvWjMfi560AYAe1 nhM+BOAVhrxNIhnQoGdJw164oDxtFr1/SVpWWMI74s4/mGAfgAiiY3xH+RUsO/p6kIBU d1pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H/ZXePw08jIq7OBB1YUZ7Aye4n93ozY+7PwFaAkmQrs=; b=nJOW2FhcIiqDvJo6e19NVJZELFG4yGfMLd6CaOxuLiHoB6JvqpgxuegQuWgbH7tKGa YKCS+wa2jqUv2ckRRq3XaDMQiTMsMqEbKdb/xyqMwiOwQ/I5iC+JsP9IJngQKyDqkfFK eaVtXsd/vB6XxRhDpkZO3QxEHiHY1fC8KgEPki8Xu/wx41jact29UKO2WwmWYMIUeYF2 PpCxyiyoD8xXHGsZt+u7BPxqilQuKzePC4UeQt1zjJBQDksI3Y0seLHaPVhJHkKkIvh4 hujHoKCQI6H2AfsbdZrXHpDwfHoeWxaa3/dQvd6/4BDm/EUq2L+I5Rmx0fB2h+2L3lAY izig== X-Gm-Message-State: ANhLgQ1HCYKuYeVfxEZK2XIandCFabKa5ZAiFBq5Ti0smYdXKDv9LVDr Kp3QCN1rti5W1rmrd7EVPHB4E+hNfMiPNRkS460= X-Received: by 2002:a1f:284:: with SMTP id 126mr151121vkc.16.1583187699557; Mon, 02 Mar 2020 14:21:39 -0800 (PST) MIME-Version: 1.0 References: <20200227210454.18217-1-alistair.francis@wdc.com> <20200228095748.uu4sqkz6y477eabc@sirius.home.kraxel.org> In-Reply-To: <20200228095748.uu4sqkz6y477eabc@sirius.home.kraxel.org> From: Alistair Francis Date: Mon, 2 Mar 2020 14:14:02 -0800 Message-ID: Subject: Re: [PATCH] drm/bochs: Remove vga write To: Gerd Hoffmann Cc: Alistair Francis , Linux Kernel Mailing List , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, daniel@ffwll.ch, airlied@linux.ie, Khem Raj Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 28, 2020 at 1:57 AM Gerd Hoffmann wrote: > > On Thu, Feb 27, 2020 at 01:04:54PM -0800, Alistair Francis wrote: > > The QEMU model for the Bochs display has no VGA memory section at offset > > 0x400 [1]. By writing to this register Linux can create a write to > > unassigned memory which depending on machine and architecture can result > > in a store fault. > > > > I don't see any reference to this address at OSDev [2] or in the Bochs > > source code. > > > > Removing this write still allows graphics to work inside QEMU with > > the bochs-display. > > It's not that simple. The driver also handles the qemu stdvga (-device > VGA, -device secondary-vga) which *does* need the vga port write. > There is no way for the guest to figure whenever the device is > secondary-vga or bochs-display. > > So how about fixing things on the host side? Does qemu patch below > help? That patch looks like it will fix the problem, but it doesn't seem like the correct fix. I would rather avoid adding a large chunk of dummy I/O to handle the two devices. > > Maybe another possible approach is to enable/disable vga access per > arch. On x86 this doesn't cause any problems. I guess you are on > risc-v? I would prefer this option. I do see this on RISC-V, but I suspect the issue will appear on other architectures (although how they handle I/O failures in QEMU is a different story). Can I just do the VGA write if x86? Alistair > > cheers, > Gerd > > diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c > index 62085f9fc063..e93e838243b8 100644 > --- a/hw/display/bochs-display.c > +++ b/hw/display/bochs-display.c > @@ -151,6 +151,26 @@ static const MemoryRegionOps bochs_display_qext_ops = { > .endianness = DEVICE_LITTLE_ENDIAN, > }; > > +static uint64_t dummy_read(void *ptr, hwaddr addr, unsigned size) > +{ > + return -1; > +} > + > +static void dummy_write(void *ptr, hwaddr addr, > + uint64_t val, unsigned size) > +{ > +} > + > +static const MemoryRegionOps dummy_ops = { > + .read = dummy_read, > + .write = dummy_write, > + .valid.min_access_size = 1, > + .valid.max_access_size = 4, > + .impl.min_access_size = 1, > + .impl.max_access_size = 1, > + .endianness = DEVICE_LITTLE_ENDIAN, > +}; > + > static int bochs_display_get_mode(BochsDisplayState *s, > BochsDisplayMode *mode) > { > @@ -284,8 +304,8 @@ static void bochs_display_realize(PCIDevice *dev, Error **errp) > memory_region_init_io(&s->qext, obj, &bochs_display_qext_ops, s, > "qemu extended regs", PCI_VGA_QEXT_SIZE); > > - memory_region_init(&s->mmio, obj, "bochs-display-mmio", > - PCI_VGA_MMIO_SIZE); > + memory_region_init_io(&s->mmio, obj, &dummy_ops, NULL, > + "bochs-display-mmio", PCI_VGA_MMIO_SIZE); > memory_region_add_subregion(&s->mmio, PCI_VGA_BOCHS_OFFSET, &s->vbe); > memory_region_add_subregion(&s->mmio, PCI_VGA_QEXT_OFFSET, &s->qext); > >