All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] qemu-kvm BIOS move _PR to SSDT
@ 2009-06-10 15:01 Jes Sorensen
  2009-06-10 15:13 ` Gleb Natapov
  0 siblings, 1 reply; 4+ messages in thread
From: Jes Sorensen @ 2009-06-10 15:01 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

Hi,

Per Avi's request, here's a patch which moves the current _PR section
from the DSDT table into a new SSDT table.

The long term idea is to be able to have multiple different SSDTs for
different sized systems, and in particular allow to keep the legacy one
for supporting legacy operating systems which cannot handle more then 15
vcpus.

Cheers,
Jes


[-- Attachment #2: 0001-qemu-kvm-ssdt.patch --]
[-- Type: text/x-patch, Size: 11507 bytes --]

Move _PR block from the DSDT to a new SSDT in the KVM BIOS.

This will make it possible to plug in different SSDTs with different
processor counts in the future.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 kvm/bios/Makefile      |   10 ++-
 kvm/bios/acpi-dsdt.dsl |  115 ----------------------------------------
 kvm/bios/acpi-ssdt.dsl |  140 +++++++++++++++++++++++++++++++++++++++++++++++++
 kvm/bios/rombios32.c   |   16 ++++-
 4 files changed, 162 insertions(+), 119 deletions(-)

Index: qemu-kvm/kvm/bios/Makefile
===================================================================
--- qemu-kvm.orig/kvm/bios/Makefile
+++ qemu-kvm/kvm/bios/Makefile
@@ -108,13 +108,19 @@ rombios32.bin: rombios32.out rombios.h
 rombios32.out: rombios32start.o rombios32.o vapic.o rombios32.ld
 	ld -o $@ -T rombios32.ld rombios32start.o vapic.o rombios32.o
 
-rombios32.o: rombios32.c acpi-dsdt.hex
+rombios32.o: rombios32.c acpi-dsdt.hex acpi-ssdt.hex
 	$(GCC) -m32 -O2 -Wall -c -o $@ $<
 
 acpi-dsdt.hex: acpi-dsdt.dsl
 	cpp -P $< $<.i
 	iasl -tc -p $@ $<.i
-	sed -i -e's/^unsigned/const unsigned/' $@
+	sed -i -e's/^unsigned char AmlCode/const unsigned char DSDTCode/' $@
+	rm $<.i
+
+acpi-ssdt.hex: acpi-ssdt.dsl
+	cpp -P $< $<.i
+	iasl -tc -p $@ $<.i
+	sed -i -e's/^unsigned char AmlCode/const unsigned char SSDTCode/' $@
 	rm $<.i
 
 rombios32start.o: rombios32start.S
Index: qemu-kvm/kvm/bios/acpi-dsdt.dsl
===================================================================
--- qemu-kvm.orig/kvm/bios/acpi-dsdt.dsl
+++ qemu-kvm/kvm/bios/acpi-dsdt.dsl
@@ -25,119 +25,6 @@ DefinitionBlock (
     0x1                 // OEM Revision
     )
 {
-   Scope (\_PR)
-   {
-	/* pointer to first element of MADT APIC structures */
-	OperationRegion(ATPR, SystemMemory, 0x0514, 4)
-	Field (ATPR, DwordAcc, NoLock, Preserve)
-	{
-		ATP, 32
-	}
-
-#define madt_addr(nr)  Add (ATP, Multiply(nr, 8))
-
-#define gen_processor(nr, name) 				            \
-	Processor (CPU##name, nr, 0x0000b010, 0x06) {                       \
-	    OperationRegion (MATR, SystemMemory, madt_addr(nr), 8)          \
-	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
-	    {                                                               \
-	        MAT, 64                                                     \
-	    }                                                               \
-	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
-	    {                                                               \
-	        Offset(4),                                                  \
-	        FLG, 1                                                      \
-	    }                                                               \
-            Method(_MAT, 0) {                                               \
-		Return(MAT)                                                 \
-            }                                                               \
-            Method (_STA) {                                                 \
-                If (FLG) { Return(0xF) } Else { Return(0x9) }               \
-            }                                                               \
-        }                                                                   \
-
-
-	gen_processor(0, 0)
-	gen_processor(1, 1)
-	gen_processor(2, 2)
-	gen_processor(3, 3)
-	gen_processor(4, 4)
-	gen_processor(5, 5)
-	gen_processor(6, 6)
-	gen_processor(7, 7)
-	gen_processor(8, 8)
-	gen_processor(9, 9)
-	gen_processor(10, A)
-	gen_processor(11, B)
-	gen_processor(12, C)
-	gen_processor(13, D)
-	gen_processor(14, E)
-
-	Method (NTFY, 2) {
-#define gen_ntfy(nr)                                        \
-	If (LEqual(Arg0, 0x##nr)) {                         \
-		If (LNotEqual(Arg1, \_PR.CPU##nr.FLG)) {    \
-			Store (Arg1, \_PR.CPU##nr.FLG)      \
-			If (LEqual(Arg1, 1)) {              \
-				Notify(CPU##nr, 1)          \
-			} Else {                            \
-				Notify(CPU##nr, 3)          \
-			}                                   \
-		}                                           \
-	}
-		gen_ntfy(0)
-		gen_ntfy(1)
-		gen_ntfy(2)
-		gen_ntfy(3)
-		gen_ntfy(4)
-		gen_ntfy(5)
-		gen_ntfy(6)
-		gen_ntfy(7)
-		gen_ntfy(8)
-		gen_ntfy(9)
-		gen_ntfy(A)
-		gen_ntfy(B)
-		gen_ntfy(C)
-		gen_ntfy(D)
-		gen_ntfy(E)
-		Return(One)
-	}
-
-	OperationRegion(PRST, SystemIO, 0xaf00, 32)
-	Field (PRST, ByteAcc, NoLock, Preserve)
-	{
-		PRS, 256
-	}
-
-	Method(PRSC, 0) {
-		Store(PRS, Local3)
-		Store(Zero, Local0)
-		While(LLess(Local0, 32)) {
-			Store(Zero, Local1)
-			Store(DerefOf(Index(Local3, Local0)), Local2)
-			While(LLess(Local1, 8)) {
-				NTFY(Add(Multiply(Local0, 8), Local1),
-						And(Local2, 1))
-				ShiftRight(Local2, 1, Local2)
-				Increment(Local1)
-			}
-			Increment(Local0)
-		}
-		Return(One)
-	}
-    }
-
-    Scope (\)
-    {
-        /* Debug Output */
-        OperationRegion (DBG, SystemIO, 0xb044, 0x04)
-        Field (DBG, DWordAcc, NoLock, Preserve)
-        {
-            DBGL,   32,
-        }
-    }
-
-
     /* PCI Bus definition */
     Scope(\_SB) {
         Device(PCI0) {
@@ -803,6 +690,8 @@ DefinitionBlock (
             Return(0x01)
         }
 
+	External(\_PR.PRSC, MethodObj, IntObj)
+
         Method(_L02) {
 	    Return(\_PR.PRSC())
         }
Index: qemu-kvm/kvm/bios/acpi-ssdt.dsl
===================================================================
--- /dev/null
+++ qemu-kvm/kvm/bios/acpi-ssdt.dsl
@@ -0,0 +1,140 @@
+/*
+ * Bochs/QEMU ACPI SSDT ASL definition
+ *
+ * Copyright (c) 2006 Fabrice Bellard
+ * Copyright (c) 2009 SGI, Jes Sorensen <jes@sgi.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+DefinitionBlock (
+    "acpi-ssdt.aml",    // Output Filename
+    "SSDT",             // Signature
+    0x01,               // DSDT Compliance Revision
+    "BXPC",             // OEMID
+    "BXSSDT",           // TABLE ID
+    0x1                 // OEM Revision
+    )
+{
+   Scope (\_PR)
+   {
+	/* pointer to first element of MADT APIC structures */
+	OperationRegion(ATPR, SystemMemory, 0x0514, 4)
+	Field (ATPR, DwordAcc, NoLock, Preserve)
+	{
+		ATP, 32
+	}
+
+#define madt_addr(nr)  Add (ATP, Multiply(nr, 8))
+
+#define gen_processor(nr, name) 				            \
+	Processor (C##name, nr, 0x0000b010, 0x06) {                       \
+	    OperationRegion (MATR, SystemMemory, madt_addr(nr), 8)          \
+	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
+	    {                                                               \
+	        MAT, 64                                                     \
+	    }                                                               \
+	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
+	    {                                                               \
+	        Offset(4),                                                  \
+	        FLG, 1                                                      \
+	    }                                                               \
+            Method(_MAT, 0) {                                               \
+		Return(MAT)                                                 \
+            }                                                               \
+            Method (_STA) {                                                 \
+                If (FLG) { Return(0xF) } Else { Return(0x9) }               \
+            }                                                               \
+        }                                                                   \
+
+
+	gen_processor(0, 0)
+	gen_processor(1, 1)
+	gen_processor(2, 2)
+	gen_processor(3, 3)
+	gen_processor(4, 4)
+	gen_processor(5, 5)
+	gen_processor(6, 6)
+	gen_processor(7, 7)
+	gen_processor(8, 8)
+	gen_processor(9, 9)
+	gen_processor(10, A)
+	gen_processor(11, B)
+	gen_processor(12, C)
+	gen_processor(13, D)
+	gen_processor(14, E)
+
+	Method (NTFY, 2) {
+#define gen_ntfy(nr)                                        \
+	If (LEqual(Arg0, 0x##nr)) {                         \
+		If (LNotEqual(Arg1, \_PR.C##nr.FLG)) {      \
+			Store (Arg1, \_PR.C##nr.FLG)        \
+			If (LEqual(Arg1, 1)) {              \
+				Notify(C##nr, 1)            \
+			} Else {                            \
+				Notify(C##nr, 3)            \
+			}                                   \
+		}                                           \
+	}
+		gen_ntfy(0)
+		gen_ntfy(1)
+		gen_ntfy(2)
+		gen_ntfy(3)
+		gen_ntfy(4)
+		gen_ntfy(5)
+		gen_ntfy(6)
+		gen_ntfy(7)
+		gen_ntfy(8)
+		gen_ntfy(9)
+		gen_ntfy(A)
+		gen_ntfy(B)
+		gen_ntfy(C)
+		gen_ntfy(D)
+		gen_ntfy(E)
+		Return(One)
+	}
+
+	OperationRegion(PRST, SystemIO, 0xaf00, 32)
+	Field (PRST, ByteAcc, NoLock, Preserve)
+	{
+		PRS, 256
+	}
+
+	Method(PRSC, 0) {
+		Store(PRS, Local3)
+		Store(Zero, Local0)
+		While(LLess(Local0, 32)) {
+			Store(Zero, Local1)
+			Store(DerefOf(Index(Local3, Local0)), Local2)
+			While(LLess(Local1, 8)) {
+				NTFY(Add(Multiply(Local0, 8), Local1),
+						And(Local2, 1))
+				ShiftRight(Local2, 1, Local2)
+				Increment(Local1)
+			}
+			Increment(Local0)
+		}
+		Return(One)
+	}
+    }
+
+    Scope (\)
+    {
+        /* Debug Output */
+        OperationRegion (DBG, SystemIO, 0xb044, 0x04)
+        Field (DBG, DWordAcc, NoLock, Preserve)
+        {
+            DBGL,   32,
+        }
+    }
+}
Index: qemu-kvm/kvm/bios/rombios32.c
===================================================================
--- qemu-kvm.orig/kvm/bios/rombios32.c
+++ qemu-kvm/kvm/bios/rombios32.c
@@ -1526,6 +1526,7 @@ struct madt_int_override
 #endif
 
 #include "acpi-dsdt.hex"
+#include "acpi-ssdt.hex"
 
 static inline uint16_t cpu_to_le16(uint16_t x)
 {
@@ -1641,7 +1642,12 @@ void acpi_bios_init(void)
 
     dsdt_addr = addr;
     dsdt = (void *)(addr);
-    addr += sizeof(AmlCode);
+    addr += sizeof(DSDTCode);
+
+    addr = (addr + 7) & ~7;
+    ssdt_addr = addr;
+    ssdt = (void *)(addr);
+    addr += sizeof(SSDTCode);
 
 #ifdef BX_QEMU
     qemu_cfg_select(QEMU_CFG_NUMA);
@@ -1727,7 +1733,10 @@ void acpi_bios_init(void)
     BX_INFO("Firmware waking vector %p\n", &facs->firmware_waking_vector);
 
     /* DSDT */
-    memcpy(dsdt, AmlCode, sizeof(AmlCode));
+    memcpy(dsdt, DSDTCode, sizeof(DSDTCode));
+
+    /* SSDT */
+    memcpy(ssdt, SSDTCode, sizeof(SSDTCode));
 
     /* MADT */
     {
@@ -1884,8 +1893,7 @@ void acpi_bios_init(void)
     /* RSDT */
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(fadt_addr);
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(madt_addr);
-    /* kvm has no ssdt (processors are in dsdt) */
-//  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
+    rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
 #ifdef BX_QEMU
     /* No HPET (yet) */
 //  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(hpet_addr);

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

* Re: [patch] qemu-kvm BIOS move _PR to SSDT
  2009-06-10 15:01 [patch] qemu-kvm BIOS move _PR to SSDT Jes Sorensen
@ 2009-06-10 15:13 ` Gleb Natapov
  2009-06-10 15:30   ` Jes Sorensen
  0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2009-06-10 15:13 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Avi Kivity, kvm

On Wed, Jun 10, 2009 at 05:01:18PM +0200, Jes Sorensen wrote:
> Index: qemu-kvm/kvm/bios/acpi-ssdt.dsl
> ===================================================================
> --- /dev/null
> +++ qemu-kvm/kvm/bios/acpi-ssdt.dsl
> @@ -0,0 +1,140 @@
> +/*
> + * Bochs/QEMU ACPI SSDT ASL definition
> + *
> + * Copyright (c) 2006 Fabrice Bellard
I am not sure that there is even one bit of code below written by Fabrice.

> + * Copyright (c) 2009 SGI, Jes Sorensen <jes@sgi.com>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License version 2 as published by the Free Software Foundation.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
> + */
> +DefinitionBlock (
> +    "acpi-ssdt.aml",    // Output Filename
> +    "SSDT",             // Signature
> +    0x01,               // DSDT Compliance Revision
> +    "BXPC",             // OEMID
> +    "BXSSDT",           // TABLE ID
> +    0x1                 // OEM Revision
> +    )
> +{
> +   Scope (\_PR)
> +   {
> +	/* pointer to first element of MADT APIC structures */
> +	OperationRegion(ATPR, SystemMemory, 0x0514, 4)
> +	Field (ATPR, DwordAcc, NoLock, Preserve)
> +	{
> +		ATP, 32
> +	}
> +
> +#define madt_addr(nr)  Add (ATP, Multiply(nr, 8))
> +
> +#define gen_processor(nr, name) 				            \
> +	Processor (C##name, nr, 0x0000b010, 0x06) {                       \
> +	    OperationRegion (MATR, SystemMemory, madt_addr(nr), 8)          \
> +	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
> +	    {                                                               \
> +	        MAT, 64                                                     \
> +	    }                                                               \
> +	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
> +	    {                                                               \
> +	        Offset(4),                                                  \
> +	        FLG, 1                                                      \
> +	    }                                                               \
> +            Method(_MAT, 0) {                                               \
> +		Return(MAT)                                                 \
> +            }                                                               \
> +            Method (_STA) {                                                 \
> +                If (FLG) { Return(0xF) } Else { Return(0x9) }               \
> +            }                                                               \
> +        }                                                                   \
> +
> +
> +	gen_processor(0, 0)
> +	gen_processor(1, 1)
> +	gen_processor(2, 2)
> +	gen_processor(3, 3)
> +	gen_processor(4, 4)
> +	gen_processor(5, 5)
> +	gen_processor(6, 6)
> +	gen_processor(7, 7)
> +	gen_processor(8, 8)
> +	gen_processor(9, 9)
> +	gen_processor(10, A)
> +	gen_processor(11, B)
> +	gen_processor(12, C)
> +	gen_processor(13, D)
> +	gen_processor(14, E)
> +
> +	Method (NTFY, 2) {
> +#define gen_ntfy(nr)                                        \
> +	If (LEqual(Arg0, 0x##nr)) {                         \
> +		If (LNotEqual(Arg1, \_PR.C##nr.FLG)) {      \
> +			Store (Arg1, \_PR.C##nr.FLG)        \
> +			If (LEqual(Arg1, 1)) {              \
> +				Notify(C##nr, 1)            \
> +			} Else {                            \
> +				Notify(C##nr, 3)            \
> +			}                                   \
> +		}                                           \
> +	}
> +		gen_ntfy(0)
> +		gen_ntfy(1)
> +		gen_ntfy(2)
> +		gen_ntfy(3)
> +		gen_ntfy(4)
> +		gen_ntfy(5)
> +		gen_ntfy(6)
> +		gen_ntfy(7)
> +		gen_ntfy(8)
> +		gen_ntfy(9)
> +		gen_ntfy(A)
> +		gen_ntfy(B)
> +		gen_ntfy(C)
> +		gen_ntfy(D)
> +		gen_ntfy(E)
> +		Return(One)
> +	}
> +
> +	OperationRegion(PRST, SystemIO, 0xaf00, 32)
> +	Field (PRST, ByteAcc, NoLock, Preserve)
> +	{
> +		PRS, 256
> +	}
> +
> +	Method(PRSC, 0) {
> +		Store(PRS, Local3)
> +		Store(Zero, Local0)
> +		While(LLess(Local0, 32)) {
> +			Store(Zero, Local1)
> +			Store(DerefOf(Index(Local3, Local0)), Local2)
> +			While(LLess(Local1, 8)) {
> +				NTFY(Add(Multiply(Local0, 8), Local1),
> +						And(Local2, 1))
> +				ShiftRight(Local2, 1, Local2)
> +				Increment(Local1)
> +			}
> +			Increment(Local0)
> +		}
> +		Return(One)
> +	}
> +    }
> +
> +    Scope (\)
> +    {
> +        /* Debug Output */
> +        OperationRegion (DBG, SystemIO, 0xb044, 0x04)
> +        Field (DBG, DWordAcc, NoLock, Preserve)
> +        {
> +            DBGL,   32,
> +        }
> +    }
Except may be this one, but it should stay in DSDT.

--
			Gleb.

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

* Re: [patch] qemu-kvm BIOS move _PR to SSDT
  2009-06-10 15:13 ` Gleb Natapov
