qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] pci: improve w1c mask handling
@ 2010-10-27 14:05 Michael S. Tsirkin
  2010-10-28  2:02 ` [Qemu-devel] " Isaku Yamahata
  0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2010-10-27 14:05 UTC (permalink / raw)
  To: qemu-devel, yamahata

- save/restore must not check w1c bits
  since they are in fact guest controlled
- clear w1c bits on reset

Note: for express there are different kinds of
reset, some leave part of config space alone.
We will likely need a sticky bit mask to implement this.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Isaku, does the below make sense?

 hw/pci.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index e50de14..1a14a0e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -141,7 +141,8 @@ static void pci_device_reset(PCIDevice *dev)
     pci_update_irq_status(dev);
     /* Clear all writeable bits */
     pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
-                                 pci_get_word(dev->wmask + PCI_COMMAND));
+                                 pci_get_word(dev->wmask + PCI_COMMAND) |
+                                 pci_get_word(dev->w1cmask + PCI_COMMAND));
     dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
     dev->config[PCI_INTERRUPT_LINE] = 0x0;
     for (r = 0; r < PCI_NUM_REGIONS; ++r) {
@@ -293,7 +294,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
 
     qemu_get_buffer(f, config, size);
     for (i = 0; i < size; ++i) {
-        if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) {
+        if ((config[i] ^ s->config[i]) &
+            s->cmask[i] & ~s->wmask[i] & ~s->w1cmask) {
             qemu_free(config);
             return -EINVAL;
         }
-- 
1.7.3.2.91.g446ac

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] pci: improve w1c mask handling
  2010-10-27 14:05 [Qemu-devel] [PATCH] pci: improve w1c mask handling Michael S. Tsirkin
@ 2010-10-28  2:02 ` Isaku Yamahata
  2010-10-28  4:59   ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: Isaku Yamahata @ 2010-10-28  2:02 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

On Wed, Oct 27, 2010 at 04:05:58PM +0200, Michael S. Tsirkin wrote:
> - save/restore must not check w1c bits
>   since they are in fact guest controlled
> - clear w1c bits on reset
> 
> Note: for express there are different kinds of
> reset, some leave part of config space alone.
> We will likely need a sticky bit mask to implement this.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Isaku, does the below make sense?
> 
>  hw/pci.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index e50de14..1a14a0e 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -141,7 +141,8 @@ static void pci_device_reset(PCIDevice *dev)
>      pci_update_irq_status(dev);
>      /* Clear all writeable bits */
>      pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
> -                                 pci_get_word(dev->wmask + PCI_COMMAND));
> +                                 pci_get_word(dev->wmask + PCI_COMMAND) |
> +                                 pci_get_word(dev->w1cmask + PCI_COMMAND));
>      dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
>      dev->config[PCI_INTERRUPT_LINE] = 0x0;
>      for (r = 0; r < PCI_NUM_REGIONS; ++r) {
> @@ -293,7 +294,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
>  
>      qemu_get_buffer(f, config, size);
>      for (i = 0; i < size; ++i) {
> -        if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) {
> +        if ((config[i] ^ s->config[i]) &
> +            s->cmask[i] & ~s->wmask[i] & ~s->w1cmask) {

[i] is needed for w1cmask.
~s->w1cmask[i]
           ^^^



>              qemu_free(config);
>              return -EINVAL;
>          }
> -- 
> 1.7.3.2.91.g446ac
> 

-- 
yamahata

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] pci: improve w1c mask handling
  2010-10-28  2:02 ` [Qemu-devel] " Isaku Yamahata
@ 2010-10-28  4:59   ` Michael S. Tsirkin
  0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2010-10-28  4:59 UTC (permalink / raw)
  To: Isaku Yamahata; +Cc: qemu-devel

On Thu, Oct 28, 2010 at 11:02:48AM +0900, Isaku Yamahata wrote:
> On Wed, Oct 27, 2010 at 04:05:58PM +0200, Michael S. Tsirkin wrote:
> > - save/restore must not check w1c bits
> >   since they are in fact guest controlled
> > - clear w1c bits on reset
> > 
> > Note: for express there are different kinds of
> > reset, some leave part of config space alone.
> > We will likely need a sticky bit mask to implement this.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > 
> > Isaku, does the below make sense?
> > 
> >  hw/pci.c |    6 ++++--
> >  1 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/hw/pci.c b/hw/pci.c
> > index e50de14..1a14a0e 100644
> > --- a/hw/pci.c
> > +++ b/hw/pci.c
> > @@ -141,7 +141,8 @@ static void pci_device_reset(PCIDevice *dev)
> >      pci_update_irq_status(dev);
> >      /* Clear all writeable bits */
> >      pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
> > -                                 pci_get_word(dev->wmask + PCI_COMMAND));
> > +                                 pci_get_word(dev->wmask + PCI_COMMAND) |
> > +                                 pci_get_word(dev->w1cmask + PCI_COMMAND));
> >      dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
> >      dev->config[PCI_INTERRUPT_LINE] = 0x0;
> >      for (r = 0; r < PCI_NUM_REGIONS; ++r) {
> > @@ -293,7 +294,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
> >  
> >      qemu_get_buffer(f, config, size);
> >      for (i = 0; i < size; ++i) {
> > -        if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) {
> > +        if ((config[i] ^ s->config[i]) &
> > +            s->cmask[i] & ~s->wmask[i] & ~s->w1cmask) {
> 
> [i] is needed for w1cmask.
> ~s->w1cmask[i]
>            ^^^

Yes, I sent out a borken patch but it's correct on my branch.

> 
> 
> >              qemu_free(config);
> >              return -EINVAL;
> >          }
> > -- 
> > 1.7.3.2.91.g446ac
> > 
> 
> -- 
> yamahata

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-28  4:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-27 14:05 [Qemu-devel] [PATCH] pci: improve w1c mask handling Michael S. Tsirkin
2010-10-28  2:02 ` [Qemu-devel] " Isaku Yamahata
2010-10-28  4:59   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).