Skip to contentSkip to conversation

Make ACPI builder available to components other than hvmloader

RFC PATCH In review Boris Ostrovsky 5 participants 91 messages Apr 6, 2016 – Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

cover Make ACPI builder available to components other than hvmloader

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

The series
* Removes dependency of today's builder on hvmloader interfaces
* Makes many of the tables built optionally.
* Moves tools/hvmloader/acpi directory to xen/common/libacpi
* Builds tables for PVHv2 domU guests in libxc

There is still a number of questions about this implementation, thus it's an RFC. Examples of things that need to be discussed are

* ACPI tables are built for PVHv2 guests unconditionally. We probably want to make this an option.
* Not sure about header files, especially xen/common/libacpi/x86.h and tools/firmware/hvmloader/{stdio.h,string.h}
* The builder is compiled into the hypervisor even though currently there are no users (PVHv2 dom0 will be the one)
* Patch 19 is somewhat of a spec violation
* Makefiles are questionable
* May need changes to guests' e820 map

This is also available from git://oss.oracle.com/git/bostrovs/xen.git:acpi_rfc.

It has been tested with Linux PVHv2 (and I believe Roger tested an earlier version with FreeBSD). No passthrough testing has been done.

(I realize that many people are busy because of Friday's freeze but I figured I'd post it now in the hope that this may get some reading so that we can talk about it at the hackathon)

Boris Ostrovsky (20):
hvmloader: Provide hvmloader_acpi_build_tables() acpi/hvmloader: Move acpi_info initialization out of ACPI code acpi/hvmloader: Initialize vm_gid data outside ACPI code acpi/hvmloader: Decide which SSDTs to build in hvmloader acpi/hvmloader: Move passthrough initialization from ACPI code acpi/hvmloader: Collect processor and NUMA info in hvmloader acpi/hvmloader: Set TIS header address in hvmloader acpi/hvmloader: Make providing IOAPIC in MADT optional acpi/hvmloader: Build WAET optionally
acpi/hvmloader: Provide address of acpi_info as an argument to ACPI
code
acpi/hvmloader: Translate all addresses when assigning addresses in
ACPI tables
acpi/hvmloader: Link ACPI object files directly acpi/hvmloader: Add stdio.h, string.h and x86.h acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops
acpi: Move ACPI code to xen/common/libacpi
x86/vlapic: Don't try to accept 8259 interrupt if !has_vpic()
x86: Allow LAPIC-only emulation_flags for HVM guests libxc/acpi: Build ACPI tables for HVMlite guests
acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported
acpi: Make ACPI builder available to hypervisor code

 .gitignore                                         |   8 +-
 tools/firmware/hvmloader/Makefile                  |  16 +-
 tools/firmware/hvmloader/config.h                  |  13 +-
 tools/firmware/hvmloader/hvmloader.c               |   3 +-
 tools/firmware/hvmloader/mp_tables.c               |   1 +
 tools/firmware/hvmloader/ovmf.c                    |   4 +-
 tools/firmware/hvmloader/pci.c                     |   1 +
 tools/firmware/hvmloader/pir.c                     |   1 +
 tools/firmware/hvmloader/rombios.c                 |   4 +-
 tools/firmware/hvmloader/seabios.c                 |   4 +-
 tools/firmware/hvmloader/smbios.c                  |   1 +
 tools/firmware/hvmloader/smp.c                     |   1 +
 tools/firmware/hvmloader/stdio.h                   |   7 +
 tools/firmware/hvmloader/string.h                  |   7 +
 tools/firmware/hvmloader/util.c                    |  85 +++++
 tools/firmware/hvmloader/util.h                    |   6 +-
 tools/firmware/rombios/32bit/Makefile              |   2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile      |   2 +-
 tools/firmware/rombios/32bit/util.h                |   2 +-
 tools/libxc/Makefile                               |  22 +-
 tools/libxc/include/xc_dom.h                       |   1 +
 tools/libxc/xc_acpi.c                              | 268 +++++++++++++
 tools/libxc/xc_dom_x86.c                           |   7 +
 tools/libxl/libxl_x86.c                            |  19 +-
 xen/arch/x86/domain.c                              |  26 +-
 xen/arch/x86/hvm/vlapic.c                          |   3 +
 xen/common/Makefile                                |   2 +-
 .../hvmloader/acpi => xen/common/libacpi}/Makefile |  33 +-
 .../hvmloader/acpi => xen/common/libacpi}/README   |   0
 .../acpi => xen/common/libacpi}/acpi2_0.h          |  66 +++-
 .../hvmloader/acpi => xen/common/libacpi}/build.c  | 415 ++++++++++-----------
 .../hvmloader/acpi => xen/common/libacpi}/dsdt.asl |   0
 xen/common/libacpi/dsdt_empty.asl                  |  22 ++
 .../acpi => xen/common/libacpi}/mk_dsdt.c          |   4 +
 .../acpi => xen/common/libacpi}/ssdt_pm.asl        |   0
 .../acpi => xen/common/libacpi}/ssdt_s3.asl        |   0
 .../acpi => xen/common/libacpi}/ssdt_s4.asl        |   0
 .../acpi => xen/common/libacpi}/ssdt_tpm.asl       |   0
 .../acpi => xen/common/libacpi}/static_tables.c    |   1 -
 xen/common/libacpi/x86.h                           |  14 +
 40 files changed, 794 insertions(+), 277 deletions(-)
 create mode 100644 tools/firmware/hvmloader/stdio.h
 create mode 100644 tools/firmware/hvmloader/string.h
 create mode 100644 tools/libxc/xc_acpi.c
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile (70%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h (84%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c (58%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl (100%)
 create mode 100644 xen/common/libacpi/dsdt_empty.asl
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c (99%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/static_tables.c (99%)
 create mode 100644 xen/common/libacpi/x86.h
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

RFC PATCH 1/20 hvmloader: Provide hvmloader_acpi_build_tables()

In preparation for moving out ACPI builder make all BIOSes call hvmloader_acpi_build_tables() instead of calling ACPI code directly.

---
 tools/firmware/hvmloader/ovmf.c    | 2 +-
 tools/firmware/hvmloader/rombios.c | 2 +-
 tools/firmware/hvmloader/seabios.c | 2 +-
 tools/firmware/hvmloader/util.c    | 7 +++++++
 tools/firmware/hvmloader/util.h    | 4 ++++
 5 files changed, 14 insertions(+), 3 deletions(-)
tools/firmware/hvmloader/ovmf.c +1 -1
index db9fa7a..74fec56 100644
@@ -125,7 +125,7 @@ static void ovmf_acpi_build_tables(void)
         .dsdt_15cpu_len = 0
     };
 
-    acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS);
+    hvmloader_acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS);
 }
 
 static void ovmf_create_smbios_tables(void)
tools/firmware/hvmloader/rombios.c +1 -1
index 1f15b94..1f8fc2d 100644
@@ -180,7 +180,7 @@ static void rombios_acpi_build_tables(void)
         .dsdt_15cpu_len = dsdt_15cpu_len,
     };
 
-    acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS);
+    hvmloader_acpi_build_tables(&config, ACPI_PHYSICAL_ADDRESS);
 }
 
 static void rombios_create_mp_tables(void)
tools/firmware/hvmloader/seabios.c +1 -1
index c6b3d9f..9f66a79 100644
@@ -100,7 +100,7 @@ static void seabios_acpi_build_tables(void)
         .dsdt_15cpu_len = 0,
     };
 
-    acpi_build_tables(&config, rsdp);
+    hvmloader_acpi_build_tables(&config, rsdp);
     add_table(rsdp);
 }
 
tools/firmware/hvmloader/util.c +7 -0
index 9382709..9af29b1 100644
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "hypercall.h"
 #include "ctype.h"
+#include "acpi/acpi2_0.h"
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
@@ -856,6 +857,12 @@ int hpet_exists(unsigned long hpet_base)
     return ((hpet_id >> 16) == 0x8086);
 }
 
+void hvmloader_acpi_build_tables(struct acpi_config *config,
+                                 unsigned int physical)
+{
+    acpi_build_tables(config, physical);
+}
+
 /*
  * Local variables:
  * mode: C
tools/firmware/hvmloader/util.h +4 -0
index 3126817..b226df4 100644
@@ -273,6 +273,10 @@ extern struct e820map memory_map;
 bool check_overlap(uint64_t start, uint64_t size,
                    uint64_t reserved_start, uint64_t reserved_size);
 
+struct acpi_config;
+void hvmloader_acpi_build_tables(struct acpi_config *config,
+                                 unsigned int physical);
+
 #endif /* __HVMLOADER_UTIL_H__ */
 
 /*
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH RFC 01/20] hvmloader: Provide hvmloader_acpi_build_tables()

tools/firmware/hvmloader/util.c int hpet_exists(unsigned long hpet_base) · line 864

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/util.c +5 -0
@@ -856,6 +857,12 @@ int hpet_exists(unsigned long hpet_base)
     return ((hpet_id >> 16) == 0x8086);
 }
 
+void hvmloader_acpi_build_tables(struct acpi_config *config,
+                                 unsigned int physical)
+{
+    acpi_build_tables(config, physical);
+}

I guess later patches will make clear why this is an improvement. On its own it doesn't look worthwhile.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH RFC 01/20] hvmloader: Provide hvmloader_acpi_build_tables()

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/util.c +0 -0
@@ -856,6 +857,12 @@ int hpet_exists(unsigned long hpet_base)
     return ((hpet_id >> 16) == 0x8086);
 }
 
Quoted 8 lines

tools/firmware/hvmloader/util.c int hpet_exists(unsigned long hpet_base) · line 864

Quoted 5 lines
tools/firmware/hvmloader/util.c +5 -0
+void hvmloader_acpi_build_tables(struct acpi_config *config,
+                                 unsigned int physical)
+{
+    acpi_build_tables(config, physical);
+}

I guess later patches will make clear why this is an improvement. On its own it doesn't look worthwhile.

This is really to make reviewing easier. Not an improvement of any kind.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

RFC PATCH 2/20 acpi/hvmloader: Move acpi_info initialization out of ACPI code

In reply to Boris Ostrovsky

acpi_info can be initialized by hvmloader itself. Now ACPI code doesn't need to use hvmloader-private variables/routines such as uart_exists(), lpt_exists() etc.

---
 tools/firmware/hvmloader/acpi/acpi2_0.h | 18 ++++++++++++++
 tools/firmware/hvmloader/acpi/build.c   | 44 ++++++---------------------------
 tools/firmware/hvmloader/util.c         | 15 +++++++++++
 3 files changed, 40 insertions(+), 37 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +18 -0
index 78eb43d..24f86c9 100644
@@ -451,11 +451,29 @@ struct acpi_20_slit {
 
 #pragma pack ()
 
+/*
+ * Located at ACPI_INFO_PHYSICAL_ADDRESS.
+ *
+ * This must match the Field("BIOS"....) definition in the DSDT.
+ */
+struct acpi_info {
+    uint8_t  com1_present:1;    /* 0[0] - System has COM1? */
+    uint8_t  com2_present:1;    /* 0[1] - System has COM2? */
+    uint8_t  lpt1_present:1;    /* 0[2] - System has LPT1? */
+    uint8_t  hpet_present:1;    /* 0[3] - System has HPET? */
+    uint32_t pci_min, pci_len;  /* 4, 8 - PCI I/O hole boundaries */
+    uint32_t madt_csum_addr;    /* 12   - Address of MADT checksum */
+    uint32_t madt_lapic0_addr;  /* 16   - Address of first MADT LAPIC struct */
+    uint32_t vm_gid_addr;       /* 20   - Address of VM generation id buffer */
+    uint64_t pci_hi_min, pci_hi_len; /* 24, 32 - PCI I/O hole boundaries */
+};
+
 struct acpi_config {
     unsigned char *dsdt_anycpu;
     int dsdt_anycpu_len;
     unsigned char *dsdt_15cpu;
     int dsdt_15cpu_len;
+    struct acpi_info acpi_info;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +7 -37

82 lines not on this page · raw message

tools/firmware/hvmloader/util.c +15 -0
index 9af29b1..7ce5f5d 100644
@@ -860,6 +860,21 @@ int hpet_exists(unsigned long hpet_base)
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
+    /* Allocate and initialise the acpi info area. */
+    mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
+
+    config->acpi_info.com1_present = uart_exists(0x3f8);
+    config->acpi_info.com2_present = uart_exists(0x2f8);
+    config->acpi_info.lpt1_present = lpt_exists(0x378);
+    config->acpi_info.hpet_present = hpet_exists(ACPI_HPET_ADDRESS);
+    config->acpi_info.pci_min = pci_mem_start;
+    config->acpi_info.pci_len = pci_mem_end - pci_mem_start;
+    if ( pci_hi_mem_end > pci_hi_mem_start )
+    {
+        config->acpi_info.pci_hi_min = pci_hi_mem_start;
+        config->acpi_info.pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
+    }
+
     acpi_build_tables(config, physical);
 }
 
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#5 lore raw

Re: [PATCH RFC 02/20] acpi/hvmloader: Move acpi_info initialization out of ACPI code

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

acpi_info can be initialized by hvmloader itself. Now ACPI code doesn't need to use hvmloader-private variables/routines such as uart_exists(), lpt_exists() etc.

So from a mechanical pov the patch looks fine (one remark below), but if you move this out from acpi/, who's going to do the setup of that structure outside of hvmloader? And if done by another entity, how do you mean things to remain in sync? And btw., you're still not fully decoupling things: ACPI_INFO_PHYSICAL_ADDRESS is a hvmloader thing, which you just move the reference to inside acpi/.

Quoted 12 lines
tools/firmware/hvmloader/acpi/build.c +1 -5
@@ -619,20 +597,12 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    if ( !new_vm_gid(acpi_info) )
+    if ( !new_vm_gid(&config->acpi_info) )
         goto oom;
 
-    acpi_info->com1_present = uart_exists(0x3f8);
-    acpi_info->com2_present = uart_exists(0x2f8);
-    acpi_info->lpt1_present = lpt_exists(0x378);
-    acpi_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS);

tools/firmware/hvmloader/acpi/build.c void acpi_build_tables(struct acpi_config *config, unsigned int physical) · line 605

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -7
-    acpi_info->pci_min = pci_mem_start;
-    acpi_info->pci_len = pci_mem_end - pci_mem_start;
-    if ( pci_hi_mem_end > pci_hi_mem_start )
-    {
-        acpi_info->pci_hi_min = pci_hi_mem_start;
-        acpi_info->pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
-    }
+    memcpy((struct acpi_info *)ACPI_INFO_PHYSICAL_ADDRESS,
+           &config->acpi_info,
+           sizeof(config->acpi_info));

I'd prefer structure assignment to be used in cases like this, as that lets the compiler check that the types match.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH RFC 02/20] acpi/hvmloader: Move acpi_info initialization out of ACPI code

Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

acpi_info can be initialized by hvmloader itself. Now ACPI code doesn't need to use hvmloader-private variables/routines such as uart_exists(), lpt_exists() etc.

So from a mechanical pov the patch looks fine (one remark below), but if you move this out from acpi/, who's going to do the setup of that structure outside of hvmloader? And if done by another entity, how do you mean things to remain in sync?

Each caller (currently hvmloader and libxc, possibly the hypervisor in the future) will initialize it. (I think you saw this in the next patch)

Quoted 4 lines

And btw., you're
still not fully decoupling things: ACPI_INFO_PHYSICAL_ADDRESS is a hvmloader thing, which you just move the reference to inside acpi/.

It's not an hvmloader thing, it's the ACPI thing: this is the address that should match DSDT's description.

Perhaps I should have a script that extracts this address from dsdt.asl and then make libacpi return it instead of hardcoding it in callers' code.

-boris

Quoted 26 lines
Quoted 13 lines
tools/firmware/hvmloader/acpi/build.c +1 -5
@@ -619,20 +597,12 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    if ( !new_vm_gid(acpi_info) )
+    if ( !new_vm_gid(&config->acpi_info) )
         goto oom;
 
-    acpi_info->com1_present = uart_exists(0x3f8);
-    acpi_info->com2_present = uart_exists(0x2f8);
-    acpi_info->lpt1_present = lpt_exists(0x378);
-    acpi_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS);

tools/firmware/hvmloader/acpi/build.c void acpi_build_tables(struct acpi_config *config, unsigned int physical) · line 605

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -7
-    acpi_info->pci_min = pci_mem_start;
-    acpi_info->pci_len = pci_mem_end - pci_mem_start;
-    if ( pci_hi_mem_end > pci_hi_mem_start )
-    {
-        acpi_info->pci_hi_min = pci_hi_mem_start;
-        acpi_info->pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
-    }
+    memcpy((struct acpi_info *)ACPI_INFO_PHYSICAL_ADDRESS,
+           &config->acpi_info,
+           sizeof(config->acpi_info));

I'd prefer structure assignment to be used in cases like this, as that lets the compiler check that the types match.

Quoted 2 lines

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH RFC 02/20] acpi/hvmloader: Move acpi_info initialization out of ACPI code

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 18:54, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

acpi_info can be initialized by hvmloader itself. Now ACPI code doesn't need to use hvmloader-private variables/routines such as uart_exists(), lpt_exists() etc.

Quoted 7 lines
Quoted 4 lines

So from a mechanical pov the patch looks fine (one remark below), but if you move this out from acpi/, who's going to do the setup of that structure outside of hvmloader? And if done by another entity, how do you mean things to remain in sync?

Each caller (currently hvmloader and libxc, possibly the hypervisor in the future) will initialize it. (I think you saw this in the next patch)

I don't think I've made it to patches touching libxc yet.

That aside, what about the "things to remain in sync" part?

Quoted 7 lines
Quoted 4 lines

And btw., you're
still not fully decoupling things: ACPI_INFO_PHYSICAL_ADDRESS is a hvmloader thing, which you just move the reference to inside acpi/.

It's not an hvmloader thing, it's the ACPI thing: this is the address that should match DSDT's description.

As to matching - sure. But it's not libacpi to determine that address. Guest memory layout gets determined elsewhere (and might differ between HVM and HVMlite, as well as between DomU and Dom0), and that's where the sole definition of that address should imo live.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH RFC 02/20] acpi/hvmloader: Move acpi_info initialization out of ACPI code

Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 18:54, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

acpi_info can be initialized by hvmloader itself. Now ACPI code doesn't need to use hvmloader-private variables/routines such as uart_exists(), lpt_exists() etc.

So from a mechanical pov the patch looks fine (one remark below), but if you move this out from acpi/, who's going to do the setup of that structure outside of hvmloader? And if done by another entity, how do you mean things to remain in sync?

Quoted 6 lines
Quoted 2 lines

Each caller (currently hvmloader and libxc, possibly the hypervisor in the future) will initialize it. (I think you saw this in the next patch)

I don't think I've made it to patches touching libxc yet.

That aside, what about the "things to remain in sync" part?

I was referring to your comment for patch 3 where you said

If different entities are responsible for filling different parts of acpi_info, I think this should be documented in the structure definition

and my response was that acpi_info has IN and OUT fields that I need to document. If that's not answering your question about things remaining in sync then I guess I don't understand the question.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

And btw., you're
still not fully decoupling things: ACPI_INFO_PHYSICAL_ADDRESS is a hvmloader thing, which you just move the reference to inside acpi/.

Quoted 7 lines
Quoted 2 lines

It's not an hvmloader thing, it's the ACPI thing: this is the address that should match DSDT's description.

As to matching - sure. But it's not libacpi to determine that address. Guest memory layout gets determined elsewhere (and might differ between HVM and HVMlite, as well as between DomU and Dom0), and that's where the sole definition of that address should imo live.

Right, but I figured that since ASL files live in acpi/ (libacpi/ in the future) then ACPI_INFO_PHYSICAL_ADDRESS should also be defined here.

I used ACPI_INFO_PHYSICAL_ADDRESS for HVMlite guests as well (you will see it in a later patch for libxc) but really I don't need to: those guests use only DSDT header (dsdt_empty.asl) and don't refer to this address in their ASL file. In fact, they don't need acpi_info at all.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#9 lore raw

Re: [PATCH RFC 02/20] acpi/hvmloader: Move acpi_info initialization out of ACPI code

Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 03.06.16 at 16:42, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 18:54, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

acpi_info can be initialized by hvmloader itself. Now ACPI code doesn't need to use hvmloader-private variables/routines such as uart_exists(), lpt_exists() etc.

So from a mechanical pov the patch looks fine (one remark below), but if you move this out from acpi/, who's going to do the setup of that structure outside of hvmloader? And if done by another entity, how do you mean things to remain in sync?

Quoted 6 lines
Quoted 2 lines

Each caller (currently hvmloader and libxc, possibly the hypervisor in the future) will initialize it. (I think you saw this in the next patch)

I don't think I've made it to patches touching libxc yet.

That aside, what about the "things to remain in sync" part?

I was referring to your comment for patch 3 where you said

Quoted 7 lines

If different entities are responsible for filling different parts of acpi_info, I think this should be documented in the structure definition

and my response was that acpi_info has IN and OUT fields that I need to document. If that's not answering your question about things remaining in sync then I guess I don't understand the question.

Well, first of all the definition of this structure will likely need to become part of the public interface, so that all consumers of it (hvmloader, libxc, and maybe the domain builder) can access it. Which then raises the question of how to deal with updates to that structure: We should avoid making this part of the stable public interface, but limiting it to Xen and tools would exclude hvmloader.

Perhaps the follow-on thing - consumers living in far apart portions of the tree, and hence it's easy to forget one if an adjustment is being done - isn't that much different from e.g. touching code consumed by qemu. But then again we all know that some things at the xen/tools vs qemu boundary are pretty fragile, and I'd like to avoid such here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH RFC 02/20] acpi/hvmloader: Move acpi_info initialization out of ACPI code

Quoted 8 lines · Jan Beulich

Well, first of all the definition of this structure will likely need to become part of the public interface, so that all consumers of it (hvmloader, libxc, and maybe the domain builder) can access it. Which then raises the question of how to deal with updates to that structure: We should avoid making this part of the stable public interface, but limiting it to Xen and tools would exclude hvmloader.

Quoted 7 lines

Perhaps the follow-on thing - consumers living in far apart portions of the tree, and hence it's easy to forget one if an adjustment is being done - isn't that much different from e.g. touching code consumed by qemu. But then again we all know that some things at the xen/tools vs qemu boundary are pretty fragile, and I'd like to avoid such here.

We can add version to acpi_build_tables() call (or to struct acpi_config)?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#11 lore raw

RFC PATCH 3/20 acpi/hvmloader: Initialize vm_gid data outside ACPI code

In reply to Boris Ostrovsky

This way ACPI code won't use xenstore-read() and hvm_param_set() which are private to hvmloader.

---
 tools/firmware/hvmloader/acpi/acpi2_0.h |  1 +
 tools/firmware/hvmloader/acpi/build.c   | 30 +++++++++++-------------------
 tools/firmware/hvmloader/util.c         | 15 +++++++++++++++
 3 files changed, 27 insertions(+), 19 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
index 24f86c9..275981e 100644
@@ -474,6 +474,7 @@ struct acpi_config {
     unsigned char *dsdt_15cpu;
     int dsdt_15cpu_len;
     struct acpi_info acpi_info;
+    uint64_t vm_gid[2];
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +11 -19
index e039d9e..e3e8b05 100644
@@ -448,32 +448,24 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
  *
  * Return 0 if memory failure, != 0 if success
  */
-static int new_vm_gid(struct acpi_info *acpi_info)
+static int new_vm_gid(struct acpi_config *config)
 {
-    uint64_t vm_gid[2], *buf;
-    const char * s;
-    char *end;
-
-    acpi_info->vm_gid_addr = 0;
-
-    /* read ID and check for 0 */
-    s = xenstore_read("platform/generation-id", "0:0");
-    vm_gid[0] = strtoll(s, &end, 0);
-    vm_gid[1] = 0;
-    if ( end && end[0] == ':' )
-        vm_gid[1] = strtoll(end+1, NULL, 0);
-    if ( !vm_gid[0] && !vm_gid[1] )
+    uint64_t *buf;
+
+    config->acpi_info.vm_gid_addr = 0;
+
+    /* check for 0 ID*/
+    if ( !config->vm_gid[0] && !config->vm_gid[1] )
         return 1;
 
     /* copy to allocate BIOS memory */
-    buf = (uint64_t *) mem_alloc(sizeof(vm_gid), 8);
+    buf = (uint64_t *) mem_alloc(sizeof(config->vm_gid), 8);
     if ( !buf )
         return 0;
-    memcpy(buf, vm_gid, sizeof(vm_gid));
+    memcpy(buf, config->vm_gid, sizeof(config->vm_gid));
 
     /* set into ACPI table and HVM param the address */
-    acpi_info->vm_gid_addr = virt_to_phys(buf);
-    hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, acpi_info->vm_gid_addr);
+    config->acpi_info.vm_gid_addr = virt_to_phys(buf);
 
     return 1;
 }
@@ -597,7 +589,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    if ( !new_vm_gid(&config->acpi_info) )
+    if ( !new_vm_gid(config) )
         goto oom;
 
     memcpy((struct acpi_info *)ACPI_INFO_PHYSICAL_ADDRESS,
tools/firmware/hvmloader/util.c +15 -0
index 7ce5f5d..e4c188c 100644
@@ -26,6 +26,7 @@
 #include <xen/xen.h>
 #include <xen/memory.h>
 #include <xen/sched.h>
+#include <xen/hvm/params.h>
 
 /*
  * Check whether there exists overlap in the specified memory range.
@@ -860,6 +861,8 @@ int hpet_exists(unsigned long hpet_base)
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
+    const char *s;
+
     /* Allocate and initialise the acpi info area. */
     mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
 
@@ -875,7 +878,19 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
         config->acpi_info.pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
     }
 
