All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Laszlo Ersek <lersek@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>,
	akong@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH] PIIX: reset the VM when the Reset Control Register's RCPU bit gets set
Date: Fri, 11 Jan 2013 13:10:50 +0100	[thread overview]
Message-ID: <50F0014A.5050804@suse.de> (raw)
In-Reply-To: <50EFDBA4.4050201@redhat.com>

Hi,

Am 11.01.2013 10:30, schrieb Laszlo Ersek:
> On 01/09/13 22:01, Blue Swirl wrote:
>> On Tue, Jan 8, 2013 at 9:44 PM, Laszlo Ersek <lersek@redhat.com> wrote:
> 
>>> +static void i440fx_host_config_write(void *opaque, hwaddr addr,
>>> +                                     uint64_t val, unsigned len)
>>> +{
>>> +    if (addr == 1 && len == 1) {
>>> +        if (val & 4) {
>>> +            qemu_system_reset_request();
>>> +        }
>>> +        return;
>>> +    }
>>> +    pci_host_conf_le_ops.write(opaque, addr, val, len);
>>> +}
>>> +
>>> +static MemoryRegionOps i440fx_host_conf_ops = {
>>> +    .read       = NULL,
>>> +    .write      = i440fx_host_config_write,
>>> +    .endianness = DEVICE_LITTLE_ENDIAN
>>> +};
>>> +
>>>  static int i440fx_pcihost_initfn(SysBusDevice *dev)
>>>  {
>>>      PCIHostState *s = PCI_HOST_BRIDGE(dev);
>>>
>>> -    memory_region_init_io(&s->conf_mem, &pci_host_conf_le_ops, s,
>>> +    i440fx_host_conf_ops.read = pci_host_conf_le_ops.read;
>>
>> It would be cleaner to introduce a new memory region (without this
>> copying) which passes 0xcf8 and 0xcfc to standard PCI host but catches
>> accesses to 0xcf9. This may mean that pci_host_config_{read,write}
>> will need to be exposed.
> 
> Do you mean:
> 
> (1) introducing the new "i440fx_host_conf_ops" struct-of-funcptrs with
> detached functions (that is, duplicating the guts of
> pci_host_config_{read,write} and modifying them, and then registering
> s->conf_mem with this "i440fx_host_conf_ops"; or
> 
> (2) leaving s->conf_mem as-is, and introducing a sub-region just for
> port 0xcf9, with higher visibility priority?
> 
> (I don't feel confident about (2), and based on "docs/memory.txt" I
> thought that overlapping regions had not been invented for this purpose.)
> 
> IOW, are you OK with the explicit offset + access-width based check,
> just organized differently, or are you proposing a one-byte-wide subregion?

Another option:

(3) leaving s->conf_mem as-is but implementing your own read function as
well that forwards to pci_host_conf_le_ops.read() to avoid this unusual
non-const MemoryRegionOps construct

But I guess Blue meant (2), which should be slightly more performant.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-01-11 12:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 21:44 [Qemu-devel] [RFC PATCH] PIIX: reset the VM when the Reset Control Register's RCPU bit gets set Laszlo Ersek
2013-01-09 21:01 ` Blue Swirl
2013-01-11  9:30   ` Laszlo Ersek
2013-01-11 12:10     ` Andreas Färber [this message]
2013-01-11 12:20   ` Laszlo Ersek
2013-01-12 12:13     ` Blue Swirl
2013-01-14 17:05       ` Laszlo Ersek
2013-01-14 17:54         ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F0014A.5050804@suse.de \
    --to=afaerber@suse.de \
    --cc=akong@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.