From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MsxjP-0000XT-DT for qemu-devel@nongnu.org; Wed, 30 Sep 2009 07:52:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MsxjK-0000Te-9f for qemu-devel@nongnu.org; Wed, 30 Sep 2009 07:52:26 -0400 Received: from [199.232.76.173] (port=34397 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MsxjJ-0000TK-Pz for qemu-devel@nongnu.org; Wed, 30 Sep 2009 07:52:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63158) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MsxjJ-0001pM-46 for qemu-devel@nongnu.org; Wed, 30 Sep 2009 07:52:21 -0400 Date: Wed, 30 Sep 2009 13:50:19 +0200 From: "Michael S. Tsirkin" Message-ID: <20090930115019.GK18802@redhat.com> References: <1254305917-14784-1-git-send-email-yamahata@valinux.co.jp> <1254305917-14784-38-git-send-email-yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1254305917-14784-38-git-send-email-yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH 37/61] pci: add helper function for pci config write function to check address. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: qemu-devel@nongnu.org On Wed, Sep 30, 2009 at 07:18:13PM +0900, Isaku Yamahata wrote: > add helper function for pci config write function to check address. > Those function will be used later. > > Signed-off-by: Isaku Yamahata > --- > hw/pci.h | 14 ++++++++++++++ > 1 files changed, 14 insertions(+), 0 deletions(-) > > diff --git a/hw/pci.h b/hw/pci.h > index 5cd882c..26c15c5 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > @@ -406,6 +406,20 @@ pci_config_get_quad(PCIDevice *d, uint32_t addr) > return pci_get_quad(&d->config[addr]); > } > > +static inline int pci_config_changed(uint32_t addr, uint32_t len, > + uint32_t base, uint32_t end) > +{ > + /* check if [addr, addr + len] intersects [base, end] */ > + return base <= addr + len && addr <= end; > +} > + > +static inline int pci_config_changed_with_size(uint32_t addr, uint32_t len, > + uint32_t base, uint32_t size) > +{ > + /* check if [addr, addr + len] intersects [base, base + size] */ > + return base <= addr + len && addr <= base + size; > +} > + This does not really check whether the value was changed: just that transaction touched it, the new value could be same as old. What I think we should do, is on each config access, store the previous config inside pci device structure. Then to see whether something changed, you just do a memcpy, or pci_get_word(d->orig) != pci_get_word(d->config), or anything you like, and no need for wrappers. > typedef int (*pci_qdev_initfn)(PCIDevice *dev); > typedef struct { > DeviceInfo qdev; > -- > 1.6.0.2 > >