+    s = xenstore_read("platform/generation-id", "0:0");
+    if (s) {
+        char *end;
+
+        config->vm_gid[0] = strtoll(s, &end, 0);
+        config->vm_gid[1] = 0;
+        if ( end && end[0] == ':' )
+            config->vm_gid[1] = strtoll(end+1, NULL, 0);
+    }
+
     acpi_build_tables(config, physical);
+
+    hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->acpi_info.vm_gid_addr);
 }
 
 /*
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#12 lore raw

Re: [PATCH RFC 03/20] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +7 -15
@@ -448,32 +448,24 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
  *
  * Return 0 if memory failure, != 0 if success
  */
-static int new_vm_gid(struct acpi_info *acpi_info)
+static int new_vm_gid(struct acpi_config *config)
 {
-    uint64_t vm_gid[2], *buf;
-    const char * s;
-    char *end;
-
-    acpi_info->vm_gid_addr = 0;
-
-    /* read ID and check for 0 */
-    s = xenstore_read("platform/generation-id", "0:0");
-    vm_gid[0] = strtoll(s, &end, 0);
-    vm_gid[1] = 0;
-    if ( end && end[0] == ':' )
-        vm_gid[1] = strtoll(end+1, NULL, 0);
-    if ( !vm_gid[0] && !vm_gid[1] )
+    uint64_t *buf;
+
+    config->acpi_info.vm_gid_addr = 0;
+
+    /* check for 0 ID*/
+    if ( !config->vm_gid[0] && !config->vm_gid[1] )
         return 1;
 
     /* copy to allocate BIOS memory */
-    buf = (uint64_t *) mem_alloc(sizeof(vm_gid), 8);

tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 468

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -3
+    buf = (uint64_t *) mem_alloc(sizeof(config->vm_gid), 8);
     if ( !buf )
         return 0;
-    memcpy(buf, vm_gid, sizeof(vm_gid));
+    memcpy(buf, config->vm_gid, sizeof(config->vm_gid));
 
     /* set into ACPI table and HVM param the address */
-    acpi_info->vm_gid_addr = virt_to_phys(buf);
-    hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, acpi_info->vm_gid_addr);
+    config->acpi_info.vm_gid_addr = virt_to_phys(buf);

Here things get interesting: If different entities are responsible for filling different parts of acpi_info, I think this should be documented in the structure definition. Can't this be left to the entity initializing that structure?

tools/firmware/hvmloader/acpi/build.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 882

Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +2 -0
@@ -875,7 +878,19 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
         config->acpi_info.pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
     }
 
+    s = xenstore_read("platform/generation-id", "0:0");
+    if (s) {

Please use hypervisor coding style here; Interestingly you do so ...

tools/firmware/hvmloader/acpi/build.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 887

Quoted 5 lines
tools/firmware/hvmloader/acpi/build.c +5 -0
+        char *end;
+
+        config->vm_gid[0] = strtoll(s, &end, 0);
+        config->vm_gid[1] = 0;
+        if ( end && end[0] == ':' )

... here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

Re: [PATCH RFC 03/20] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 39 lines · Jan Beulich
Quoted 39 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +9 -16
@@ -448,32 +448,24 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
  *
  * Return 0 if memory failure, != 0 if success
  */
-static int new_vm_gid(struct acpi_info *acpi_info)
+static int new_vm_gid(struct acpi_config *config)
 {
-    uint64_t vm_gid[2], *buf;
-    const char * s;
-    char *end;
-
-    acpi_info->vm_gid_addr = 0;
-
-    /* read ID and check for 0 */
-    s = xenstore_read("platform/generation-id", "0:0");
-    vm_gid[0] = strtoll(s, &end, 0);
-    vm_gid[1] = 0;
-    if ( end && end[0] == ':' )
-        vm_gid[1] = strtoll(end+1, NULL, 0);
-    if ( !vm_gid[0] && !vm_gid[1] )
+    uint64_t *buf;
+
+    config->acpi_info.vm_gid_addr = 0;
+
+    /* check for 0 ID*/
+    if ( !config->vm_gid[0] && !config->vm_gid[1] )
         return 1;
 
     /* copy to allocate BIOS memory */
-    buf = (uint64_t *) mem_alloc(sizeof(vm_gid), 8);
+    buf = (uint64_t *) mem_alloc(sizeof(config->vm_gid), 8);
     if ( !buf )
         return 0;
-    memcpy(buf, vm_gid, sizeof(vm_gid));
+    memcpy(buf, config->vm_gid, sizeof(config->vm_gid));
 
Quoted 7 lines

tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 468

Quoted 4 lines
tools/firmware/hvmloader/acpi/build.c +1 -2
     /* set into ACPI table and HVM param the address */
-    acpi_info->vm_gid_addr = virt_to_phys(buf);
-    hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, acpi_info->vm_gid_addr);
+    config->acpi_info.vm_gid_addr = virt_to_phys(buf);

Here things get interesting: If different entities are responsible for filling different parts of acpi_info, I think this should be documented in the structure definition.

There are IN and OUT parameters in acpi_info, and this is not documented. It should be.

Quoted 2 lines

Can't this be left to the entity initializing
that structure?

vm_gid_addr is calculated by (what will be) libacpi, it's an OUT parameter.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#14 lore raw

RFC PATCH 4/20 acpi/hvmloader: Decide which SSDTs to build in hvmloader

In reply to Boris Ostrovsky

With that, xenstore_read() won't need to be done in ACPI code

---
 tools/firmware/hvmloader/acpi/acpi2_0.h |  6 ++++++
 tools/firmware/hvmloader/acpi/build.c   | 20 +++++++-------------
 tools/firmware/hvmloader/util.c         | 12 ++++++++++++
 3 files changed, 25 insertions(+), 13 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +6 -0
index 275981e..1ed0d44 100644
@@ -451,6 +451,11 @@ struct acpi_20_slit {
 
 #pragma pack ()
 
+/* Flags indicating which tables to build */
+#define ACPI_BUILD_SSDT_PM        (1<<0)
+#define ACPI_BUILD_SSDT_S3        (1<<1)
+#define ACPI_BUILD_SSDT_S4        (1<<2)
+
 /*
  * Located at ACPI_INFO_PHYSICAL_ADDRESS.
  *
@@ -475,6 +480,7 @@ struct acpi_config {
     int dsdt_15cpu_len;
     struct acpi_info acpi_info;
     uint64_t vm_gid[2];
+    uint32_t table_flags;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +7 -13
index e3e8b05..9f45f26 100644
@@ -56,11 +56,6 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static uint8_t battery_port_exists(void)
-{
-    return (inb(0x88) == 0x1F);
-}
-
 static struct acpi_20_madt *construct_madt(struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
@@ -322,7 +317,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
 }
 
 static int construct_secondary_tables(unsigned long *table_ptrs,
-                                      struct acpi_info *info)
+                                      struct acpi_config *config)
 {
     int nr_tables = 0;
     struct acpi_20_madt *madt;
@@ -337,13 +332,13 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* MADT. */
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
-        madt = construct_madt(info);
+        madt = construct_madt(&config->acpi_info);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
 
     /* HPET. */
-    if ( info->hpet_present )
+    if ( config->acpi_info.hpet_present )
     {
         hpet = construct_hpet();
         if (!hpet) return -1;
@@ -355,7 +350,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     if (!waet) return -1;
     table_ptrs[nr_tables++] = (unsigned long)waet;
 
-    if ( battery_port_exists() )
+    if ( config->table_flags & ACPI_BUILD_SSDT_PM )
     {
         ssdt = mem_alloc(sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
@@ -363,7 +358,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
     }
 
-    if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1) )
+    if ( config->table_flags & ACPI_BUILD_SSDT_S3 )
     {
         ssdt = mem_alloc(sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
@@ -373,7 +368,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         printf("S3 disabled\n");
     }
 
-    if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1) )
+    if ( config->table_flags & ACPI_BUILD_SSDT_S4 )
     {
         ssdt = mem_alloc(sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
@@ -543,8 +538,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    nr_secondaries = construct_secondary_tables(secondary_tables,
-                                                &config->acpi_info);
+    nr_secondaries = construct_secondary_tables(secondary_tables, config);
     if ( nr_secondaries < 0 )
         goto oom;
 
tools/firmware/hvmloader/util.c +12 -0
index e4c188c..54261ae 100644
@@ -858,6 +858,11 @@ int hpet_exists(unsigned long hpet_base)
     return ((hpet_id >> 16) == 0x8086);
 }
 
+static uint8_t battery_port_exists(void)
+{
+    return (inb(0x88) == 0x1F);
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
@@ -888,6 +893,13 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
             config->vm_gid[1] = strtoll(end+1, NULL, 0);
     }
 
+    if ( battery_port_exists() )
+        config->table_flags |= ACPI_BUILD_SSDT_PM;
+    if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1)  )
+        config->table_flags |= ACPI_BUILD_SSDT_S3;
+    if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
+        config->table_flags |= ACPI_BUILD_SSDT_S4;
+
     acpi_build_tables(config, physical);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->acpi_info.vm_gid_addr);
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#15 lore raw

Re: [PATCH RFC 04/20] acpi/hvmloader: Decide which SSDTs to build in hvmloader

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With that, xenstore_read() won't need to be done in ACPI code

Except for maybe s/build/install/ in the title, this patch looks fine.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#16 lore raw

RFC PATCH 5/20 acpi/hvmloader: Move passthrough initialization from ACPI code

In reply to Boris Ostrovsky

Initiale it in hvmloader, avoiding ACPI code's use of xenstore_read()

---
 tools/firmware/hvmloader/acpi/acpi2_0.h |  4 ++++
 tools/firmware/hvmloader/acpi/build.c   | 22 +++++++---------------
 tools/firmware/hvmloader/util.c         | 10 ++++++++++
 3 files changed, 21 insertions(+), 15 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +4 -0
index 1ed0d44..2617762 100644
@@ -481,6 +481,10 @@ struct acpi_config {
     struct acpi_info acpi_info;
     uint64_t vm_gid[2];
     uint32_t table_flags;
+    struct {
+        unsigned long acpi_pt_addr;
+        uint32_t acpi_pt_length;
+    } pt;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +7 -15
index 9f45f26..8a05c7c 100644
@@ -271,10 +271,10 @@ static struct acpi_20_slit *construct_slit(void)
 }
 
 static int construct_passthrough_tables(unsigned long *table_ptrs,
-                                        int nr_tables)
+                                        int nr_tables,
+                                        struct acpi_config *config)
 {
-    const char *s;
-    uint8_t *acpi_pt_addr;
+    unsigned long acpi_pt_addr;
     uint32_t acpi_pt_length;
     struct acpi_header *header;
     int nr_added;
@@ -282,19 +282,11 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
     uint32_t total = 0;
     uint8_t *buffer;
 
-    s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL);
-    if ( s == NULL )
-        return 0;    
-
-    acpi_pt_addr = (uint8_t*)(uint32_t)strtoll(s, NULL, 0);
-    if ( acpi_pt_addr == NULL )
-        return 0;
-
-    s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL);
-    if ( s == NULL )
+    if ( config->pt.acpi_pt_addr == 0 )
         return 0;
 
-    acpi_pt_length = (uint32_t)strtoll(s, NULL, 0);
+    acpi_pt_addr = config->pt.acpi_pt_addr;
+    acpi_pt_length = config->pt.acpi_pt_length;
 
     for ( nr_added = 0; nr_added < nr_max; nr_added++ )
     {        
@@ -430,7 +422,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* Load any additional tables passed through. */
-    nr_tables += construct_passthrough_tables(table_ptrs, nr_tables);
+    nr_tables += construct_passthrough_tables(table_ptrs, nr_tables, config);
 
     table_ptrs[nr_tables] = 0;
     return nr_tables;
tools/firmware/hvmloader/util.c +10 -0
index 54261ae..230e14a 100644
@@ -26,6 +26,7 @@
 #include <xen/xen.h>
 #include <xen/memory.h>
 #include <xen/sched.h>
+#include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
 /*
@@ -893,6 +894,15 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
             config->vm_gid[1] = strtoll(end+1, NULL, 0);
     }
 
+    s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL);
+    if ( s ) {
+        config->pt.acpi_pt_addr = strtoll(s, NULL, 0);
+
+        s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL);
+        if ( s  )
+            config->pt.acpi_pt_length = strtoll(s, NULL, 0);
+    }
+
     if ( battery_port_exists() )
         config->table_flags |= ACPI_BUILD_SSDT_PM;
     if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1)  )
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#17 lore raw

Re: [PATCH RFC 05/20] acpi/hvmloader: Move passthrough initialization from ACPI code

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 487

Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +4 -0
@@ -481,6 +481,10 @@ struct acpi_config {
     struct acpi_info acpi_info;
     uint64_t vm_gid[2];
     uint32_t table_flags;
+    struct {
+        unsigned long acpi_pt_addr;
+        uint32_t acpi_pt_length;
+    } pt;

Redundant "acpi" and "pt". (Which btw also holds for the earlier added acpi_info, as I now realize.) Further please consider also making the address uint32_t.

tools/firmware/hvmloader/acpi/acpi2_0.h void hvmloader_acpi_build_tables(struct acpi_config *config, · line 898

Quoted 6 lines
tools/firmware/hvmloader/acpi/acpi2_0.h +2 -0
@@ -893,6 +894,15 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
             config->vm_gid[1] = strtoll(end+1, NULL, 0);
     }
 
+    s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL);
+    if ( s ) {

Coding style.

Beyond that looks okay.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#18 lore raw

RFC PATCH 6/20 acpi/hvmloader: Collect processor and NUMA info in hvmloader

In reply to Boris Ostrovsky

No need for ACPI code to rely on hvm_info.

---
 tools/firmware/hvmloader/acpi/acpi2_0.h | 13 +++++++++
 tools/firmware/hvmloader/acpi/build.c   | 49 +++++++++++++++++----------------
 tools/firmware/hvmloader/util.c         | 11 ++++++++
 3 files changed, 49 insertions(+), 24 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +13 -0
index 2617762..c52315a 100644
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/hvm/ioreq.h>
+#include <xen/memory.h>
 
 #define ASCII32(a,b,c,d)         \
     (((a) <<  0) | ((b) <<  8) | ((c) << 16) | ((d) << 24))
@@ -473,6 +474,14 @@ struct acpi_info {
     uint64_t pci_hi_min, pci_hi_len; /* 24, 32 - PCI I/O hole boundaries */
 };
 
+struct acpi_numa {
+    uint32_t nr_vmemranges;
+    uint32_t nr_vnodes;
+    unsigned int *vcpu_to_vnode;
+    unsigned int *vdistance;
+    xen_vmemrange_t *vmemrange;
+};
+
 struct acpi_config {
     unsigned char *dsdt_anycpu;
     int dsdt_anycpu_len;
@@ -485,6 +494,10 @@ struct acpi_config {
         unsigned long acpi_pt_addr;
         uint32_t acpi_pt_length;
     } pt;
+    uint32_t nr_vcpus;
+    uint8_t  *vcpu_online;
+    int apic_mode;
+    struct acpi_numa numa;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +25 -24

141 lines not on this page · raw message

tools/firmware/hvmloader/util.c +11 -0
index 230e14a..b56f4e6 100644
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "hypercall.h"
 #include "ctype.h"
+#include "vnuma.h"
 #include "acpi/acpi2_0.h"
 #include <stdint.h>
 #include <xen/xen.h>
@@ -910,6 +911,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->nr_vcpus = hvm_info->nr_vcpus;
+    config->vcpu_online = hvm_info->vcpu_online;
+    config->apic_mode = 1;
+
+    config->numa.nr_vmemranges = nr_vmemranges;
+    config->numa.nr_vnodes = nr_vnodes;
+    config->numa.vcpu_to_vnode = vcpu_to_vnode;
+    config->numa.vdistance = vdistance;
+    config->numa.vmemrange = vmemrange;
+
     acpi_build_tables(config, physical);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->acpi_info.vm_gid_addr);
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#19 lore raw

Re: [PATCH RFC 06/20] acpi/hvmloader: Collect processor and NUMA info in hvmloader

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 499

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +3 -0
@@ -485,6 +494,10 @@ struct acpi_config {
         unsigned long acpi_pt_addr;
         uint32_t acpi_pt_length;
     } pt;
+    uint32_t nr_vcpus;
+    uint8_t  *vcpu_online;
+    int apic_mode;

Instead of copying those fields, how about simply adding a pointer to struct hvm_info_table here?

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 500

Quoted 1 line
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
+    struct acpi_numa numa;

Same for this one - perhaps better a pointer, and an instance of the structure could then replace all those individual global variables.

tools/firmware/hvmloader/util.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 916

Quoted 7 lines
tools/firmware/hvmloader/util.c +3 -0
@@ -910,6 +911,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->nr_vcpus = hvm_info->nr_vcpus;
+    config->vcpu_online = hvm_info->vcpu_online;
+    config->apic_mode = 1;

Why is this a hard coded 1? It was hvm_info->apic_mode before.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#20 lore raw

Re: [PATCH RFC 06/20] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 15 lines · Jan Beulich

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 499

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +3 -0
@@ -485,6 +494,10 @@ struct acpi_config {
         unsigned long acpi_pt_addr;
         uint32_t acpi_pt_length;
     } pt;
+    uint32_t nr_vcpus;
+    uint8_t  *vcpu_online;
+    int apic_mode;

Instead of copying those fields, how about simply adding a pointer to struct hvm_info_table here?

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 500

Quoted 1 line
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
+    struct acpi_numa numa;

Same for this one - perhaps better a pointer, and an instance of the structure could then replace all those individual global variables.

Quoted 8 lines

tools/firmware/hvmloader/util.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 916

Quoted 7 lines
tools/firmware/hvmloader/util.c +3 -0
@@ -910,6 +911,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->nr_vcpus = hvm_info->nr_vcpus;
+    config->vcpu_online = hvm_info->vcpu_online;
+    config->apic_mode = 1;

Why is this a hard coded 1? It was hvm_info->apic_mode before.

I think that's because hvm_info is initialized in libxl very late, after ACPI is already set. Let me see whether there was a reason for this order and if there wasn't then yes, I can point to hvm_info.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#21 lore raw

Re: [PATCH RFC 06/20] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 19:18, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 499

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +3 -0
@@ -485,6 +494,10 @@ struct acpi_config {
         unsigned long acpi_pt_addr;
         uint32_t acpi_pt_length;
     } pt;
+    uint32_t nr_vcpus;
+    uint8_t  *vcpu_online;
+    int apic_mode;

Instead of copying those fields, how about simply adding a pointer to struct hvm_info_table here?

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 500

Quoted 1 line
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
+    struct acpi_numa numa;

Same for this one - perhaps better a pointer, and an instance of the structure could then replace all those individual global variables.

Quoted 4 lines
tools/firmware/hvmloader/util.c +0 -0
@@ -910,6 +911,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
Quoted 8 lines
Quoted 4 lines

tools/firmware/hvmloader/util.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 916

Quoted 3 lines
tools/firmware/hvmloader/util.c +3 -0
+    config->nr_vcpus = hvm_info->nr_vcpus;
+    config->vcpu_online = hvm_info->vcpu_online;
+    config->apic_mode = 1;

Why is this a hard coded 1? It was hvm_info->apic_mode before.

I think that's because hvm_info is initialized in libxl very late, after ACPI is already set. Let me see whether there was a reason for this order and if there wasn't then yes, I can point to hvm_info.

No matter when libxl initializes hvm_info, it necessarily happens before the guest starts. And we're inside the running guest here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#22 lore raw

Re: [PATCH RFC 06/20] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 25 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 19:18, <[email protected]> wrote:
Quoted 23 lines · Jan Beulich

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 499

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +3 -0
@@ -485,6 +494,10 @@ struct acpi_config {
         unsigned long acpi_pt_addr;
         uint32_t acpi_pt_length;
     } pt;
+    uint32_t nr_vcpus;
+    uint8_t  *vcpu_online;
+    int apic_mode;

Instead of copying those fields, how about simply adding a pointer to struct hvm_info_table here?

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_config { · line 500

Quoted 1 line
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
+    struct acpi_numa numa;

Same for this one - perhaps better a pointer, and an instance of the structure could then replace all those individual global variables.

tools/firmware/hvmloader/util.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 916

Quoted 7 lines
tools/firmware/hvmloader/util.c +3 -0
@@ -910,6 +911,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->nr_vcpus = hvm_info->nr_vcpus;
+    config->vcpu_online = hvm_info->vcpu_online;
+    config->apic_mode = 1;

Why is this a hard coded 1? It was hvm_info->apic_mode before.

Quoted 5 lines
Quoted 3 lines

I think that's because hvm_info is initialized in libxl very late, after ACPI is already set. Let me see whether there was a reason for this order and if there wasn't then yes, I can point to hvm_info.

No matter when libxl initializes hvm_info, it necessarily happens before the guest starts. And we're inside the running guest here.

At this point -- yes. However, this is (partly) done in preparation to making this code available to libxc for building HVMlite guests, so this will run before the guest has started.

In any case, I suspect I may be able to move ACPI building in libxl to after hvm_info is initialized.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#23 lore raw

RFC PATCH 7/20 acpi/hvmloader: Set TIS header address in hvmloader

In reply to Boris Ostrovsky

Users other than hvmloader may provide TIS address as virtual.

---
 tools/firmware/hvmloader/acpi/acpi2_0.h |  4 ++
 tools/firmware/hvmloader/acpi/build.c   | 65 +++++++++++++++++----------------
 tools/firmware/hvmloader/util.c         |  4 ++
 3 files changed, 41 insertions(+), 32 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +4 -0
index c52315a..2628a2f 100644
@@ -304,6 +304,8 @@ struct acpi_20_waet {
     uint32_t           flags;
 };
 
+#define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
+
 /*
  * Multiple APIC Flags.
  */
@@ -456,6 +458,7 @@ struct acpi_20_slit {
 #define ACPI_BUILD_SSDT_PM        (1<<0)
 #define ACPI_BUILD_SSDT_S3        (1<<1)
 #define ACPI_BUILD_SSDT_S4        (1<<2)
+#define ACPI_BUILD_TCPA           (1<<3)
 
 /*
  * Located at ACPI_INFO_PHYSICAL_ADDRESS.
@@ -498,6 +501,7 @@ struct acpi_config {
     uint8_t  *vcpu_online;
     int apic_mode;
     struct acpi_numa numa;
+    uint16_t *tis_hdr;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +33 -32

81 lines not on this page · raw message

tools/firmware/hvmloader/util.c +4 -0
index b56f4e6..ce74fe2 100644
@@ -911,6 +911,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->table_flags |= ACPI_BUILD_TCPA;
+
     config->nr_vcpus = hvm_info->nr_vcpus;
     config->vcpu_online = hvm_info->vcpu_online;
     config->apic_mode = 1;
@@ -921,6 +923,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->numa.vdistance = vdistance;
     config->numa.vmemrange = vmemrange;
 
+    config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
+
     acpi_build_tables(config, physical);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->acpi_info.vm_gid_addr);
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#24 lore raw

Re: [PATCH RFC 07/20] acpi/hvmloader: Set TIS header address in hvmloader

Quoted 59 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +22 -30
@@ -371,41 +370,43 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         printf("S4 disabled\n");
     }
 
-    /* TPM TCPA and SSDT. */
-    tis_hdr = (uint16_t *)0xFED40F00;
-    if ( (tis_hdr[0] == tis_signature[0]) &&
-         (tis_hdr[1] == tis_signature[1]) &&
-         (tis_hdr[2] == tis_signature[2]) )
+    if ( config->table_flags & ACPI_BUILD_TCPA )
     {
-        ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
-        if (!ssdt) return -1;
-        memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
-
-        tcpa = mem_alloc(sizeof(struct acpi_20_tcpa), 16);
-        if (!tcpa) return -1;
-        memset(tcpa, 0, sizeof(*tcpa));
-        table_ptrs[nr_tables++] = (unsigned long)tcpa;
-
-        tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
-        tcpa->header.length    = sizeof(*tcpa);
-        tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
-        fixed_strcpy(tcpa->header.oem_id, ACPI_OEM_ID);
-        fixed_strcpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID);
-        tcpa->header.oem_revision = ACPI_OEM_REVISION;
-        tcpa->header.creator_id   = ACPI_CREATOR_ID;
-        tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
-        if ( (lasa = mem_alloc(ACPI_2_0_TCPA_LAML_SIZE, 16)) != NULL )
+        /* TPM TCPA and SSDT. */
+        if ( (config->tis_hdr[0] == tis_signature[0]) &&
+             (config->tis_hdr[1] == tis_signature[1]) &&
+             (config->tis_hdr[2] == tis_signature[2]) )
         {
-            tcpa->lasa = virt_to_phys(lasa);
-            tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
-            memset(lasa, 0, tcpa->laml);
-            set_checksum(tcpa,
-                         offsetof(struct acpi_header, checksum),
-                         tcpa->header.length);
+            ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
+            if (!ssdt) return -1;
+            memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm));
+            table_ptrs[nr_tables++] = (unsigned long)ssdt;
+
+            tcpa = mem_alloc(sizeof(struct acpi_20_tcpa), 16);
+            if (!tcpa) return -1;
+            memset(tcpa, 0, sizeof(*tcpa));
+            table_ptrs[nr_tables++] = (unsigned long)tcpa;
+
+            tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
+            tcpa->header.length    = sizeof(*tcpa);
+            tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
+            fixed_strcpy(tcpa->header.oem_id, ACPI_OEM_ID);
+            fixed_strcpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID);
+            tcpa->header.oem_revision = ACPI_OEM_REVISION;
+            tcpa->header.creator_id   = ACPI_CREATOR_ID;

tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 406

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +10 -0
+            tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
+            if ( (lasa = mem_alloc(ACPI_2_0_TCPA_LAML_SIZE, 16)) != NULL )
+            {
+                tcpa->lasa = virt_to_phys(lasa);
+                tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
+                memset(lasa, 0, tcpa->laml);
+                set_checksum(tcpa,
+                             offsetof(struct acpi_header, checksum),
+                             tcpa->header.length);
+            }

As it looks, all of this code churn could be avoided by simply merging the two if()s at the top.

tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 409

Quoted 4 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
         }
     }
-
+    

Stray addition of trailing blanks.

Quoted 12 lines
tools/firmware/hvmloader/util.c +2 -0
@@ -911,6 +911,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->table_flags |= ACPI_BUILD_TCPA;
+
     config->nr_vcpus = hvm_info->nr_vcpus;
     config->vcpu_online = hvm_info->vcpu_online;
     config->apic_mode = 1;

tools/firmware/hvmloader/util.c void hvmloader_acpi_build_tables(struct acpi_config *config, · line 926

Quoted 4 lines
tools/firmware/hvmloader/util.c +1 -0
@@ -921,6 +923,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->numa.vdistance = vdistance;
     config->numa.vmemrange = vmemrange;
 
+    config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;

Please put these two additions next to each other.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#25 lore raw

RFC PATCH 8/20 acpi/hvmloader: Make providing IOAPIC in MADT optional

In reply to Boris Ostrovsky
---
 tools/firmware/hvmloader/acpi/acpi2_0.h |  1 +
 tools/firmware/hvmloader/acpi/build.c   | 68 ++++++++++++++++++---------------
 tools/firmware/hvmloader/util.c         |  2 +-
 3 files changed, 39 insertions(+), 32 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
index 2628a2f..6c762e0 100644
@@ -459,6 +459,7 @@ struct acpi_20_slit {
 #define ACPI_BUILD_SSDT_S3        (1<<1)
 #define ACPI_BUILD_SSDT_S4        (1<<2)
 #define ACPI_BUILD_TCPA           (1<<3)
+#define ACPI_BUILD_IOAPIC         (1<<4)
 
 /*
  * Located at ACPI_INFO_PHYSICAL_ADDRESS.
tools/firmware/hvmloader/acpi/build.c +37 -31

80 lines not on this page · raw message

tools/firmware/hvmloader/util.c +1 -1
index ce74fe2..982d023 100644
@@ -911,7 +911,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
-    config->table_flags |= ACPI_BUILD_TCPA;
+    config->table_flags |= (ACPI_BUILD_TCPA | ACPI_BUILD_IOAPIC);
 
     config->nr_vcpus = hvm_info->nr_vcpus;
     config->vcpu_online = hvm_info->vcpu_online;
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#26 lore raw

RFC PATCH 9/20 acpi/hvmloader: Build WAET optionally

In reply to Boris Ostrovsky
---
 tools/firmware/hvmloader/acpi/acpi2_0.h | 1 +
 tools/firmware/hvmloader/acpi/build.c   | 9 ++++++---
 tools/firmware/hvmloader/util.c         | 3 ++-
 3 files changed, 9 insertions(+), 4 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +1 -0
index 6c762e0..cf707b8 100644
@@ -460,6 +460,7 @@ struct acpi_20_slit {
 #define ACPI_BUILD_SSDT_S4        (1<<2)
 #define ACPI_BUILD_TCPA           (1<<3)
 #define ACPI_BUILD_IOAPIC         (1<<4)
+#define ACPI_BUILD_WAET           (1<<5)
 
 /*
  * Located at ACPI_INFO_PHYSICAL_ADDRESS.
tools/firmware/hvmloader/acpi/build.c +6 -3
index 08cf78b..2bf89e4 100644
@@ -344,9 +344,12 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* WAET. */
-    waet = construct_waet();
-    if (!waet) return -1;
-    table_ptrs[nr_tables++] = (unsigned long)waet;
+    if ( config->table_flags & ACPI_BUILD_WAET )
+    {
+        waet = construct_waet();
+        if (!waet) return -1;
+        table_ptrs[nr_tables++] = (unsigned long)waet;
+    }
 
     if ( config->table_flags & ACPI_BUILD_SSDT_PM )
     {
tools/firmware/hvmloader/util.c +2 -1
index 982d023..c2145f6 100644
@@ -911,7 +911,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
-    config->table_flags |= (ACPI_BUILD_TCPA | ACPI_BUILD_IOAPIC);
+    config->table_flags |= (ACPI_BUILD_TCPA | ACPI_BUILD_IOAPIC |
+                            ACPI_BUILD_WAET);
 
     config->nr_vcpus = hvm_info->nr_vcpus;
     config->vcpu_online = hvm_info->vcpu_online;
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#27 lore raw

Re: [PATCH RFC 09/20] acpi/hvmloader: Build WAET optionally

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long *table_ptrs, · line 350

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +4 -3
@@ -344,9 +344,12 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* WAET. */
-    waet = construct_waet();
-    if (!waet) return -1;
-    table_ptrs[nr_tables++] = (unsigned long)waet;
+    if ( config->table_flags & ACPI_BUILD_WAET )
+    {
+        waet = construct_waet();
+        if (!waet) return -1;

Please fix coding style issues as you re-indent code.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#28 lore raw

RFC PATCH 10/20 acpi/hvmloader: Provide address of acpi_info as an argument to ACPI code

In reply to Boris Ostrovsky

Some users of ACPI builder may be building tables in virtual address space.

---
 tools/firmware/hvmloader/acpi/acpi2_0.h | 4 ++++
 tools/firmware/hvmloader/acpi/build.c   | 3 +--
 tools/firmware/hvmloader/config.h       | 3 +--
 tools/firmware/hvmloader/util.c         | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +4 -0
index cf707b8..0bfd3ed 100644
@@ -306,6 +306,9 @@ struct acpi_20_waet {
 
 #define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
 
+/* NB. ACPI_INFO_PHYSICAL_ADDRESS *MUST* match definition in acpi/dsdt.asl! */
+#define ACPI_INFO_PHYSICAL_ADDRESS    0xFC000000UL
+
 /*
  * Multiple APIC Flags.
  */
@@ -504,6 +507,7 @@ struct acpi_config {
     int apic_mode;
     struct acpi_numa numa;
     uint16_t *tis_hdr;
+    void *acpi_info_page;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +1 -2
index 2bf89e4..991a73f 100644
@@ -589,8 +589,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     if ( !new_vm_gid(config) )
         goto oom;
 
-    memcpy((struct acpi_info *)ACPI_INFO_PHYSICAL_ADDRESS,
-           &config->acpi_info,
+    memcpy(config->acpi_info_page, &config->acpi_info,
            sizeof(config->acpi_info));
 
     return;
tools/firmware/hvmloader/config.h +1 -2
index b838cf9..6253155 100644
@@ -65,8 +65,7 @@ extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
 #define HVMLOADER_PHYSICAL_ADDRESS    0x00100000
 /* Special BIOS mappings, etc. are allocated from here upwards... */
 #define RESERVED_MEMBASE              0xFC000000
-/* NB. ACPI_INFO_PHYSICAL_ADDRESS *MUST* match definition in acpi/dsdt.asl! */
-#define ACPI_INFO_PHYSICAL_ADDRESS    0xFC000000
+
 #define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
 #define RESERVED_MEMORY_DYNAMIC_END   0xFE000000
 /*
tools/firmware/hvmloader/util.c +1 -0
index c2145f6..d099adb 100644
@@ -925,6 +925,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->numa.vmemrange = vmemrange;
 
     config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
+    config->acpi_info_page = (void *)ACPI_INFO_PHYSICAL_ADDRESS;
 
     acpi_build_tables(config, physical);
 
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#29 lore raw

Re: [PATCH RFC 10/20] acpi/hvmloader: Provide address of acpi_info as an argument to ACPI code

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_20_waet { · line 310

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +2 -0
@@ -306,6 +306,9 @@ struct acpi_20_waet {
 
 #define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
 
+/* NB. ACPI_INFO_PHYSICAL_ADDRESS *MUST* match definition in acpi/dsdt.asl! */
+#define ACPI_INFO_PHYSICAL_ADDRESS    0xFC000000UL

As said in the context of another patch - I don't think this belongs here, the more that the consumer is in hvmloader/util.c. This is genuinely a decision of the rest of the firmware (i.e. hvmloader here). Plus, even if it was to be determined by libacpi, this would be the wrong header- here there are supposed to be only ACPI interface definitions.

The same then of course applies to ACPI_TIS_HDR_ADDRESS.

tools/firmware/hvmloader/config.h extern uint64_t pci_hi_mem_start, pci_hi_mem_end; · line 70

Quoted 11 lines
tools/firmware/hvmloader/config.h +1 -2
@@ -65,8 +65,7 @@ extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
 #define HVMLOADER_PHYSICAL_ADDRESS    0x00100000
 /* Special BIOS mappings, etc. are allocated from here upwards... */
 #define RESERVED_MEMBASE              0xFC000000
-/* NB. ACPI_INFO_PHYSICAL_ADDRESS *MUST* match definition in acpi/dsdt.asl! */
-#define ACPI_INFO_PHYSICAL_ADDRESS    0xFC000000
+
 #define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
 #define RESERVED_MEMORY_DYNAMIC_END   0xFE000000

The lower context here actually supports what I've said above. So I think that itsem should stay here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#30 lore raw

RFC PATCH 11/20 acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables

In reply to Boris Ostrovsky

Non-hvmloader users may be building tables in virtual address space and therefore we need to make sure that values that end up in tables are physical addresses.

---
 tools/firmware/hvmloader/acpi/build.c | 47 ++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 23 deletions(-)
tools/firmware/hvmloader/acpi/build.c +24 -23
index 991a73f..941dd0b 100644
@@ -126,7 +126,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config)
     else
         lapic = (struct acpi_20_madt_lapic *)(madt + 1);
 
-    config->acpi_info.madt_lapic0_addr = (uint32_t)lapic;
+    config->acpi_info.madt_lapic0_addr = virt_to_phys(lapic);
     for ( i = 0; i < nr_processor_objects; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
@@ -144,7 +144,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config)
     madt->header.length = (unsigned char *)lapic - (unsigned char *)madt;
     set_checksum(madt, offsetof(struct acpi_header, checksum),
                  madt->header.length);
-    config->acpi_info.madt_csum_addr = (uint32_t)&madt->header.checksum;
+    config->acpi_info.madt_csum_addr =
+        virt_to_phys(&madt->header.checksum);
 
     return madt;
 }
@@ -307,7 +308,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
             break;
         memcpy(buffer, header, header->length);
 
-        table_ptrs[nr_tables++] = (unsigned long)buffer;
+        table_ptrs[nr_tables++] = virt_to_phys(buffer);
         total += header->length;
         acpi_pt_addr += header->length;
     }
@@ -332,7 +333,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     {
         madt = construct_madt(config);
         if (!madt) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)madt;
+        table_ptrs[nr_tables++] = virt_to_phys(madt);
     }
 
     /* HPET. */
@@ -340,7 +341,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     {
         hpet = construct_hpet();
         if (!hpet) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)hpet;
+        table_ptrs[nr_tables++] = virt_to_phys(hpet);
     }
 
     /* WAET. */
@@ -348,7 +349,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     {
         waet = construct_waet();
         if (!waet) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)waet;
+        table_ptrs[nr_tables++] = virt_to_phys(waet);
     }
 
     if ( config->table_flags & ACPI_BUILD_SSDT_PM )
@@ -356,7 +357,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         ssdt = mem_alloc(sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_pm, sizeof(ssdt_pm));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = virt_to_phys(ssdt);
     }
 
     if ( config->table_flags & ACPI_BUILD_SSDT_S3 )
@@ -364,7 +365,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         ssdt = mem_alloc(sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s3, sizeof(ssdt_s3));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = virt_to_phys(ssdt);
     } else {
         printf("S3 disabled\n");
     }
@@ -374,7 +375,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         ssdt = mem_alloc(sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s4, sizeof(ssdt_s4));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = virt_to_phys(ssdt);
     } else {
         printf("S4 disabled\n");
     }
@@ -389,12 +390,12 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
             ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
             if (!ssdt) return -1;
             memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm));
-            table_ptrs[nr_tables++] = (unsigned long)ssdt;
+            table_ptrs[nr_tables++] = virt_to_phys(ssdt);
 
             tcpa = mem_alloc(sizeof(struct acpi_20_tcpa), 16);
             if (!tcpa) return -1;
             memset(tcpa, 0, sizeof(*tcpa));
-            table_ptrs[nr_tables++] = (unsigned long)tcpa;
+            table_ptrs[nr_tables++] = virt_to_phys(tcpa);
 
             tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
             tcpa->header.length    = sizeof(*tcpa);
@@ -423,11 +424,11 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         struct acpi_20_slit *slit = construct_slit(config);
 
         if ( srat )
-            table_ptrs[nr_tables++] = (unsigned long)srat;
+            table_ptrs[nr_tables++] = virt_to_phys(srat);
         else
             printf("Failed to build SRAT, skipping...\n");
         if ( slit )
-            table_ptrs[nr_tables++] = (unsigned long)slit;
+            table_ptrs[nr_tables++] = virt_to_phys(slit);
         else
             printf("Failed to build SLIT, skipping...\n");
     }
@@ -524,8 +525,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     memcpy(fadt_10, &Fadt, sizeof(struct acpi_10_fadt));
     fadt_10->header.length = sizeof(struct acpi_10_fadt);
     fadt_10->header.revision = ACPI_1_0_FADT_REVISION;
-    fadt_10->dsdt          = (unsigned long)dsdt;
-    fadt_10->firmware_ctrl = (unsigned long)facs;
+    fadt_10->dsdt          = virt_to_phys(dsdt);
+    fadt_10->firmware_ctrl = virt_to_phys(facs);
     set_checksum(fadt_10,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_10_fadt));
@@ -533,10 +534,10 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     fadt = mem_alloc(sizeof(struct acpi_20_fadt), 16);
     if (!fadt) goto oom;
     memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
-    fadt->dsdt   = (unsigned long)dsdt;
-    fadt->x_dsdt = (unsigned long)dsdt;
-    fadt->firmware_ctrl   = (unsigned long)facs;
-    fadt->x_firmware_ctrl = (unsigned long)facs;
+    fadt->dsdt   = virt_to_phys(dsdt);
+    fadt->x_dsdt = virt_to_phys(dsdt);
+    fadt->firmware_ctrl   = virt_to_phys(facs);
+    fadt->x_firmware_ctrl = virt_to_phys(facs);
     set_checksum(fadt,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
@@ -550,7 +551,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
                      16);
     if (!xsdt) goto oom;
     memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
-    xsdt->entry[0] = (unsigned long)fadt;
+    xsdt->entry[0] = virt_to_phys(fadt);
     for ( i = 0; secondary_tables[i]; i++ )
         xsdt->entry[i+1] = secondary_tables[i];
     xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t);
@@ -563,7 +564,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
                      16);
     if (!rsdt) goto oom;
     memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
-    rsdt->entry[0] = (unsigned long)fadt_10;
+    rsdt->entry[0] = virt_to_phys(fadt_10);
     for ( i = 0; secondary_tables[i]; i++ )
         rsdt->entry[i+1] = secondary_tables[i];
     rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t);
@@ -577,8 +578,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     rsdp = (struct acpi_20_rsdp *)physical;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
-    rsdp->rsdt_address = (unsigned long)rsdt;
-    rsdp->xsdt_address = (unsigned long)xsdt;
+    rsdp->rsdt_address = virt_to_phys(rsdt);
+    rsdp->xsdt_address = virt_to_phys(xsdt);
     set_checksum(rsdp,
                  offsetof(struct acpi_10_rsdp, checksum),
                  sizeof(struct acpi_10_rsdp));
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#31 lore raw

Re: [PATCH RFC 11/20] acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables

tools/firmware/hvmloader/acpi/build.c static struct acpi_20_madt *construct_madt(struct acpi_config *config) · line 129

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -126,7 +126,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config)
     else
         lapic = (struct acpi_20_madt_lapic *)(madt + 1);
 
-    config->acpi_info.madt_lapic0_addr = (uint32_t)lapic;
+    config->acpi_info.madt_lapic0_addr = virt_to_phys(lapic);

While perhaps it doesn't matter much, considering that hvmloader already has virt_to_phys() I think earlier patches touching lines like the one above would better switch to using it right away, instead of using (or even introducing) explicit casts. That'll reduce code churn and make the history of the changes to the affected lines more clear.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#32 lore raw

RFC PATCH 12/20 acpi/hvmloader: Link ACPI object files directly

In reply to Boris Ostrovsky

ACPI sources will be available to various component which will build them according to their own rules. ACPI directory will only build sources.

---
 tools/firmware/hvmloader/Makefile             | 17 ++++++++++++++---
 tools/firmware/hvmloader/acpi/Makefile        |  9 ++-------
 tools/firmware/hvmloader/hvmloader.c          |  2 +-
 tools/firmware/hvmloader/ovmf.c               |  2 +-
 tools/firmware/hvmloader/rombios.c            |  2 +-
 tools/firmware/hvmloader/seabios.c            |  2 +-
 tools/firmware/hvmloader/util.c               |  2 +-
 tools/firmware/rombios/32bit/Makefile         |  2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile |  2 +-
 tools/firmware/rombios/32bit/util.h           |  2 +-
 10 files changed, 24 insertions(+), 18 deletions(-)
tools/firmware/hvmloader/Makefile +14 -3
index f2f4791..ef66019 100644
@@ -20,8 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 
@@ -33,10 +31,18 @@ CFLAGS += $(CFLAGS_xeninclude)
 # We mustn't use tools-only public interfaces.
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
+# ACPI table builder
+ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
+vpath %.c $(ACPI_PATH)
+ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c build.c
+ACPI_SRC = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
+CFLAGS += -I$(ACPI_PATH)
+
 OBJS  = hvmloader.o mp_tables.o util.o smbios.o 
 OBJS += smp.o cacheattr.o xenbus.o vnuma.o
 OBJS += e820.o pci.o pir.o ctype.o
 OBJS += hvm_param.o
+OBJS += $(patsubst %.c,%.o,$(ACPI_FILES))
 ifeq ($(debug),y)
 OBJS += tests.o
 endif
@@ -95,7 +101,11 @@ all: subdirs-all
 ovmf.o rombios.o seabios.o hvmloader.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+.NOTPARALLEL: $(ACPI_SRC)
+$(ACPI_SRC):
+	$(MAKE) -C $(ACPI_PATH)
+
+hvmloader: $(OBJS)
 	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(LOADADDR) -o hvmloader.tmp $^
 	$(OBJCOPY) hvmloader.tmp hvmloader
 	rm -f hvmloader.tmp
@@ -143,6 +153,7 @@ endif
 clean: subdirs-clean
 	rm -f roms.inc roms.inc.new acpi.h
 	rm -f hvmloader hvmloader.tmp *.o $(DEPS)
+	$(MAKE) -C $(ACPI_PATH) clean
 
 .PHONY: distclean
 distclean: clean
tools/firmware/hvmloader/acpi/Makefile +2 -7
index d3e882a..4d84e4c 100644
@@ -23,7 +23,7 @@ OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 CFLAGS += $(CFLAGS_xeninclude)
 
 vpath iasl $(PATH)
-all: acpi.a
+all: $(C_SRC) ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
 
 ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
 	iasl -vs -p $* -tc $<
@@ -56,13 +56,8 @@ iasl:
 	@echo 
 	@exit 1
 
-build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
-
-acpi.a: $(OBJS)
-	$(AR) rc $@ $(OBJS)
-
 clean:
-	rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
+	rm -rf *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
 	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
 
 distclean: clean
tools/firmware/hvmloader/hvmloader.c +1 -1
index 716d03c..c8311a1 100644
@@ -24,7 +24,7 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"
 #include "vnuma.h"
 #include <xen/version.h>
 #include <xen/hvm/params.h>
tools/firmware/hvmloader/ovmf.c +1 -1
index 74fec56..e7c48a5 100644
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"
 #include "apic_regs.h"
 #include "../rombios/config.h"
 #include "util.h"
tools/firmware/hvmloader/rombios.c +1 -1
index 1f8fc2d..863c1a7 100644
@@ -24,7 +24,7 @@
 #include "../rombios/config.h"
 
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"
 #include "pci_regs.h"
 #include "util.h"
 #include "hypercall.h"
tools/firmware/hvmloader/seabios.c +1 -1
index 9f66a79..5184275 100644
@@ -25,7 +25,7 @@
 #include "util.h"
 
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"
 
 #define ROM_INCLUDE_SEABIOS
 #include "roms.inc"
tools/firmware/hvmloader/util.c +1 -1
index d099adb..a21d3cb 100644
@@ -22,7 +22,7 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "vnuma.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
tools/firmware/rombios/32bit/Makefile +1 -1
index 396906c..9b523bd 100644
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I$(XEN_ROOT)/tools/firmware/hvmloader/acpi/
 
 SUBDIRS = tcgbios
 
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
index f6f2649..6555028 100644
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I$(XEN_ROOT)/tools/firmware/hvmloader/acpi/
 
 .PHONY: all
 all: $(TARGET)
tools/firmware/rombios/32bit/util.h +1 -1
index e245be6..8f8ab35 100644
@@ -1,7 +1,7 @@
 #ifndef UTIL_H
 #define UTIL_H
 
-#include "../hvmloader/acpi/acpi2_0.h"
+#include "acpi2_0.h"
 
 void outb(uint16_t addr, uint8_t val);
 void outw(uint16_t addr, uint16_t val);
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#33 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

ACPI sources will be available to various component which will build them according to their own rules. ACPI directory will only build sources.

"build sources" is kind of contradictory. How about "build intermediate files"?

Quoted 12 lines
tools/firmware/hvmloader/Makefile +0 -2
@@ -20,8 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 

tools/firmware/hvmloader/Makefile CFLAGS += $(CFLAGS_xeninclude) · line 36

Quoted 6 lines
tools/firmware/hvmloader/Makefile +3 -0
@@ -33,10 +31,18 @@ CFLAGS += $(CFLAGS_xeninclude)
 # We mustn't use tools-only public interfaces.
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
+# ACPI table builder
+ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
+vpath %.c $(ACPI_PATH)

Please don't - this would preclude having files with the same names in hvmloader/ and (the future) libacpi/.

tools/firmware/hvmloader/Makefile all: subdirs-all · line 104

Quoted 6 lines
tools/firmware/hvmloader/Makefile +1 -1
@@ -95,7 +101,11 @@ all: subdirs-all
 ovmf.o rombios.o seabios.o hvmloader.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+.NOTPARALLEL: $(ACPI_SRC)

And very clearly we will want to avoid the use of .NOTPARALLEL anywhere in our trees.

tools/firmware/hvmloader/Makefile all: subdirs-all · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +2 -0
+$(ACPI_SRC):
+	$(MAKE) -C $(ACPI_PATH)

The more that you can't do this from multiple points in the tree. Did you consider e.g. symlinking the subtree into the multiple parent trees?

tools/firmware/hvmloader/acpi/Makefile OBJS = $(patsubst %.c,%.o,$(C_SRC)) · line 26

Quoted 8 lines
tools/firmware/hvmloader/acpi/Makefile +1 -1
@@ -23,7 +23,7 @@ OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 CFLAGS += $(CFLAGS_xeninclude)
 
 vpath iasl $(PATH)
-all: acpi.a
+all: $(C_SRC) ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h

Why $(C_CRC)? Clearly build.c and static_tables.c don't need listing here.

tools/firmware/rombios/32bit/Makefile include $(XEN_ROOT)/tools/firmware/Rules.mk · line 6

Quoted 8 lines
tools/firmware/rombios/32bit/Makefile +1 -1
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I$(XEN_ROOT)/tools/firmware/hvmloader/acpi/

As long as nothing speaks against doing so, I think such references are better done in a relative manner. That way moving the entire build tree won't affect the command lines passed to build tools.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#34 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

Quoted 31 lines · Jan Beulich
Quoted 13 lines
tools/firmware/hvmloader/Makefile +0 -2
@@ -20,8 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 

tools/firmware/hvmloader/Makefile CFLAGS += $(CFLAGS_xeninclude) · line 36

Quoted 6 lines
tools/firmware/hvmloader/Makefile +3 -0
@@ -33,10 +31,18 @@ CFLAGS += $(CFLAGS_xeninclude)
 # We mustn't use tools-only public interfaces.
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
+# ACPI table builder
+ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
+vpath %.c $(ACPI_PATH)

Please don't - this would preclude having files with the same names in hvmloader/ and (the future) libacpi/.

tools/firmware/hvmloader/Makefile all: subdirs-all · line 104

Quoted 6 lines
tools/firmware/hvmloader/Makefile +1 -1
@@ -95,7 +101,11 @@ all: subdirs-all
 ovmf.o rombios.o seabios.o hvmloader.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+.NOTPARALLEL: $(ACPI_SRC)

And very clearly we will want to avoid the use of .NOTPARALLEL anywhere in our trees.

Quoted 5 lines

tools/firmware/hvmloader/Makefile all: subdirs-all · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +2 -0
+$(ACPI_SRC):
+	$(MAKE) -C $(ACPI_PATH)

The more that you can't do this from multiple points in the tree. Did you consider e.g. symlinking the subtree into the multiple parent trees?

