qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 37/61] pci: add helper function for pci config w


From: Michael S. Tsirkin
Subject: [Qemu-devel] Re: [PATCH 37/61] pci: add helper function for pci config write function to check address.
Date: Wed, 30 Sep 2009 13:50:19 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

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 <address@hidden>
> ---
>  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
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]