diff mbox

[v17] Add pvpanic device driver

Message ID 1365146271-6220-1-git-send-email-hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao April 5, 2013, 7:17 a.m. UTC
pvpanic device is used to notify host(qemu) when guest panic happens.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---

No change from v16. qemu patches at:

http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg01028.html

 src/acpi.c        |  3 +++
 src/ssdt-misc.dsl | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

Comments

Paolo Bonzini April 30, 2013, 4 p.m. UTC | #1
Il 05/04/2013 09:17, Hu Tao ha scritto:
> pvpanic device is used to notify host(qemu) when guest panic happens.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
> 
> No change from v16. qemu patches at:
> 
> http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg01028.html

Ping.  The QEMU parts will be committed shortly.

Paolo
Kevin O'Connor May 1, 2013, 1:07 a.m. UTC | #2
On Tue, Apr 30, 2013 at 06:00:09PM +0200, Paolo Bonzini wrote:
> Il 05/04/2013 09:17, Hu Tao ha scritto:
> > pvpanic device is used to notify host(qemu) when guest panic happens.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> > ---
> > 
> > No change from v16. qemu patches at:
> > 
> > http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg01028.html
> 
> Ping.  The QEMU parts will be committed shortly.

Thanks.  I pushed this patch to SeaBIOS head.

-Kevin
Laszlo Ersek May 15, 2013, 7:21 a.m. UTC | #3
On 04/05/13 09:17, Hu Tao wrote:

> +            Method(RDPT, 0, NotSerialized) {
> +                Store(PEPT, Local0)
> +                Return (Local0)
> +            }
> +
> +            Method(WRPT, 1, NotSerialized) {
> +                Store(Arg0, PEPT)
> +            }

Please excuse my asking, I haven't been following this -- who's supposed
to call these methods? The latest guest kernel patch I managed to find
([PATCH v7] kvm: notify host when the guest is panicked -- probably
obsolete by now) appears to do a direct outl().

Thanks,
Laszlo
Hu Tao May 15, 2013, 7:27 a.m. UTC | #4
On Wed, May 15, 2013 at 09:21:54AM +0200, Laszlo Ersek wrote:
> On 04/05/13 09:17, Hu Tao wrote:
> 
> > +            Method(RDPT, 0, NotSerialized) {
> > +                Store(PEPT, Local0)
> > +                Return (Local0)
> > +            }
> > +
> > +            Method(WRPT, 1, NotSerialized) {
> > +                Store(Arg0, PEPT)
> > +            }
> 
> Please excuse my asking, I haven't been following this -- who's supposed
> to call these methods? The latest guest kernel patch I managed to find
> ([PATCH v7] kvm: notify host when the guest is panicked -- probably
> obsolete by now) appears to do a direct outl().

An old version calls WRPT but is buggy, so you see the outl version.
This patch is in seabios before the outl version. If you think these
methods are needless, feel free to send a patch.
Hu Tao May 15, 2013, 7:30 a.m. UTC | #5
On Wed, May 15, 2013 at 03:27:39PM +0800, Hu Tao wrote:
> On Wed, May 15, 2013 at 09:21:54AM +0200, Laszlo Ersek wrote:
> > On 04/05/13 09:17, Hu Tao wrote:
> > 
> > > +            Method(RDPT, 0, NotSerialized) {
> > > +                Store(PEPT, Local0)
> > > +                Return (Local0)
> > > +            }
> > > +
> > > +            Method(WRPT, 1, NotSerialized) {
> > > +                Store(Arg0, PEPT)
> > > +            }
> > 
> > Please excuse my asking, I haven't been following this -- who's supposed
> > to call these methods? The latest guest kernel patch I managed to find
> > ([PATCH v7] kvm: notify host when the guest is panicked -- probably
> > obsolete by now) appears to do a direct outl().
> 
> An old version calls WRPT but is buggy, so you see the outl version.
> This patch is in seabios before the outl version. If you think these
> methods are needless, feel free to send a patch.

I mean v19 by outl verson. Sorry for confusing.
Christian Borntraeger May 15, 2013, 7:32 a.m. UTC | #6
On 05/04/13 09:17, Hu Tao wrote:
> pvpanic device is used to notify host(qemu) when guest panic happens.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>

Another question: are you planning to provide libvirt support? Currently
I see the guest as paused after a crash. Since there is a crashed state in
libvirt it might make sense to use that. 

Christian
Laszlo Ersek May 15, 2013, 7:36 a.m. UTC | #7
On 05/15/13 09:27, Hu Tao wrote:
> On Wed, May 15, 2013 at 09:21:54AM +0200, Laszlo Ersek wrote:
>> On 04/05/13 09:17, Hu Tao wrote:
>>
>>> +            Method(RDPT, 0, NotSerialized) {
>>> +                Store(PEPT, Local0)
>>> +                Return (Local0)
>>> +            }
>>> +
>>> +            Method(WRPT, 1, NotSerialized) {
>>> +                Store(Arg0, PEPT)
>>> +            }
>>
>> Please excuse my asking, I haven't been following this -- who's supposed
>> to call these methods? The latest guest kernel patch I managed to find
>> ([PATCH v7] kvm: notify host when the guest is panicked -- probably
>> obsolete by now) appears to do a direct outl().
> 
> An old version calls WRPT but is buggy, so you see the outl version.
> This patch is in seabios before the outl version. If you think these
> methods are needless, feel free to send a patch.