How would this help with avoiding building the intermediate files from multiple paces (libxc and hvmloader specifically --- that was the reason for .NOTPARALLEL).

I thought of flock-ing directory but then I was afraid that interrupted make may not clean up properly.

Or are you suggesting symlinking to help with include paths (i.e. to drop vpath above)?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#35 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

Quoted 39 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 16:20, <[email protected]> wrote:
Quoted 31 lines · Jan Beulich
Quoted 13 lines
tools/firmware/hvmloader/Makefile +0 -2
@@ -20,8 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 

tools/firmware/hvmloader/Makefile CFLAGS += $(CFLAGS_xeninclude) · line 36

Quoted 6 lines
tools/firmware/hvmloader/Makefile +3 -0
@@ -33,10 +31,18 @@ CFLAGS += $(CFLAGS_xeninclude)
 # We mustn't use tools-only public interfaces.
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
+# ACPI table builder
+ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
+vpath %.c $(ACPI_PATH)

Please don't - this would preclude having files with the same names in hvmloader/ and (the future) libacpi/.

tools/firmware/hvmloader/Makefile all: subdirs-all · line 104

Quoted 6 lines
tools/firmware/hvmloader/Makefile +1 -1
@@ -95,7 +101,11 @@ all: subdirs-all
 ovmf.o rombios.o seabios.o hvmloader.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+.NOTPARALLEL: $(ACPI_SRC)

And very clearly we will want to avoid the use of .NOTPARALLEL anywhere in our trees.

Quoted 5 lines

tools/firmware/hvmloader/Makefile all: subdirs-all · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +2 -0
+$(ACPI_SRC):
+	$(MAKE) -C $(ACPI_PATH)

The more that you can't do this from multiple points in the tree. Did you consider e.g. symlinking the subtree into the multiple parent trees?

Quoted 3 lines

How would this help with avoiding building the intermediate files from multiple paces (libxc and hvmloader specifically --- that was the reason for .NOTPARALLEL).

If you symlink the source files into three different subdirectories, building in those three subdirectories will become independent. (Or, just like libelf, build the hypervisor part in the actual directory, and symlink only the libxc and hvmloader uses.)

Quoted 5 lines

I thought of flock-ing directory but then I was afraid that interrupted make may not clean up properly.

Or are you suggesting symlinking to help with include paths (i.e. to drop vpath above)?

That as well - symlinking would solve a number of issues that I have pointed out, afaict at least.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#36 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

Quoted 7 lines · Jan Beulich
Quoted 3 lines

How would this help with avoiding building the intermediate files from multiple paces (libxc and hvmloader specifically --- that was the reason for .NOTPARALLEL).

If you symlink the source files into three different subdirectories, building in those three subdirectories will become independent. (Or, just like libelf, build the hypervisor part in the actual directory, and symlink only the libxc and hvmloader uses.)

I see. I didn't want to generate intermediate files multiple times but yes, it's better than dealing with make synchronization issues.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#37 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 16:49, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines

How would this help with avoiding building the intermediate files from multiple paces (libxc and hvmloader specifically --- that was the reason for .NOTPARALLEL).

Quoted 7 lines
Quoted 4 lines

If you symlink the source files into three different subdirectories, building in those three subdirectories will become independent. (Or, just like libelf, build the hypervisor part in the actual directory, and symlink only the libxc and hvmloader uses.)

I see. I didn't want to generate intermediate files multiple times but yes, it's better than dealing with make synchronization issues.

Plus, in the end, there may be a need for slightly different build settings (resulting in slightly different intermediate files).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#38 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

In reply to Boris Ostrovsky
Quoted 10 lines · Boris Ostrovsky
Quoted 7 lines · Jan Beulich
Quoted 3 lines

How would this help with avoiding building the intermediate files from multiple paces (libxc and hvmloader specifically --- that was the reason for .NOTPARALLEL).

If you symlink the source files into three different subdirectories, building in those three subdirectories will become independent. (Or, just like libelf, build the hypervisor part in the actual directory, and symlink only the libxc and hvmloader uses.)

I see. I didn't want to generate intermediate files multiple times but yes, it's better than dealing with make synchronization issues.

It is exceedingly unlikely that Xen, the toolstack, and hvmloader will have libacpi compiled with the same compiler settings.

Sharing intermediate files is not safe to do in this context.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#39 lore raw

Re: [PATCH RFC 12/20] acpi/hvmloader: Link ACPI object files directly

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 17:31, <[email protected]> wrote:
Quoted 8 lines · Boris Ostrovsky
Quoted 7 lines · Jan Beulich
Quoted 3 lines

How would this help with avoiding building the intermediate files from multiple paces (libxc and hvmloader specifically --- that was the reason for .NOTPARALLEL).

If you symlink the source files into three different subdirectories, building in those three subdirectories will become independent. (Or, just like libelf, build the hypervisor part in the actual directory, and symlink only the libxc and hvmloader uses.)

Quoted 7 lines
Quoted 2 lines

I see. I didn't want to generate intermediate files multiple times but yes, it's better than dealing with make synchronization issues.

It is exceedingly unlikely that Xen, the toolstack, and hvmloader will have libacpi compiled with the same compiler settings.

Sharing intermediate files is not safe to do in this context.

But you realize we don't talk about compiler settings here? The intermediate .c files are to represent compiled .asl ones, and the .asl -> .c conversion is much more likely to happen in mostly similar fashion. But I can foresee customization, which would end up being different between the consumer environments.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#40 lore raw

RFC PATCH 13/20 acpi/hvmloader: Add stdio.h, string.h and x86.h

In reply to Boris Ostrovsky

Users of ACPI builder will need to provide their own implemetations of strncpy(), memcpy, memset() and printf declared in stdio.h and string.h. For hvmloader we provide those two as wrappers around utul.h.

Some x86-specific definitions move to ACPI builder's x86.h file so that users won't have to re-define them themselves.

Explicitly define a few things that are currently available to to build.c via util.h.

Remove unnecessary #include "../config.h" from static_tables.c

---
 tools/firmware/hvmloader/Makefile             |  2 +-
 tools/firmware/hvmloader/acpi/build.c         | 23 +++++++++++++++++------
 tools/firmware/hvmloader/acpi/static_tables.c |  1 -
 tools/firmware/hvmloader/acpi/x86.h           | 14 ++++++++++++++
 tools/firmware/hvmloader/config.h             | 10 ----------
 tools/firmware/hvmloader/hvmloader.c          |  1 +
 tools/firmware/hvmloader/mp_tables.c          |  1 +
 tools/firmware/hvmloader/pci.c                |  1 +
 tools/firmware/hvmloader/pir.c                |  1 +
 tools/firmware/hvmloader/smp.c                |  1 +
 tools/firmware/hvmloader/stdio.h              |  7 +++++++
 tools/firmware/hvmloader/string.h             |  7 +++++++
 tools/firmware/hvmloader/util.c               |  1 +
 13 files changed, 52 insertions(+), 18 deletions(-)
 create mode 100644 tools/firmware/hvmloader/acpi/x86.h
 create mode 100644 tools/firmware/hvmloader/stdio.h
 create mode 100644 tools/firmware/hvmloader/string.h
tools/firmware/hvmloader/Makefile +1 -1
index ef66019..c778174 100644
@@ -36,7 +36,7 @@ ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
 vpath %.c $(ACPI_PATH)
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c build.c
 ACPI_SRC = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
-CFLAGS += -I$(ACPI_PATH)
+CFLAGS += -I$(ACPI_PATH) -I.
 
 OBJS  = hvmloader.o mp_tables.o util.o smbios.o 
 OBJS += smp.o cacheattr.o xenbus.o vnuma.o
tools/firmware/hvmloader/acpi/build.c +17 -6
index 941dd0b..09c1ed3 100644
@@ -15,14 +15,16 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <stdio.h>
+#include <string.h>
+
 #include "acpi2_0.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
-#include "../config.h"
-#include "../util.h"
-#include "../vnuma.h"
+#include "x86.h"
+#include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
@@ -30,6 +32,12 @@
 
 #define align16(sz)        (((sz) + 15) & ~15)
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+#ifndef offsetof
+#define offsetof(t, m) ((unsigned long)&((t *)0)->m)
+#endif
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
 
 extern struct acpi_20_rsdp Rsdp;
 extern struct acpi_20_rsdt Rsdt;
@@ -41,6 +49,11 @@ extern struct acpi_20_waet Waet;
 /* Number of processor objects in the chosen DSDT. */
 static unsigned int nr_processor_objects;
 
+static inline int __test_bit(unsigned int b, void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}
+
 static void set_checksum(
     void *table, uint32_t checksum_offset, uint32_t length)
 {
@@ -136,7 +149,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config)
         lapic->acpi_processor_id = i;
         lapic->apic_id = LAPIC_ID(i);
         lapic->flags = ((i < config->nr_vcpus) &&
-                        test_bit(i, config->vcpu_online)
+                        __test_bit(i, config->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
         lapic++;
     }
@@ -238,8 +251,6 @@ static struct acpi_20_srat *construct_srat(struct acpi_config *config)
         memory++;
     }
 
-    ASSERT(((unsigned long)memory) - ((unsigned long)p) == size);
-
     srat->header.length = size;
     set_checksum(srat, offsetof(struct acpi_header, checksum), size);
 
tools/firmware/hvmloader/acpi/static_tables.c +0 -1
index f4d627b..d4db030 100644
@@ -16,7 +16,6 @@
  */
 
 #include "acpi2_0.h"
-#include "../config.h"
 
 /*
  * Firmware ACPI Control Structure (FACS).
tools/firmware/hvmloader/acpi/x86.h new file +14 -0
new file mode 100644
index 0000000..99a2d5c
@@ -0,0 +1,14 @@
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000
+#define IOAPIC_ID           0x01
+#define IOAPIC_VERSION      0x11
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+
+#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
+#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
+
+#endif /* __ACPI_X86_H__ */
tools/firmware/hvmloader/config.h +0 -10
index 6253155..9d1eacb 100644
@@ -42,16 +42,6 @@ extern struct bios_config ovmf_config;
 #define PAGE_SHIFT 12
 #define PAGE_SIZE  (1ul << PAGE_SHIFT)
 
-#define IOAPIC_BASE_ADDRESS 0xfec00000
-#define IOAPIC_ID           0x01
-#define IOAPIC_VERSION      0x11
-
-#define LAPIC_BASE_ADDRESS  0xfee00000
-#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
-
-#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
-#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
-
 /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
 #define PCI_MEM_END         0xfc000000
 
tools/firmware/hvmloader/hvmloader.c +1 -0
index c8311a1..5fe8007 100644
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
+#include "x86.h"
 #include "acpi2_0.h"
 #include "vnuma.h"
 #include <xen/version.h>
tools/firmware/hvmloader/mp_tables.c +1 -0
index 69c2885..4d21304 100644
@@ -29,6 +29,7 @@
 
 #include <stdint.h>
 #include "config.h"
+#include "x86.h"
 
 /* number of non-processor MP table entries */
 #define NR_NONPROC_ENTRIES     18
tools/firmware/hvmloader/pci.c +1 -0
index 4eb1a31..1813ffa 100644
@@ -22,6 +22,7 @@
 #include "util.h"
 #include "hypercall.h"
 #include "config.h"
+#include "x86.h"
 #include "pci_regs.h"
 
 #include <xen/memory.h>
tools/firmware/hvmloader/pir.c +1 -0
index cc420dd..d238a14 100644
@@ -14,6 +14,7 @@
  */
 
 #include "config.h"
+#include "x86.h"
 #include "pir_types.h"
 #include "util.h"
 
tools/firmware/hvmloader/smp.c +1 -0
index 082b17f..ae309b3 100644
@@ -21,6 +21,7 @@
 
 #include "util.h"
 #include "config.h"
+#include "x86.h"
 #include "apic_regs.h"
 
 #define AP_BOOT_EIP 0x1000
tools/firmware/hvmloader/stdio.h new file +7 -0
new file mode 100644
index 0000000..6475ce8
@@ -0,0 +1,7 @@
+#ifndef __HVMLOADER_STDIO_H_
+#define __HVMLOADER_STDIO_H_
+
+/* Declaration for printf */
+#include "util.h"
+
+#endif
tools/firmware/hvmloader/string.h new file +7 -0
new file mode 100644
index 0000000..a6085e2
@@ -0,0 +1,7 @@
+#ifndef __HVMLOADER_STRING_H_
+#define __HVMLOADER_STRING_H_
+
+/* Declarations for memset, memcpy, strcpy */
+#include "util.h"
+
+#endif
tools/firmware/hvmloader/util.c +1 -0
index a21d3cb..c111f61 100644
@@ -22,6 +22,7 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "vnuma.h"
+#include "x86.h"
 #include "acpi2_0.h"
 #include <stdint.h>
 #include <xen/xen.h>
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#41 lore raw

Re: [PATCH RFC 13/20] acpi/hvmloader: Add stdio.h, string.h and x86.h

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

Users of ACPI builder will need to provide their own implemetations of strncpy(), memcpy, memset() and printf declared in stdio.h and string.h. For hvmloader we provide those two as wrappers around utul.h.

Some x86-specific definitions move to ACPI builder's x86.h file so that users won't have to re-define them themselves.

Explicitly define a few things that are currently available to to build.c via util.h.

Considering the first paragraph, this last sentence was more confusing than clarifying to me: I expected util.h to get changed in some way, but aiui having gone through the entire patch this is just a (very different) re-statement of what you've said already.

Quoted 3 lines
 create mode 100644 tools/firmware/hvmloader/acpi/x86.h
 create mode 100644 tools/firmware/hvmloader/stdio.h
 create mode 100644 tools/firmware/hvmloader/string.h

I have to admit that I'm not really looking forward to see the hypervisor gain a file stdio.h. I'm also not convinced libxc'e planned use of the libacpi/ would fit well with uses of printf() in that subtree.

tools/firmware/hvmloader/Makefile ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi · line 39

Quoted 9 lines
tools/firmware/hvmloader/Makefile +0 -0
@@ -36,7 +36,7 @@ ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
 vpath %.c $(ACPI_PATH)
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c static_tables.c 

dsdt_anycpu_qemu_xen.c build.c
ACPI_SRC = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))

tools/firmware/hvmloader/Makefile +1 -1
-CFLAGS += -I$(ACPI_PATH)
+CFLAGS += -I$(ACPI_PATH) -I.

With the subtree symlink approach, such an addition could then be limited to just the libacpi/ files, i.e. not affecting core hvmloader ones.

tools/firmware/hvmloader/Makefile line 40

Quoted 10 lines
tools/firmware/hvmloader/Makefile +6 -0
@@ -30,6 +32,12 @@
 
 #define align16(sz)        (((sz) + 15) & ~15)
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+#ifndef offsetof
+#define offsetof(t, m) ((unsigned long)&((t *)0)->m)
+#endif
+#ifndef NULL
+#define NULL ((void *)0)
+#endif

These should be provided by the consumer too, I would say (stddef.h).

tools/firmware/hvmloader/Makefile extern struct acpi_20_waet Waet; · line 55

Quoted 8 lines
tools/firmware/hvmloader/Makefile +4 -0
@@ -41,6 +49,11 @@ extern struct acpi_20_waet Waet;
 /* Number of processor objects in the chosen DSDT. */
 static unsigned int nr_processor_objects;
 
+static inline int __test_bit(unsigned int b, void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}

This one too, without the leading underscores (bitops.h or some other sbtraction). All three potential consumers of this code already have test_bit().

tools/firmware/hvmloader/Makefile static struct acpi_20_srat *construct_srat(struct acpi_config *config) · line 241

Quoted 5 lines
tools/firmware/hvmloader/Makefile +0 -1
@@ -238,8 +251,6 @@ static struct acpi_20_srat *construct_srat(struct acpi_config *config)
         memory++;
     }
 
-    ASSERT(((unsigned long)memory) - ((unsigned long)p) == size);

I think this was put here for a reason, and hence shouldn't be removed without good reason (I wouldn't count ASSERT() not being available as one).

Quoted 5 lines
tools/firmware/hvmloader/acpi/x86.h new file +2 -0
@@ -0,0 +1,14 @@
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__

tools/firmware/hvmloader/acpi/x86.h line 12

Quoted 10 lines
tools/firmware/hvmloader/acpi/x86.h new file +10 -0
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000
+#define IOAPIC_ID           0x01
+#define IOAPIC_VERSION      0x11
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+
+#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
+#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */

Only the latter of those last two is used by build.c. Please limit what you move to the very minimum. I.e. IOAPIC_VERSION shouldn't move either imo (and I notice there's a disconnect between it and the hypervisor's VIOAPIC_VERSION_ID, but that's a pre-existing issue).

tools/firmware/hvmloader/hvmloader.c line 27

Quoted 7 lines
tools/firmware/hvmloader/hvmloader.c +1 -0
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
+#include "x86.h"

Looking at an inclusion point like this, it is completely unclear that this comes from libacpi/. One more argument in favor of keeping the subtree.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#42 lore raw

Re: [PATCH RFC 13/20] acpi/hvmloader: Add stdio.h, string.h and x86.h

Quoted 15 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

Users of ACPI builder will need to provide their own implemetations of strncpy(), memcpy, memset() and printf declared in stdio.h and string.h. For hvmloader we provide those two as wrappers around utul.h.

Some x86-specific definitions move to ACPI builder's x86.h file so that users won't have to re-define them themselves.

Explicitly define a few things that are currently available to to build.c via util.h.

Considering the first paragraph, this last sentence was more confusing than clarifying to me: I expected util.h to get changed in some way, but aiui having gone through the entire patch this is just a (very different) re-statement of what you've said already.

Quoted 7 lines
Quoted 3 lines
 create mode 100644 tools/firmware/hvmloader/acpi/x86.h
 create mode 100644 tools/firmware/hvmloader/stdio.h
 create mode 100644 tools/firmware/hvmloader/string.h

I have to admit that I'm not really looking forward to see the hypervisor gain a file stdio.h. I'm also not convinced libxc'e planned use of the libacpi/ would fit well with uses of printf() in that subtree.

Hypervisor won't use it, it will be included under '#ifndef __XEN__' (in patch 20).

Quoted 12 lines
Quoted 12 lines
tools/firmware/hvmloader/acpi/x86.h new file +8 -0
@@ -0,0 +1,14 @@
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000
+#define IOAPIC_ID           0x01
+#define IOAPIC_VERSION      0x11
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
Quoted 8 lines

tools/firmware/hvmloader/acpi/x86.h line 12

Quoted 4 lines
tools/firmware/hvmloader/acpi/x86.h new file +4 -0
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+
+#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
+#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */

Only the latter of those last two is used by build.c. Please limit what you move to the very minimum. I.e. IOAPIC_VERSION shouldn't move either imo (and I notice there's a disconnect between it and the hypervisor's VIOAPIC_VERSION_ID, but that's a pre-existing issue).

You don't think logically all these should be in the same file?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#43 lore raw

Re: [PATCH RFC 13/20] acpi/hvmloader: Add stdio.h, string.h and x86.h

Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 17:08, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/x86.h new file +8 -0
@@ -0,0 +1,14 @@
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000
+#define IOAPIC_ID           0x01
+#define IOAPIC_VERSION      0x11
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
Quoted 8 lines

tools/firmware/hvmloader/acpi/x86.h line 12

Quoted 4 lines
tools/firmware/hvmloader/acpi/x86.h new file +4 -0
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+
+#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
+#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */

Only the latter of those last two is used by build.c. Please limit what you move to the very minimum. I.e. IOAPIC_VERSION shouldn't move either imo (and I notice there's a disconnect between it and the hypervisor's VIOAPIC_VERSION_ID, but that's a pre-existing issue).

Quoted 1 line

You don't think logically all these should be in the same file?

Not really, no. IOAPIC_VERSION, as said, should go away. Meanwhile I already have a patch for that (at once dropping IOAPIC_BASE_ADDRESS too), albeit that conflicts with what you're doing.

And the two PCI_ISA_ ones seem to belong together solely because of their name. The IRQ mask is a simple number, unrelated to any specific PCI device.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#44 lore raw

RFC PATCH 14/20 acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops

In reply to Boris Ostrovsky

Components that wish to use ACPI builder will need to provide their own mem_alloc() and virt_to_phys() routines. Pointers to these routines will be passed to the builder as memory ops.

---
 tools/firmware/hvmloader/acpi/acpi2_0.h |   6 ++
 tools/firmware/hvmloader/acpi/build.c   | 104 +++++++++++++++++---------------
 tools/firmware/hvmloader/util.c         |   8 +++
 tools/firmware/hvmloader/util.h         |   2 +-
 4 files changed, 70 insertions(+), 50 deletions(-)
tools/firmware/hvmloader/acpi/acpi2_0.h +6 -0
index 0bfd3ed..0525a1e 100644
@@ -490,6 +490,11 @@ struct acpi_numa {
     xen_vmemrange_t *vmemrange;
 };
 
+struct acpi_mem_ops {
+    void *(*alloc)(uint32_t size, uint32_t align);
+    unsigned long (*v2p)(void *v);
+};
+
 struct acpi_config {
     unsigned char *dsdt_anycpu;
     int dsdt_anycpu_len;
@@ -508,6 +513,7 @@ struct acpi_config {
     struct acpi_numa numa;
     uint16_t *tis_hdr;
     void *acpi_info_page;
+    struct acpi_mem_ops mem_ops;
 };
 
 void acpi_build_tables(struct acpi_config *config, unsigned int physical);
tools/firmware/hvmloader/acpi/build.c +55 -49

300 lines not on this page · raw message

tools/firmware/hvmloader/util.c +8 -0
index c111f61..9e6ee7d 100644
@@ -866,6 +866,11 @@ static uint8_t battery_port_exists(void)
     return (inb(0x88) == 0x1F);
 }
 
+unsigned long virt_to_phys(void *v)
+{
+    return (unsigned long)v;
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
@@ -928,6 +933,9 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
     config->acpi_info_page = (void *)ACPI_INFO_PHYSICAL_ADDRESS;
 
+    config->mem_ops.alloc = mem_alloc;
+    config->mem_ops.v2p = virt_to_phys;
+
     acpi_build_tables(config, physical);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->acpi_info.vm_gid_addr);
tools/firmware/hvmloader/util.h +1 -1
index b226df4..91c210c 100644
@@ -196,7 +196,7 @@ xen_pfn_t mem_hole_alloc(uint32_t nr_mfns);
 
 /* Allocate memory in a reserved region below 4GB. */
 void *mem_alloc(uint32_t size, uint32_t align);
-#define virt_to_phys(v) ((unsigned long)(v))
+unsigned long virt_to_phys(void *v);
 
 /* Allocate memory in a scratch region */
 void *scratch_alloc(uint32_t size, uint32_t align);
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#45 lore raw