@ 2009-06-10 15:30   ` Jes Sorensen
  2009-06-10 16:15     ` Gleb Natapov
  0 siblings, 1 reply; 4+ messages in thread
From: Jes Sorensen @ 2009-06-10 15:30 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: Avi Kivity, kvm

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

On 06/10/2009 05:13 PM, Gleb Natapov wrote:
>> + * Bochs/QEMU ACPI SSDT ASL definition
>> + *
>> + * Copyright (c) 2006 Fabrice Bellard
> I am not sure that there is even one bit of code below written by Fabrice.

Well better safe than sorry, since I copied over a bunch of stuff,
I figured it was simpler to just leave it intact.

>> +    Scope (\)
>> +    {
>> +        /* Debug Output */
>> +        OperationRegion (DBG, SystemIO, 0xb044, 0x04)
>> +        Field (DBG, DWordAcc, NoLock, Preserve)
>> +        {
>> +            DBGL,   32,
>> +        }
>> +    }
> Except may be this one, but it should stay in DSDT.

Hmmm, good point. I think I just moved it when I had zero idea what was
going on at first in this AML hell :-)

Try this one.

Cheers,
Jes

[-- Attachment #2: 0001-qemu-kvm-ssdt.patch --]
[-- Type: text/x-patch, Size: 11194 bytes --]

Move _PR block from the DSDT to a new SSDT in the KVM BIOS.

This will make it possible to plug in different SSDTs with different
processor counts in the future.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 kvm/bios/Makefile      |   10 +++
 kvm/bios/acpi-dsdt.dsl |  105 ---------------------------------------
 kvm/bios/acpi-ssdt.dsl |  130 +++++++++++++++++++++++++++++++++++++++++++++++++
 kvm/bios/rombios32.c   |   16 ++++--
 4 files changed, 152 insertions(+), 109 deletions(-)

Index: qemu-kvm/kvm/bios/Makefile
===================================================================
--- qemu-kvm.orig/kvm/bios/Makefile
+++ qemu-kvm/kvm/bios/Makefile
@@ -108,13 +108,19 @@ rombios32.bin: rombios32.out rombios.h
 rombios32.out: rombios32start.o rombios32.o vapic.o rombios32.ld
 	ld -o $@ -T rombios32.ld rombios32start.o vapic.o rombios32.o
 
-rombios32.o: rombios32.c acpi-dsdt.hex
+rombios32.o: rombios32.c acpi-dsdt.hex acpi-ssdt.hex
 	$(GCC) -m32 -O2 -Wall -c -o $@ $<
 
 acpi-dsdt.hex: acpi-dsdt.dsl
 	cpp -P $< $<.i
 	iasl -tc -p $@ $<.i
-	sed -i -e's/^unsigned/const unsigned/' $@
+	sed -i -e's/^unsigned char AmlCode/const unsigned char DSDTCode/' $@
+	rm $<.i
+
+acpi-ssdt.hex: acpi-ssdt.dsl
+	cpp -P $< $<.i
+	iasl -tc -p $@ $<.i
+	sed -i -e's/^unsigned char AmlCode/const unsigned char SSDTCode/' $@
 	rm $<.i
 
 rombios32start.o: rombios32start.S
Index: qemu-kvm/kvm/bios/acpi-dsdt.dsl
===================================================================
--- qemu-kvm.orig/kvm/bios/acpi-dsdt.dsl
+++ qemu-kvm/kvm/bios/acpi-dsdt.dsl
@@ -25,108 +25,6 @@ DefinitionBlock (
     0x1                 // OEM Revision
     )
 {
-   Scope (\_PR)
-   {
-	/* pointer to first element of MADT APIC structures */
-	OperationRegion(ATPR, SystemMemory, 0x0514, 4)
-	Field (ATPR, DwordAcc, NoLock, Preserve)
-	{
-		ATP, 32
-	}
-
-#define madt_addr(nr)  Add (ATP, Multiply(nr, 8))
-
-#define gen_processor(nr, name) 				            \
-	Processor (CPU##name, nr, 0x0000b010, 0x06) {                       \
-	    OperationRegion (MATR, SystemMemory, madt_addr(nr), 8)          \
-	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
-	    {                                                               \
-	        MAT, 64                                                     \
-	    }                                                               \
-	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
-	    {                                                               \
-	        Offset(4),                                                  \
-	        FLG, 1                                                      \
-	    }                                                               \
-            Method(_MAT, 0) {                                               \
-		Return(MAT)                                                 \
-            }                                                               \
-            Method (_STA) {                                                 \
-                If (FLG) { Return(0xF) } Else { Return(0x9) }               \
-            }                                                               \
-        }                                                                   \
-
-
-	gen_processor(0, 0)
-	gen_processor(1, 1)
-	gen_processor(2, 2)
-	gen_processor(3, 3)
-	gen_processor(4, 4)
-	gen_processor(5, 5)
-	gen_processor(6, 6)
-	gen_processor(7, 7)
-	gen_processor(8, 8)
-	gen_processor(9, 9)
-	gen_processor(10, A)
-	gen_processor(11, B)
-	gen_processor(12, C)
-	gen_processor(13, D)
-	gen_processor(14, E)
-
-	Method (NTFY, 2) {
-#define gen_ntfy(nr)                                        \
-	If (LEqual(Arg0, 0x##nr)) {                         \
-		If (LNotEqual(Arg1, \_PR.CPU##nr.FLG)) {    \
-			Store (Arg1, \_PR.CPU##nr.FLG)      \
-			If (LEqual(Arg1, 1)) {              \
-				Notify(CPU##nr, 1)          \
-			} Else {                            \
-				Notify(CPU##nr, 3)          \
-			}                                   \
-		}                                           \
-	}
-		gen_ntfy(0)
-		gen_ntfy(1)
-		gen_ntfy(2)
-		gen_ntfy(3)
-		gen_ntfy(4)
-		gen_ntfy(5)
-		gen_ntfy(6)
-		gen_ntfy(7)
-		gen_ntfy(8)
-		gen_ntfy(9)
-		gen_ntfy(A)
-		gen_ntfy(B)
-		gen_ntfy(C)
-		gen_ntfy(D)
-		gen_ntfy(E)
-		Return(One)
-	}
-
-	OperationRegion(PRST, SystemIO, 0xaf00, 32)
-	Field (PRST, ByteAcc, NoLock, Preserve)
-	{
-		PRS, 256
-	}
-
-	Method(PRSC, 0) {
-		Store(PRS, Local3)
-		Store(Zero, Local0)
-		While(LLess(Local0, 32)) {
-			Store(Zero, Local1)
-			Store(DerefOf(Index(Local3, Local0)), Local2)
-			While(LLess(Local1, 8)) {
-				NTFY(Add(Multiply(Local0, 8), Local1),
-						And(Local2, 1))
-				ShiftRight(Local2, 1, Local2)
-				Increment(Local1)
-			}
-			Increment(Local0)
-		}
-		Return(One)
-	}
-    }
-
     Scope (\)
     {
         /* Debug Output */
@@ -137,7 +35,6 @@ DefinitionBlock (
         }
     }
 
-
     /* PCI Bus definition */
     Scope(\_SB) {
         Device(PCI0) {
@@ -803,6 +700,8 @@ DefinitionBlock (
             Return(0x01)
         }
 
+	External(\_PR.PRSC, MethodObj, IntObj)
+
         Method(_L02) {
 	    Return(\_PR.PRSC())
         }
Index: qemu-kvm/kvm/bios/acpi-ssdt.dsl
===================================================================
--- /dev/null
+++ qemu-kvm/kvm/bios/acpi-ssdt.dsl
@@ -0,0 +1,130 @@
+/*
+ * Bochs/QEMU ACPI SSDT ASL definition
+ *
+ * Copyright (c) 2006 Fabrice Bellard
+ * Copyright (c) 2009 SGI, Jes Sorensen <jes@sgi.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+DefinitionBlock (
+    "acpi-ssdt.aml",    // Output Filename
+    "SSDT",             // Signature
+    0x01,               // DSDT Compliance Revision
+    "BXPC",             // OEMID
+    "BXSSDT",           // TABLE ID
+    0x1                 // OEM Revision
+    )
+{
+   Scope (\_PR)
+   {
+	/* pointer to first element of MADT APIC structures */
+	OperationRegion(ATPR, SystemMemory, 0x0514, 4)
+	Field (ATPR, DwordAcc, NoLock, Preserve)
+	{
+		ATP, 32
+	}
+
+#define madt_addr(nr)  Add (ATP, Multiply(nr, 8))
+
+#define gen_processor(nr, name) 				            \
+	Processor (C##name, nr, 0x0000b010, 0x06) {                       \
+	    OperationRegion (MATR, SystemMemory, madt_addr(nr), 8)          \
+	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
+	    {                                                               \
+	        MAT, 64                                                     \
+	    }                                                               \
+	    Field (MATR, ByteAcc, NoLock, Preserve)                         \
+	    {                                                               \
+	        Offset(4),                                                  \
+	        FLG, 1                                                      \
+	    }                                                               \
+            Method(_MAT, 0) {                                               \
+		Return(MAT)                                                 \
+            }                                                               \
+            Method (_STA) {                                                 \
+                If (FLG) { Return(0xF) } Else { Return(0x9) }               \
+            }                                                               \
+        }                                                                   \
+
+
+	gen_processor(0, 0)
+	gen_processor(1, 1)
+	gen_processor(2, 2)
+	gen_processor(3, 3)
+	gen_processor(4, 4)
+	gen_processor(5, 5)
+	gen_processor(6, 6)
+	gen_processor(7, 7)
+	gen_processor(8, 8)
+	gen_processor(9, 9)
+	gen_processor(10, A)
+	gen_processor(11, B)
+	gen_processor(12, C)
+	gen_processor(13, D)
+	gen_processor(14, E)
+
+	Method (NTFY, 2) {
+#define gen_ntfy(nr)                                        \
+	If (LEqual(Arg0, 0x##nr)) {                         \
+		If (LNotEqual(Arg1, \_PR.C##nr.FLG)) {      \
+			Store (Arg1, \_PR.C##nr.FLG)        \
+			If (LEqual(Arg1, 1)) {              \
+				Notify(C##nr, 1)            \
+			} Else {                            \
+				Notify(C##nr, 3)            \
+			}                                   \
+		}                                           \
+	}
+		gen_ntfy(0)
+		gen_ntfy(1)
+		gen_ntfy(2)
+		gen_ntfy(3)
+		gen_ntfy(4)
+		gen_ntfy(5)
+		gen_ntfy(6)
+		gen_ntfy(7)
+		gen_ntfy(8)
+		gen_ntfy(9)
+		gen_ntfy(A)
+		gen_ntfy(B)
+		gen_ntfy(C)
+		gen_ntfy(D)
+		gen_ntfy(E)
+		Return(One)
+	}
+
+	OperationRegion(PRST, SystemIO, 0xaf00, 32)
+	Field (PRST, ByteAcc, NoLock, Preserve)
+	{
+		PRS, 256
+	}
+
+	Method(PRSC, 0) {
+		Store(PRS, Local3)
+		Store(Zero, Local0)
+		While(LLess(Local0, 32)) {
+			Store(Zero, Local1)
+			Store(DerefOf(Index(Local3, Local0)), Local2)
+			While(LLess(Local1, 8)) {
+				NTFY(Add(Multiply(Local0, 8), Local1),
+						And(Local2, 1))
+				ShiftRight(Local2, 1, Local2)
+				Increment(Local1)
+			}
+			Increment(Local0)
+		}
+		Return(One)
+	}
+    }
+}
Index: qemu-kvm/kvm/bios/rombios32.c
===================================================================
--- qemu-kvm.orig/kvm/bios/rombios32.c
+++ qemu-kvm/kvm/bios/rombios32.c
@@ -1526,6 +1526,7 @@ struct madt_int_override
 #endif
 
 #include "acpi-dsdt.hex"
+#include "acpi-ssdt.hex"
 
 static inline uint16_t cpu_to_le16(uint16_t x)
 {
@@ -1641,7 +1642,12 @@ void acpi_bios_init(void)
 
     dsdt_addr = addr;
     dsdt = (void *)(addr);
-    addr += sizeof(AmlCode);
+    addr += sizeof(DSDTCode);
+
+    addr = (addr + 7) & ~7;
+    ssdt_addr = addr;
+    ssdt = (void *)(addr);
+    addr += sizeof(SSDTCode);
 
 #ifdef BX_QEMU
     qemu_cfg_select(QEMU_CFG_NUMA);
@@ -1727,7 +1733,10 @@ void acpi_bios_init(void)
     BX_INFO("Firmware waking vector %p\n", &facs->firmware_waking_vector);
 
     /* DSDT */
-    memcpy(dsdt, AmlCode, sizeof(AmlCode));
+    memcpy(dsdt, DSDTCode, sizeof(DSDTCode));
+
+    /* SSDT */
+    memcpy(ssdt, SSDTCode, sizeof(SSDTCode));
 
     /* MADT */
     {
@@ -1884,8 +1893,7 @@ void acpi_bios_init(void)
     /* RSDT */
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(fadt_addr);
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(madt_addr);
-    /* kvm has no ssdt (processors are in dsdt) */
-//  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
+    rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
 #ifdef BX_QEMU
     /* No HPET (yet) */
 //  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(hpet_addr);

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

* Re: [patch] qemu-kvm BIOS move _PR to SSDT
  2009-06-10 15:30   ` Jes Sorensen
@ 2009-06-10 16:15     ` Gleb Natapov
  0 siblings, 0 replies; 4+ messages in thread
From: Gleb Natapov @ 2009-06-10 16:15 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Avi Kivity, kvm

On Wed, Jun 10, 2009 at 05:30:40PM +0200, Jes Sorensen wrote:
> On 06/10/2009 05:13 PM, Gleb Natapov wrote:
>>> + * Bochs/QEMU ACPI SSDT ASL definition
>>> + *
>>> + * Copyright (c) 2006 Fabrice Bellard
>> I am not sure that there is even one bit of code below written by Fabrice.
>
> Well better safe than sorry, since I copied over a bunch of stuff,
> I figured it was simpler to just leave it intact.
>
>>> +    Scope (\)
>>> +    {
>>> +        /* Debug Output */
>>> +        OperationRegion (DBG, SystemIO, 0xb044, 0x04)
>>> +        Field (DBG, DWordAcc, NoLock, Preserve)
>>> +        {
>>> +            DBGL,   32,
>>> +        }
>>> +    }
>> Except may be this one, but it should stay in DSDT.
>
> Hmmm, good point. I think I just moved it when I had zero idea what was
> going on at first in this AML hell :-)
>
> Try this one.
>
WindowXP/Windows7 BSOD -> The system is not (MS)ACPI compliant.

--
			Gleb.

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

end of thread, other threads:[~2009-06-10 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-10 15:01 [patch] qemu-kvm BIOS move _PR to SSDT Jes Sorensen
2009-06-10 15:13 ` Gleb Natapov
2009-06-10 15:30   ` Jes Sorensen
2009-06-10 16:15     ` Gleb Natapov

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.