Oh no, that's not what I meant! I'm just rounding up backport candidates :)

Thanks!
Laszlo
Hu Tao May 15, 2013, 7:36 a.m. UTC | #8
On Wed, May 15, 2013 at 09:32:40AM +0200, Christian Borntraeger wrote:
> On 05/04/13 09:17, Hu Tao wrote:
> > pvpanic device is used to notify host(qemu) when guest panic happens.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> 
> Another question: are you planning to provide libvirt support? Currently
> I see the guest as paused after a crash. Since there is a crashed state in
> libvirt it might make sense to use that. 

Yep, patch for libvirt is in progress.
Paolo Bonzini May 15, 2013, 4:25 p.m. UTC | #9
Il 15/05/2013 18:25, Laszlo Ersek ha scritto:
> (Not sure why the CC list has grown this huge, but I'm adding Drew for
> good mesaure.)
> 
> On 05/15/13 09:27, Hu Tao wrote:
>> On Wed, May 15, 2013 at 09:21:54AM +0200, Laszlo Ersek wrote:
>>> On 04/05/13 09:17, Hu Tao wrote:
>>>
>>>> +            Method(RDPT, 0, NotSerialized) {
>>>> +                Store(PEPT, Local0)
>>>> +                Return (Local0)
>>>> +            }
>>>> +
>>>> +            Method(WRPT, 1, NotSerialized) {
>>>> +                Store(Arg0, PEPT)
>>>> +            }
>>>
>>> Please excuse my asking, I haven't been following this -- who's supposed
>>> to call these methods? The latest guest kernel patch I managed to find
>>> ([PATCH v7] kvm: notify host when the guest is panicked -- probably
>>> obsolete by now) appears to do a direct outl().
>>
>> An old version calls WRPT but is buggy, so you see the outl version.
>> This patch is in seabios before the outl version. If you think these
>> methods are needless, feel free to send a patch.
> 
> After Drew located the guest kernel commit for me,
> 
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=8b10acd7
> 
> I can see this SeaBIOS patch *is* necessary -- even though the RDPT /
> WRPT methods are not used for port access, the port number itself is
> available from ACPI (\_SB.PCI0.ISA.PEVT._CRS, identified by the
> "QEMU0001" HID) to the kernel.
> 
> Hu, can you (and are you willing to) relicense this commit (seabios
> commit e9725dd7) under the 2-clause BSDL so I can port it to OVMF?
> 
> (Actually I'm somewhat confused because the first S-o-b is from Paolo.
> Since I share an employer with Paolo, getting permission from Paolo
> would be either quite easy or even unnecessary. Anyway it's better to ask!)

I and Hu did half of the patch each. :)

But I think it's simpler to avoid OVMF and wait for the time when QEMU
will produce the ACPI tables.

Paolo
Laszlo Ersek May 15, 2013, 4:25 p.m. UTC | #10
(Not sure why the CC list has grown this huge, but I'm adding Drew for
good mesaure.)

On 05/15/13 09:27, Hu Tao wrote:
> On Wed, May 15, 2013 at 09:21:54AM +0200, Laszlo Ersek wrote:
>> On 04/05/13 09:17, Hu Tao wrote:
>>
>>> +            Method(RDPT, 0, NotSerialized) {
>>> +                Store(PEPT, Local0)
>>> +                Return (Local0)
>>> +            }
>>> +
>>> +            Method(WRPT, 1, NotSerialized) {
>>> +                Store(Arg0, PEPT)
>>> +            }
>>
>> Please excuse my asking, I haven't been following this -- who's supposed
>> to call these methods? The latest guest kernel patch I managed to find
>> ([PATCH v7] kvm: notify host when the guest is panicked -- probably
>> obsolete by now) appears to do a direct outl().
> 
> An old version calls WRPT but is buggy, so you see the outl version.
> This patch is in seabios before the outl version. If you think these
> methods are needless, feel free to send a patch.

After Drew located the guest kernel commit for me,

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=8b10acd7

I can see this SeaBIOS patch *is* necessary -- even though the RDPT /
WRPT methods are not used for port access, the port number itself is
available from ACPI (\_SB.PCI0.ISA.PEVT._CRS, identified by the
"QEMU0001" HID) to the kernel.

Hu, can you (and are you willing to) relicense this commit (seabios
commit e9725dd7) under the 2-clause BSDL so I can port it to OVMF?