Re: [PATCH RFC 14/20] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_numa { · line 496

Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +4 -0
@@ -490,6 +490,11 @@ struct acpi_numa {
     xen_vmemrange_t *vmemrange;
 };
 
+struct acpi_mem_ops {
+    void *(*alloc)(uint32_t size, uint32_t align);
+    unsigned long (*v2p)(void *v);
+};

As before, I think this is the wrong header for such stuff.

And then I think I agree with the allocation hook (or otherwise the too generic name would need to be changed), but I don't think I agree with the v2p one. Instead I think the consumer should provide a suitable virt_to_phys(): That's already the case for hvmloader, should be trivial for libxc. And as long as we provide Dom0 with a 1:1 machine/physical addresses, the existing one in the hypervisor would do too.

At the very least alternatively, to reduce code churn, patch order should be changed, so that you don't touch again all the lines that you made use virt_to_phys() just a patch or two ago.

Plus I think the allocation hook should be accompanied by a freeing one, even if for now this may not be used. Iirc there are cases where space gets allocated without being retained, not getting freed just because the simplistic allocator can't handle such.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#46 lore raw

Re: [PATCH RFC 14/20] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops

Quoted 21 lines · Jan Beulich

tools/firmware/hvmloader/acpi/acpi2_0.h struct acpi_numa { · line 496

Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/acpi2_0.h +4 -0
@@ -490,6 +490,11 @@ struct acpi_numa {
     xen_vmemrange_t *vmemrange;
 };
 
+struct acpi_mem_ops {
+    void *(*alloc)(uint32_t size, uint32_t align);
+    unsigned long (*v2p)(void *v);
+};

As before, I think this is the wrong header for such stuff.

And then I think I agree with the allocation hook (or otherwise the too generic name would need to be changed), but I don't think I agree with the v2p one. Instead I think the consumer should provide a suitable virt_to_phys(): That's already the case for hvmloader, should be trivial for libxc. And as long as we provide Dom0 with a 1:1 machine/physical addresses, the existing one in the hypervisor would do too.

Quoted 3 lines

At the very least alternatively, to reduce code churn, patch order should be changed, so that you don't touch again all the lines that you made use virt_to_phys() just a patch or two ago.

I'd rather go this route. IIRC I initially had both mem_alloc() and virt_to_phys() being provided by callers by name but it ended up being somewhat messy. And I think for consistency sake they should both be either hooks or provided directly.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#47 lore raw

RFC PATCH 15/20 acpi: Move ACPI code to xen/common/libacpi

In reply to Boris Ostrovsky
---
 .gitignore                                                        | 8 ++++----
 tools/firmware/hvmloader/Makefile                                 | 3 +--
 tools/firmware/hvmloader/smbios.c                                 | 1 +
 tools/firmware/rombios/32bit/Makefile                             | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile                     | 2 +-
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile    | 6 +++---
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README      | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c     | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl    | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl | 0
 .../firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl   | 0
 .../hvmloader/acpi => xen/common/libacpi}/static_tables.c         | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h       | 0
 17 files changed, 11 insertions(+), 11 deletions(-)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile (94%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/static_tables.c (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h (100%)
.gitignore +4 -4
index 91f690c..15d3705 100644
@@ -123,10 +123,6 @@ tools/firmware/*bios/*bios*.txt
 tools/firmware/etherboot/gpxe/*
 tools/firmware/extboot/extboot.img
 tools/firmware/extboot/signrom
-tools/firmware/hvmloader/acpi/mk_dsdt
-tools/firmware/hvmloader/acpi/dsdt*.c
-tools/firmware/hvmloader/acpi/dsdt_*.asl
-tools/firmware/hvmloader/acpi/ssdt_*.h
 tools/firmware/hvmloader/hvmloader
 tools/firmware/hvmloader/roms.h
 tools/firmware/hvmloader/roms.inc
@@ -259,6 +255,10 @@ xen/include/public/public
 xen/include/xen/*.new
 xen/include/xen/acm_policy.h
 xen/include/xen/compile.h
+xen/common/libacpi/mk_dsdt
+xen/common/libacpi/dsdt*.c
+xen/common/libacpi/dsdt_*cpu*.asl
+xen/common/libacpi/ssdt_*.h
 xen/tools/kconfig/.tmp_gtkcheck
 xen/tools/kconfig/.tmp_qtcheck
 xen/tools/symbols
tools/firmware/hvmloader/Makefile +1 -2
index c778174..cbc4ae0 100644
@@ -32,7 +32,7 @@ CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
 # ACPI table builder
-ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
+ACPI_PATH = $(XEN_ROOT)/xen/common/libacpi
 vpath %.c $(ACPI_PATH)
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c build.c
 ACPI_SRC = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
@@ -153,7 +153,6 @@ endif
 clean: subdirs-clean
 	rm -f roms.inc roms.inc.new acpi.h
 	rm -f hvmloader hvmloader.tmp *.o $(DEPS)
-	$(MAKE) -C $(ACPI_PATH) clean
 
 .PHONY: distclean
 distclean: clean
tools/firmware/hvmloader/smbios.c +1 -0
index 210c7b0..bfe8562 100644
@@ -24,6 +24,7 @@
 #include <xen/version.h>
 #include "smbios_types.h"
 #include "util.h"
+#include "acpi2_0.h"
 #include "hypercall.h"
 #include <xen/hvm/hvm_xs_strings.h>
 
tools/firmware/rombios/32bit/Makefile +1 -1
index 9b523bd..9795960 100644
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I$(XEN_ROOT)/tools/firmware/hvmloader/acpi/
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I$(XEN_ROOT)/xen/common/libacpi
 
 SUBDIRS = tcgbios
 
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
index 6555028..4ce25e3 100644
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I$(XEN_ROOT)/tools/firmware/hvmloader/acpi/
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I$(XEN_ROOT)/xen/common/libacpi
 
 .PHONY: all
 all: $(TARGET)
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +3 -3
similarity index 94%
rename from tools/firmware/hvmloader/acpi/Makefile
rename to xen/common/libacpi/Makefile
index 4d84e4c..efef589 100644
@@ -14,13 +14,13 @@
 # this program; If not, see <http://www.gnu.org/licenses/>.
 #
 
-XEN_ROOT = $(CURDIR)/../../../..
-include $(XEN_ROOT)/tools/firmware/Rules.mk
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/Config.mk
 
 C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
-CFLAGS += $(CFLAGS_xeninclude)
+CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include
 
 vpath iasl $(PATH)
 all: $(C_SRC) ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
xen/common/libacpi/README renamed from tools/firmware/hvmloader/acpi/README +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/README
rename to xen/common/libacpi/README
xen/common/libacpi/acpi2_0.h renamed from tools/firmware/hvmloader/acpi/acpi2_0.h +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/acpi2_0.h
rename to xen/common/libacpi/acpi2_0.h
xen/common/libacpi/build.c renamed from tools/firmware/hvmloader/acpi/build.c +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/build.c
rename to xen/common/libacpi/build.c
xen/common/libacpi/dsdt.asl renamed from tools/firmware/hvmloader/acpi/dsdt.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/dsdt.asl
rename to xen/common/libacpi/dsdt.asl
xen/common/libacpi/mk_dsdt.c renamed from tools/firmware/hvmloader/acpi/mk_dsdt.c +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/mk_dsdt.c
rename to xen/common/libacpi/mk_dsdt.c
xen/common/libacpi/ssdt_pm.asl renamed from tools/firmware/hvmloader/acpi/ssdt_pm.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_pm.asl
rename to xen/common/libacpi/ssdt_pm.asl
xen/common/libacpi/ssdt_s3.asl renamed from tools/firmware/hvmloader/acpi/ssdt_s3.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s3.asl
rename to xen/common/libacpi/ssdt_s3.asl
xen/common/libacpi/ssdt_s4.asl renamed from tools/firmware/hvmloader/acpi/ssdt_s4.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s4.asl
rename to xen/common/libacpi/ssdt_s4.asl
xen/common/libacpi/ssdt_tpm.asl renamed from tools/firmware/hvmloader/acpi/ssdt_tpm.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_tpm.asl
rename to xen/common/libacpi/ssdt_tpm.asl
xen/common/libacpi/static_tables.c renamed from tools/firmware/hvmloader/acpi/static_tables.c +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/static_tables.c
rename to xen/common/libacpi/static_tables.c
xen/common/libacpi/x86.h renamed from tools/firmware/hvmloader/acpi/x86.h +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/x86.h
rename to xen/common/libacpi/x86.h
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#48 lore raw

Re: [PATCH RFC 15/20] acpi: Move ACPI code to xen/common/libacpi

Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
 .gitignore                                                        | 8 ++++----
 tools/firmware/hvmloader/Makefile                                 | 3 +--
 tools/firmware/hvmloader/smbios.c                                 | 1 +
 tools/firmware/rombios/32bit/Makefile                             | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile                     | 2 +-
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile    | 6 +++---
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README      | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c     | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl    | 0
Quoted 8 lines
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl | 0
 .../firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl   | 0
 .../hvmloader/acpi => xen/common/libacpi}/static_tables.c         | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h       | 0
 17 files changed, 11 insertions(+), 11 deletions(-)

As mentioned before, new placement subject to determination whether this is to eventually be used by the hypervisor.

tools/firmware/hvmloader/smbios.c line 29

Quoted 9 lines
tools/firmware/hvmloader/smbios.c +1 -0
@@ -24,6 +24,7 @@
 #include <xen/version.h>
 #include "smbios_types.h"
 #include "util.h"
+#include "acpi2_0.h"
 #include "hypercall.h"
 #include <xen/hvm/hvm_xs_strings.h>

This change doesn't seem to belong here (since you only move around files, and adjustments get done solely to makefiles).

Quoted 6 lines
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +0 -0
@@ -14,13 +14,13 @@
 # this program; If not, see <http://www.gnu.org/licenses/>.
 #
 

xen/common/libacpi/Makefile line 23

Quoted 10 lines
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +3 -3
-XEN_ROOT = $(CURDIR)/../../../..
-include $(XEN_ROOT)/tools/firmware/Rules.mk
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/Config.mk
 
 C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
-CFLAGS += $(CFLAGS_xeninclude)
+CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include

Where would this now get consumed? This appears to be a tools/ only setting, which should thus no longer be needed here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#49 lore raw

Re: [PATCH RFC 15/20] acpi: Move ACPI code to xen/common/libacpi

Quoted 19 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
 .gitignore                                                        | 8 ++++----
 tools/firmware/hvmloader/Makefile                                 | 3 +--
 tools/firmware/hvmloader/smbios.c                                 | 1 +
 tools/firmware/rombios/32bit/Makefile                             | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile                     | 2 +-
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile    | 6 +++---
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README      | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c     | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl    | 0
Quoted 8 lines
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl | 0
 .../firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl   | 0
 .../hvmloader/acpi => xen/common/libacpi}/static_tables.c         | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h       | 0
 17 files changed, 11 insertions(+), 11 deletions(-)
Quoted 2 lines

As mentioned before, new placement subject to determination whether this is to eventually be used by the hypervisor.

Roger, when do you think you'll be able to see whether dom0 builder will use this? I can start working on v1 with assumption that this will be used by hypervisor. We can drop the last patch (and modify this one to move acpi to somewhere in tools) if it becomes clear that hypervisor does not want it.

Quoted 12 lines
Quoted 12 lines
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +2 -2
@@ -14,13 +14,13 @@
 # this program; If not, see <http://www.gnu.org/licenses/>.
 #
 
-XEN_ROOT = $(CURDIR)/../../../..
-include $(XEN_ROOT)/tools/firmware/Rules.mk
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/Config.mk
 
Quoted 7 lines

xen/common/libacpi/Makefile line 23

Quoted 5 lines
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +1 -1
 C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
-CFLAGS += $(CFLAGS_xeninclude)
+CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include

Where would this now get consumed? This appears to be a tools/ only setting, which should thus no longer be needed here.

This is needed for building mk_dsdt.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#50 lore raw

Re: [PATCH RFC 15/20] acpi: Move ACPI code to xen/common/libacpi

Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 18:09, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
 .gitignore                                                        | 8 ++++----
 tools/firmware/hvmloader/Makefile                                 | 3 +--
 tools/firmware/hvmloader/smbios.c                                 | 1 +
 tools/firmware/rombios/32bit/Makefile                             | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile                     | 2 +-
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile    | 6 +++---
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README      | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c     | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl    | 0
Quoted 8 lines
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl | 0
 .../firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl   | 0
 .../hvmloader/acpi => xen/common/libacpi}/static_tables.c         | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h       | 0
 17 files changed, 11 insertions(+), 11 deletions(-)
Quoted 2 lines

As mentioned before, new placement subject to determination whether this is to eventually be used by the hypervisor.

Quoted 5 lines

Roger, when do you think you'll be able to see whether dom0 builder will use this? I can start working on v1 with assumption that this will be used by hypervisor. We can drop the last patch (and modify this one to move acpi to somewhere in tools) if it becomes clear that hypervisor does not want it.

I guess if it doesn't become clear by then we could still allow for it to be moved as you do, with the expectation of a follow-up patch to move it under tools/ if it turns out Dom0 doesn't want/need it.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +2 -2
@@ -14,13 +14,13 @@
 # this program; If not, see <http://www.gnu.org/licenses/>.
 #
 
-XEN_ROOT = $(CURDIR)/../../../..
-include $(XEN_ROOT)/tools/firmware/Rules.mk
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/Config.mk
 
 C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
Quoted 6 lines
Quoted 4 lines

xen/common/libacpi/Makefile line 23

Quoted 2 lines
xen/common/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +1 -1
-CFLAGS += $(CFLAGS_xeninclude)
+CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include

Where would this now get consumed? This appears to be a tools/ only setting, which should thus no longer be needed here.

This is needed for building mk_dsdt.

Which you rename later on. This being a tools/ construct, I'd appreciate the renaming to happen right away, both to cut the connection to tools/ and to make the (sole) consumer obvious to reviewers.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#51 lore raw

Re: [PATCH RFC 15/20] acpi: Move ACPI code to xen/common/libacpi

In reply to Boris Ostrovsky
Quoted 24 lines · Boris Ostrovsky
Quoted 19 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
 .gitignore                                                        | 8 ++++----
 tools/firmware/hvmloader/Makefile                                 | 3 +--
 tools/firmware/hvmloader/smbios.c                                 | 1 +
 tools/firmware/rombios/32bit/Makefile                             | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile                     | 2 +-
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile    | 6 +++---
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README      | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c     | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl    | 0
Quoted 8 lines
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl | 0
 .../firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl   | 0
 .../hvmloader/acpi => xen/common/libacpi}/static_tables.c         | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h       | 0
 17 files changed, 11 insertions(+), 11 deletions(-)
Quoted 2 lines

As mentioned before, new placement subject to determination whether this is to eventually be used by the hypervisor.

Quoted 5 lines

Roger, when do you think you'll be able to see whether dom0 builder will use this? I can start working on v1 with assumption that this will be used by hypervisor. We can drop the last patch (and modify this one to move acpi to somewhere in tools) if it becomes clear that hypervisor does not want it.

What we need to do is quite similar to what ARM does, and they seem to prefer to have different ACPI code for Dom0/DomU, so I'm quite sure we could do the same for x86 also. FWIW, when Boris and I discussed this we though it would be better to have a single place where all the ACPI code resides, both to create tables or to modify them.

Would it be a lot of work to leave it in tools/ for the time being and move it later if we see that we could benefit from merging both? Or maybe leave it in xen/common without linking it with the hypervisor just yet (but that would need sorting out later anyway).

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#52 lore raw

Re: [PATCH RFC 15/20] acpi: Move ACPI code to xen/common/libacpi

Quoted 29 lines · Roger Pau Monné
Quoted 20 lines · Boris Ostrovsky
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
 .gitignore                                                        | 8 ++++----
 tools/firmware/hvmloader/Makefile                                 | 3 +--
 tools/firmware/hvmloader/smbios.c                                 | 1 +
 tools/firmware/rombios/32bit/Makefile                             | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile                     | 2 +-
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile    | 6 +++---
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README      | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c     | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl    | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c   | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl | 0
 .../firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl   | 0
 .../hvmloader/acpi => xen/common/libacpi}/static_tables.c         | 0
 {tools/firmware/hvmloader/acpi => xen/common/libacpi}/x86.h       | 0
 17 files changed, 11 insertions(+), 11 deletions(-)
Quoted 8 lines
Quoted 2 lines

As mentioned before, new placement subject to determination whether this is to eventually be used by the hypervisor.

Roger, when do you think you'll be able to see whether dom0 builder will use this? I can start working on v1 with assumption that this will be used by hypervisor. We can drop the last patch (and modify this one to move acpi to somewhere in tools) if it becomes clear that hypervisor does not want it.

Quoted 8 lines

What we need to do is quite similar to what ARM does, and they seem to prefer to have different ACPI code for Dom0/DomU, so I'm quite sure we could do the same for x86 also. FWIW, when Boris and I discussed this we though it would be better to have a single place where all the ACPI code resides, both to create tables or to modify them.

Would it be a lot of work to leave it in tools/ for the time being and move it later if we see that we could benefit from merging both?

It's not a whole lot of work to keep it in tools. It will probably make things easier, in fact.

-boris

Quoted 3 lines

Or maybe leave
it in xen/common without linking it with the hypervisor just yet (but that would need sorting out later anyway).

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#53 lore raw

RFC PATCH 16/20 x86/vlapic: Don't try to accept 8259 interrupt if !has_vpic()

In reply to Boris Ostrovsky
---
 xen/arch/x86/hvm/vlapic.c | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/x86/hvm/vlapic.c +3 -0
index 01a8430..d8b887c 100644
@@ -1133,6 +1133,9 @@ void vlapic_adjust_i8259_target(struct domain *d)
 {
     struct vcpu *v;
 
+    if ( !has_vpic(d) )
+       return;
+
     for_each_vcpu ( d, v )
         if ( __vlapic_accept_pic_intr(v) )
             goto found;
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#54 lore raw

Re: [PATCH RFC 16/20] x86/vlapic: Don't try to accept 8259 interrupt if !has_vpic()

xen/arch/x86/hvm/vlapic.c void vlapic_adjust_i8259_target(struct domain *d) · line 1137

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
xen/arch/x86/hvm/vlapic.c +2 -0
@@ -1133,6 +1133,9 @@ void vlapic_adjust_i8259_target(struct domain *d)
 {
     struct vcpu *v;
 
+    if ( !has_vpic(d) )
+       return;

Considering the title of the patch (which doesn't match the function you alter) - wouldn't this better go into __vlapic_accept_pic_intr()? It missing here I have more problems to see any harm than from it missing there. (Arguably _also_ putting it here then would have the benefit of avoiding a for_each_vcpu() loop.)

In any event this looks like a relatively independent change.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#55 lore raw

Re: [PATCH RFC 16/20] x86/vlapic: Don't try to accept 8259 interrupt if !has_vpic()

Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
xen/arch/x86/hvm/vlapic.c +0 -0
@@ -1133,6 +1133,9 @@ void vlapic_adjust_i8259_target(struct domain *d)
 {
     struct vcpu *v;
 
Quoted 7 lines

xen/arch/x86/hvm/vlapic.c void vlapic_adjust_i8259_target(struct domain *d) · line 1137

Quoted 2 lines
xen/arch/x86/hvm/vlapic.c +2 -0
+    if ( !has_vpic(d) )
+       return;

Considering the title of the patch (which doesn't match the function you alter) - wouldn't this better go into __vlapic_accept_pic_intr()? It missing here I have more problems to see any harm than from it missing there. (Arguably _also_ putting it here then would have the benefit of avoiding a for_each_vcpu() loop.)

One of the reasons I put it here was exactly to avoid this loop. It also (implicitly) prevented us from going down to pt_adjust_global_vcpu_target(). In addition, we wouldn't need to check for IOAPIC presence.

I guess I should add has_vpic(), has_vpit() and has_ioapic() in all these places.

Quoted 1 line

In any event this looks like a relatively independent change.

Right. Once ACPI became available to the PVHv2 guest I immediately tripped here (because the guest started seeing APIC). So in principle I can submit this as standalone patch.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#56 lore raw

RFC PATCH 17/20 x86: Allow LAPIC-only emulation_flags for HVM guests

In reply to Boris Ostrovsky

PVH guests may request LAPIC emulation (and nothing else)

---
 xen/arch/x86/domain.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
xen/arch/x86/domain.c +16 -10
index a6d721b..3b614d7 100644
@@ -540,25 +540,31 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
     }
     else
     {
-        if ( (config->emulation_flags & ~XEN_X86_EMU_ALL) != 0 )
+        uint32_t emflags;
+
+        if ( is_hardware_domain(d) )
+            config->emulation_flags |= XEN_X86_EMU_PIT;
+
+        emflags = config->emulation_flags;
+        if ( (emflags & ~XEN_X86_EMU_ALL) != 0 )
         {
             printk(XENLOG_G_ERR "d%d: Invalid emulation bitmap: %#x\n",
-                   d->domain_id, config->emulation_flags);
+                   d->domain_id, emflags);
             return -EINVAL;
         }
-        if ( is_hardware_domain(d) )
-            config->emulation_flags |= XEN_X86_EMU_PIT;
-        if ( config->emulation_flags != 0 &&
-             (config->emulation_flags !=
-              (is_hvm_domain(d) ? XEN_X86_EMU_ALL : XEN_X86_EMU_PIT)) )
+
+        /* PVH guests can request emulated APIC */
+        if ( emflags &&
+            (is_hvm_domain(d) ? ((emflags != XEN_X86_EMU_ALL) &&
+                                 (emflags != XEN_X86_EMU_LAPIC)) :
+                                (emflags != XEN_X86_EMU_PIT)) )
         {
             printk(XENLOG_G_ERR "d%d: Xen does not allow %s domain creation "
                    "with the current selection of emulators: %#x\n",
-                   d->domain_id, is_hvm_domain(d) ? "HVM" : "PV",
-                   config->emulation_flags);
+                   d->domain_id, is_hvm_domain(d) ? "HVM" : "PV", emflags);
             return -EOPNOTSUPP;
         }
-        d->arch.emulation_flags = config->emulation_flags;
+        d->arch.emulation_flags = emflags;
     }
 
     if ( has_hvm_container_domain(d) )
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#57 lore raw

Re: [PATCH RFC 17/20] x86: Allow LAPIC-only emulation_flags for HVM guests

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

PVH guests may request LAPIC emulation (and nothing else)

This looks okay, except that I'd like to avoid the use of PVH here (in the description and at least on code comment) - please make this PVHv2 to avoid confusion with the original PVH code that's still there.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#58 lore raw

RFC PATCH 18/20 libxc/acpi: Build ACPI tables for HVMlite guests

In reply to Boris Ostrovsky
---
 tools/libxc/Makefile              |  22 +++-
 tools/libxc/include/xc_dom.h      |   1 +
 tools/libxc/xc_acpi.c             | 268 ++++++++++++++++++++++++++++++++++++++
 tools/libxc/xc_dom_x86.c          |   7 +
 tools/libxl/libxl_x86.c           |  19 +--
 xen/common/libacpi/Makefile       |   5 +-
 xen/common/libacpi/acpi2_0.h      |   2 +-
 xen/common/libacpi/build.c        |   2 +-
 xen/common/libacpi/dsdt_empty.asl |  22 ++++
 9 files changed, 335 insertions(+), 13 deletions(-)
 create mode 100644 tools/libxc/xc_acpi.c
 create mode 100644 xen/common/libacpi/dsdt_empty.asl
tools/libxc/Makefile +21 -1
index 608404f..9569e54 100644
@@ -79,6 +79,26 @@ GUEST_SRCS-y += $(ELF_SRCS-y)
 $(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
 $(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
 
+ACPI_PATH = $(XEN_ROOT)/xen/common/libacpi
+vpath %.c $(ACPI_PATH)
+ACPI_FILES  = dsdt_anycpu.c dsdt_15cpu.c static_tables.c
+ACPI_FILES += dsdt_anycpu_qemu_xen.c dsdt_empty.c build.c
+ACPI_SRCS = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
+
+.NOTPARALLEL: $(ACPI_SRCS)
+$(ACPI_SRCS):
+	make -C $(ACPI_PATH)
+
+$(patsubst %.c,%.o,$(ACPI_SRCS)): CFLAGS += -I$(ACPI_PATH)
+$(patsubst %.c,%.opic,$(ACPI_SRCS)): CFLAGS += -I$(ACPI_PATH)
+xc_acpi.o: CFLAGS += -I$(ACPI_PATH)
+xc_acpi.opic: CFLAGS += -I$(ACPI_PATH)
+
+GUEST_SRCS-y += $(ACPI_FILES)
+
+$(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
+$(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
+
 # new domain builder
 GUEST_SRCS-y                 += xc_dom_core.c xc_dom_boot.c
 GUEST_SRCS-y                 += xc_dom_elfloader.c
@@ -89,7 +109,7 @@ GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_armzimageloader.c
 GUEST_SRCS-y                 += xc_dom_binloader.c
 GUEST_SRCS-y                 += xc_dom_compat_linux.c
 
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c
+GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c xc_acpi.c
 GUEST_SRCS-$(CONFIG_X86)     += xc_cpuid_x86.c
 GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_arm.c
 
tools/libxc/include/xc_dom.h +1 -0
index 6ebe946..3842fb1 100644
@@ -407,6 +407,7 @@ void *xc_dom_pfn_to_ptr_retcount(struct xc_dom_image *dom, xen_pfn_t first,
                                  xen_pfn_t count, xen_pfn_t *count_out);
 void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn);
 void xc_dom_unmap_all(struct xc_dom_image *dom);
+int xc_dom_build_acpi(struct xc_dom_image *dom);
 
 static inline void *xc_dom_seg_to_ptr_pages(struct xc_dom_image *dom,
                                       struct xc_dom_seg *seg,
tools/libxc/xc_acpi.c new file +268 -0

268 lines not on this page · raw message

tools/libxc/xc_dom_x86.c +7 -0
index bdec40a..8698b36 100644
@@ -643,6 +643,13 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
             DOMPRINTF("Unable to reserve memory for the start info");
             goto out;
         }
+
+        rc = xc_dom_build_acpi(dom);
+        if ( rc != 0 )
+        {
+            DOMPRINTF("Unable to build ACPI tables");
+            goto out;
+        }
     }
     else
     {
tools/libxl/libxl_x86.c +11 -8
index 46cfafb..ef6c239 100644
@@ -8,15 +8,18 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
                                       xc_domain_configuration_t *xc_config)
 {
 
-    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
-        d_config->b_info.device_model_version !=
-        LIBXL_DEVICE_MODEL_VERSION_NONE) {
-        /* HVM domains with a device model. */
-        xc_config->emulation_flags = XEN_X86_EMU_ALL;
-    } else {
-        /* PV or HVM domains without a device model. */
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+        if (d_config->b_info.device_model_version !=
+            LIBXL_DEVICE_MODEL_VERSION_NONE)
+            xc_config->emulation_flags = XEN_X86_EMU_ALL;
+        else
+            /*
+             * HVM guests without device model will want
+             * to have LAPIC emulation.
+             */
+            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
+    } else 
         xc_config->emulation_flags = 0;
-    }
 
     return 0;
 }
xen/common/libacpi/Makefile +3 -2
index efef589..a1f233f 100644
@@ -17,7 +17,8 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/Config.mk
 
-C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
+C_SRC  = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c
+C_SRC += dsdt_anycpu_qemu_xen.c dsdt_empty.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
 CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include
@@ -58,7 +59,7 @@ iasl:
 
 clean:
 	rm -rf *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
-	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
+	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*cpu*.asl
 
 distclean: clean
 
xen/common/libacpi/acpi2_0.h +1 -1
index 0525a1e..458fb49 100644
@@ -516,7 +516,7 @@ struct acpi_config {
     struct acpi_mem_ops mem_ops;
 };
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical);
+void acpi_build_tables(struct acpi_config *config, unsigned long physical);
 
 #endif /* _ACPI_2_0_H_ */
 
