From: Laszlo Ersek <lersek@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, imammedo@redhat.com, mst@redhat.com,
dgilbert@redhat.com, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 1/2] acpi-dsdt: procedurally generate _PRT
Date: Wed, 23 Jul 2014 21:27:44 +0200 [thread overview]
Message-ID: <53D00CB0.7050206@redhat.com> (raw)
In-Reply-To: <1406133466-1824-2-git-send-email-pbonzini@redhat.com>
On 07/23/14 18:37, Paolo Bonzini wrote:
> This replaces the _PRT constant with a method that computes it.
>
> The problem is that the DSDT+SSDT have grown from 2.0 to 2.1,
> enough to cross the 8k barrier (we align the ACPI tables to 4k
> before putting them in fw_cfg). This causes problems with
> migration and the pc-2.0 machine type.
>
> The solution to the problem is to hardcode 64k as the limit,
> but this doesn't solve the bug with pc-2.0. The fix will be
> for QEMU 2.1 to use exactly the same size as QEMU 2.0 for the
> ACPI tables. First, however, we must make the actual AML size
> equal or smaller; to do this, rewrite _PRT in a way that saves
> over 1k of bytecode.
>
> Tested on Windows XP. Q35 already uses a method for _PRT
> so most guests should be okay.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/i386/acpi-dsdt.dsl | 90 ++++++++++++++++++++++-----------------------------
> 1 file changed, 39 insertions(+), 51 deletions(-)
>
> diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> index 3cc0ea0..6ba0170 100644
> --- a/hw/i386/acpi-dsdt.dsl
> +++ b/hw/i386/acpi-dsdt.dsl
> @@ -181,57 +181,45 @@ DefinitionBlock (
>
> Scope(\_SB) {
> Scope(PCI0) {
> - Name(_PRT, Package() {
> - /* PCI IRQ routing table, example from ACPI 2.0a specification,
> - section 6.2.8.1 */
> - /* Note: we provide the same info as the PCI routing
> - table of the Bochs BIOS */
> -
> -#define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
> - Package() { nr##ffff, 0, lnk0, 0 }, \
> - Package() { nr##ffff, 1, lnk1, 0 }, \
> - Package() { nr##ffff, 2, lnk2, 0 }, \
> - Package() { nr##ffff, 3, lnk3, 0 }
> -
> -#define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
> -#define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
> -#define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
> -#define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
> -
> - prt_slot0(0x0000),
> - /* Device 1 is power mgmt device, and can only use irq 9 */
> - prt_slot(0x0001, LNKS, LNKB, LNKC, LNKD),
> - prt_slot2(0x0002),
> - prt_slot3(0x0003),
> - prt_slot0(0x0004),
> - prt_slot1(0x0005),
> - prt_slot2(0x0006),
> - prt_slot3(0x0007),
> - prt_slot0(0x0008),
> - prt_slot1(0x0009),
> - prt_slot2(0x000a),
> - prt_slot3(0x000b),
> - prt_slot0(0x000c),
> - prt_slot1(0x000d),
> - prt_slot2(0x000e),
> - prt_slot3(0x000f),
> - prt_slot0(0x0010),
> - prt_slot1(0x0011),
> - prt_slot2(0x0012),
> - prt_slot3(0x0013),
> - prt_slot0(0x0014),
> - prt_slot1(0x0015),
> - prt_slot2(0x0016),
> - prt_slot3(0x0017),
> - prt_slot0(0x0018),
> - prt_slot1(0x0019),
> - prt_slot2(0x001a),
> - prt_slot3(0x001b),
> - prt_slot0(0x001c),
> - prt_slot1(0x001d),
> - prt_slot2(0x001e),
> - prt_slot3(0x001f),
> - })
> + Method (_PRT, 0) {
> + Store(Package(128) {}, Local0)
> + Store(Zero, Local1)
> + While(LLess(Local1, 128)) {
> + // slot = pin >> 2
> + Store(ShiftRight(Local1, 2), Local2)
> +
> + // lnk = (slot + pin) & 3
> + Store(And(Add(Local1, Local2), 3), Local3)
> + If (LEqual(Local3, 0)) {
> + Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
> + }
> + If (LEqual(Local3, 1)) {
> + // device 1 is the power-management device, needs SCI
> + If (LEqual(Local1, 4)) {
> + Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
> + } Else {
> + Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
> + }
> + }
> + If (LEqual(Local3, 2)) {
> + Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
> + }
> + If (LEqual(Local3, 3)) {
> + Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
> + }
> +
> + // Complete the interrupt routing entry:
> + // Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
> +
> + Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
> + Store(And(Local1, 3), Index(Local4, 1))
> + Store(Local4, Index(Local0, Local1))
> +
> + Increment(Local1)
> + }
> +
> + Return(Local0)
> + }
> }
>
> Field(PCI0.ISA.P40C, ByteAcc, NoLock, Preserve) {
>
Awesome!
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(In this case you might consider a "tested-by" more useful, but I can't
promise to help in that regard.)
next prev parent reply other threads:[~2014-07-23 19:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 16:37 [Qemu-devel] [PATCH 0/2] pc: fix /etc/acpi/tables size in fw_cfg for -M pc-2.0 Paolo Bonzini
2014-07-23 16:37 ` [Qemu-devel] [PATCH 1/2] acpi-dsdt: procedurally generate _PRT Paolo Bonzini
2014-07-23 19:27 ` Laszlo Ersek [this message]
2014-07-24 8:22 ` Igor Mammedov
2014-07-23 16:37 ` [Qemu-devel] [PATCH 2/2] pc: hack for migration compatibility from QEMU 2.0 Paolo Bonzini
2014-07-23 19:34 ` Laszlo Ersek
2014-07-24 8:59 ` Igor Mammedov
2014-07-24 14:28 ` Paolo Bonzini
2014-07-24 15:22 ` [Qemu-devel] [PATCH 0/2] pc: fix /etc/acpi/tables size in fw_cfg for -M pc-2.0 Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53D00CB0.7050206@redhat.com \
--to=lersek@redhat.com \
--cc=amit.shah@redhat.com \
--cc=dgilbert@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.