(Actually I'm somewhat confused because the first S-o-b is from Paolo.
Since I share an employer with Paolo, getting permission from Paolo
would be either quite easy or even unnecessary. Anyway it's better to ask!)

Thanks,
Laszlo
Laszlo Ersek May 15, 2013, 4:34 p.m. UTC | #11
On 05/15/13 18:25, Paolo Bonzini wrote:
> Il 15/05/2013 18:25, Laszlo Ersek ha scritto:
>> (Not sure why the CC list has grown this huge, but I'm adding Drew for
>> good mesaure.)
>>
>> On 05/15/13 09:27, Hu Tao wrote:
>>> On Wed, May 15, 2013 at 09:21:54AM +0200, Laszlo Ersek wrote:
>>>> On 04/05/13 09:17, Hu Tao wrote:
>>>>
>>>>> +            Method(RDPT, 0, NotSerialized) {
>>>>> +                Store(PEPT, Local0)
>>>>> +                Return (Local0)
>>>>> +            }
>>>>> +
>>>>> +            Method(WRPT, 1, NotSerialized) {
>>>>> +                Store(Arg0, PEPT)
>>>>> +            }
>>>>
>>>> Please excuse my asking, I haven't been following this -- who's supposed
>>>> to call these methods? The latest guest kernel patch I managed to find
>>>> ([PATCH v7] kvm: notify host when the guest is panicked -- probably
>>>> obsolete by now) appears to do a direct outl().
>>>
>>> An old version calls WRPT but is buggy, so you see the outl version.
>>> This patch is in seabios before the outl version. If you think these
>>> methods are needless, feel free to send a patch.
>>
>> After Drew located the guest kernel commit for me,
>>
>> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=8b10acd7
>>
>> I can see this SeaBIOS patch *is* necessary -- even though the RDPT /
>> WRPT methods are not used for port access, the port number itself is
>> available from ACPI (\_SB.PCI0.ISA.PEVT._CRS, identified by the
>> "QEMU0001" HID) to the kernel.
>>
>> Hu, can you (and are you willing to) relicense this commit (seabios
>> commit e9725dd7) under the 2-clause BSDL so I can port it to OVMF?
>>
>> (Actually I'm somewhat confused because the first S-o-b is from Paolo.
>> Since I share an employer with Paolo, getting permission from Paolo
>> would be either quite easy or even unnecessary. Anyway it's better to ask!)
> 
> I and Hu did half of the patch each. :)
> 
> But I think it's simpler to avoid OVMF and wait for the time when QEMU
> will produce the ACPI tables.

That's fine by me; thanks.
Laszlo
diff mbox

Patch

diff --git a/src/acpi.c b/src/acpi.c
index bc4d8ea..fe504f0 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -534,6 +534,9 @@  build_ssdt(void)
         ssdt_ptr[acpi_pci64_valid[0]] = 0;
     }
 
+    int pvpanic_port = romfile_loadint("etc/pvpanic-port", 0x0);
+    *(u16 *)(ssdt_ptr + *ssdt_isa_pest) = pvpanic_port;
+
     ssdt_ptr += sizeof(ssdp_misc_aml);
 
     // build Scope(_SB_) header
diff --git a/src/ssdt-misc.dsl b/src/ssdt-misc.dsl
index 679422b..acc850e 100644
--- a/src/ssdt-misc.dsl
+++ b/src/ssdt-misc.dsl
@@ -55,4 +55,50 @@  DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
             Zero   /* reserved */
         })
     }
+
+    External(\_SB.PCI0, DeviceObj)
+    External(\_SB.PCI0.ISA, DeviceObj)
+
+    Scope(\_SB.PCI0.ISA) {
+        Device(PEVT) {
+            Name(_HID, "QEMU0001")
+            /* PEST will be patched to be Zero if no such device */
+            ACPI_EXTRACT_NAME_WORD_CONST ssdt_isa_pest
+            Name(PEST, 0xFFFF)
+            OperationRegion(PEOR, SystemIO, PEST, 0x01)
+            Field(PEOR, ByteAcc, NoLock, Preserve) {
+                PEPT,   8,
+            }
+
+            Method(_STA, 0, NotSerialized) {
+                Store(PEST, Local0)
+                If (LEqual(Local0, Zero)) {
+                    Return (0x00)
+                } Else {
+                    Return (0x0F)
+                }
+            }
+
+            Method(RDPT, 0, NotSerialized) {
+                Store(PEPT, Local0)
+                Return (Local0)
+            }
+
+            Method(WRPT, 1, NotSerialized) {
+                Store(Arg0, PEPT)
+            }
+
+            Name(_CRS, ResourceTemplate() {
+                IO(Decode16, 0x00, 0x00, 0x01, 0x01, IO)
+            })
+
+            CreateWordField(_CRS, IO._MIN, IOMN)
+            CreateWordField(_CRS, IO._MAX, IOMX)
+
+            Method(_INI, 0, NotSerialized) {
+                Store(PEST, IOMN)
+                Store(PEST, IOMX)
+            }
+        }
+    }
 }