diff mbox

[2/2] xen_platform: SUSE xenlinux unplug for emulated PCI

Message ID 20160901121131.16007-3-olaf@aepfle.de (mailing list archive)
State New, archived
Headers show

Commit Message

Olaf Hering Sept. 1, 2016, 12:11 p.m. UTC
Implement SUSE specific unplug protocol for emulated PCI devices
in PVonHVM guests. Its a simple 'outl(1, (ioaddr + 4));'.
This protocol was implemented and used since Xen 3.0.4.
It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and
openSUSE 12.3.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

Comments

Konrad Rzeszutek Wilk Sept. 1, 2016, 11:55 p.m. UTC | #1
On Thu, Sep 01, 2016 at 02:11:31PM +0200, Olaf Hering wrote:
> Implement SUSE specific unplug protocol for emulated PCI devices
> in PVonHVM guests. Its a simple 'outl(1, (ioaddr + 4));'.
> This protocol was implemented and used since Xen 3.0.4.
> It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and
> openSUSE 12.3.

Should this be documented in the protocol?

> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>  hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
> index d94b53c..8802482 100644
> --- a/hw/i386/xen/xen_platform.c
> +++ b/hw/i386/xen/xen_platform.c
> @@ -314,13 +314,42 @@ static void xen_platform_ioport_writeb(void *opaque, hwaddr addr,
>                                         uint64_t val, unsigned int size)
>  {
>      PCIXenPlatformState *s = opaque;
> +    PCIDevice *pci_dev = PCI_DEVICE(s);
>  
>      switch (addr) {
>      case 0: /* Platform flags */
>          platform_fixed_ioport_writeb(opaque, 0, (uint32_t)val);
>          break;
> +    case 4:
> +        if (val == 1) {
> +            /*
> +             * SUSE unplug for Xenlinux
> +             * xen-kmp used this since xen-3.0.4, instead the official protocol from xen-3.3+
> +             * It did an unconditional "outl(1, (ioaddr + 4));"
> +             * Pre VMDP 1.7 made use of 4 and 8 depending on how VMDP was configured.
> +             * If VMDP was to control both disk and LAN it would use 4.
> +             * If it controlled just disk or just LAN, it would use 8 below.
> +             */
> +            blk_drain_all();
> +            blk_flush_all();
> +            pci_unplug_disks(pci_dev->bus);
> +            pci_unplug_nics(pci_dev->bus);
> +        }
> +        break;
>      case 8:
> -        log_writeb(s, (uint32_t)val);
> +        switch (val) {
> +        case 1:
> +            blk_drain_all();
> +            blk_flush_all();
> +            pci_unplug_disks(pci_dev->bus);
> +            break;
> +        case 2:
> +            pci_unplug_nics(pci_dev->bus);
> +            break;
> +        default:
> +            log_writeb(s, (uint32_t)val);
> +            break;
> +        }
>          break;
>      default:
>          break;
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
Stefano Stabellini Sept. 2, 2016, 1:57 a.m. UTC | #2
On Thu, 1 Sep 2016, Konrad Rzeszutek Wilk wrote:
> On Thu, Sep 01, 2016 at 02:11:31PM +0200, Olaf Hering wrote:
> > Implement SUSE specific unplug protocol for emulated PCI devices
> > in PVonHVM guests. Its a simple 'outl(1, (ioaddr + 4));'.
> > This protocol was implemented and used since Xen 3.0.4.
> > It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and
> > openSUSE 12.3.
> 
> Should this be documented in the protocol?

Yes, please. The file is docs/misc/hvm-emulated-unplug.markdown in the
Xen repository. Please also document the behavior with SCSI disks, which
is currently missing.


> > 
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > ---
> >  hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++-
> >  1 file changed, 30 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
> > index d94b53c..8802482 100644
> > --- a/hw/i386/xen/xen_platform.c
> > +++ b/hw/i386/xen/xen_platform.c
> > @@ -314,13 +314,42 @@ static void xen_platform_ioport_writeb(void *opaque, hwaddr addr,
> >                                         uint64_t val, unsigned int size)
> >  {
> >      PCIXenPlatformState *s = opaque;
> > +    PCIDevice *pci_dev = PCI_DEVICE(s);
> >  
> >      switch (addr) {
> >      case 0: /* Platform flags */
> >          platform_fixed_ioport_writeb(opaque, 0, (uint32_t)val);
> >          break;
> > +    case 4:
> > +        if (val == 1) {
> > +            /*
> > +             * SUSE unplug for Xenlinux
> > +             * xen-kmp used this since xen-3.0.4, instead the official protocol from xen-3.3+
> > +             * It did an unconditional "outl(1, (ioaddr + 4));"
> > +             * Pre VMDP 1.7 made use of 4 and 8 depending on how VMDP was configured.
> > +             * If VMDP was to control both disk and LAN it would use 4.
> > +             * If it controlled just disk or just LAN, it would use 8 below.
> > +             */
> > +            blk_drain_all();
> > +            blk_flush_all();
> > +            pci_unplug_disks(pci_dev->bus);
> > +            pci_unplug_nics(pci_dev->bus);
> > +        }
> > +        break;
> >      case 8:
> > -        log_writeb(s, (uint32_t)val);
> > +        switch (val) {
> > +        case 1:
> > +            blk_drain_all();
> > +            blk_flush_all();
> > +            pci_unplug_disks(pci_dev->bus);
> > +            break;
> > +        case 2:
> > +            pci_unplug_nics(pci_dev->bus);
> > +            break;
> > +        default:
> > +            log_writeb(s, (uint32_t)val);
> > +            break;
> > +        }
> >          break;
> >      default:
> >          break;
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > https://lists.xen.org/xen-devel
>
diff mbox

Patch

diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index d94b53c..8802482 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -314,13 +314,42 @@  static void xen_platform_ioport_writeb(void *opaque, hwaddr addr,
                                        uint64_t val, unsigned int size)
 {
     PCIXenPlatformState *s = opaque;
+    PCIDevice *pci_dev = PCI_DEVICE(s);
 
     switch (addr) {
     case 0: /* Platform flags */
         platform_fixed_ioport_writeb(opaque, 0, (uint32_t)val);
         break;
+    case 4:
+        if (val == 1) {
+            /*
+             * SUSE unplug for Xenlinux
+             * xen-kmp used this since xen-3.0.4, instead the official protocol from xen-3.3+
+             * It did an unconditional "outl(1, (ioaddr + 4));"
+             * Pre VMDP 1.7 made use of 4 and 8 depending on how VMDP was configured.
+             * If VMDP was to control both disk and LAN it would use 4.
+             * If it controlled just disk or just LAN, it would use 8 below.
+             */
+            blk_drain_all();
+            blk_flush_all();
+            pci_unplug_disks(pci_dev->bus);
+            pci_unplug_nics(pci_dev->bus);
+        }
+        break;
     case 8:
-        log_writeb(s, (uint32_t)val);
+        switch (val) {
+        case 1:
+            blk_drain_all();
+            blk_flush_all();
+            pci_unplug_disks(pci_dev->bus);
+            break;
+        case 2:
+            pci_unplug_nics(pci_dev->bus);
+            break;
+        default:
+            log_writeb(s, (uint32_t)val);
+            break;
+        }
         break;
     default:
         break;