xen/common/libacpi/build.c +1 -1
index eb8c632..e53b4a7 100644
@@ -480,7 +480,7 @@ static int new_vm_gid(struct acpi_config *config)
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config, unsigned long physical)
 {
     struct acpi_20_rsdp *rsdp;
     struct acpi_20_rsdt *rsdt;
xen/common/libacpi/dsdt_empty.asl new file +22 -0
new file mode 100644
index 0000000..25c0b95
@@ -0,0 +1,22 @@
+/******************************************************************************
+ * DSDT for Xen with Qemu device model
+ *
+ * Copyright (c) 2004, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
+{
+
+}
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#59 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Thanks for looking into this, I've found a couple of issues when compiling this with clang.

Quoted 17 lines · Boris Ostrovsky
---
 tools/libxc/Makefile              |  22 +++-
 tools/libxc/include/xc_dom.h      |   1 +
 tools/libxc/xc_acpi.c             | 268 ++++++++++++++++++++++++++++++++++++++
 tools/libxc/xc_dom_x86.c          |   7 +
 tools/libxl/libxl_x86.c           |  19 +--
 xen/common/libacpi/Makefile       |   5 +-
 xen/common/libacpi/acpi2_0.h      |   2 +-
 xen/common/libacpi/build.c        |   2 +-
 xen/common/libacpi/dsdt_empty.asl |  22 ++++
 9 files changed, 335 insertions(+), 13 deletions(-)
 create mode 100644 tools/libxc/xc_acpi.c
 create mode 100644 xen/common/libacpi/dsdt_empty.asl
tools/libxc/Makefile +0 -0
index 608404f..9569e54 100644

tools/libxc/Makefile

Quoted 1 line
tools/libxc/Makefile +1 -0
+++ b/tools/libxc/xc_acpi.c

Missing license header?

Quoted 134 lines
tools/libxc/Makefile +133 -0
@@ -0,0 +1,268 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <xen/xen.h>
+#include <xen/foreign/x86_32.h>
+#include <xen/foreign/x86_64.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/io/protocols.h>
+
+#include "xg_private.h"
+#include "xc_dom.h"
+#include "xenctrl.h"
+
+#include "acpi2_0.h"
+
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16
+
+#define PFN(paddr)  ((paddr) >> PAGE_SHIFT)
+
+extern unsigned char dsdt_anycpu[], dsdt_15cpu[], dsdt_empty[];
+extern int dsdt_anycpu_len, dsdt_15cpu_len, dsdt_empty_len;
+
+static uint64_t alloc_up, alloc_down;
+static unsigned long base_addr;
+
+/* Assumes contiguous physical space */
+static unsigned long virt_to_phys(void *v)
+{
+	return (((unsigned long)v - base_addr) + RESERVED_MEMORY_DYNAMIC_START);
+}
+
+static void *mem_alloc(uint32_t size, uint32_t align)
+{
+    uint64_t s, e;
+
+    /* Align to at least 16 bytes. */
+    if ( align < 16 )
+        align = 16;
+
+    s = (alloc_up + align) & ~((uint64_t)align - 1);
+    e = s + size - 1;
+
+    /* TODO: Reallocate memory */
+    if ((e < s) || (e >= alloc_down)) return NULL;
+
+    while ( PFN(alloc_up) != PFN(e) )
+    {
+        alloc_up += PAGE_SIZE;
+    }
+
+    alloc_up = e;
+
+    return (void *)(unsigned long)s;
+}
+
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+    {
+        DOMPRINTF("%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->apic_mode = 1;
+
+    if ( dom->nr_vnodes )
+    {
+        struct acpi_numa *numa = &config->numa;
+
+        numa->vmemrange = calloc(dom->nr_vmemranges,
+                                 sizeof(*numa->vmemrange));
+        numa->vdistance = calloc(dom->nr_vnodes,
+                                 sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = calloc(config->nr_vcpus,
+                                     sizeof(*numa->vcpu_to_vnode));
+        if ( !numa->vmemrange || !numa->vdistance || !numa->vcpu_to_vnode )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            free(numa->vmemrange);
+            free(numa->vdistance);
+            free(numa->vcpu_to_vnode);
+            return -ENOMEM;
+        }
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);
+
+	    if ( rc )
+        {
+            DOMPRINTF("%s: xc_domain_getvnuma failed (rc=%d)", __FUNCTION__, rc);
+            return rc;
+        }
+    }
+    else
+        config->nr_vcpus = info.max_vcpu_id + 1;
+
+    config->vcpu_online = calloc((HVM_MAX_VCPUS + 7) / 8,
+                                 sizeof(*config->vcpu_online));
+    if ( config->vcpu_online == NULL )
+    {
+        DOMPRINTF("%s: Can't allocate vcpu_online", __FUNCTION__);
+        return -ENOMEM;
+    }
+
+    for (i=0; i<config->nr_vcpus; i++)
+        config->vcpu_online[i / 8] |= 1 << (i & 7);
+
+    config->mem_ops.alloc = mem_alloc;
+    config->mem_ops.v2p = virt_to_phys;
+
+    return 0;
+}

tools/libxc/Makefile line 143

Quoted 10 lines
tools/libxc/Makefile +10 -0
+
+int xc_dom_build_acpi(struct xc_dom_image *dom)
+{
+    struct acpi_config config;
+    uint32_t domid = dom->guest_domid;
+    xc_interface *xch = dom->xch;
+    int rc, i, acpi_pages_num;
+    xen_pfn_t extent, *extents;
+    void *acpi_pages, *acpi_physical;
+    void *guest_info_page, *guest_acpi_pages;

guest_acpi_pages, guest_info_page, acpi_physical, extents and acpi_pages should be initialized to NULL, and acpi_pages_num to 0.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#60 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

In reply to Boris Ostrovsky
Quoted 15 lines · Boris Ostrovsky
---
 tools/libxc/Makefile              |  22 +++-
 tools/libxc/include/xc_dom.h      |   1 +
 tools/libxc/xc_acpi.c             | 268 ++++++++++++++++++++++++++++++++++++++
 tools/libxc/xc_dom_x86.c          |   7 +
 tools/libxl/libxl_x86.c           |  19 +--
 xen/common/libacpi/Makefile       |   5 +-
 xen/common/libacpi/acpi2_0.h      |   2 +-
 xen/common/libacpi/build.c        |   2 +-
 xen/common/libacpi/dsdt_empty.asl |  22 ++++
 9 files changed, 335 insertions(+), 13 deletions(-)
 create mode 100644 tools/libxc/xc_acpi.c
 create mode 100644 xen/common/libacpi/dsdt_empty.asl

I've only done a very rough review.

Quoted 5 lines
tools/libxc/Makefile +0 -0
index 608404f..9569e54 100644

tools/libxc/Makefile GUEST_SRCS-y += $(ELF_SRCS-y) · line 88

Quoted 10 lines
tools/libxc/Makefile +7 -0
@@ -79,6 +79,26 @@ GUEST_SRCS-y += $(ELF_SRCS-y)
 $(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
 $(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
 
+ACPI_PATH = $(XEN_ROOT)/xen/common/libacpi
+vpath %.c $(ACPI_PATH)
+ACPI_FILES  = dsdt_anycpu.c dsdt_15cpu.c static_tables.c
+ACPI_FILES += dsdt_anycpu_qemu_xen.c dsdt_empty.c build.c
+ACPI_SRCS = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
+
+.NOTPARALLEL: $(ACPI_SRCS)

Why is this needed?

Quoted 149 lines
tools/libxc/Makefile +14 -1
+$(ACPI_SRCS):
+	make -C $(ACPI_PATH)
+
+$(patsubst %.c,%.o,$(ACPI_SRCS)): CFLAGS += -I$(ACPI_PATH)
+$(patsubst %.c,%.opic,$(ACPI_SRCS)): CFLAGS += -I$(ACPI_PATH)
+xc_acpi.o: CFLAGS += -I$(ACPI_PATH)
+xc_acpi.opic: CFLAGS += -I$(ACPI_PATH)
+
+GUEST_SRCS-y += $(ACPI_FILES)
+
+$(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
+$(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
+
 # new domain builder
 GUEST_SRCS-y                 += xc_dom_core.c xc_dom_boot.c
 GUEST_SRCS-y                 += xc_dom_elfloader.c
@@ -89,7 +109,7 @@ GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_armzimageloader.c
 GUEST_SRCS-y                 += xc_dom_binloader.c
 GUEST_SRCS-y                 += xc_dom_compat_linux.c
 
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c
+GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c xc_acpi.c
 GUEST_SRCS-$(CONFIG_X86)     += xc_cpuid_x86.c
 GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_arm.c
 
tools/libxc/include/xc_dom.h +1 -0
index 6ebe946..3842fb1 100644
@@ -407,6 +407,7 @@ void *xc_dom_pfn_to_ptr_retcount(struct xc_dom_image *dom, xen_pfn_t first,
                                  xen_pfn_t count, xen_pfn_t *count_out);
 void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn);
 void xc_dom_unmap_all(struct xc_dom_image *dom);
+int xc_dom_build_acpi(struct xc_dom_image *dom);
 
 static inline void *xc_dom_seg_to_ptr_pages(struct xc_dom_image *dom,
                                       struct xc_dom_seg *seg,
tools/libxc/xc_acpi.c new file +106 -0
new file mode 100644
index 0000000..3173d49
@@ -0,0 +1,268 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <xen/xen.h>
+#include <xen/foreign/x86_32.h>
+#include <xen/foreign/x86_64.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/io/protocols.h>
+
+#include "xg_private.h"
+#include "xc_dom.h"
+#include "xenctrl.h"
+
+#include "acpi2_0.h"
+
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16
+
+#define PFN(paddr)  ((paddr) >> PAGE_SHIFT)
+
+extern unsigned char dsdt_anycpu[], dsdt_15cpu[], dsdt_empty[];
+extern int dsdt_anycpu_len, dsdt_15cpu_len, dsdt_empty_len;
+
+static uint64_t alloc_up, alloc_down;
+static unsigned long base_addr;
+
+/* Assumes contiguous physical space */
+static unsigned long virt_to_phys(void *v)
+{
+	return (((unsigned long)v - base_addr) + RESERVED_MEMORY_DYNAMIC_START);
+}
+
+static void *mem_alloc(uint32_t size, uint32_t align)
+{
+    uint64_t s, e;
+
+    /* Align to at least 16 bytes. */
+    if ( align < 16 )
+        align = 16;
+
+    s = (alloc_up + align) & ~((uint64_t)align - 1);
+    e = s + size - 1;
+
+    /* TODO: Reallocate memory */
+    if ((e < s) || (e >= alloc_down)) return NULL;
+
+    while ( PFN(alloc_up) != PFN(e) )
+    {
+        alloc_up += PAGE_SIZE;
+    }
+
+    alloc_up = e;
+
+    return (void *)(unsigned long)s;
+}
+
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+    {
+        DOMPRINTF("%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->apic_mode = 1;
+
+    if ( dom->nr_vnodes )
+    {
+        struct acpi_numa *numa = &config->numa;
+
+        numa->vmemrange = calloc(dom->nr_vmemranges,
+                                 sizeof(*numa->vmemrange));
+        numa->vdistance = calloc(dom->nr_vnodes,
+                                 sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = calloc(config->nr_vcpus,
+                                     sizeof(*numa->vcpu_to_vnode));
+        if ( !numa->vmemrange || !numa->vdistance || !numa->vcpu_to_vnode )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            free(numa->vmemrange);
+            free(numa->vdistance);
+            free(numa->vcpu_to_vnode);
+            return -ENOMEM;
+        }
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->nr_vcpus, numa->vmemrange,

tools/libxc/xc_acpi.c line 116

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+                                numa->vdistance, numa->vcpu_to_vnode);
+
+	    if ( rc )
+        {
+            DOMPRINTF("%s: xc_domain_getvnuma failed (rc=%d)", __FUNCTION__, rc);
+            return rc;
+        }
+    }
+    else
+        config->nr_vcpus = info.max_vcpu_id + 1;

This looks wrong, at least it is not immediately clear why you would want to do this.

tools/libxc/xc_acpi.c line 126

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+
+    config->vcpu_online = calloc((HVM_MAX_VCPUS + 7) / 8,
+                                 sizeof(*config->vcpu_online));
+    if ( config->vcpu_online == NULL )
+    {
+        DOMPRINTF("%s: Can't allocate vcpu_online", __FUNCTION__);
+        return -ENOMEM;
+    }
+
+    for (i=0; i<config->nr_vcpus; i++)

Coding style.

Quoted 8 lines
tools/libxc/xc_acpi.c new file +8 -0
+        config->vcpu_online[i / 8] |= 1 << (i & 7);
+
+    config->mem_ops.alloc = mem_alloc;
+    config->mem_ops.v2p = virt_to_phys;
+
+    return 0;
+}
+

tools/libxc/xc_acpi.c line 144

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+int xc_dom_build_acpi(struct xc_dom_image *dom)
+{
+    struct acpi_config config;
+    uint32_t domid = dom->guest_domid;
+    xc_interface *xch = dom->xch;
+    int rc, i, acpi_pages_num;
+    xen_pfn_t extent, *extents;
+    void *acpi_pages, *acpi_physical;
+    void *guest_info_page, *guest_acpi_pages;
+

Need to initialise these to NULL and 0 in case you take the exit path earlier.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#61 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 9 lines · Wei Liu
Quoted 9 lines
tools/libxc/Makefile +0 -0
index 608404f..9569e54 100644
@@ -79,6 +79,26 @@ GUEST_SRCS-y += $(ELF_SRCS-y)
 $(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
 $(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
 
Quoted 8 lines

tools/libxc/Makefile GUEST_SRCS-y += $(ELF_SRCS-y) · line 88

Quoted 7 lines
tools/libxc/Makefile +7 -0
+ACPI_PATH = $(XEN_ROOT)/xen/common/libacpi
+vpath %.c $(ACPI_PATH)
+ACPI_FILES  = dsdt_anycpu.c dsdt_15cpu.c static_tables.c
+ACPI_FILES += dsdt_anycpu_qemu_xen.c dsdt_empty.c build.c
+ACPI_SRCS = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
+
+.NOTPARALLEL: $(ACPI_SRCS)

Why is this needed?

To prevent building intermediate *.c files in parallel from multiple places (libxc and hvmloader). But this will be removed per Jan's suggestion not to create those files in libacpi and instead keep them in libxc and hvmloader.

Quoted 55 lines
tools/libxc/xc_acpi.c new file +54 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+    {
+        DOMPRINTF("%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->apic_mode = 1;
+
+    if ( dom->nr_vnodes )
+    {
+        struct acpi_numa *numa = &config->numa;
+
+        numa->vmemrange = calloc(dom->nr_vmemranges,
+                                 sizeof(*numa->vmemrange));
+        numa->vdistance = calloc(dom->nr_vnodes,
+                                 sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = calloc(config->nr_vcpus,
+                                     sizeof(*numa->vcpu_to_vnode));
+        if ( !numa->vmemrange || !numa->vdistance || !numa->vcpu_to_vnode )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            free(numa->vmemrange);
+            free(numa->vdistance);
+            free(numa->vcpu_to_vnode);
+            return -ENOMEM;
+        }
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);
+
+	    if ( rc )
+        {
+            DOMPRINTF("%s: xc_domain_getvnuma failed (rc=%d)", __FUNCTION__, rc);
+            return rc;
+        }
+    }
+    else
+        config->nr_vcpus = info.max_vcpu_id + 1;
Quoted 2 lines

This looks wrong, at least it is not immediately clear why you would want to do this.

Why is this wrong? If we have one VCPU max_vcpu_id will be zero, won't it?

Quoted 12 lines
tools/libxc/xc_acpi.c new file +12 -0
+}
+
+int xc_dom_build_acpi(struct xc_dom_image *dom)
+{
+    struct acpi_config config;
+    uint32_t domid = dom->guest_domid;
+    xc_interface *xch = dom->xch;
+    int rc, i, acpi_pages_num;
+    xen_pfn_t extent, *extents;
+    void *acpi_pages, *acpi_physical;
+    void *guest_info_page, *guest_acpi_pages;
+
Quoted 2 lines

Need to initialise these to NULL and 0 in case you take the exit path earlier.

Right. I think Roger pointed out that clang doesn't like this neither.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#62 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

On Mon, Jun 06, 2016 at 11:15:22AM -0400, Boris Ostrovsky wrote:
[...]

Quoted 51 lines
Quoted 51 lines
tools/libxc/xc_acpi.c new file +51 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+    {
+        DOMPRINTF("%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->apic_mode = 1;
+
+    if ( dom->nr_vnodes )
+    {
+        struct acpi_numa *numa = &config->numa;
+
+        numa->vmemrange = calloc(dom->nr_vmemranges,
+                                 sizeof(*numa->vmemrange));
+        numa->vdistance = calloc(dom->nr_vnodes,
+                                 sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = calloc(config->nr_vcpus,
+                                     sizeof(*numa->vcpu_to_vnode));
+        if ( !numa->vmemrange || !numa->vdistance || !numa->vcpu_to_vnode )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            free(numa->vmemrange);
+            free(numa->vdistance);
+            free(numa->vcpu_to_vnode);
+            return -ENOMEM;
+        }
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);
+
+	    if ( rc )
+        {
+            DOMPRINTF("%s: xc_domain_getvnuma failed (rc=%d)", __FUNCTION__, rc);
+            return rc;
+        }
Quoted 9 lines
Quoted 5 lines
tools/libxc/xc_acpi.c new file +3 -0
+    }
+    else
+        config->nr_vcpus = info.max_vcpu_id + 1;

This looks wrong, at least it is not immediately clear why you would want to do this.

Why is this wrong? If we have one VCPU max_vcpu_id will be zero, won't it?

I'm not saying it is absolutely wrong, just that I don't quite understand why it is coded this way.

It's guarded by dom->nr_vnodes and the code is not immediately clear why you want to do that. Perhaps you can add a comment here?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#63 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 61 lines · Wei Liu

On Mon, Jun 06, 2016 at 11:15:22AM -0400, Boris Ostrovsky wrote:
[...]

Quoted 50 lines
Quoted 50 lines
tools/libxc/xc_acpi.c new file +50 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+    {
+        DOMPRINTF("%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->apic_mode = 1;
+
+    if ( dom->nr_vnodes )
+    {
+        struct acpi_numa *numa = &config->numa;
+
+        numa->vmemrange = calloc(dom->nr_vmemranges,
+                                 sizeof(*numa->vmemrange));
+        numa->vdistance = calloc(dom->nr_vnodes,
+                                 sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = calloc(config->nr_vcpus,
+                                     sizeof(*numa->vcpu_to_vnode));
+        if ( !numa->vmemrange || !numa->vdistance || !numa->vcpu_to_vnode )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            free(numa->vmemrange);
+            free(numa->vdistance);
+            free(numa->vcpu_to_vnode);
+            return -ENOMEM;
+        }
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);
+
+	    if ( rc )
+        {
+            DOMPRINTF("%s: xc_domain_getvnuma failed (rc=%d)", __FUNCTION__, rc);
+            return rc;
Quoted 9 lines
Quoted 6 lines
tools/libxc/xc_acpi.c new file +4 -0
+        }
+    }
+    else
+        config->nr_vcpus = info.max_vcpu_id + 1;

This looks wrong, at least it is not immediately clear why you would want to do this.

Why is this wrong? If we have one VCPU max_vcpu_id will be zero, won't it?

Quoted 5 lines

I'm not saying it is absolutely wrong, just that I don't quite understand why it is coded this way.

It's guarded by dom->nr_vnodes and the code is not immediately clear why you want to do that. Perhaps you can add a comment here?

So this actually *is* wrong: I am trying to calloc(config->nr_vcpus,...) before I call xc_domain_getvnuma(), which sets config->nr_vcpus. And I suspect the same is true for nr_vmemranges.

I think I lost an earlier call to xc_domain_getvnuma(.., NULL, NULL, NULL).

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#64 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

In reply to Boris Ostrovsky

tools/libxc/xc_acpi.c line 9

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/libxc/xc_acpi.c new file +9 -0
@@ -0,0 +1,268 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <xen/xen.h>
+#include <xen/foreign/x86_32.h>
+#include <xen/foreign/x86_64.h>

Why are these two needed here? The code here shouldn't care about the mode the guest may later want to run in.

Quoted 4 lines
tools/libxc/xc_acpi.c new file +4 -0
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/io/protocols.h>
+
+#include "xg_private.h"

tools/libxc/xc_acpi.c line 23

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+#include "xc_dom.h"
+#include "xenctrl.h"
+
+#include "acpi2_0.h"
+
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16

With which other definitions do these three need to remain in sync?

tools/libxc/xc_acpi.c line 27

Quoted 3 lines
tools/libxc/xc_acpi.c new file +3 -0
+#define PFN(paddr)  ((paddr) >> PAGE_SHIFT)
+
+extern unsigned char dsdt_anycpu[], dsdt_15cpu[], dsdt_empty[];

const

tools/libxc/xc_acpi.c line 28

Quoted 1 line
tools/libxc/xc_acpi.c new file +1 -0
+extern int dsdt_anycpu_len, dsdt_15cpu_len, dsdt_empty_len;

And even these may want to be const (and certainly unsigned).

tools/libxc/xc_acpi.c line 74

Quoted 12 lines
tools/libxc/xc_acpi.c new file +12 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;

What good does an empty DSDT do? (Perhaps this question is a result of there not being any description of this change.)

Quoted 41 lines
tools/libxc/xc_acpi.c new file +41 -0
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+    {
+        DOMPRINTF("%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->apic_mode = 1;
+
+    if ( dom->nr_vnodes )
+    {
+        struct acpi_numa *numa = &config->numa;
+
+        numa->vmemrange = calloc(dom->nr_vmemranges,
+                                 sizeof(*numa->vmemrange));
+        numa->vdistance = calloc(dom->nr_vnodes,
+                                 sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = calloc(config->nr_vcpus,
+                                     sizeof(*numa->vcpu_to_vnode));
+        if ( !numa->vmemrange || !numa->vdistance || !numa->vcpu_to_vnode )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            free(numa->vmemrange);
+            free(numa->vdistance);
+            free(numa->vcpu_to_vnode);
+            return -ENOMEM;
+        }
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);
+
+	    if ( rc )
+        {
+            DOMPRINTF("%s: xc_domain_getvnuma failed (rc=%d)", __FUNCTION__, rc);
+            return rc;
+        }
+    }
+    else
+        config->nr_vcpus = info.max_vcpu_id + 1;

tools/libxc/xc_acpi.c line 126

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+
+    config->vcpu_online = calloc((HVM_MAX_VCPUS + 7) / 8,
+                                 sizeof(*config->vcpu_online));
+    if ( config->vcpu_online == NULL )
+    {
+        DOMPRINTF("%s: Can't allocate vcpu_online", __FUNCTION__);
+        return -ENOMEM;
+    }
+
+    for (i=0; i<config->nr_vcpus; i++)

You seem to be mixing styles here.

Quoted 70 lines
tools/libxc/xc_acpi.c new file +70 -0
+int xc_dom_build_acpi(struct xc_dom_image *dom)
+{
+    struct acpi_config config;
+    uint32_t domid = dom->guest_domid;
+    xc_interface *xch = dom->xch;
+    int rc, i, acpi_pages_num;
+    xen_pfn_t extent, *extents;
+    void *acpi_pages, *acpi_physical;
+    void *guest_info_page, *guest_acpi_pages;
+
+    rc = init_acpi_config(dom, &config);
+    if ( rc )
+    {
+        DOMPRINTF("%s: init_acpi_config failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    /*
+     * Pages to hold ACPI tables and one page for acpi_info, which
+     * will be the first one in this region.
+     */
+    acpi_pages = xc_memalign(xch, PAGE_SIZE, NUM_ACPI_PAGES * PAGE_SIZE);
+    if ( !acpi_pages )
+    {
+        DOMPRINTF("%s: Can't allocate acpi pages", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+
+    config.acpi_info_page = acpi_pages;
+
+    /* Set up allocator memory */
+    base_addr = alloc_up = (unsigned long)acpi_pages + PAGE_SIZE;
+    alloc_down = (unsigned long)acpi_pages + (NUM_ACPI_PAGES * PAGE_SIZE);
+
+    /* Map page that will hold RSDP */
+    extent = PFN(ACPI_PHYSICAL_ADDRESS);
+    rc = xc_domain_populate_physmap_exact(xch, domid, 1, 0, 0, &extent);
+    if ( rc )
+    {
+        DOMPRINTF("%s: xc_domain_populate_physmap failed with %d",
+                  __FUNCTION__, rc);
+        goto out;
+    }
+    acpi_physical = xc_map_foreign_range(xch, domid, PAGE_SIZE,
+                                         PROT_READ | PROT_WRITE,
+                                         PFN(ACPI_PHYSICAL_ADDRESS));
+    if ( !acpi_physical )
+    {
+        DOMPRINTF("%s: Can't map acpi_physical", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+
+    /* Build the tables */
+    acpi_build_tables(&config, (unsigned long)acpi_physical);
+
+    /* Copy acpi_info page into guest's memory */
+    extent = PFN(ACPI_INFO_PHYSICAL_ADDRESS);
+    rc = xc_domain_populate_physmap_exact(xch, domid, 1, 0, 0, &extent);
+    if ( rc )
+    {
+        DOMPRINTF("%s: xc_domain_populate_physmap failed with %d\n",
+                  __FUNCTION__, rc);
+        goto out;
+    }
+    guest_info_page = xc_map_foreign_range(xch, domid, PAGE_SIZE,
+                                           PROT_READ | PROT_WRITE,
+                                           PFN(ACPI_INFO_PHYSICAL_ADDRESS));
+    if ( !guest_info_page )

tools/libxc/xc_acpi.c line 214

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+    {
+        DOMPRINTF("%s: Can't map acpi_info_page", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+    memcpy(guest_info_page, acpi_pages, PAGE_SIZE);
+
+    /* Copy ACPI tables into guest's memory */
+    acpi_pages_num = ((alloc_up - (unsigned long)acpi_pages +
+                       (PAGE_SIZE - 1)) >> PAGE_SHIFT) - 1;

This looks like there are acpi_pages_num pages starting at acpi_pages, yet ...

Quoted 20 lines
tools/libxc/xc_acpi.c new file +20 -0
+    extents = malloc(acpi_pages_num * sizeof(*extents));
+    if ( !extents )
+    {
+        DOMPRINTF("%s: Can't allocate extents array", __FUNCTION__);
+        rc = -ENOMEM;
+        goto out;
+    }
+    for (i = 0; i < acpi_pages_num; i++)
+        extents[i] = PFN(RESERVED_MEMORY_DYNAMIC_START) + i;
+    rc = xc_domain_populate_physmap_exact(xch, domid, acpi_pages_num,
+                                          0, 0, extents);
+    if ( rc )
+    {
+        DOMPRINTF("%s: xc_domain_populate_physmap failed with %d",
+                  __FUNCTION__, rc);
+        goto out;
+    }
+    guest_acpi_pages = xc_map_foreign_range(xch, domid,
+                                            PAGE_SIZE * acpi_pages_num,
+                                            PROT_READ | PROT_WRITE,

tools/libxc/xc_acpi.c line 244

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+                                            PFN(RESERVED_MEMORY_DYNAMIC_START));
+    if ( !guest_acpi_pages )
+    {
+        DOMPRINTF("%s Can't map guest_acpi_pages", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+
+    memcpy(guest_acpi_pages, acpi_pages + PAGE_SIZE,
+           acpi_pages_num * PAGE_SIZE);

... this looks like there are acpi_pages_num pages starting at acpi_pages + PAGE_SIZE.

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 652

Quoted 13 lines
tools/libxc/xc_dom_x86.c +7 -0
@@ -643,6 +643,13 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
             DOMPRINTF("Unable to reserve memory for the start info");
             goto out;
         }
+
+        rc = xc_dom_build_acpi(dom);
+        if ( rc != 0 )
+        {
+            DOMPRINTF("Unable to build ACPI tables");
+            goto out;
+        }

Iirc there is an "acpi=" guest config setting, yet neither here nor down the call tree I have been able to find a respective check. Is that option not relevant anymore? Do we really want to always have those tables built?

Quoted 16 lines
tools/libxl/libxl_x86.c +3 -7
@@ -8,15 +8,18 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
                                       xc_domain_configuration_t *xc_config)
 {
 
-    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
-        d_config->b_info.device_model_version !=
-        LIBXL_DEVICE_MODEL_VERSION_NONE) {
-        /* HVM domains with a device model. */
-        xc_config->emulation_flags = XEN_X86_EMU_ALL;
-    } else {
-        /* PV or HVM domains without a device model. */
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+        if (d_config->b_info.device_model_version !=
+            LIBXL_DEVICE_MODEL_VERSION_NONE)

tools/libxl/libxl_x86.c int libxl__arch_domain_prepare_config(libxl__gc *gc, · line 19

Quoted 10 lines
tools/libxl/libxl_x86.c +8 -1
+            xc_config->emulation_flags = XEN_X86_EMU_ALL;
+        else
+            /*
+             * HVM guests without device model will want
+             * to have LAPIC emulation.
+             */
+            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
+    } else 
         xc_config->emulation_flags = 0;
-    }

I'm not maintainer of this code, but I think this would read better if you used an if/else if/else sequence instead of nested if.

xen/common/libacpi/build.c static int new_vm_gid(struct acpi_config *config) · line 483

Quoted 8 lines
xen/common/libacpi/build.c +1 -1
@@ -480,7 +480,7 @@ static int new_vm_gid(struct acpi_config *config)
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config, unsigned long physical)

I'm having some difficulty seeing how this change belongs here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#65 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 15 lines · Jan Beulich

tools/libxc/xc_acpi.c line 9

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/libxc/xc_acpi.c new file +9 -0
@@ -0,0 +1,268 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <xen/xen.h>
+#include <xen/foreign/x86_32.h>
+#include <xen/foreign/x86_64.h>

Why are these two needed here? The code here shouldn't care about the mode the guest may later want to run in.

These two are not needed.

Quoted 16 lines
Quoted 5 lines
tools/libxc/xc_acpi.c new file +4 -0
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/io/protocols.h>
+
+#include "xg_private.h"

tools/libxc/xc_acpi.c line 23

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+#include "xc_dom.h"
+#include "xenctrl.h"
+
+#include "acpi2_0.h"
+
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16

With which other definitions do these three need to remain in sync?

NUM_ACPI_PAGES is private to this file.

ACPI_PHYSICAL_ADDRESS (RSDP pointer) needs to be between 0xe0000 and 0xfffff, I picked this number because that's where most systems that I have appear to have it. (And by "most" I mean the two that I checked ;-))

RESERVED_MEMORY_DYNAMIC_START is one page after DSDT's SystemMemory (aka ACPI_INFO_PHYSICAL_ADDRESS). But then it looks like PVHv2 doesn't need SystemMemory so it can be anywhere (and e820 should presumably be aware of this, which it is not right now)

Quoted 15 lines

tools/libxc/xc_acpi.c line 74

Quoted 13 lines
tools/libxc/xc_acpi.c new file +12 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;

What good does an empty DSDT do? (Perhaps this question is a result of there not being any description of this change.)

DSDT is required to be present by the spec. And ACPICA gets upset if it doesn't see it.

Quoted 56 lines
tools/libxc/xc_acpi.c new file +23 -0
+    /* Copy acpi_info page into guest's memory */
+    extent = PFN(ACPI_INFO_PHYSICAL_ADDRESS);
+    rc = xc_domain_populate_physmap_exact(xch, domid, 1, 0, 0, &extent);
+    if ( rc )
+    {
+        DOMPRINTF("%s: xc_domain_populate_physmap failed with %d\n",
+                  __FUNCTION__, rc);
+        goto out;
+    }
+    guest_info_page = xc_map_foreign_range(xch, domid, PAGE_SIZE,
+                                           PROT_READ | PROT_WRITE,
+                                           PFN(ACPI_INFO_PHYSICAL_ADDRESS));
+    if ( !guest_info_page )
+    {
+        DOMPRINTF("%s: Can't map acpi_info_page", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+    memcpy(guest_info_page, acpi_pages, PAGE_SIZE);
+
+    /* Copy ACPI tables into guest's memory */
+    acpi_pages_num = ((alloc_up - (unsigned long)acpi_pages +
+                       (PAGE_SIZE - 1)) >> PAGE_SHIFT) - 1;

This looks like there are acpi_pages_num pages starting at acpi_pages, yet ...

Quoted 20 lines
tools/libxc/xc_acpi.c new file +20 -0
+    extents = malloc(acpi_pages_num * sizeof(*extents));
+    if ( !extents )
+    {
+        DOMPRINTF("%s: Can't allocate extents array", __FUNCTION__);
+        rc = -ENOMEM;
+        goto out;
+    }
+    for (i = 0; i < acpi_pages_num; i++)
+        extents[i] = PFN(RESERVED_MEMORY_DYNAMIC_START) + i;
+    rc = xc_domain_populate_physmap_exact(xch, domid, acpi_pages_num,
+                                          0, 0, extents);
+    if ( rc )
+    {
+        DOMPRINTF("%s: xc_domain_populate_physmap failed with %d",
+                  __FUNCTION__, rc);
+        goto out;
+    }
+    guest_acpi_pages = xc_map_foreign_range(xch, domid,
+                                            PAGE_SIZE * acpi_pages_num,
+                                            PROT_READ | PROT_WRITE,

tools/libxc/xc_acpi.c line 244

Quoted 10 lines
tools/libxc/xc_acpi.c new file +10 -0
+                                            PFN(RESERVED_MEMORY_DYNAMIC_START));
+    if ( !guest_acpi_pages )
+    {
+        DOMPRINTF("%s Can't map guest_acpi_pages", __FUNCTION__);
+        rc = -1;
+        goto out;
+    }
+
+    memcpy(guest_acpi_pages, acpi_pages + PAGE_SIZE,
+           acpi_pages_num * PAGE_SIZE);
Quoted 2 lines

... this looks like there are acpi_pages_num pages starting at acpi_pages + PAGE_SIZE.

Yes, I am off-by-one here. The first page (ACPI_INFO_PHYSICAL_ADDRESS) is managed separately.

Quoted 10 lines
Quoted 10 lines
tools/libxc/xc_dom_x86.c +3 -0
@@ -643,6 +643,13 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
             DOMPRINTF("Unable to reserve memory for the start info");
             goto out;
         }
+
+        rc = xc_dom_build_acpi(dom);
+        if ( rc != 0 )
Quoted 8 lines

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 652

Quoted 4 lines
tools/libxc/xc_dom_x86.c +4 -0
+        {
+            DOMPRINTF("Unable to build ACPI tables");
+            goto out;
+        }

Iirc there is an "acpi=" guest config setting, yet neither here nor down the call tree I have been able to find a respective check. Is that option not relevant anymore? Do we really want to always have those tables built?

Right, I should check. Come think of it, we should probably also check "apic=" option when building MADT in libacpi.

Quoted 10 lines

xen/common/libacpi/build.c static int new_vm_gid(struct acpi_config *config) · line 483

Quoted 9 lines
xen/common/libacpi/build.c +1 -1
@@ -480,7 +480,7 @@ static int new_vm_gid(struct acpi_config *config)
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config, unsigned long physical)

I'm having some difficulty seeing how this change belongs here.

acpi_build_tables() is called with virtual (i.e. 64-bit) address from libxc.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#66 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 18:59, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

tools/libxc/xc_acpi.c line 23

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/libxc/xc_acpi.c new file +5 -0
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16

With which other definitions do these three need to remain in sync?

Quoted 5 lines

NUM_ACPI_PAGES is private to this file.

ACPI_PHYSICAL_ADDRESS (RSDP pointer) needs to be between 0xe0000 and 0xfffff, I picked this number because that's where most systems that I have appear to have it. (And by "most" I mean the two that I checked ;-))

With there not being a BIOS, I can see this being pretty arbitrary. Yet in that case I'm not convinced of this getting put at a random address in the middle. Plus I'm not sure I see the connection to the reservations done in the E820 map the guest gets to see.

Quoted 4 lines

RESERVED_MEMORY_DYNAMIC_START is one page after DSDT's SystemMemory (aka ACPI_INFO_PHYSICAL_ADDRESS). But then it looks like PVHv2 doesn't need SystemMemory so it can be anywhere (and e820 should presumably be aware of this, which it is not right now)

So you say there's no connection to the end of hvmloader's window for PCI MMIO assignments (an equivalent of which is going to be needed for PVHv2)?

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
tools/libxc/xc_acpi.c new file +6 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
Quoted 8 lines

tools/libxc/xc_acpi.c line 74

Quoted 6 lines
tools/libxc/xc_acpi.c new file +6 -0
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;

What good does an empty DSDT do? (Perhaps this question is a result of there not being any description of this change.)

Quoted 2 lines

DSDT is required to be present by the spec. And ACPICA gets upset if it doesn't see it.

But my point (also mentioned further down in the original reply) was that there's no need for anything if acpi=0. But note that as soon as you report processors in MADT, the combined set of tables holding AML code can't be empty anymore: Processors need to be declared using Processor() (legacy) or Device(). Maybe we don't need as much as an ordinary HVM guest, but nothing seems too little.

Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
tools/libxc/xc_dom_x86.c +3 -0
@@ -643,6 +643,13 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
             DOMPRINTF("Unable to reserve memory for the start info");
             goto out;
         }
+
+        rc = xc_dom_build_acpi(dom);
+        if ( rc != 0 )
Quoted 8 lines

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 652

Quoted 4 lines
tools/libxc/xc_dom_x86.c +4 -0
+        {
+            DOMPRINTF("Unable to build ACPI tables");
+            goto out;
+        }

Iirc there is an "acpi=" guest config setting, yet neither here nor down the call tree I have been able to find a respective check. Is that option not relevant anymore? Do we really want to always have those tables built?

Quoted 2 lines

Right, I should check. Come think of it, we should probably also check "apic=" option when building MADT in libacpi.

Very likely, yes.

Quoted 11 lines
Quoted 9 lines

xen/common/libacpi/build.c static int new_vm_gid(struct acpi_config *config) · line 483

Quoted 8 lines
xen/common/libacpi/build.c +1 -1
@@ -480,7 +480,7 @@ static int new_vm_gid(struct acpi_config *config)
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config, unsigned long physical)

I'm having some difficulty seeing how this change belongs here.

acpi_build_tables() is called with virtual (i.e. 64-bit) address from libxc.

Oh - so the parameter name is then wrong?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#67 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 18:59, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

tools/libxc/xc_acpi.c line 23

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/libxc/xc_acpi.c new file +5 -0
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16

With which other definitions do these three need to remain in sync?

Quoted 8 lines
Quoted 5 lines

NUM_ACPI_PAGES is private to this file.

ACPI_PHYSICAL_ADDRESS (RSDP pointer) needs to be between 0xe0000 and 0xfffff, I picked this number because that's where most systems that I have appear to have it. (And by "most" I mean the two that I checked ;-))

With there not being a BIOS, I can see this being pretty arbitrary. Yet in that case I'm not convinced of this getting put at a random address in the middle.

I can put it in the beginning, at 0xe0000.

Quoted 2 lines

Plus I'm not sure I see the connection to the reservations done in the E820 map the guest gets to see.

I thought ACPI data is supposed to live in reserved areas (ACPI data, actually)?

Quoted 8 lines
Quoted 5 lines

RESERVED_MEMORY_DYNAMIC_START is one page after DSDT's SystemMemory (aka ACPI_INFO_PHYSICAL_ADDRESS). But then it looks like PVHv2 doesn't need SystemMemory so it can be anywhere (and e820 should presumably be aware of this, which it is not right now)

So you say there's no connection to the end of hvmloader's window for PCI MMIO assignments (an equivalent of which is going to be needed for PVHv2)?

I haven't thought about this but then we don't have MMIO hole now. I can try finding available memory chunk in guest's memory under 4G.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

tools/libxc/xc_acpi.c line 74

Quoted 13 lines
tools/libxc/xc_acpi.c new file +12 -0
+static int init_acpi_config(struct xc_dom_image *dom,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    memset(config, 0, sizeof(*config));
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_empty;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_empty_len;

What good does an empty DSDT do? (Perhaps this question is a result of there not being any description of this change.)

Quoted 4 lines
Quoted 2 lines

DSDT is required to be present by the spec. And ACPICA gets upset if it doesn't see it.

But my point (also mentioned further down in the original reply) was that there's no need for anything if acpi=0.

Right, but the whole routine will not be called if that's the case (in v1).

Quoted 5 lines

But note that as soon as
you report processors in MADT, the combined set of tables holding AML code can't be empty anymore: Processors need to be declared using Processor() (legacy) or Device(). Maybe we don't need as much as an ordinary HVM guest, but nothing seems too little.

I will add Processor.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/common/libacpi/build.c +0 -0
@@ -480,7 +480,7 @@ static int new_vm_gid(struct acpi_config *config)
     return 1;
 }
 
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

xen/common/libacpi/build.c static int new_vm_gid(struct acpi_config *config) · line 483

Quoted 2 lines
xen/common/libacpi/build.c +1 -1
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config, unsigned long physical)

I'm having some difficulty seeing how this change belongs here.

acpi_build_tables() is called with virtual (i.e. 64-bit) address from libxc.

Oh - so the parameter name is then wrong?

Yes, it should have a more appropriate name. Like rsdp or something like that.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#68 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 15:59, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 18:59, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

tools/libxc/xc_acpi.c line 23

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/libxc/xc_acpi.c new file +5 -0
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16

With which other definitions do these three need to remain in sync?

NUM_ACPI_PAGES is private to this file.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

ACPI_PHYSICAL_ADDRESS (RSDP pointer) needs to be between 0xe0000 and 0xfffff, I picked this number because that's where most systems that I have appear to have it. (And by "most" I mean the two that I checked ;-))

With there not being a BIOS, I can see this being pretty arbitrary. Yet in that case I'm not convinced of this getting put at a random address in the middle.

I can put it in the beginning, at 0xe0000.

I'd rather see it put higher up, close below 1Mb.

Quoted 5 lines
Quoted 2 lines

Plus I'm not sure I see the connection to the reservations done in the E820 map the guest gets to see.

I thought ACPI data is supposed to live in reserved areas (ACPI data, actually)?

Correct - but where is such an E820 entry being produced for the guest?

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

RESERVED_MEMORY_DYNAMIC_START is one page after DSDT's SystemMemory (aka ACPI_INFO_PHYSICAL_ADDRESS). But then it looks like PVHv2 doesn't need SystemMemory so it can be anywhere (and e820 should presumably be aware of this, which it is not right now)

So you say there's no connection to the end of hvmloader's window for PCI MMIO assignments (an equivalent of which is going to be needed for PVHv2)?

I haven't thought about this but then we don't have MMIO hole now. I can try finding available memory chunk in guest's memory under 4G.

Well, we first need to settle on the intended memory layout. And then we need to put this down in exactly one place, for all players to consume (and adhere to).

Quoted 7 lines
Quoted 5 lines

But note that as soon as
you report processors in MADT, the combined set of tables holding AML code can't be empty anymore: Processors need to be declared using Processor() (legacy) or Device(). Maybe we don't need as much as an ordinary HVM guest, but nothing seems too little.

I will add Processor.

And did you check whether there's something else that's mandatory (or even just kind of, due to e.g. ACPI CA relying on it)?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#69 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 20 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 15:59, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 18:59, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

tools/libxc/xc_acpi.c line 23

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
tools/libxc/xc_acpi.c new file +5 -0
+#define RESERVED_MEMORY_DYNAMIC_START 0xFC001000
+#define ACPI_PHYSICAL_ADDRESS         0x000EA020
+
+/* Initial allocation for ACPI tables */
+#define NUM_ACPI_PAGES  16

With which other definitions do these three need to remain in sync?

NUM_ACPI_PAGES is private to this file.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

ACPI_PHYSICAL_ADDRESS (RSDP pointer) needs to be between 0xe0000 and 0xfffff, I picked this number because that's where most systems that I have appear to have it. (And by "most" I mean the two that I checked ;-))

With there not being a BIOS, I can see this being pretty arbitrary. Yet in that case I'm not convinced of this getting put at a random address in the middle.

I can put it in the beginning, at 0xe0000.

Quoted 8 lines

I'd rather see it put higher up, close below 1Mb.

Quoted 4 lines
Quoted 2 lines

Plus I'm not sure I see the connection to the reservations done in the E820 map the guest gets to see.

I thought ACPI data is supposed to live in reserved areas (ACPI data, actually)?

Correct - but where is such an E820 entry being produced for the guest?

It's not. I actually mentioned this in cover letter.

I prototyped this at some point in libxl__arch_domain_construct_memmap().

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

RESERVED_MEMORY_DYNAMIC_START is one page after DSDT's SystemMemory (aka ACPI_INFO_PHYSICAL_ADDRESS). But then it looks like PVHv2 doesn't need SystemMemory so it can be anywhere (and e820 should presumably be aware of this, which it is not right now)

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

So you say there's no connection to the end of hvmloader's window for PCI MMIO assignments (an equivalent of which is going to be needed for PVHv2)?

I haven't thought about this but then we don't have MMIO hole now. I can try finding available memory chunk in guest's memory under 4G.

Well, we first need to settle on the intended memory layout. And then we need to put this down in exactly one place, for all players to consume (and adhere to).

On the few systems that I looked at they are placed right before the MMIO region.

How about (HVM_BELOW_4G_RAM_END - NUM_ACPI_PAGES)?

Quoted 10 lines
Quoted 7 lines
Quoted 6 lines

But note that as soon as
you report processors in MADT, the combined set of tables holding AML code can't be empty anymore: Processors need to be declared using Processor() (legacy) or Device(). Maybe we don't need as much as an ordinary HVM guest, but nothing seems too little.

I will add Processor.

And did you check whether there's something else that's mandatory (or even just kind of, due to e.g. ACPI CA relying on it)?

I didn't check the spec but as far as ACPICA is concerned --- this was tested with PVHv2 Linux and I think Roger ran this version on FreeBSD.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#70 lore raw

Re: [PATCH RFC 18/20] libxc/acpi: Build ACPI tables for HVMlite guests

Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:47, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 15:59, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 18:59, <[email protected]> wrote:
Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

RESERVED_MEMORY_DYNAMIC_START is one page after DSDT's SystemMemory (aka ACPI_INFO_PHYSICAL_ADDRESS). But then it looks like PVHv2 doesn't need SystemMemory so it can be anywhere (and e820 should presumably be aware of this, which it is not right now)

So you say there's no connection to the end of hvmloader's window for PCI MMIO assignments (an equivalent of which is going to be needed for PVHv2)?

I haven't thought about this but then we don't have MMIO hole now. I can try finding available memory chunk in guest's memory under 4G.

Quoted 8 lines
Quoted 3 lines

Well, we first need to settle on the intended memory layout. And then we need to put this down in exactly one place, for all players to consume (and adhere to).

On the few systems that I looked at they are placed right before the MMIO region.

How about (HVM_BELOW_4G_RAM_END - NUM_ACPI_PAGES)?

Sounds reasonable. But as said - all involved parties need to be made agree on memory use.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#71 lore raw

RFC PATCH 19/20 acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

In reply to Boris Ostrovsky

With this flags set guests will not try to set up SCI.

---
 xen/common/libacpi/build.c | 2 ++
 1 file changed, 2 insertions(+)
xen/common/libacpi/build.c +2 -0
index e53b4a7..7f2662a 100644
@@ -555,6 +555,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned long physical)
     fadt->x_dsdt = config->mem_ops.v2p(dsdt);
     fadt->firmware_ctrl   = config->mem_ops.v2p(facs);
     fadt->x_firmware_ctrl = config->mem_ops.v2p(facs);
+    if ( !(config->table_flags & ACPI_BUILD_IOAPIC) )
+        fadt->flags |= (1<<20); /* HW_REDUCED_ACPI */
     set_checksum(fadt,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#72 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

xen/common/libacpi/build.c void acpi_build_tables(struct acpi_config *config, unsigned long physical) · line 559

Quoted 8 lines
xen/common/libacpi/build.c +2 -0
@@ -555,6 +555,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned long physical)
     fadt->x_dsdt = config->mem_ops.v2p(dsdt);
     fadt->firmware_ctrl   = config->mem_ops.v2p(facs);
     fadt->x_firmware_ctrl = config->mem_ops.v2p(facs);
+    if ( !(config->table_flags & ACPI_BUILD_IOAPIC) )
+        fadt->flags |= (1<<20); /* HW_REDUCED_ACPI */

I think this would better be made a suitable #define in acpi2_0.h.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#73 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

-boris

Quoted 11 lines

xen/common/libacpi/build.c void acpi_build_tables(struct acpi_config *config, unsigned long physical) · line 559

Quoted 9 lines
xen/common/libacpi/build.c +2 -0
@@ -555,6 +555,8 @@ void acpi_build_tables(struct acpi_config *config, unsigned long physical)
     fadt->x_dsdt = config->mem_ops.v2p(dsdt);
     fadt->firmware_ctrl   = config->mem_ops.v2p(facs);
     fadt->x_firmware_ctrl = config->mem_ops.v2p(facs);
+    if ( !(config->table_flags & ACPI_BUILD_IOAPIC) )
+        fadt->flags |= (1<<20); /* HW_REDUCED_ACPI */

I think this would better be made a suitable #define in acpi2_0.h.

Quoted 2 lines

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#74 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

Quoted 6 lines

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#75 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 17 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

Quoted 6 lines

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 4 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#76 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 6 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks. And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#77 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks.

Who should those people be? linux-acpi?

Quoted 3 lines

And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

FWIW, the Microsoft's reading is
https://msdn.microsoft.com/en-us/windows/hardware/drivers/bringup/hardware-requirements-for-soc-based-platforms

ACPI fixed hardware features such as the following are not required:
Power Management (PM) timer
Real Time Clock (RTC) wake alarm
System Control Interrupt (SCI)
Fixed Hardware register set (PMx_* event/control/status registers) GPE block registers (GPEx_* event/control/status registers) Embedded controller

Also, from ACPICA perpective, HW-reduced mode appears to be the only way to prevent initialization of SCI.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#78 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 17:17, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks.

Who should those people be? linux-acpi?

That may yield valuable, but not dependable input. I'd rather think of folks actually working on / contributing to the spec. I'm sure Intel can name a few of their employees ...

Quoted 16 lines
Quoted 3 lines

And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

FWIW, the Microsoft's reading is
https://msdn.microsoft.com/en-us/windows/hardware/drivers/bringup/hardware-req
uirements-for-soc-based-platforms

ACPI fixed hardware features such as the following are not required:
Power Management (PM) timer
Real Time Clock (RTC) wake alarm
System Control Interrupt (SCI)
Fixed Hardware register set (PMx_* event/control/status registers) GPE block registers (GPEx_* event/control/status registers) Embedded controller

Quoted 2 lines

Also, from ACPICA perpective, HW-reduced mode appears to be the only way to prevent initialization of SCI.

Well, we could of course start out with HW-reduced mode, but we'd then need to settle on all aspects before any of this becomes fully supported.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#79 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 47 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 17:17, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks.

Who should those people be? linux-acpi?

That may yield valuable, but not dependable input. I'd rather think of folks actually working on / contributing to the spec. I'm sure Intel can name a few of their employees ...

Quoted 15 lines
Quoted 3 lines

And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

FWIW, the Microsoft's reading is
https://msdn.microsoft.com/en-us/windows/hardware/drivers/bringup/hardware-req
uirements-for-soc-based-platforms

ACPI fixed hardware features such as the following are not required:
Power Management (PM) timer
Real Time Clock (RTC) wake alarm
System Control Interrupt (SCI)
Fixed Hardware register set (PMx_* event/control/status registers) GPE block registers (GPEx_* event/control/status registers) Embedded controller

Quoted 5 lines
Quoted 2 lines

Also, from ACPICA perpective, HW-reduced mode appears to be the only way to prevent initialization of SCI.

Well, we could of course start out with HW-reduced mode, but we'd then need to settle on all aspects before any of this becomes fully supported.

So it looks like we can avoid needing this mode in Linux by simply allocating an irq descriptor for the SCI. We shouldn't receive anything on that interrupt in PVH anyway.

I don't know whether this will work for other OSs (i.e. FreeBSD).

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#80 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 54 lines · Boris Ostrovsky
Quoted 47 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 17:17, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks.

Who should those people be? linux-acpi?

That may yield valuable, but not dependable input. I'd rather think of folks actually working on / contributing to the spec. I'm sure Intel can name a few of their employees ...

Quoted 15 lines
Quoted 3 lines

And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

FWIW, the Microsoft's reading is
https://msdn.microsoft.com/en-us/windows/hardware/drivers/bringup/hardware-req
uirements-for-soc-based-platforms

ACPI fixed hardware features such as the following are not required:
Power Management (PM) timer
Real Time Clock (RTC) wake alarm
System Control Interrupt (SCI)
Fixed Hardware register set (PMx_* event/control/status registers) GPE block registers (GPEx_* event/control/status registers) Embedded controller

Quoted 5 lines
Quoted 2 lines

Also, from ACPICA perpective, HW-reduced mode appears to be the only way to prevent initialization of SCI.

Well, we could of course start out with HW-reduced mode, but we'd then need to settle on all aspects before any of this becomes fully supported.

Quoted 5 lines

So it looks like we can avoid needing this mode in Linux by simply allocating an irq descriptor for the SCI. We shouldn't receive anything on that interrupt in PVH anyway.

I don't know whether this will work for other OSs (i.e. FreeBSD).

I will have to check this, but AFAICT, setting the Hardware-Reduced ACPI make sense IMHO for DomU, since we are not providing a PM timer, RTC, SCI or any of those PMx and GPEx registers. Not setting it would mean that we would have to provide all those in order to comply with the ACPI specification.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#81 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 62 lines
Quoted 1 line
Quoted 1 line · On 09.06.16 at 10:13, <[email protected]> wrote:
Quoted 33 lines · Boris Ostrovsky
Quoted 32 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 17:17, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks.

Who should those people be? linux-acpi?

That may yield valuable, but not dependable input. I'd rather think of folks actually working on / contributing to the spec. I'm sure Intel can name a few of their employees ...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

FWIW, the Microsoft's reading is

https://msdn.microsoft.com/en-us/windows/hardware/drivers/bringup/hardware-req

Quoted 20 lines
Quoted 10 lines
Quoted 10 lines

uirements-for-soc-based-platforms

ACPI fixed hardware features such as the following are not required:
Power Management (PM) timer
Real Time Clock (RTC) wake alarm
System Control Interrupt (SCI)
Fixed Hardware register set (PMx_* event/control/status registers) GPE block registers (GPEx_* event/control/status registers) Embedded controller

Quoted 5 lines
Quoted 2 lines

Also, from ACPICA perpective, HW-reduced mode appears to be the only way to prevent initialization of SCI.

Well, we could of course start out with HW-reduced mode, but we'd then need to settle on all aspects before any of this becomes fully supported.

So it looks like we can avoid needing this mode in Linux by simply allocating an irq descriptor for the SCI. We shouldn't receive anything on that interrupt in PVH anyway.

Quoted 6 lines
Quoted 1 line

I don't know whether this will work for other OSs (i.e. FreeBSD).

I will have to check this, but AFAICT, setting the Hardware-Reduced ACPI make sense IMHO for DomU, since we are not providing a PM timer, RTC, SCI or any of those PMx and GPEx registers. Not setting it would mean that we would have to provide all those in order to comply with the ACPI specification.

That's true for the current black-or-white model, but won't be true anymore as soon as we allow other than emulate-all and emulate-nothing.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#82 lore raw

Re: [PATCH RFC 19/20] acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported

Quoted 61 lines · Jan Beulich
Quoted 61 lines
Quoted 1 line
Quoted 1 line · On 09.06.16 at 10:13, <[email protected]> wrote:
Quoted 33 lines · Boris Ostrovsky
Quoted 32 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 17:17, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 16:02, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

With this flags set guests will not try to set up SCI.

I've just read through the respective ACPI spec section again, and I couldn't find a reference to SCI from there ("Hardware-Reduced ACPI"). Can you clarify this connection please. Also there are other consequences of setting that flag, so in order to understand the reasons behind this change in case of future problems I think the description here will need to be significantly extended, despite the change being so small.

My understanding is that hardware-reduced platforms don't use ACPI Platform Event Model (Sec. 4.1.1) and that model requires SCI (and vice versa --- SCI is present when ACPI Platform Event Model is in use). The (somewhat indirect) evidence of this is in section 4.6 "The ACPI Hardware Model" where is says: "In the ACPI Legacy state, the ACPI event model is disabled (no SCIs are generated) ..."

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

In the sum of all the non-explicit wording I can only convince myself that SCI is a prereq for the event model. Yet I could see this being an if-and-only-if, just that I couldn't find any place saying so.

Not sure how I should interpret this: do you (reluctantly, possibly) agree that we can use HW-reduced flag to indicate that SCI is not there?

I really think we need to get confirmation on this from ACPI folks.

Who should those people be? linux-acpi?

That may yield valuable, but not dependable input. I'd rather think of folks actually working on / contributing to the spec. I'm sure Intel can name a few of their employees ...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

And I think (and I said so before) we need to understand all the other implications from setting that flag (i.e. we _cannot_ use this flag _just_ to indicate there's no SCI).

FWIW, the Microsoft's reading is

https://msdn.microsoft.com/en-us/windows/hardware/drivers/bringup/hardware-req

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines

uirements-for-soc-based-platforms

ACPI fixed hardware features such as the following are not required:
Power Management (PM) timer
Real Time Clock (RTC) wake alarm
System Control Interrupt (SCI)
Fixed Hardware register set (PMx_* event/control/status registers) GPE block registers (GPEx_* event/control/status registers) Embedded controller

Quoted 5 lines
Quoted 2 lines

Also, from ACPICA perpective, HW-reduced mode appears to be the only way to prevent initialization of SCI.

Well, we could of course start out with HW-reduced mode, but we'd then need to settle on all aspects before any of this becomes fully supported.

So it looks like we can avoid needing this mode in Linux by simply allocating an irq descriptor for the SCI. We shouldn't receive anything on that interrupt in PVH anyway.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

I don't know whether this will work for other OSs (i.e. FreeBSD).

I will have to check this, but AFAICT, setting the Hardware-Reduced ACPI make sense IMHO for DomU, since we are not providing a PM timer, RTC, SCI or any of those PMx and GPEx registers. Not setting it would mean that we would have to provide all those in order to comply with the ACPI specification.

That's true for the current black-or-white model, but won't be true anymore as soon as we allow other than emulate-all and emulate-nothing.

We probably don't want to be too fine-grained about what we emulate. So one option could be that we either emulate all devices that Roger listed above or none.

Also, there is a more definitive answer in the spec about what HW-reduced mode means as far as SCI (and other features) is concerned:
"5.2.9 Fixed ACPI Description Table (FADT)", Note above table 5-34.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#83 lore raw

RFC PATCH 20/20 acpi: Make ACPI builder available to hypervisor code

In reply to Boris Ostrovsky
---
 xen/common/Makefile          |  2 +-
 xen/common/libacpi/Makefile  | 15 ++++++++++++---
 xen/common/libacpi/acpi2_0.h |  6 ++++++
 xen/common/libacpi/build.c   | 15 +++++++++++++++
 xen/common/libacpi/mk_dsdt.c |  4 ++++
 5 files changed, 38 insertions(+), 4 deletions(-)
xen/common/Makefile +1 -1
index 77de27e..6e0ac8b 100644
@@ -73,5 +73,5 @@ subdir-$(CONFIG_X86) += hvm
 
 subdir-$(coverage) += gcov
 
-subdir-y += libelf
+subdir-y += libelf libacpi
 subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
xen/common/libacpi/Makefile +12 -3
index a1f233f..6cf98db 100644
@@ -21,7 +21,16 @@ C_SRC  = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c
 C_SRC += dsdt_anycpu_qemu_xen.c dsdt_empty.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
-CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include
+ifneq (,$(findstring -D__XEN__,$(CFLAGS)))
+# Hypervisor
+obj-y	= $(OBJS)
+$(OBJS): all
+CFLAGS  += -I$(XEN_ROOT)/xen/include/public
+CFLAGS_MKDSDT = -I$(XEN_ROOT)/xen/include/public/hvm -D__XEN__
+else
+# Toolstack
+CFLAGS_MKDSDT = -I$(XEN_ROOT)/tools/include
+endif
 
 vpath iasl $(PATH)
 all: $(C_SRC) ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
@@ -32,7 +41,7 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
 	rm -f $*.hex $*.aml
 
 mk_dsdt: mk_dsdt.c
-	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
+	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_MKDSDT) -o $@ mk_dsdt.c
 
 dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
@@ -57,7 +66,7 @@ iasl:
 	@echo 
 	@exit 1
 
-clean:
+clean::
 	rm -rf *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
 	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*cpu*.asl
 
xen/common/libacpi/acpi2_0.h +6 -0
index 458fb49..d47ad84 100644
@@ -17,10 +17,16 @@
 #ifndef _ACPI_2_0_H_
 #define _ACPI_2_0_H_
 
+#ifndef __XEN__
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
+#else
+#include <xen/lib.h>
+#include <memory.h>
+#include <hvm/ioreq.h>
+#endif
 
 #define ASCII32(a,b,c,d)         \
     (((a) <<  0) | ((b) <<  8) | ((c) << 16) | ((d) << 24))
xen/common/libacpi/build.c +15 -0
index 7f2662a..cbde7f9 100644
@@ -15,8 +15,13 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#ifndef __XEN__
 #include <stdio.h>
 #include <string.h>
+#else
+#include <xen/lib.h>
+#define printf printk
+#endif
 
 #include "acpi2_0.h"
 #include "ssdt_s3.h"
@@ -24,14 +29,24 @@
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
 #include "x86.h"
+#ifndef __XEN__
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
+#else
+#include <hvm/hvm_info_table.h>
+#include <hvm/hvm_xs_strings.h>
+#include <hvm/params.h>
+#endif
 
 #define ACPI_MAX_SECONDARY_TABLES 16
 
 #define align16(sz)        (((sz) + 15) & ~15)
+#ifndef __XEN__
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+#else
+#define fixed_strcpy(d, s) strlcpy((d), (s), sizeof(d))
+#endif
 #ifndef offsetof
 #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
 #endif
xen/common/libacpi/mk_dsdt.c +4 -0
index b567b38..e38a2f2 100644
@@ -5,7 +5,11 @@
 #include <getopt.h>
 #include <stdlib.h>
 #include <stdbool.h>
+#ifndef __XEN__
 #include <xen/hvm/hvm_info_table.h>
+#else
+#include <hvm_info_table.h>
+#endif
 
 static unsigned int indent_level;
 static bool debug = false;
Signature · 7 lines
2.4.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#84 lore raw

Re: [PATCH RFC 20/20] acpi: Make ACPI builder available to hypervisor code

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:
xen/common/libacpi/Makefile +0 -1
@@ -21,7 +21,16 @@ C_SRC  = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c
 C_SRC += dsdt_anycpu_qemu_xen.c dsdt_empty.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
-CFLAGS_xeninclude = -I$(XEN_ROOT)/tools/include

xen/common/libacpi/Makefile C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c · line 33

Quoted 10 lines
xen/common/libacpi/Makefile +10 -0
+ifneq (,$(findstring -D__XEN__,$(CFLAGS)))
+# Hypervisor
+obj-y	= $(OBJS)
+$(OBJS): all
+CFLAGS  += -I$(XEN_ROOT)/xen/include/public
+CFLAGS_MKDSDT = -I$(XEN_ROOT)/xen/include/public/hvm -D__XEN__
+else
+# Toolstack
+CFLAGS_MKDSDT = -I$(XEN_ROOT)/tools/include
+endif

This again speaks against makefile sharing. Note that libelf doesn't have anything like that.

Quoted 6 lines
xen/common/libacpi/acpi2_0.h +0 -0
@@ -17,10 +17,16 @@
 #ifndef _ACPI_2_0_H_
 #define _ACPI_2_0_H_
 

xen/common/libacpi/acpi2_0.h line 29

Quoted 10 lines
xen/common/libacpi/acpi2_0.h +6 -0
+#ifndef __XEN__
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
+#else
+#include <xen/lib.h>
+#include <memory.h>
+#include <hvm/ioreq.h>
+#endif

I'm not sure this should be done here, albeit I do see the analogy to how libelf deals with the dual use in this regard (perhaps doing this in .c files of header other than this particular one would be fine). In any event I am missing public/ prefixes above (preferably you would drop the explicit .../public include path, but even if that's needed for some reason, please don't obscure the inclusion of public headers here by omitting that prefix).

xen/common/libacpi/build.c line 24

Quoted 13 lines
xen/common/libacpi/build.c +5 -0
@@ -15,8 +15,13 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#ifndef __XEN__
 #include <stdio.h>
 #include <string.h>
+#else
+#include <xen/lib.h>
+#define printf printk
+#endif

I think we should strive to not introduce bunches of new log-level-less printk()-s. (But I do appreciate you not introducing stdio.h here.)

Quoted 12 lines
xen/common/libacpi/build.c +5 -0
@@ -24,14 +29,24 @@
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
 #include "x86.h"
+#ifndef __XEN__
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
+#else
+#include <hvm/hvm_info_table.h>
+#include <hvm/hvm_xs_strings.h>
+#include <hvm/params.h>

xen/common/libacpi/build.c line 49

Quoted 10 lines
xen/common/libacpi/build.c +5 -0
+#endif
 
 #define ACPI_MAX_SECONDARY_TABLES 16
 
 #define align16(sz)        (((sz) + 15) & ~15)
+#ifndef __XEN__
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+#else
+#define fixed_strcpy(d, s) strlcpy((d), (s), sizeof(d))
+#endif

I'd rather see you ditch the stray parentheses in the pre-existing instance than introduce further ones.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#85 lore raw
In reply to Boris Ostrovsky
Quoted 3 lines · Boris Ostrovsky

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

When do people think they will get a chance to comment on this? Should this wait until after 4.7 is released?

Thanks.
-boris

Quoted 102 lines

The series
* Removes dependency of today's builder on hvmloader interfaces
* Makes many of the tables built optionally.
* Moves tools/hvmloader/acpi directory to xen/common/libacpi
* Builds tables for PVHv2 domU guests in libxc

There is still a number of questions about this implementation, thus it's an RFC. Examples of things that need to be discussed are

* ACPI tables are built for PVHv2 guests unconditionally. We probably want to make this an option.
* Not sure about header files, especially xen/common/libacpi/x86.h and tools/firmware/hvmloader/{stdio.h,string.h}
* The builder is compiled into the hypervisor even though currently there are no users (PVHv2 dom0 will be the one)
* Patch 19 is somewhat of a spec violation
* Makefiles are questionable
* May need changes to guests' e820 map

This is also available from git://oss.oracle.com/git/bostrovs/xen.git:acpi_rfc.

It has been tested with Linux PVHv2 (and I believe Roger tested an earlier version with FreeBSD). No passthrough testing has been done.

(I realize that many people are busy because of Friday's freeze but I figured I'd post it now in the hope that this may get some reading so that we can talk about it at the hackathon)

Boris Ostrovsky (20):
hvmloader: Provide hvmloader_acpi_build_tables() acpi/hvmloader: Move acpi_info initialization out of ACPI code acpi/hvmloader: Initialize vm_gid data outside ACPI code acpi/hvmloader: Decide which SSDTs to build in hvmloader acpi/hvmloader: Move passthrough initialization from ACPI code acpi/hvmloader: Collect processor and NUMA info in hvmloader acpi/hvmloader: Set TIS header address in hvmloader acpi/hvmloader: Make providing IOAPIC in MADT optional acpi/hvmloader: Build WAET optionally
acpi/hvmloader: Provide address of acpi_info as an argument to ACPI
code
acpi/hvmloader: Translate all addresses when assigning addresses in
ACPI tables
acpi/hvmloader: Link ACPI object files directly acpi/hvmloader: Add stdio.h, string.h and x86.h acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops
acpi: Move ACPI code to xen/common/libacpi
x86/vlapic: Don't try to accept 8259 interrupt if !has_vpic()
x86: Allow LAPIC-only emulation_flags for HVM guests libxc/acpi: Build ACPI tables for HVMlite guests
acpi: Set HW_REDUCED_ACPI in FADT if IOAPIC is not supported
acpi: Make ACPI builder available to hypervisor code

 .gitignore                                         |   8 +-
 tools/firmware/hvmloader/Makefile                  |  16 +-
 tools/firmware/hvmloader/config.h                  |  13 +-
 tools/firmware/hvmloader/hvmloader.c               |   3 +-
 tools/firmware/hvmloader/mp_tables.c               |   1 +
 tools/firmware/hvmloader/ovmf.c                    |   4 +-
 tools/firmware/hvmloader/pci.c                     |   1 +
 tools/firmware/hvmloader/pir.c                     |   1 +
 tools/firmware/hvmloader/rombios.c                 |   4 +-
 tools/firmware/hvmloader/seabios.c                 |   4 +-
 tools/firmware/hvmloader/smbios.c                  |   1 +
 tools/firmware/hvmloader/smp.c                     |   1 +
 tools/firmware/hvmloader/stdio.h                   |   7 +
 tools/firmware/hvmloader/string.h                  |   7 +
 tools/firmware/hvmloader/util.c                    |  85 +++++
 tools/firmware/hvmloader/util.h                    |   6 +-
 tools/firmware/rombios/32bit/Makefile              |   2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile      |   2 +-
 tools/firmware/rombios/32bit/util.h                |   2 +-
 tools/libxc/Makefile                               |  22 +-
 tools/libxc/include/xc_dom.h                       |   1 +
 tools/libxc/xc_acpi.c                              | 268 +++++++++++++
 tools/libxc/xc_dom_x86.c                           |   7 +
 tools/libxl/libxl_x86.c                            |  19 +-
 xen/arch/x86/domain.c                              |  26 +-
 xen/arch/x86/hvm/vlapic.c                          |   3 +
 xen/common/Makefile                                |   2 +-
 .../hvmloader/acpi => xen/common/libacpi}/Makefile |  33 +-
 .../hvmloader/acpi => xen/common/libacpi}/README   |   0
 .../acpi => xen/common/libacpi}/acpi2_0.h          |  66 +++-
 .../hvmloader/acpi => xen/common/libacpi}/build.c  | 415 ++++++++++-----------
 .../hvmloader/acpi => xen/common/libacpi}/dsdt.asl |   0
 xen/common/libacpi/dsdt_empty.asl                  |  22 ++
 .../acpi => xen/common/libacpi}/mk_dsdt.c          |   4 +
 .../acpi => xen/common/libacpi}/ssdt_pm.asl        |   0
 .../acpi => xen/common/libacpi}/ssdt_s3.asl        |   0
 .../acpi => xen/common/libacpi}/ssdt_s4.asl        |   0
 .../acpi => xen/common/libacpi}/ssdt_tpm.asl       |   0
 .../acpi => xen/common/libacpi}/static_tables.c    |   1 -
 xen/common/libacpi/x86.h                           |  14 +
 40 files changed, 794 insertions(+), 277 deletions(-)
 create mode 100644 tools/firmware/hvmloader/stdio.h
 create mode 100644 tools/firmware/hvmloader/string.h
 create mode 100644 tools/libxc/xc_acpi.c
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/Makefile (70%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/README (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/acpi2_0.h (84%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/build.c (58%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/dsdt.asl (100%)
Quoted 9 lines
 create mode 100644 xen/common/libacpi/dsdt_empty.asl
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/mk_dsdt.c (99%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_pm.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s3.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_s4.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/ssdt_tpm.asl (100%)
 rename {tools/firmware/hvmloader/acpi => xen/common/libacpi}/static_tables.c (99%)
 create mode 100644 xen/common/libacpi/x86.h

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#86 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 09.05.16 at 22:10, <[email protected]> wrote:
Quoted 3 lines · Boris Ostrovsky

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

When do people think they will get a chance to comment on this? Should this wait until after 4.7 is released?

I'm sorry, I don't anticipate to get to this much earlier than that.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#87 lore raw
In reply to Boris Ostrovsky
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

The series
* Removes dependency of today's builder on hvmloader interfaces
* Makes many of the tables built optionally.
* Moves tools/hvmloader/acpi directory to xen/common/libacpi
* Builds tables for PVHv2 domU guests in libxc

There is still a number of questions about this implementation, thus it's an RFC. Examples of things that need to be discussed are

Quoted 6 lines

* ACPI tables are built for PVHv2 guests unconditionally. We probably want to make this an option.
* Not sure about header files, especially xen/common/libacpi/x86.h and tools/firmware/hvmloader/{stdio.h,string.h}
* The builder is compiled into the hypervisor even though currently there are no users (PVHv2 dom0 will be the one)

Is that really what we want? I thought we don't really mean to build ACPI tables from scratch for Dom0, but rather follow ARM's customization approach. And if we don't want this, then the placement of this now shared code would need reconsidering.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#88 lore raw
Quoted 20 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

The series
* Removes dependency of today's builder on hvmloader interfaces
* Makes many of the tables built optionally.
* Moves tools/hvmloader/acpi directory to xen/common/libacpi
* Builds tables for PVHv2 domU guests in libxc

There is still a number of questions about this implementation, thus it's an RFC. Examples of things that need to be discussed are

Quoted 6 lines

* ACPI tables are built for PVHv2 guests unconditionally. We probably want to make this an option.
* Not sure about header files, especially xen/common/libacpi/x86.h and tools/firmware/hvmloader/{stdio.h,string.h}
* The builder is compiled into the hypervisor even though currently there are no users (PVHv2 dom0 will be the one)

Quoted 3 lines

Is that really what we want? I thought we don't really mean to build ACPI tables from scratch for Dom0, but rather follow ARM's customization approach.

You mean xen/arch/arm/domain_build.c:prepare_acpi()?

The thinking was that customization will be able to make use of this library. Roger?

Quoted 2 lines

And if we don't want this, then the
placement of this now shared code would need reconsidering.

Right. In fact I originally had this as tools/libacpi.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#89 lore raw
Quoted 21 lines · Boris Ostrovsky
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

The series
* Removes dependency of today's builder on hvmloader interfaces
* Makes many of the tables built optionally.
* Moves tools/hvmloader/acpi directory to xen/common/libacpi
* Builds tables for PVHv2 domU guests in libxc

There is still a number of questions about this implementation, thus it's an RFC. Examples of things that need to be discussed are

* ACPI tables are built for PVHv2 guests unconditionally. We probably want to make this an option.
* Not sure about header files, especially xen/common/libacpi/x86.h and tools/firmware/hvmloader/{stdio.h,string.h}
* The builder is compiled into the hypervisor even though currently there are no users (PVHv2 dom0 will be the one)

Quoted 8 lines
Quoted 3 lines

Is that really what we want? I thought we don't really mean to build ACPI tables from scratch for Dom0, but rather follow ARM's customization approach.

You mean xen/arch/arm/domain_build.c:prepare_acpi()?

The thinking was that customization will be able to make use of this library. Roger?

Yes, I (at least) thought that the same library would be used for crafting the tables for DomU or customizing the ones presented to Dom0 so that all the ACPI code resides at the same place. I was planning to place this code in the Xen .init section, so that it's gone after Dom0 construction.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#90 lore raw
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 03.06.16 at 09:18, <[email protected]> wrote:
Quoted 25 lines · Boris Ostrovsky
Quoted 23 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 06.04.16 at 03:25, <[email protected]> wrote:

This is an RFC for making hvmloader's ACPI builder available to both the toolstack and the hypervisor, as discussed in
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01228.html

The series
* Removes dependency of today's builder on hvmloader interfaces
* Makes many of the tables built optionally.
* Moves tools/hvmloader/acpi directory to xen/common/libacpi
* Builds tables for PVHv2 domU guests in libxc

There is still a number of questions about this implementation, thus it's an RFC. Examples of things that need to be discussed are

Quoted 6 lines

* ACPI tables are built for PVHv2 guests unconditionally. We probably want to make this an option.
* Not sure about header files, especially xen/common/libacpi/x86.h and tools/firmware/hvmloader/{stdio.h,string.h}
* The builder is compiled into the hypervisor even though currently there are no users (PVHv2 dom0 will be the one)

Is that really what we want? I thought we don't really mean to build ACPI tables from scratch for Dom0, but rather follow ARM's customization approach.

Quoted 8 lines
Quoted 4 lines

You mean xen/arch/arm/domain_build.c:prepare_acpi()?

The thinking was that customization will be able to make use of this library. Roger?

Yes, I (at least) thought that the same library would be used for crafting the tables for DomU or customizing the ones presented to Dom0 so that all the ACPI code resides at the same place.

Okay, I can't see much code sharing between customization and creation from scratch, but I can certainly be convinced otherwise.

Quoted 2 lines

I was planning to place this code
in the Xen .init section, so that it's gone after Dom0 construction.

Sure, that's a requirement in any case (just like is the case for libelf).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel