Skip to contentSkip to conversation

Make ACPI builder available to components other than hvmloader

PATCH Superseded Boris Ostrovsky 5 participants 69 messages Aug 4, 2016 – Aug 16, 2016

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Make ACPI builder available to components other than hvmloader

The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.

This version is built on top of Anthony's
git://xenbits.xen.org/people/aperard/xen-unstable.git:hvmloader-with-separated-bios-v7

It also requires (still not fully ACKed, sigh) ACPI relicensing patch
https://lists.xenproject.org/archives/html/xen-devel/2016-07/msg01975.html

Major changes:
* Keep struct_acpi_info private to build.c
* Separate table allocation and loading, similar to ARM's approach

More detailed changes are listed per patch.

Boris Ostrovsky (23):
hvmloader: Provide hvmloader_acpi_build_tables() acpi/hvmloader: Allow acpi_build_tables() callers specify acpi_info
values
acpi/hvmloader: Initialize vm_gid data outside ACPI code acpi/hvmloader: Decide which SSDTs to install 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: Replace mem_alloc() and virt_to_phys() with memory ops acpi/hvmloader: Translate all addresses when assigning addresses in
ACPI tables
acpi/hvmloader: Link ACPI object files directly acpi/hvmloader: Include file/paths adjustments
acpi: Move ACPI code to tools/libacpi
x86: Add more checks verifying that PIT/PIC/IOAPIC are emulated
x86: Allow LAPIC-only emulation_flags for HVM guests
libacpi: Build DSDT for PVH guests
libxc/libxl: Allow multiple ACPI modules
libxl/acpi: Add ACPI e820 entry
libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
ilibxl: Initialize domain build info before calling libxl__domain_make libxl/acpi: Build ACPI tables for HVMlite guests libxc/xc_dom_core: Copy ACPI tables to guest space

 .gitignore                                    |  20 +-
 tools/firmware/hvmloader/Makefile             |  20 +-
 tools/firmware/hvmloader/acpi/Makefile        |  70 ---
 tools/firmware/hvmloader/acpi/README          |  24 -
 tools/firmware/hvmloader/acpi/acpi2_0.h       | 470 -------------------
 tools/firmware/hvmloader/acpi/build.c         | 646 --------------------------
 tools/firmware/hvmloader/acpi/dsdt.asl        | 478 -------------------
 tools/firmware/hvmloader/acpi/mk_dsdt.c       | 501 --------------------
 tools/firmware/hvmloader/acpi/ssdt_pm.asl     | 418 -----------------
 tools/firmware/hvmloader/acpi/ssdt_s3.asl     |  28 --
 tools/firmware/hvmloader/acpi/ssdt_s4.asl     |  28 --
 tools/firmware/hvmloader/acpi/ssdt_tpm.asl    |  28 --
 tools/firmware/hvmloader/acpi/static_tables.c | 168 -------
 tools/firmware/hvmloader/config.h             |   8 +-
 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            |   5 +-
 tools/firmware/hvmloader/smp.c                |   1 +
 tools/firmware/hvmloader/util.c               |  98 ++++
 tools/firmware/hvmloader/util.h               |   4 +
 tools/libacpi/Makefile                        |  80 ++++
 tools/libacpi/README                          |  32 ++
 tools/libacpi/acpi2_0.h                       | 461 ++++++++++++++++++
 tools/libacpi/build.c                         | 645 +++++++++++++++++++++++++
 tools/libacpi/dsdt.asl                        | 458 ++++++++++++++++++
 tools/libacpi/dsdt_acpi_info.asl              |  23 +
 tools/libacpi/libacpi.h                       | 110 +++++
 tools/libacpi/mk_dsdt.c                       | 511 ++++++++++++++++++++
 tools/libacpi/ssdt_pm.asl                     | 418 +++++++++++++++++
 tools/libacpi/ssdt_s3.asl                     |  28 ++
 tools/libacpi/ssdt_s4.asl                     |  28 ++
 tools/libacpi/ssdt_tpm.asl                    |  28 ++
 tools/libacpi/static_tables.c                 | 168 +++++++
 tools/libacpi/x86.h                           |  30 ++
 tools/libxc/include/xc_dom.h                  |   5 +-
 tools/libxc/xc_dom_core.c                     |  92 ++++
 tools/libxc/xc_dom_hvmloader.c                |   3 +-
 tools/libxl/Makefile                          |  19 +-
 tools/libxl/libxl_arch.h                      |   3 +
 tools/libxl/libxl_create.c                    |  22 +-
 tools/libxl/libxl_dom.c                       |  57 ++-
 tools/libxl/libxl_x86.c                       |  44 +-
 tools/libxl/libxl_x86_acpi.c                  | 199 ++++++++
 tools/libxl/libxl_x86_acpi.h                  |  35 ++
 xen/arch/x86/domain.c                         |  26 +-
 xen/arch/x86/hvm/vlapic.c                     |  14 +-
 xen/arch/x86/hvm/vpt.c                        |   2 +-
 51 files changed, 3633 insertions(+), 2937 deletions(-)
 delete mode 100644 tools/firmware/hvmloader/acpi/Makefile
 delete mode 100644 tools/firmware/hvmloader/acpi/README
 delete mode 100644 tools/firmware/hvmloader/acpi/acpi2_0.h
 delete mode 100644 tools/firmware/hvmloader/acpi/build.c
 delete mode 100644 tools/firmware/hvmloader/acpi/dsdt.asl
 delete mode 100644 tools/firmware/hvmloader/acpi/mk_dsdt.c
 delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_pm.asl
 delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_s3.asl
 delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_s4.asl
 delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_tpm.asl
 delete mode 100644 tools/firmware/hvmloader/acpi/static_tables.c
 create mode 100644 tools/libacpi/Makefile
 create mode 100644 tools/libacpi/README
 create mode 100644 tools/libacpi/acpi2_0.h
 create mode 100644 tools/libacpi/build.c
 create mode 100644 tools/libacpi/dsdt.asl
 create mode 100644 tools/libacpi/dsdt_acpi_info.asl
 create mode 100644 tools/libacpi/libacpi.h
 create mode 100644 tools/libacpi/mk_dsdt.c
 create mode 100644 tools/libacpi/ssdt_pm.asl
 create mode 100644 tools/libacpi/ssdt_s3.asl
 create mode 100644 tools/libacpi/ssdt_s4.asl
 create mode 100644 tools/libacpi/ssdt_tpm.asl
 create mode 100644 tools/libacpi/static_tables.c
 create mode 100644 tools/libacpi/x86.h
 create mode 100644 tools/libxl/libxl_x86_acpi.c
 create mode 100644 tools/libxl/libxl_x86_acpi.h
Signature · 7 lines
1.8.3.1


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

PATCH v2 1/23 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.

No functional changes.

---
 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 59d0e45..1c8a71b 100644
@@ -127,7 +127,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 2ded844..38a86ff 100644
@@ -181,7 +181,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 c5d2b34..3d046fd 100644
@@ -97,7 +97,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 9808016..0fb266e 100644
@@ -276,6 +276,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
1.8.3.1


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

PATCH v2 2/23 acpi/hvmloader: Allow acpi_build_tables() callers specify acpi_info values

In reply to Boris Ostrovsky

By doing this we can move hvmloader-private interfaces (such as uart_exists(), lpt_exists() etc.) out of the ACPI builder. This will help us with allowing to call the builder from places other than hvmloader.

---
v2:
* Keep struct acpi_info private to build.c and instead pass information necessary to set its fields via acpi_config's flags.

 tools/firmware/hvmloader/acpi/acpi2_0.h |  9 -----
 tools/firmware/hvmloader/acpi/build.c   | 34 +++++++++---------
 tools/firmware/hvmloader/acpi/libacpi.h | 63 +++++++++++++++++++++++++++++++++
 tools/firmware/hvmloader/ovmf.c         |  2 +-
 tools/firmware/hvmloader/seabios.c      |  1 +
 tools/firmware/hvmloader/util.c         | 26 +++++++++++++-
 6 files changed, 106 insertions(+), 29 deletions(-)
 create mode 100644 tools/firmware/hvmloader/acpi/libacpi.h
tools/firmware/hvmloader/acpi/acpi2_0.h +0 -9
index 6fa3452..775eb7a 100644
@@ -448,15 +448,6 @@ struct acpi_20_slit {
 
 #pragma pack ()
 
-struct acpi_config {
-    unsigned char *dsdt_anycpu;
-    int dsdt_anycpu_len;
-    unsigned char *dsdt_15cpu;
-    int dsdt_15cpu_len;
-};
-
-void acpi_build_tables(struct acpi_config *config, unsigned int physical);
-
 #endif /* _ACPI_2_0_H_ */
 
 /*
tools/firmware/hvmloader/acpi/build.c +16 -18
index 8be9b90..f251c05 100644
@@ -14,6 +14,7 @@
  */
 
 #include "acpi2_0.h"
+#include "libacpi.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
@@ -356,7 +357,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* HPET. */
-    if ( hpet_exists(ACPI_HPET_ADDRESS) )
+    if ( info->hpet_present )
     {
         hpet = construct_hpet();
         if (!hpet) return -1;
@@ -491,7 +492,7 @@ static int new_vm_gid(struct acpi_info *acpi_info)
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -504,10 +505,19 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     unsigned long        secondary_tables[ACPI_MAX_SECONDARY_TABLES];
     int                  nr_secondaries, i;
 
-    /* Allocate and initialise the acpi info area. */
-    mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
-    acpi_info = (struct acpi_info *)ACPI_INFO_PHYSICAL_ADDRESS;
+    acpi_info = (struct acpi_info *)config->infop;
     memset(acpi_info, 0, sizeof(*acpi_info));
+    acpi_info->com1_present = !!(config->table_flags & ACPI_HAS_COM1);
+    acpi_info->com2_present = !!(config->table_flags & ACPI_HAS_COM2);
+    acpi_info->lpt1_present = !!(config->table_flags & ACPI_HAS_LPT1);
+    acpi_info->hpet_present = !!(config->table_flags & ACPI_HAS_HPET);
+    acpi_info->pci_min = config->pci_start;
+    acpi_info->pci_len = config->pci_len;
+    if ( config->pci_hi_len )
+    {
+        acpi_info->pci_hi_min = config->pci_hi_start;
+        acpi_info->pci_hi_len = config->pci_hi_len;
+    }
 
     /*
      * Fill in high-memory data structures, starting at @buf.
@@ -601,7 +611,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     /*
      * Fill in low-memory data structures: acpi_info and RSDP.
      */
-    rsdp = (struct acpi_20_rsdp *)physical;
+    rsdp = (struct acpi_20_rsdp *)config->rsdp;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
     rsdp->rsdt_address = (unsigned long)rsdt;
@@ -616,18 +626,6 @@ void acpi_build_tables(struct acpi_config *config, unsigned int physical)
     if ( !new_vm_gid(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);
-    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;
-    }
-
     return;
 
 oom:
tools/firmware/hvmloader/acpi/libacpi.h new file +63 -0

63 lines not on this page · raw message

tools/firmware/hvmloader/ovmf.c +1 -1
index 1c8a71b..b4bcc93 100644
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
+#include "acpi/libacpi.h"
 #include "apic_regs.h"
 #include "../rombios/config.h"
 #include "util.h"
tools/firmware/hvmloader/seabios.c +1 -0
index 3d046fd..5c9a351 100644
@@ -26,6 +26,7 @@
 
 #include "smbios_types.h"
 #include "acpi/acpi2_0.h"
+#include "acpi/libacpi.h"
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
tools/firmware/hvmloader/util.c +25 -1
index 9af29b1..7de2fb6 100644
@@ -22,6 +22,7 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "acpi/acpi2_0.h"
+#include "acpi/libacpi.h"
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
@@ -860,7 +861,30 @@ int hpet_exists(unsigned long hpet_base)
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
-    acpi_build_tables(config, physical);
+    /* Allocate and initialise the acpi info area. */
+    mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
+
+    if ( uart_exists(0x3f8)  )
+        config->table_flags |= ACPI_HAS_COM1;
+    if (  uart_exists(0x2f8) )
+        config->table_flags |= ACPI_HAS_COM2;
+    if ( lpt_exists(0x378) )
+        config->table_flags |= ACPI_HAS_LPT1;
+    if (  hpet_exists(ACPI_HPET_ADDRESS) )
+        config->table_flags |= ACPI_HAS_HPET;
+
+    config->pci_start = pci_mem_start;
+    config->pci_len = pci_mem_end - pci_mem_start;
+    if ( pci_hi_mem_end > pci_hi_mem_start )
+    {
+        config->pci_hi_start = pci_hi_mem_start;
+        config->pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
+    }
+
+    config->rsdp = physical;
+    config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
+
+    acpi_build_tables(config);
 }
 
 /*
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 2/23
#3 lore raw

Re: [PATCH v2 02/23] acpi/hvmloader: Allow acpi_build_tables() callers specify acpi_info values

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

By doing this we can move hvmloader-private interfaces (such as uart_exists(), lpt_exists() etc.) out of the ACPI builder. This will help us with allowing to call the builder from places other than hvmloader.

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

#4 lore raw

PATCH v2 3/23 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.

---
v2:
* Pass VM GID address back via acpi_config.vm_gid_addr.

 tools/firmware/hvmloader/acpi/build.c   | 34 ++++++++++++++-------------------
 tools/firmware/hvmloader/acpi/libacpi.h |  3 +++
 tools/firmware/hvmloader/util.c         | 16 ++++++++++++++++
 3 files changed, 33 insertions(+), 20 deletions(-)
tools/firmware/hvmloader/acpi/build.c +14 -20
index f251c05..df104a3 100644
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = 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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);
+    config->vm_gid_addr = virt_to_phys(buf);
 
     return 1;
 }
@@ -623,7 +617,7 @@ void acpi_build_tables(struct acpi_config *config)
                  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;
 
     return;
tools/firmware/hvmloader/acpi/libacpi.h +3 -0
index 5e0f400..4cbd41e 100644
@@ -37,6 +37,9 @@ struct acpi_config {
 
     uint32_t table_flags;
 
+    uint64_t vm_gid[2];
+    unsigned long vm_gid_addr; /* OUT parameter */
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
tools/firmware/hvmloader/util.c +16 -0
index 7de2fb6..e8ce12b 100644
@@ -27,6 +27,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.
@@ -861,6 +862,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);
 
@@ -881,10 +884,23 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
         config->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);
+    }
+
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
     acpi_build_tables(config);
+
+    hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->vm_gid_addr);
 }
 
 /*
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +9 -15
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = mem_alloc(sizeof(config->vm_gid), 8);

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

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -4
     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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

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

Quoted 1 line
tools/firmware/hvmloader/acpi/build.c +1 -0
+    config->vm_gid_addr = virt_to_phys(buf);

If it can't, and considering that virt_to_phys() is going to become a function call, the second initialization would better use the first one's result.

Jan

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

#6 lore raw

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 40 lines · Jan Beulich
Quoted 40 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +10 -16
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = 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 6 lines

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

Quoted 5 lines
tools/firmware/hvmloader/acpi/build.c +2 -3
-    /* 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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

In acpi_info? TBH, I don't know, I thought this was introduced to deal with something in Windows (commit 978cc62b looks generic but then c5a29a87 is for Windows).

-boris

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

#7 lore raw

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 49 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:50, <[email protected]> wrote:
Quoted 40 lines · Jan Beulich
Quoted 40 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +10 -16
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = 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 6 lines

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

Quoted 5 lines
tools/firmware/hvmloader/acpi/build.c +2 -3
-    /* 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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

Quoted 3 lines

In acpi_info? TBH, I don't know, I thought this was introduced to deal with something in Windows (commit 978cc62b looks generic but then c5a29a87 is for Windows).

Sure, but the need for the field appears to go away with the introduction of the one in acpi_config.

Jan

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

#8 lore raw

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 48 lines · Jan Beulich
Quoted 48 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:50, <[email protected]> wrote:
Quoted 46 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +9 -15
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = mem_alloc(sizeof(config->vm_gid), 8);

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

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -4
     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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

Quoted 5 lines
Quoted 3 lines

In acpi_info? TBH, I don't know, I thought this was introduced to deal with something in Windows (commit 978cc62b looks generic but then c5a29a87 is for Windows).

Sure, but the need for the field appears to go away with the introduction of the one in acpi_config.

The way genid needs to work is this:

1) Allocate some memory, reserving it in the e820
2) Represents that physical address in the ACPI tables for the guest to consume
3) Update Xenstore with the physical address, for the toolstack to consume

So long as HVMLoader continues to function in that way, it is fine.

~Andrew

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

#9 lore raw

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 54 lines · Andrew Cooper
Quoted 48 lines · Jan Beulich
Quoted 48 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:50, <[email protected]> wrote:
Quoted 46 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +9 -15
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = mem_alloc(sizeof(config->vm_gid), 8);

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

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -4
     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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

Quoted 5 lines
Quoted 3 lines

In acpi_info? TBH, I don't know, I thought this was introduced to deal with something in Windows (commit 978cc62b looks generic but then c5a29a87 is for Windows).

Sure, but the need for the field appears to go away with the introduction of the one in acpi_config.

Quoted 8 lines

The way genid needs to work is this:

1) Allocate some memory, reserving it in the e820
2) Represents that physical address in the ACPI tables for the guest to consume
3) Update Xenstore with the physical address, for the toolstack to consume

So long as HVMLoader continues to function in that way, it is fine.

What about VGID device in dsdt.asl? Doesn't it want to see the address stored in VGIA, which is acpi_info->vm_gid_addr?

-boris

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

#10 lore raw

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

Quoted 57 lines · Boris Ostrovsky
Quoted 56 lines · Andrew Cooper
Quoted 48 lines · Jan Beulich
Quoted 48 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:50, <[email protected]> wrote:
Quoted 46 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +9 -15
@@ -462,32 +462,26 @@ 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = mem_alloc(sizeof(config->vm_gid), 8);

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

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -4
     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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

Quoted 5 lines
Quoted 3 lines

In acpi_info? TBH, I don't know, I thought this was introduced to deal with something in Windows (commit 978cc62b looks generic but then c5a29a87 is for Windows).

Sure, but the need for the field appears to go away with the introduction of the one in acpi_config.

The way genid needs to work is this:

Quoted 8 lines
Quoted 6 lines

1) Allocate some memory, reserving it in the e820
2) Represents that physical address in the ACPI tables for the guest to consume
3) Update Xenstore with the physical address, for the toolstack to consume

So long as HVMLoader continues to function in that way, it is fine.

What about VGID device in dsdt.asl? Doesn't it want to see the address stored in VGIA, which is acpi_info->vm_gid_addr?

Sorry - that is what I meant by section 2. The physical location has to be stored in a place where AML can read it.

~Andrew

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

#11 lore raw

Re: [PATCH v2 03/23] acpi/hvmloader: Initialize vm_gid data outside ACPI code

In reply to Boris Ostrovsky
Quoted 64 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 17:09, <[email protected]> wrote:
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:50, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich

tools/firmware/hvmloader/acpi/build.c static int construct_secondary_tables(unsigned long

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +0 -0
@@ -462,32 +462,26 @@ static int construct_secondary_tables(unsigned long 

*table_ptrs,

Quoted 54 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 31 lines
tools/firmware/hvmloader/acpi/build.c +9 -15
  *
  * 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,
+                      struct acpi_info *info)
 {
-    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;
+
+    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 = mem_alloc(sizeof(config->vm_gid), 8);

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

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -4
     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);
+    /* set the address into ACPI table and also pass it back to the caller */
+    info->vm_gid_addr = virt_to_phys(buf);

What consumer of this value is left? Can't that field go away now?

Quoted 5 lines
Quoted 3 lines

In acpi_info? TBH, I don't know, I thought this was introduced to deal with something in Windows (commit 978cc62b looks generic but then c5a29a87 is for Windows).

Sure, but the need for the field appears to go away with the introduction of the one in acpi_config.

The way genid needs to work is this:

1) Allocate some memory, reserving it in the e820
2) Represents that physical address in the ACPI tables for the guest to consume
3) Update Xenstore with the physical address, for the toolstack to consume

Quoted 4 lines
Quoted 1 line

So long as HVMLoader continues to function in that way, it is fine.

What about VGID device in dsdt.asl? Doesn't it want to see the address stored in VGIA, which is acpi_info->vm_gid_addr?

Oh, right, of course. So please simply eliminate the duplicate virt_to_phys() invocation, slightly decreasing the size of one of the later patches at once.

Jan

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

#12 lore raw

PATCH v2 4/23 acpi/hvmloader: Decide which SSDTs to install in hvmloader

In reply to Boris Ostrovsky

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

---
 tools/firmware/hvmloader/acpi/build.c   | 15 ++++++---------
 tools/firmware/hvmloader/acpi/libacpi.h |  4 ++++
 tools/firmware/hvmloader/util.c         | 12 ++++++++++++
 3 files changed, 22 insertions(+), 9 deletions(-)
tools/firmware/hvmloader/acpi/build.c +6 -9
index df104a3..a5750eb 100644
@@ -70,11 +70,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;
@@ -336,6 +331,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
 }
 
 static int construct_secondary_tables(unsigned long *table_ptrs,
+                                      struct acpi_config *config,
                                       struct acpi_info *info)
 {
     int nr_tables = 0;
@@ -369,7 +365,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_HAS_SSDT_PM )
     {
         ssdt = mem_alloc(sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
@@ -377,7 +373,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_HAS_SSDT_S3 )
     {
         ssdt = mem_alloc(sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
@@ -387,7 +383,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_HAS_SSDT_S4 )
     {
         ssdt = mem_alloc(sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
@@ -572,7 +568,8 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    nr_secondaries = construct_secondary_tables(secondary_tables, acpi_info);
+    nr_secondaries = construct_secondary_tables(secondary_tables,
+                 config, acpi_info);
     if ( nr_secondaries < 0 )
         goto oom;
 
tools/firmware/hvmloader/acpi/libacpi.h +4 -0
index 4cbd41e..f397a93 100644
@@ -24,6 +24,10 @@
 #define ACPI_HAS_COM2        (1<<1)
 #define ACPI_HAS_LPT1        (1<<2)
 #define ACPI_HAS_HPET        (1<<3)
+#define ACPI_HAS_SSDT_PM     (1<<4)
+#define ACPI_HAS_SSDT_S3     (1<<5)
+#define ACPI_HAS_SSDT_S4     (1<<6)
+
 
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
tools/firmware/hvmloader/util.c +12 -0
index e8ce12b..61fc211 100644
@@ -859,6 +859,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)
 {
@@ -895,6 +900,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_HAS_SSDT_PM;
+    if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1)  )
+        config->table_flags |= ACPI_HAS_SSDT_S3;
+    if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
+        config->table_flags |= ACPI_HAS_SSDT_S4;
+
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
Signature · 7 lines
1.8.3.1


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

PATCH v2 5/23 acpi/hvmloader: Move passthrough initialization from ACPI code

In reply to Boris Ostrovsky

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

---
v2:
* Dropped pt_ prefix
* Slight change in construct_passthrough_tables() code (thus dropped Jan's R-b)

 tools/firmware/hvmloader/acpi/build.c   | 28 +++++++++-------------------
 tools/firmware/hvmloader/acpi/libacpi.h |  5 +++++
 tools/firmware/hvmloader/util.c         | 11 +++++++++++
 3 files changed, 25 insertions(+), 19 deletions(-)
tools/firmware/hvmloader/acpi/build.c +9 -19
index a5750eb..8ca7e69 100644
@@ -285,37 +285,27 @@ 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;
-    uint32_t acpi_pt_length;
+    unsigned long pt_addr;
     struct acpi_header *header;
     int nr_added;
     int nr_max = (ACPI_MAX_SECONDARY_TABLES - nr_tables - 1);
     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.addr == 0 )
         return 0;
 
-    acpi_pt_length = (uint32_t)strtoll(s, NULL, 0);
+    pt_addr = config->pt.addr;
 
     for ( nr_added = 0; nr_added < nr_max; nr_added++ )
     {        
-        if ( (acpi_pt_length - total) < sizeof(struct acpi_header) )
+        if ( (config->pt.length - total) < sizeof(struct acpi_header) )
             break;
 
-        header = (struct acpi_header*)acpi_pt_addr;
+        header = (struct acpi_header*)pt_addr;
 
         buffer = mem_alloc(header->length, 16);
         if ( buffer == NULL )
@@ -324,7 +314,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
 
         table_ptrs[nr_tables++] = (unsigned long)buffer;
         total += header->length;
-        acpi_pt_addr += header->length;
+        pt_addr += header->length;
     }
 
     return nr_added;
@@ -445,7 +435,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/acpi/libacpi.h +5 -0
index f397a93..22fd5f6 100644
@@ -44,6 +44,11 @@ struct acpi_config {
     uint64_t vm_gid[2];
     unsigned long vm_gid_addr; /* OUT parameter */
 
+    struct {
+        uint32_t addr;
+        uint32_t length;
+    } pt;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
tools/firmware/hvmloader/util.c +11 -0
index 61fc211..d61aea6 100644
@@ -27,6 +27,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>
 
 /*
@@ -900,6 +901,16 @@ 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.addr = strtoll(s, NULL, 0);
+
+        s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL);
+        if ( s )
+            config->pt.length = strtoll(s, NULL, 0);
+    }
+
     if ( battery_port_exists() )
         config->table_flags |= ACPI_HAS_SSDT_PM;
     if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1)  )
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 05/23] acpi/hvmloader: Move passthrough initialization from ACPI code

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

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

---
v2:
* Dropped pt_ prefix
* Slight change in construct_passthrough_tables() code (thus dropped Jan's R-b)

Feel free to re-instate.

Jan

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

#15 lore raw

PATCH v2 6/23 acpi/hvmloader: Collect processor and NUMA info in hvmloader

In reply to Boris Ostrovsky

No need for ACPI code to rely on hvm_info variable.

---
v2:
* Note: struct acpi_numa's pointers can't be constified due to their use in later patches

 tools/firmware/hvmloader/acpi/build.c   | 50 +++++++++++++++++----------------
 tools/firmware/hvmloader/acpi/libacpi.h | 13 +++++++++
 tools/firmware/hvmloader/util.c         |  9 ++++++
 3 files changed, 48 insertions(+), 24 deletions(-)
tools/firmware/hvmloader/acpi/build.c +26 -24
index 8ca7e69..075d8d7 100644
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(struct acpi_config *config,
+                                           struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
     struct acpi_20_madt_intsrcovr *intsrcovr;
@@ -81,7 +82,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_info *info)
     sz  = sizeof(struct acpi_20_madt);
     sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
     sz += sizeof(struct acpi_20_madt_ioapic);
-    sz += sizeof(struct acpi_20_madt_lapic) * hvm_info->nr_vcpus;
+    sz += sizeof(struct acpi_20_madt_lapic) * config->hvminfo->nr_vcpus;
 
     madt = mem_alloc(sz, 16);
     if (!madt) return NULL;
@@ -134,9 +135,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_info *info)
     io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
-    info->nr_cpus = hvm_info->nr_vcpus;
+    info->nr_cpus = config-> hvminfo->nr_vcpus;
     info->madt_lapic0_addr = (uint32_t)lapic;
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
@@ -144,7 +145,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_info *info)
         /* Processor ID must match processor-object IDs in the DSDT. */
         lapic->acpi_processor_id = i;
         lapic->apic_id = LAPIC_ID(i);
-        lapic->flags = (test_bit(i, hvm_info->vcpu_online)
+        lapic->flags = (test_bit(i, config->hvminfo->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
         lapic++;
     }
@@ -195,7 +196,7 @@ static struct acpi_20_waet *construct_waet(void)
     return waet;
 }
 
-static struct acpi_20_srat *construct_srat(void)
+static struct acpi_20_srat *construct_srat(struct acpi_config *config)
 {
     struct acpi_20_srat *srat;
     struct acpi_20_srat_processor *processor;
@@ -204,8 +205,8 @@ static struct acpi_20_srat *construct_srat(void)
     void *p;
     unsigned int i;
 
-    size = sizeof(*srat) + sizeof(*processor) * hvm_info->nr_vcpus +
-           sizeof(*memory) * nr_vmemranges;
+    size = sizeof(*srat) + sizeof(*processor) * config->hvminfo->nr_vcpus +
+           sizeof(*memory) * config->numa.nr_vmemranges;
 
     p = mem_alloc(size, 16);
     if ( !p )
@@ -222,25 +223,26 @@ static struct acpi_20_srat *construct_srat(void)
     srat->table_revision      = ACPI_SRAT_TABLE_REVISION;
 
     processor = (struct acpi_20_srat_processor *)(srat + 1);
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
     {
         processor->type     = ACPI_PROCESSOR_AFFINITY;
         processor->length   = sizeof(*processor);
-        processor->domain   = vcpu_to_vnode[i];
+        processor->domain   = config->numa.vcpu_to_vnode[i];
         processor->apic_id  = LAPIC_ID(i);
         processor->flags    = ACPI_LOCAL_APIC_AFFIN_ENABLED;
         processor++;
     }
 
     memory = (struct acpi_20_srat_memory *)processor;
-    for ( i = 0; i < nr_vmemranges; i++ )
+    for ( i = 0; i < config->numa.nr_vmemranges; i++ )
     {
         memory->type          = ACPI_MEMORY_AFFINITY;
         memory->length        = sizeof(*memory);
-        memory->domain        = vmemrange[i].nid;
+        memory->domain        = config->numa.vmemrange[i].nid;
         memory->flags         = ACPI_MEM_AFFIN_ENABLED;
-        memory->base_address  = vmemrange[i].start;
-        memory->mem_length    = vmemrange[i].end - vmemrange[i].start;
+        memory->base_address  = config->numa.vmemrange[i].start;
+        memory->mem_length    = config->numa.vmemrange[i].end -
+                                config->numa.vmemrange[i].start;
         memory++;
     }
 
@@ -252,12 +254,12 @@ static struct acpi_20_srat *construct_srat(void)
     return srat;
 }
 
-static struct acpi_20_slit *construct_slit(void)
+static struct acpi_20_slit *construct_slit(struct acpi_config *config)
 {
     struct acpi_20_slit *slit;
     unsigned int i, num, size;
 
-    num = nr_vnodes * nr_vnodes;
+    num = config->numa.nr_vnodes * config->numa.nr_vnodes;
     size = sizeof(*slit) + num * sizeof(uint8_t);
 
     slit = mem_alloc(size, 16);
@@ -274,9 +276,9 @@ static struct acpi_20_slit *construct_slit(void)
     slit->header.creator_revision = ACPI_CREATOR_REVISION;
 
     for ( i = 0; i < num; i++ )
-        slit->entry[i] = vdistance[i];
+        slit->entry[i] = config->numa.vdistance[i];
 
-    slit->localities = nr_vnodes;
+    slit->localities = config->numa.nr_vnodes;
 
     slit->header.length = size;
     set_checksum(slit, offsetof(struct acpi_header, checksum), size);
@@ -335,9 +337,9 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     void *lasa;
 
     /* MADT. */
-    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
+    if ( (config->hvminfo->nr_vcpus > 1) || config->hvminfo->apic_mode )
     {
-        madt = construct_madt(info);
+        madt = construct_madt(config, info);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
@@ -419,10 +421,10 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* SRAT and SLIT */
-    if ( nr_vnodes > 0 )
+    if ( config->numa.nr_vnodes > 0 )
     {
-        struct acpi_20_srat *srat = construct_srat();
-        struct acpi_20_slit *slit = construct_slit();
+        struct acpi_20_srat *srat = construct_srat(config);
+        struct acpi_20_slit *slit = construct_slit(config);
 
         if ( srat )
             table_ptrs[nr_tables++] = (unsigned long)srat;
@@ -515,7 +517,7 @@ void acpi_build_tables(struct acpi_config *config)
      * The latter is required for Windows 2000, which experiences a BSOD of
      * KMODE_EXCEPTION_NOT_HANDLED if it sees more than 15 processor objects.
      */
-    if ( hvm_info->nr_vcpus <= 15 && config->dsdt_15cpu)
+    if ( config->hvminfo->nr_vcpus <= 15 && config->dsdt_15cpu)
     {
         dsdt = mem_alloc(config->dsdt_15cpu_len, 16);
         if (!dsdt) goto oom;
tools/firmware/hvmloader/acpi/libacpi.h +13 -0
index 22fd5f6..3712c42 100644
@@ -20,6 +20,8 @@
 #ifndef __LIBACPI_H__
 #define __LIBACPI_H__
 
+#include <xen/memory.h>
+
 #define ACPI_HAS_COM1        (1<<0)
 #define ACPI_HAS_COM2        (1<<1)
 #define ACPI_HAS_LPT1        (1<<2)
@@ -29,6 +31,14 @@
 #define ACPI_HAS_SSDT_S4     (1<<6)
 
 
+struct acpi_numa {
+    uint32_t nr_vmemranges;
+    uint32_t nr_vnodes;
+    unsigned int *vcpu_to_vnode;
+    unsigned int *vdistance;
+    struct xen_vmemrange *vmemrange;
+};
+
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
     unsigned int dsdt_anycpu_len;
@@ -49,6 +59,9 @@ struct acpi_config {
         uint32_t length;
     } pt;
 
+    struct acpi_numa numa;
+    struct hvm_info_table *hvminfo;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
tools/firmware/hvmloader/util.c +9 -0
index d61aea6..1f8d539 100644
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "hypercall.h"
 #include "ctype.h"
+#include "vnuma.h"
 #include "acpi/acpi2_0.h"
 #include "acpi/libacpi.h"
 #include <stdint.h>
@@ -918,6 +919,14 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
+    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;
+
+    config->hvminfo = hvm_info;
+
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 06/23] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: struct acpi_numa's pointers can't be constified due to their use in later patches

Well, I hope I'll remember once I get there.

tools/firmware/hvmloader/acpi/build.c static void set_checksum( · line 73

Quoted 8 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(struct acpi_config *config,

const? (I'm btw going to take the liberty to fix up patch 2 in this regard when committing it later today, and patch 4 would need this too then for construct_secondary_tables().)

tools/firmware/hvmloader/acpi/build.c static struct acpi_20_madt *construct_madt(struct acpi_info *info) · line 138

Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -134,9 +135,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_info *info)
     io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
-    info->nr_cpus = hvm_info->nr_vcpus;
+    info->nr_cpus = config-> hvminfo->nr_vcpus;

Stray blank. This wouldn't have happened had you introduced a local variable hvm_info.

tools/firmware/hvmloader/acpi/build.c static struct acpi_20_waet *construct_waet(void) · line 199

Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -195,7 +196,7 @@ static struct acpi_20_waet *construct_waet(void)
     return waet;
 }
 
-static struct acpi_20_srat *construct_srat(void)
+static struct acpi_20_srat *construct_srat(struct acpi_config *config)

const again?

tools/firmware/hvmloader/acpi/build.c static struct acpi_20_srat *construct_srat(void) · line 257

Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -252,12 +254,12 @@ static struct acpi_20_srat *construct_srat(void)
     return srat;
 }
 
-static struct acpi_20_slit *construct_slit(void)
+static struct acpi_20_slit *construct_slit(struct acpi_config *config)

And again.

Jan

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

#17 lore raw

Re: [PATCH v2 06/23] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: struct acpi_numa's pointers can't be constified due to their use in later patches

Well, I hope I'll remember once I get there.

Patch 22, init_acpi_config() routine.

Quoted 11 lines

tools/firmware/hvmloader/acpi/build.c static void set_checksum( · line 73

Quoted 9 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(struct acpi_config *config,

const? (I'm btw going to take the liberty to fix up patch 2 in this regard when committing it later today,

Keep in mind that this series is blocked by re-licensing not yet having been acked by all parties. This affects the series starting with a later patch (the one that moves files to tools/, patch 14) but I am not sure it's worth committing early patches only. Patch 15 is the only exception.

-boris

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

#18 lore raw

Re: [PATCH v2 06/23] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 15 lines · Boris Ostrovsky
Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: struct acpi_numa's pointers can't be constified due to their use in later patches

Well, I hope I'll remember once I get there.

Patch 22, init_acpi_config() routine.

Quoted 6 lines
Quoted 6 lines
tools/firmware/hvmloader/acpi/build.c +0 -0
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
Quoted 8 lines
Quoted 4 lines

tools/firmware/hvmloader/acpi/build.c static void set_checksum( · line 73

Quoted 2 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(struct acpi_config *config,

const? (I'm btw going to take the liberty to fix up patch 2 in this regard when committing it later today,

Keep in mind that this series is blocked by re-licensing not yet having been acked by all parties. This affects the series starting with a later patch (the one that moves files to tools/, patch 14) but I am not sure it's worth committing early patches only. Patch 15 is the only exception.

Oh, and it is also built on top of Anthony's BIOS series.

-boris

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

#19 lore raw

Re: [PATCH v2 06/23] acpi/hvmloader: Collect processor and NUMA info in hvmloader

In reply to Boris Ostrovsky
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:43, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: struct acpi_numa's pointers can't be constified due to their use in later patches

Well, I hope I'll remember once I get there.

Patch 22, init_acpi_config() routine.

Thanks.

Quoted 11 lines
Quoted 10 lines

tools/firmware/hvmloader/acpi/build.c static void set_checksum( · line 73

Quoted 8 lines
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(struct acpi_config *config,

const? (I'm btw going to take the liberty to fix up patch 2 in this regard when committing it later today,

Quoted 4 lines

Keep in mind that this series is blocked by re-licensing not yet having been acked by all parties. This affects the series starting with a later patch (the one that moves files to tools/, patch 14) but I am not sure it's worth committing early patches only. Patch 15 is the only exception.

Well, primarily I wanted to reduce the amount of necessary resends. Since the initial patches shouldn't break anything, I think committing them should be fine. Unless you tell me not to, of course.

Jan

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

#20 lore raw

PATCH v2 7/23 acpi/hvmloader: Set TIS header address in hvmloader

In reply to Boris Ostrovsky

Users other than hvmloader may provide TIS address as virtual.

---
v2:
* constified tis_hdr.

 tools/firmware/hvmloader/acpi/build.c   | 9 ++++-----
 tools/firmware/hvmloader/acpi/libacpi.h | 3 +++
 tools/firmware/hvmloader/config.h       | 2 ++
 tools/firmware/hvmloader/util.c         | 4 ++++
 4 files changed, 13 insertions(+), 5 deletions(-)
tools/firmware/hvmloader/acpi/build.c +4 -5
index 075d8d7..e99b90a 100644
@@ -333,7 +333,6 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     struct acpi_20_tcpa *tcpa;
     unsigned char *ssdt;
     static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
-    uint16_t *tis_hdr;
     void *lasa;
 
     /* MADT. */
@@ -386,10 +385,10 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* 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_HAS_TCPA) &&
+         (config->tis_hdr[0] == tis_signature[0]) &&
+         (config->tis_hdr[1] == tis_signature[1]) &&
+         (config->tis_hdr[2] == tis_signature[2]) )
     {
         ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
         if (!ssdt) return -1;
tools/firmware/hvmloader/acpi/libacpi.h +3 -0
index 3712c42..2160074 100644
@@ -29,6 +29,7 @@
 #define ACPI_HAS_SSDT_PM     (1<<4)
 #define ACPI_HAS_SSDT_S3     (1<<5)
 #define ACPI_HAS_SSDT_S4     (1<<6)
+#define ACPI_HAS_TCPA        (1<<7)
 
 
 struct acpi_numa {
@@ -62,6 +63,8 @@ struct acpi_config {
     struct acpi_numa numa;
     struct hvm_info_table *hvminfo;
 
+    const uint16_t *tis_hdr;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
tools/firmware/hvmloader/config.h +2 -0
index 4c6d8ad..c9526e3 100644
@@ -55,6 +55,8 @@ extern struct bios_config ovmf_config;
 /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
 #define PCI_MEM_END         0xfc000000
 
+#define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
+
 extern unsigned long pci_mem_start, pci_mem_end;
 extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
 
tools/firmware/hvmloader/util.c +4 -0
index 1f8d539..c5ae526 100644
@@ -919,6 +919,10 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
+    config->table_flags |= ACPI_HAS_TCPA;
+
+    config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
+
     config->numa.nr_vmemranges = nr_vmemranges;
     config->numa.nr_vnodes = nr_vnodes;
     config->numa.vcpu_to_vnode = vcpu_to_vnode;
Signature · 7 lines
1.8.3.1


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

PATCH v2 8/23 acpi/hvmloader: Make providing IOAPIC in MADT optional

In reply to Boris Ostrovsky
---
 tools/firmware/hvmloader/acpi/build.c   | 70 ++++++++++++++++++---------------
 tools/firmware/hvmloader/acpi/libacpi.h |  1 +
 tools/firmware/hvmloader/util.c         |  2 +-
 3 files changed, 40 insertions(+), 33 deletions(-)
tools/firmware/hvmloader/acpi/build.c +38 -32
index e99b90a..6ec8739 100644
@@ -98,43 +98,49 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config,
     madt->lapic_addr = LAPIC_BASE_ADDRESS;
     madt->flags      = ACPI_PCAT_COMPAT;
 
-    intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
-    for ( i = 0; i < 16; i++ )
-    {
-        memset(intsrcovr, 0, sizeof(*intsrcovr));
-        intsrcovr->type   = ACPI_INTERRUPT_SOURCE_OVERRIDE;
-        intsrcovr->length = sizeof(*intsrcovr);
-        intsrcovr->source = i;
-
-        if ( i == 0 )
-        {
-            /* ISA IRQ0 routed to IOAPIC GSI 2. */
-            intsrcovr->gsi    = 2;
-            intsrcovr->flags  = 0x0;
-        }
-        else if ( PCI_ISA_IRQ_MASK & (1U << i) )
-        {
-            /* PCI: active-low level-triggered. */
-            intsrcovr->gsi    = i;
-            intsrcovr->flags  = 0xf;
-        }
-        else
+    if ( config->table_flags & ACPI_HAS_IOAPIC )
+    {     
+        intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
+        for ( i = 0; i < 16; i++ )
         {
-            /* No need for a INT source override structure. */
-            continue;
+            memset(intsrcovr, 0, sizeof(*intsrcovr));
+            intsrcovr->type   = ACPI_INTERRUPT_SOURCE_OVERRIDE;
+            intsrcovr->length = sizeof(*intsrcovr);
+            intsrcovr->source = i;
+
+            if ( i == 0 )
+            {
+                /* ISA IRQ0 routed to IOAPIC GSI 2. */
+                intsrcovr->gsi    = 2;
+                intsrcovr->flags  = 0x0;
+            }
+            else if ( PCI_ISA_IRQ_MASK & (1U << i) )
+            {
+                /* PCI: active-low level-triggered. */
+                intsrcovr->gsi    = i;
+                intsrcovr->flags  = 0xf;
+            }
+            else
+            {
+                /* No need for a INT source override structure. */
+                continue;
+            }
+
+            intsrcovr++;
         }
 
-        intsrcovr++;
-    }
+        io_apic = (struct acpi_20_madt_ioapic *)intsrcovr;
+        memset(io_apic, 0, sizeof(*io_apic));
+        io_apic->type        = ACPI_IO_APIC;
+        io_apic->length      = sizeof(*io_apic);
+        io_apic->ioapic_id   = IOAPIC_ID;
+        io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
 
-    io_apic = (struct acpi_20_madt_ioapic *)intsrcovr;
-    memset(io_apic, 0, sizeof(*io_apic));
-    io_apic->type        = ACPI_IO_APIC;
-    io_apic->length      = sizeof(*io_apic);
-    io_apic->ioapic_id   = IOAPIC_ID;
-    io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
+        lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
+    }
+    else
+        lapic = (struct acpi_20_madt_lapic *)(madt + 1);
 
-    lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     info->nr_cpus = config-> hvminfo->nr_vcpus;
     info->madt_lapic0_addr = (uint32_t)lapic;
     for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
index 2160074..e15abf7 100644
@@ -30,6 +30,7 @@
 #define ACPI_HAS_SSDT_S3     (1<<5)
 #define ACPI_HAS_SSDT_S4     (1<<6)
 #define ACPI_HAS_TCPA        (1<<7)
+#define ACPI_HAS_IOAPIC      (1<<8)
 
 
 struct acpi_numa {
tools/firmware/hvmloader/util.c +1 -1
index c5ae526..325c0a2 100644
@@ -919,7 +919,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
-    config->table_flags |= ACPI_HAS_TCPA;
+    config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC);
 
     config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
 
Signature · 7 lines
1.8.3.1


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

PATCH v2 9/23 acpi/hvmloader: Build WAET optionally

In reply to Boris Ostrovsky

---
v2:
* Note: didn't break "if ( !waet ) return -1" line since that's the style of the file.

 tools/firmware/hvmloader/acpi/build.c   | 9 ++++++---
 tools/firmware/hvmloader/acpi/libacpi.h | 1 +
 tools/firmware/hvmloader/util.c         | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)
tools/firmware/hvmloader/acpi/build.c +6 -3
index 6ec8739..e362ccd 100644
@@ -358,9 +358,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_HAS_WAET )
+    {
+        waet = construct_waet();
+        if ( !waet ) return -1;
+        table_ptrs[nr_tables++] = (unsigned long)waet;
+    }
 
     if ( config->table_flags & ACPI_HAS_SSDT_PM )
     {
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
index e15abf7..a251d7c 100644
@@ -31,6 +31,7 @@
 #define ACPI_HAS_SSDT_S4     (1<<6)
 #define ACPI_HAS_TCPA        (1<<7)
 #define ACPI_HAS_IOAPIC      (1<<8)
+#define ACPI_HAS_WAET        (1<<9)
 
 
 struct acpi_numa {
tools/firmware/hvmloader/util.c +1 -1
index 325c0a2..61018ea 100644
@@ -919,7 +919,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
-    config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC);
+    config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC | ACPI_HAS_WAET);
 
     config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
 
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 09/23] acpi/hvmloader: Build WAET optionally

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: didn't break "if ( !waet ) return -1" line since that's the style of the file.

Style of the file? At best there's a mix in the file, and hence correcting it here is rather desirable.

Jan

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

#24 lore raw

Re: [PATCH v2 09/23] acpi/hvmloader: Build WAET optionally

Quoted 9 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: didn't break "if ( !waet ) return -1" line since that's the style of the file.

Style of the file? At best there's a mix in the file, and hence correcting it here is rather desirable.

Style of construct_secondary_tables(), not the whole file, sorry.

-boris

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

#25 lore raw

Re: [PATCH v2 09/23] acpi/hvmloader: Build WAET optionally

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:51, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: didn't break "if ( !waet ) return -1" line since that's the style of the file.

Quoted 4 lines
Quoted 2 lines

Style of the file? At best there's a mix in the file, and hence correcting it here is rather desirable.

Style of construct_secondary_tables(), not the whole file, sorry.

Anyway, if you're not going to make the adjustment, and if I end up committing the patches (and remember at that time), I will make it nevertheless.

Jan

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

#26 lore raw

Re: [PATCH v2 09/23] acpi/hvmloader: Build WAET optionally

Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:51, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: didn't break "if ( !waet ) return -1" line since that's the style of the file.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

Style of the file? At best there's a mix in the file, and hence correcting it here is rather desirable.

Style of construct_secondary_tables(), not the whole file, sorry.

Anyway, if you're not going to make the adjustment, and if I end up committing the patches (and remember at that time), I will make it nevertheless.

If you decide to go ahead with committing --- sure. Otherwise I can do this in the next submission.

(I actually backed out this change at the last moment before sending the series when I noticed routine style)

-boris

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

#27 lore raw

Re: [PATCH v2 09/23] acpi/hvmloader: Build WAET optionally

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 17:13, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 15:51, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

---
v2:
* Note: didn't break "if ( !waet ) return -1" line since that's the style of the file.

Style of the file? At best there's a mix in the file, and hence correcting it here is rather desirable.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Style of construct_secondary_tables(), not the whole file, sorry.

Anyway, if you're not going to make the adjustment, and if I end up committing the patches (and remember at that time), I will make it nevertheless.

If you decide to go ahead with committing --- sure. Otherwise I can do this in the next submission.

Well, it's only going to be the first 2 or 3 patches that I can commit, as subsequent ones have pending adjustment requests.

Jan

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

#28 lore raw

PATCH v2 10/23 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.

---
v2:
* Added acpi_ctxt.free() op

 tools/firmware/hvmloader/acpi/build.c   | 91 ++++++++++++++++++---------------
 tools/firmware/hvmloader/acpi/libacpi.h | 10 +++-
 tools/firmware/hvmloader/util.c         | 16 +++++-
 3 files changed, 74 insertions(+), 43 deletions(-)
tools/firmware/hvmloader/acpi/build.c +50 -41
index e362ccd..7302c35 100644
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_config *config,
+static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
+                                           struct acpi_config *config,
                                            struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
@@ -84,7 +85,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config,
     sz += sizeof(struct acpi_20_madt_ioapic);
     sz += sizeof(struct acpi_20_madt_lapic) * config->hvminfo->nr_vcpus;
 
-    madt = mem_alloc(sz, 16);
+    madt = ctxt->mem_ops.alloc(ctxt, sz, 16);
     if (!madt) return NULL;
 
     memset(madt, 0, sizeof(*madt));
@@ -164,11 +165,12 @@ static struct acpi_20_madt *construct_madt(struct acpi_config *config,
     return madt;
 }
 
-static struct acpi_20_hpet *construct_hpet(void)
+static struct acpi_20_hpet *construct_hpet(struct acpi_ctxt *ctxt,
+                                           struct acpi_config *config)
 {
     struct acpi_20_hpet *hpet;
 
-    hpet = mem_alloc(sizeof(*hpet), 16);
+    hpet = ctxt->mem_ops.alloc(ctxt, sizeof(*hpet), 16);
     if (!hpet) return NULL;
 
     memset(hpet, 0, sizeof(*hpet));
@@ -187,11 +189,12 @@ static struct acpi_20_hpet *construct_hpet(void)
     return hpet;
 }
 
-static struct acpi_20_waet *construct_waet(void)
+static struct acpi_20_waet *construct_waet(struct acpi_ctxt *ctxt,
+                                           struct acpi_config *config)
 {
     struct acpi_20_waet *waet;
 
-    waet = mem_alloc(sizeof(*waet), 16);
+    waet = ctxt->mem_ops.alloc(ctxt, sizeof(*waet), 16);
     if (!waet) return NULL;
 
     memcpy(waet, &Waet, sizeof(*waet));
@@ -202,7 +205,8 @@ static struct acpi_20_waet *construct_waet(void)
     return waet;
 }
 
-static struct acpi_20_srat *construct_srat(struct acpi_config *config)
+static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt,
+                                           struct acpi_config *config)
 {
     struct acpi_20_srat *srat;
     struct acpi_20_srat_processor *processor;
@@ -214,7 +218,7 @@ static struct acpi_20_srat *construct_srat(struct acpi_config *config)
     size = sizeof(*srat) + sizeof(*processor) * config->hvminfo->nr_vcpus +
            sizeof(*memory) * config->numa.nr_vmemranges;
 
-    p = mem_alloc(size, 16);
+    p = ctxt->mem_ops.alloc(ctxt, size, 16);
     if ( !p )
         return NULL;
 
@@ -260,7 +264,8 @@ static struct acpi_20_srat *construct_srat(struct acpi_config *config)
     return srat;
 }
 
-static struct acpi_20_slit *construct_slit(struct acpi_config *config)
+static struct acpi_20_slit *construct_slit(struct acpi_ctxt *ctxt,
+                                           struct acpi_config *config)
 {
     struct acpi_20_slit *slit;
     unsigned int i, num, size;
@@ -268,7 +273,7 @@ static struct acpi_20_slit *construct_slit(struct acpi_config *config)
     num = config->numa.nr_vnodes * config->numa.nr_vnodes;
     size = sizeof(*slit) + num * sizeof(uint8_t);
 
-    slit = mem_alloc(size, 16);
+    slit = ctxt->mem_ops.alloc(ctxt, size, 16);
     if ( !slit )
         return NULL;
 
@@ -292,7 +297,8 @@ static struct acpi_20_slit *construct_slit(struct acpi_config *config)
     return slit;
 }
 
-static int construct_passthrough_tables(unsigned long *table_ptrs,
+static int construct_passthrough_tables(struct acpi_ctxt *ctxt,
+                                        unsigned long *table_ptrs,
                                         int nr_tables,
                                         struct acpi_config *config)
 {
@@ -315,7 +321,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
 
         header = (struct acpi_header*)pt_addr;
 
-        buffer = mem_alloc(header->length, 16);
+        buffer = ctxt->mem_ops.alloc(ctxt, header->length, 16);
         if ( buffer == NULL )
             break;
         memcpy(buffer, header, header->length);
@@ -328,7 +334,8 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
     return nr_added;
 }
 
-static int construct_secondary_tables(unsigned long *table_ptrs,
+static int construct_secondary_tables(struct acpi_ctxt *ctxt,
+                                      unsigned long *table_ptrs,
                                       struct acpi_config *config,
                                       struct acpi_info *info)
 {
@@ -344,7 +351,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* MADT. */
     if ( (config->hvminfo->nr_vcpus > 1) || config->hvminfo->apic_mode )
     {
-        madt = construct_madt(config, info);
+        madt = construct_madt(ctxt, config, info);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
@@ -352,7 +359,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* HPET. */
     if ( info->hpet_present )
     {
-        hpet = construct_hpet();
+        hpet = construct_hpet(ctxt, config);
         if (!hpet) return -1;
         table_ptrs[nr_tables++] = (unsigned long)hpet;
     }
@@ -360,14 +367,14 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* WAET. */
     if ( config->table_flags & ACPI_HAS_WAET )
     {
-        waet = construct_waet();
+        waet = construct_waet(ctxt, config);
         if ( !waet ) return -1;
         table_ptrs[nr_tables++] = (unsigned long)waet;
     }
 
     if ( config->table_flags & ACPI_HAS_SSDT_PM )
     {
-        ssdt = mem_alloc(sizeof(ssdt_pm), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_pm, sizeof(ssdt_pm));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
@@ -375,7 +382,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
 
     if ( config->table_flags & ACPI_HAS_SSDT_S3 )
     {
-        ssdt = mem_alloc(sizeof(ssdt_s3), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s3, sizeof(ssdt_s3));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
@@ -385,7 +392,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
 
     if ( config->table_flags & ACPI_HAS_SSDT_S4 )
     {
-        ssdt = mem_alloc(sizeof(ssdt_s4), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s4, sizeof(ssdt_s4));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
@@ -399,12 +406,12 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
          (config->tis_hdr[1] == tis_signature[1]) &&
          (config->tis_hdr[2] == tis_signature[2]) )
     {
-        ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, 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);
+        tcpa = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_tcpa), 16);
         if (!tcpa) return -1;
         memset(tcpa, 0, sizeof(*tcpa));
         table_ptrs[nr_tables++] = (unsigned long)tcpa;
@@ -417,9 +424,9 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         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 )
+        if ( (lasa = ctxt->mem_ops.alloc(ctxt, ACPI_2_0_TCPA_LAML_SIZE, 16)) != NULL )
         {
-            tcpa->lasa = virt_to_phys(lasa);
+            tcpa->lasa = ctxt->mem_ops.v2p(ctxt, lasa);
             tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
             memset(lasa, 0, tcpa->laml);
             set_checksum(tcpa,
@@ -431,8 +438,8 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* SRAT and SLIT */
     if ( config->numa.nr_vnodes > 0 )
     {
-        struct acpi_20_srat *srat = construct_srat(config);
-        struct acpi_20_slit *slit = construct_slit(config);
+        struct acpi_20_srat *srat = construct_srat(ctxt, config);
+        struct acpi_20_slit *slit = construct_slit(ctxt, config);
 
         if ( srat )
             table_ptrs[nr_tables++] = (unsigned long)srat;
@@ -445,7 +452,8 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* Load any additional tables passed through. */
-    nr_tables += construct_passthrough_tables(table_ptrs, nr_tables, config);
+    nr_tables += construct_passthrough_tables(ctxt, table_ptrs,
+                                              nr_tables, config);
 
     table_ptrs[nr_tables] = 0;
     return nr_tables;
@@ -458,7 +466,8 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
  *
  * Return 0 if memory failure, != 0 if success
  */
-static int new_vm_gid(struct acpi_config *config,
+static int new_vm_gid(struct acpi_ctxt *ctxt,
+                      struct acpi_config *config,
                       struct acpi_info *info)
 {
     uint64_t *buf;
@@ -470,19 +479,19 @@ static int new_vm_gid(struct acpi_config *config,
         return 1;
 
     /* copy to allocate BIOS memory */
-    buf = mem_alloc(sizeof(config->vm_gid), 8);
+    buf = ctxt->mem_ops.alloc(ctxt, sizeof(config->vm_gid), 8);
     if ( !buf )
         return 0;
     memcpy(buf, config->vm_gid, sizeof(config->vm_gid));
 
     /* set the address into ACPI table and also pass it back to the caller */
-    info->vm_gid_addr = virt_to_phys(buf);
-    config->vm_gid_addr = virt_to_phys(buf);
+    info->vm_gid_addr = ctxt->mem_ops.v2p(ctxt, buf);
+    config->vm_gid_addr = info->vm_gid_addr;
 
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config)
+void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -513,7 +522,7 @@ void acpi_build_tables(struct acpi_config *config)
      * Fill in high-memory data structures, starting at @buf.
      */
 
-    facs = mem_alloc(sizeof(struct acpi_20_facs), 16);
+    facs = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_facs), 16);
     if (!facs) goto oom;
     memcpy(facs, &Facs, sizeof(struct acpi_20_facs));
 
@@ -527,13 +536,13 @@ void acpi_build_tables(struct acpi_config *config)
      */
     if ( config->hvminfo->nr_vcpus <= 15 && config->dsdt_15cpu)
     {
-        dsdt = mem_alloc(config->dsdt_15cpu_len, 16);
+        dsdt = ctxt->mem_ops.alloc(ctxt, config->dsdt_15cpu_len, 16);
         if (!dsdt) goto oom;
         memcpy(dsdt, config->dsdt_15cpu, config->dsdt_15cpu_len);
     }
     else
     {
-        dsdt = mem_alloc(config->dsdt_anycpu_len, 16);
+        dsdt = ctxt->mem_ops.alloc(ctxt, config->dsdt_anycpu_len, 16);
         if (!dsdt) goto oom;
         memcpy(dsdt, config->dsdt_anycpu, config->dsdt_anycpu_len);
     }
@@ -546,7 +555,7 @@ void acpi_build_tables(struct acpi_config *config)
      * compatible revision 1 FADT that is linked with the RSDT. Refer to:
      *     http://www.acpi.info/presentations/S01USMOBS169_OS%20new.ppt
      */
-    fadt_10 = mem_alloc(sizeof(struct acpi_10_fadt), 16);
+    fadt_10 = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_10_fadt), 16);
     if (!fadt_10) goto oom;
     memcpy(fadt_10, &Fadt, sizeof(struct acpi_10_fadt));
     fadt_10->header.length = sizeof(struct acpi_10_fadt);
@@ -557,7 +566,7 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_10_fadt));
 
-    fadt = mem_alloc(sizeof(struct acpi_20_fadt), 16);
+    fadt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_fadt), 16);
     if (!fadt) goto oom;
     memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
     fadt->dsdt   = (unsigned long)dsdt;
@@ -568,13 +577,13 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    nr_secondaries = construct_secondary_tables(secondary_tables,
+    nr_secondaries = construct_secondary_tables(ctxt, secondary_tables,
                  config, acpi_info);
     if ( nr_secondaries < 0 )
         goto oom;
 
-    xsdt = mem_alloc(sizeof(struct acpi_20_xsdt)+
-                     sizeof(uint64_t)*nr_secondaries,
+    xsdt = ctxt->mem_ops.alloc(ctxt, (sizeof(struct acpi_20_xsdt) +
+                     sizeof(uint64_t)*nr_secondaries),
                      16);
     if (!xsdt) goto oom;
     memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
@@ -586,7 +595,7 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  xsdt->header.length);
 
-    rsdt = mem_alloc(sizeof(struct acpi_20_rsdt)+
+    rsdt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_rsdt) +
                      sizeof(uint32_t)*nr_secondaries,
                      16);
     if (!rsdt) goto oom;
@@ -614,7 +623,7 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    if ( !new_vm_gid(config, acpi_info) )
+    if ( !new_vm_gid(ctxt, config, acpi_info) )
         goto oom;
 
     return;
tools/firmware/hvmloader/acpi/libacpi.h +9 -1
index a251d7c..ce2d50b 100644
@@ -42,6 +42,14 @@ struct acpi_numa {
     struct xen_vmemrange *vmemrange;
 };
 
+struct acpi_ctxt {
+    struct acpi_mem_ops {
+        void *(*alloc)(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align);
+        void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
+        unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
+    } mem_ops;
+};
+
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
     unsigned int dsdt_anycpu_len;
@@ -78,7 +86,7 @@ struct acpi_config {
     unsigned int rsdp;
 };
 
-void acpi_build_tables(struct acpi_config *config);
+void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
 
 #endif /* __LIBACPI_H__ */
 
tools/firmware/hvmloader/util.c +15 -1
index 61018ea..c9d2c0a 100644
@@ -866,10 +866,21 @@ static uint8_t battery_port_exists(void)
     return (inb(0x88) == 0x1F);
 }
 
+static unsigned long acpi_v2p(struct acpi_ctxt *ctxt, void *v)
+{
+    return virt_to_phys(v);
+}
+
+static void *acpi_mem_alloc(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align)
+{
+    return mem_alloc(size, align);
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
     const char *s;
+    struct acpi_ctxt ctxt;
 
     /* Allocate and initialise the acpi info area. */
     mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
@@ -934,7 +945,10 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-    acpi_build_tables(config);
+    ctxt.mem_ops.alloc = acpi_mem_alloc;
+    ctxt.mem_ops.v2p = acpi_v2p;
+
+    acpi_build_tables(&ctxt, config);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->vm_gid_addr);
 }
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 10/23] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/build.c +0 -0
@@ -568,13 +577,13 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 

tools/firmware/hvmloader/acpi/build.c void acpi_build_tables(struct acpi_config *config) · line 586

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -3
-    nr_secondaries = construct_secondary_tables(secondary_tables,
+    nr_secondaries = construct_secondary_tables(ctxt, secondary_tables,
                  config, acpi_info);
     if ( nr_secondaries < 0 )
         goto oom;
 
-    xsdt = mem_alloc(sizeof(struct acpi_20_xsdt)+
-                     sizeof(uint64_t)*nr_secondaries,
+    xsdt = ctxt->mem_ops.alloc(ctxt, (sizeof(struct acpi_20_xsdt) +
+                     sizeof(uint64_t)*nr_secondaries),

Please take the opportunity and add the missing blanks in expressions like this (more elsewhere).

Quoted 25 lines
tools/firmware/hvmloader/util.c +11 -0
@@ -866,10 +866,21 @@ static uint8_t battery_port_exists(void)
     return (inb(0x88) == 0x1F);
 }
 
+static unsigned long acpi_v2p(struct acpi_ctxt *ctxt, void *v)
+{
+    return virt_to_phys(v);
+}
+
+static void *acpi_mem_alloc(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align)
+{
+    return mem_alloc(size, align);
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
     const char *s;
+    struct acpi_ctxt ctxt;
 
     /* Allocate and initialise the acpi info area. */
     mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);

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

Quoted 6 lines
tools/firmware/hvmloader/util.c +2 -1
@@ -934,7 +945,10 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-    acpi_build_tables(config);
+    ctxt.mem_ops.alloc = acpi_mem_alloc;
+    ctxt.mem_ops.v2p = acpi_v2p;

So you did add a free() hook, but now you don't set it to some dummy (e.g. invoking BUG())?

Jan

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

#30 lore raw

PATCH v2 11/23 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 7302c35..c0e0915 100644
@@ -143,7 +143,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
         lapic = (struct acpi_20_madt_lapic *)(madt + 1);
 
     info->nr_cpus = config-> hvminfo->nr_vcpus;
-    info->madt_lapic0_addr = (uint32_t)lapic;
+    info->madt_lapic0_addr = ctxt->mem_ops.v2p(ctxt, lapic);;
     for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
@@ -160,7 +160,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
     madt->header.length = (unsigned char *)lapic - (unsigned char *)madt;
     set_checksum(madt, offsetof(struct acpi_header, checksum),
                  madt->header.length);
-    info->madt_csum_addr = (uint32_t)&madt->header.checksum;
+    info->madt_csum_addr =
+        ctxt->mem_ops.v2p(ctxt, &madt->header.checksum);
 
     return madt;
 }
@@ -326,7 +327,7 @@ static int construct_passthrough_tables(struct acpi_ctxt *ctxt,
             break;
         memcpy(buffer, header, header->length);
 
-        table_ptrs[nr_tables++] = (unsigned long)buffer;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, buffer);
         total += header->length;
         pt_addr += header->length;
     }
@@ -353,7 +354,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
     {
         madt = construct_madt(ctxt, config, info);
         if (!madt) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)madt;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, madt);
     }
 
     /* HPET. */
@@ -361,7 +362,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
     {
         hpet = construct_hpet(ctxt, config);
         if (!hpet) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)hpet;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, hpet);
     }
 
     /* WAET. */
@@ -369,7 +370,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
     {
         waet = construct_waet(ctxt, config);
         if ( !waet ) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)waet;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, waet);
     }
 
     if ( config->table_flags & ACPI_HAS_SSDT_PM )
@@ -377,7 +378,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, 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++] = ctxt->mem_ops.v2p(ctxt, ssdt);
     }
 
     if ( config->table_flags & ACPI_HAS_SSDT_S3 )
@@ -385,7 +386,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, 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++] = ctxt->mem_ops.v2p(ctxt, ssdt);
     } else {
         printf("S3 disabled\n");
     }
@@ -395,7 +396,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, 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++] = ctxt->mem_ops.v2p(ctxt, ssdt);
     } else {
         printf("S4 disabled\n");
     }
@@ -409,12 +410,12 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, 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++] = ctxt->mem_ops.v2p(ctxt, ssdt);
 
         tcpa = ctxt->mem_ops.alloc(ctxt, 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++] = ctxt->mem_ops.v2p(ctxt, tcpa);
 
         tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
         tcpa->header.length    = sizeof(*tcpa);
@@ -442,11 +443,11 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         struct acpi_20_slit *slit = construct_slit(ctxt, config);
 
         if ( srat )
-            table_ptrs[nr_tables++] = (unsigned long)srat;
+            table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, srat);
         else
             printf("Failed to build SRAT, skipping...\n");
         if ( slit )
-            table_ptrs[nr_tables++] = (unsigned long)slit;
+            table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, slit);
         else
             printf("Failed to build SLIT, skipping...\n");
     }
@@ -560,8 +561,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     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          = ctxt->mem_ops.v2p(ctxt, dsdt);
+    fadt_10->firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs);
     set_checksum(fadt_10,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_10_fadt));
@@ -569,10 +570,10 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     fadt = ctxt->mem_ops.alloc(ctxt, 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   = ctxt->mem_ops.v2p(ctxt, dsdt);
+    fadt->x_dsdt = ctxt->mem_ops.v2p(ctxt, dsdt);
+    fadt->firmware_ctrl   = ctxt->mem_ops.v2p(ctxt, facs);
+    fadt->x_firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs);
     set_checksum(fadt,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
@@ -587,7 +588,7 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
                      16);
     if (!xsdt) goto oom;
     memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
-    xsdt->entry[0] = (unsigned long)fadt;
+    xsdt->entry[0] = ctxt->mem_ops.v2p(ctxt, 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);
@@ -600,7 +601,7 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
                      16);
     if (!rsdt) goto oom;
     memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
-    rsdt->entry[0] = (unsigned long)fadt_10;
+    rsdt->entry[0] = ctxt->mem_ops.v2p(ctxt, 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);
@@ -614,8 +615,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     rsdp = (struct acpi_20_rsdp *)config->rsdp;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
-    rsdp->rsdt_address = (unsigned long)rsdt;
-    rsdp->xsdt_address = (unsigned long)xsdt;
+    rsdp->rsdt_address = ctxt->mem_ops.v2p(ctxt, rsdt);
+    rsdp->xsdt_address = ctxt->mem_ops.v2p(ctxt, xsdt);
     set_checksum(rsdp,
                  offsetof(struct acpi_10_rsdp, checksum),
                  sizeof(struct acpi_10_rsdp));
Signature · 7 lines
1.8.3.1


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

PATCH v2 12/23 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's Makefile will only generate necessary source files.

---
v2:
* Reordered .gitignore changes alphabetically
* Dropped trailing slashes
* Use relative path for ACPI_PATH
* Use $(addprefix...)
* Dropped use of 'cd' in rules and instead add $(ACPI_BUILD_DIR)/ to $*

 .gitignore                             |  8 +++----
 tools/firmware/hvmloader/Makefile      | 11 +++++++++-
 tools/firmware/hvmloader/acpi/Makefile | 39 ++++++++++++++++------------------
 3 files changed, 32 insertions(+), 26 deletions(-)
.gitignore +4 -4
index e019f2e..d6ba3dd 100644
@@ -126,13 +126,13 @@ 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/dsdt*.c
+tools/firmware/hvmloader/dsdt_*.asl
 tools/firmware/hvmloader/hvmloader
+tools/firmware/hvmloader/mk_dsdt
 tools/firmware/hvmloader/roms.h
 tools/firmware/hvmloader/roms.inc
+tools/firmware/hvmloader/ssdt_*.h
 tools/firmware/rombios/BIOS-bochs-[^/]*
 tools/firmware/rombios/_rombios[^/]*_.c
 tools/firmware/rombios/rombios[^/]*.s
tools/firmware/hvmloader/Makefile +10 -1
index 9f7357f..a1ab170 100644
@@ -20,6 +20,7 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
+export ACPI_BUILD_DIR=$(shell pwd)
 SUBDIRS := acpi
 
 # The HVM loader is started in 32-bit mode at the address below:
@@ -72,7 +73,15 @@ all: subdirs-all
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+ACPI_PATH = ./acpi
+ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
+$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
+vpath build.c $(ACPI_PATH)
+vpath static_tables.c $(ACPI_PATH)
+OBJS += $(ACPI_OBJS)
+
+hvmloader: $(OBJS)
 	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(LOADADDR) -o hvmloader.tmp $^
 	$(OBJCOPY) hvmloader.tmp hvmloader
 	rm -f hvmloader.tmp
tools/firmware/hvmloader/acpi/Makefile +18 -21
index 703d67b..6937ff4 100644
@@ -15,36 +15,39 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.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))
+MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
-CFLAGS += $(CFLAGS_xeninclude)
+# Sources to be generated
+C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
+H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
-all: acpi.a
+all: $(C_SRC) $(H_SRC)
 
-ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
+$(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
+	cd $(ACPI_BUILD_DIR)
 	iasl -vs -p $* -tc $<
 	sed -e 's/AmlCode/$*/g' $*.hex >$@
 	rm -f $*.hex $*.aml
+	cd $(CURDIR)
 
-mk_dsdt: mk_dsdt.c
+$(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-dsdt_%cpu.asl: dsdt.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
+	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
-	iasl -vs -p $* -tc $*.asl
-	sed -e 's/AmlCode/$*/g' $*.hex >$@
+$(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/$*.asl
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
-	rm -f $*.aml $*.hex
+	rm -f $(ACPI_BUILD_DIR)/$*.aml $(ACPI_BUILD_DIR)/$*.hex
 
 iasl:
 	@echo
@@ -54,14 +57,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 ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
+	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC))
 
 distclean: clean
 
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 12/23] acpi/hvmloader: Link ACPI object files directly

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

v2:
* Reordered .gitignore changes alphabetically
* Dropped trailing slashes
* Use relative path for ACPI_PATH
* Use $(addprefix...)
* Dropped use of 'cd' in rules and instead add $(ACPI_BUILD_DIR)/ to $*

What about the suggested use of $(CURDIR) e.g. ...

tools/firmware/hvmloader/Makefile line 23

Quoted 7 lines
tools/firmware/hvmloader/Makefile +1 -0
@@ -20,6 +20,7 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
+export ACPI_BUILD_DIR=$(shell pwd)

... here?

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

Quoted 6 lines
tools/firmware/hvmloader/Makefile +1 -1
@@ -72,7 +73,15 @@ all: subdirs-all
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+ACPI_PATH = ./acpi

Is the leading ./ really needed?

Quoted 16 lines
tools/firmware/hvmloader/acpi/Makefile +4 -3
@@ -15,36 +15,39 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.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))
+MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
-CFLAGS += $(CFLAGS_xeninclude)
+# Sources to be generated
+C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
+H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)

tools/firmware/hvmloader/acpi/Makefile line 32

Quoted 10 lines
tools/firmware/hvmloader/acpi/Makefile +4 -2
-all: acpi.a
+all: $(C_SRC) $(H_SRC)
 
-ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
+$(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
+	cd $(ACPI_BUILD_DIR)
 	iasl -vs -p $* -tc $<
 	sed -e 's/AmlCode/$*/g' $*.hex >$@
 	rm -f $*.hex $*.aml
+	cd $(CURDIR)

The two "cd" here contradict your list of changes above.

Quoted 16 lines
tools/firmware/hvmloader/acpi/Makefile +5 -5
-mk_dsdt: mk_dsdt.c
+$(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-dsdt_%cpu.asl: dsdt.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
+	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@

tools/firmware/hvmloader/acpi/Makefile line 50

Quoted 10 lines
tools/firmware/hvmloader/acpi/Makefile +4 -4
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
-	iasl -vs -p $* -tc $*.asl
-	sed -e 's/AmlCode/$*/g' $*.hex >$@
+$(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/$*.asl
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
-	rm -f $*.aml $*.hex
+	rm -f $(ACPI_BUILD_DIR)/$*.aml $(ACPI_BUILD_DIR)/$*.hex

$(addprefix ...) again?

Jan

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

#33 lore raw

Re: [PATCH v2 12/23] acpi/hvmloader: Link ACPI object files directly

Quoted 8 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

v2:
* Reordered .gitignore changes alphabetically
* Dropped trailing slashes
* Use relative path for ACPI_PATH
* Use $(addprefix...)
* Dropped use of 'cd' in rules and instead add $(ACPI_BUILD_DIR)/ to $*

What about the suggested use of $(CURDIR) e.g. ...

I think I fixed this (and some of others that you mention) in the later patch when I moved the Makefile to tools/. I will fix it here first.

-boris

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

#34 lore raw

PATCH v2 13/23 acpi/hvmloader: Include file/paths adjustments

In reply to Boris Ostrovsky

In prepearation to moving acpi sources into generally available libacpi:

1. Move certain x86-specific definitions into acpi's x86.h
2. Modify include files serach paths to point to acpi
3. Macro-ise include file for build.c that defines various utilities used by that file. Users of libacpi will be expected to define this macro when compiling build.c

---
v2:
* Note: hvmloader.c needs <acpi2_0.h> due to its use of ACPI_PM1A_CNT_BLK_ADDRESS_V1 and ACPI_PM1C_SCI_EN

 tools/firmware/hvmloader/Makefile     |  3 ++-
 tools/firmware/hvmloader/acpi/README  | 16 ++++++++++++----
 tools/firmware/hvmloader/acpi/build.c |  5 ++---
 tools/firmware/hvmloader/acpi/x86.h   | 30 ++++++++++++++++++++++++++++++
 tools/firmware/hvmloader/config.h     |  6 ------
 tools/firmware/hvmloader/hvmloader.c  |  3 ++-
 tools/firmware/hvmloader/mp_tables.c  |  1 +
 tools/firmware/hvmloader/pci.c        |  1 +
 tools/firmware/hvmloader/pir.c        |  1 +
 tools/firmware/hvmloader/rombios.c    |  2 +-
 tools/firmware/hvmloader/seabios.c    |  4 ++--
 tools/firmware/hvmloader/smp.c        |  1 +
 tools/firmware/hvmloader/util.c       |  5 +++--
 13 files changed, 58 insertions(+), 20 deletions(-)
 create mode 100644 tools/firmware/hvmloader/acpi/x86.h
tools/firmware/hvmloader/Makefile +2 -1
index a1ab170..db64a61 100644
@@ -76,7 +76,8 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 ACPI_PATH = ./acpi
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
+$(ACPI_OBJS): CFLAGS += -I. -DSTDUTILS=\"../util.h\"
+CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
 OBJS += $(ACPI_OBJS)
tools/firmware/hvmloader/acpi/README +12 -4
index 210d5ba..ef4063b 100644
@@ -1,11 +1,19 @@
-ACPI Table for domain firmware
+ACPI builder for domain firmware
 
 
-INSTALL
+BUILDING ACPI
 -----------------
-Simply make is OK.
-# make 
+Users of ACPI builder are expected to provide an include file that defines
+the following:
+* strncpy
+* printf
+* NULL
+* test_bit
+* offsetof
 
+When compiling build.c, the name of this include file should be given to
+compiler as -DSTDUTILS=\"<filename>\". See tools/firmware/hvmloader/Makefile
+for an example.
 
 Note on DSDT Table
 ------------------
tools/firmware/hvmloader/acpi/build.c +2 -3
index c0e0915..2432eb9 100644
@@ -13,15 +13,14 @@
  * GNU Lesser General Public License for more details.
  */
 
+#include STDUTILS
 #include "acpi2_0.h"
 #include "libacpi.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_xs_strings.h>
 #include <xen/hvm/params.h>
 
tools/firmware/hvmloader/acpi/x86.h new file +30 -0
new file mode 100644
index 0000000..f305414
@@ -0,0 +1,30 @@
+/******************************************************************************
+ * x86.h
+ *
+ * x86-specific interfaces used by ACPI builder and its callers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000
+#define IOAPIC_ID           0x01
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+
+#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
+
+#endif /* __ACPI_X86_H__ */
tools/firmware/hvmloader/config.h +0 -6
index c9526e3..5116d96 100644
@@ -42,15 +42,9 @@ 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 +2 -1
index 61875a0..53ec7a1 100644
@@ -24,8 +24,9 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"
 #include "vnuma.h"
+#include "x86.h"
 #include <xen/version.h>
 #include <xen/hvm/params.h>
 #include <xen/arch-x86/hvm/start_info.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..d265109 100644
@@ -23,6 +23,7 @@
 #include "hypercall.h"
 #include "config.h"
 #include "pci_regs.h"
+#include "x86.h"
 
 #include <xen/memory.h>
 #include <xen/hvm/ioreq.h>
tools/firmware/hvmloader/pir.c +1 -0
index cc420dd..f95bcea 100644
@@ -16,6 +16,7 @@
 #include "config.h"
 #include "pir_types.h"
 #include "util.h"
+#include "x86.h"
 
 /*
  * The structure of these tables is described in
tools/firmware/hvmloader/rombios.c +1 -1
index 38a86ff..8705b92 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 +2 -2
index 5c9a351..80d1ea7 100644
@@ -25,8 +25,8 @@
 #include "util.h"
 
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
-#include "acpi/libacpi.h"
+#include "acpi2_0.h"
+#include "libacpi.h"
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
tools/firmware/hvmloader/smp.c +1 -0
index 082b17f..4c6c3c6 100644
@@ -22,6 +22,7 @@
 #include "util.h"
 #include "config.h"
 #include "apic_regs.h"
+#include "x86.h"
 
 #define AP_BOOT_EIP 0x1000
 extern char ap_boot_start[], ap_boot_end[];
tools/firmware/hvmloader/util.c +3 -2
index c9d2c0a..fb712a1 100644
@@ -22,8 +22,9 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "vnuma.h"
-#include "acpi/acpi2_0.h"
-#include "acpi/libacpi.h"
+#include "acpi2_0.h"
+#include "libacpi.h"
+#include "x86.h"
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 13/23] acpi/hvmloader: Include file/paths adjustments

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

tools/firmware/hvmloader/acpi/README line 6

Quoted 10 lines
tools/firmware/hvmloader/acpi/README +3 -4
@@ -1,11 +1,19 @@
-ACPI Table for domain firmware
+ACPI builder for domain firmware
 
 
-INSTALL
+BUILDING ACPI
 -----------------
-Simply make is OK.
-# make 
+Users of ACPI builder are expected to provide an include file that defines

s/defines/makes available/ (since a declaration would fully suffice)?

tools/firmware/hvmloader/acpi/README line 15

Quoted 9 lines
tools/firmware/hvmloader/acpi/README +8 -0
+the following:
+* strncpy
+* printf
+* NULL
+* test_bit
+* offsetof
 
+When compiling build.c, the name of this include file should be given to
+compiler as -DSTDUTILS=\"<filename>\". See tools/firmware/hvmloader/Makefile

Perhaps worthwhile using LIBACPI_STDUTILS to reduce the chance of a name space conflict?

tools/firmware/hvmloader/acpi/README line 19

Quoted 4 lines
tools/firmware/hvmloader/acpi/README +4 -0
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000

This will need re-basing - looks like your submission and my commit happened at about the same time.

tools/firmware/hvmloader/hvmloader.c line 27

Quoted 8 lines
tools/firmware/hvmloader/hvmloader.c +1 -1
@@ -24,8 +24,9 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"

Could you see to pass a suitable string via -D from the Makefile to prefix to headers like this one? That would clarify to the reader that the file being looked for is not in the current directory. The primary other option that I see would be to use <> instead of "", and keep the -I in the Makefile. Perhaps that would even be the more natural variant.

Jan

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

#36 lore raw

Re: [PATCH v2 13/23] acpi/hvmloader: Include file/paths adjustments

Quoted 6 lines · Jan Beulich

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

Quoted 4 lines
tools/firmware/hvmloader/acpi/x86.h new file +4 -0
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000

This will need re-basing - looks like your submission and my commit happened at about the same time.

Right, I saw that but this series is based on Anthony's tree so I couldn't use it yet.

Quoted 15 lines

tools/firmware/hvmloader/hvmloader.c line 27

Quoted 9 lines
tools/firmware/hvmloader/hvmloader.c +1 -1
@@ -24,8 +24,9 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
-#include "acpi/acpi2_0.h"
+#include "acpi2_0.h"

Could you see to pass a suitable string via -D from the Makefile to prefix to headers like this one? That would clarify to the reader that the file being looked for is not in the current directory. The primary other option that I see would be to use <> instead of "", and keep the -I in the Makefile. Perhaps that would even be the more natural variant.

Yes, I'll see if that (< >) works.

-boris

Quoted 1 line

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

#37 lore raw

PATCH v2 14/23 acpi: Move ACPI code to tools/libacpi

In reply to Boris Ostrovsky

---
v2:
* Minor cleanup of hvmloader's Makefile

 tools/firmware/hvmloader/Makefile                          | 14 ++++++++------
 tools/firmware/hvmloader/ovmf.c                            |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/Makefile        |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/README          |  0
 tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/build.c         |  0
 tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl        |  0
 tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl    |  0
 tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c |  0
 tools/{firmware/hvmloader/acpi => libacpi}/x86.h           |  0
 15 files changed, 10 insertions(+), 8 deletions(-)
 rename tools/{firmware/hvmloader/acpi => libacpi}/Makefile (98%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/README (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/x86.h (100%)
tools/firmware/hvmloader/Makefile +8 -6
index db64a61..694d9f1 100644
@@ -20,9 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-export ACPI_BUILD_DIR=$(shell pwd)
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 
@@ -67,16 +64,20 @@ ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
 endif
 
 .PHONY: all
-all: subdirs-all
+all: acpi subdirs-all
 	$(MAKE) hvmloader
 
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR)
+
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-ACPI_PATH = ./acpi
+ACPI_PATH = ../../libacpi
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I. -DSTDUTILS=\"../util.h\"
+$(ACPI_OBJS): CFLAGS += -I. -DSTDUTILS=\"$(CURDIR)/util.h\"
 CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
@@ -118,6 +119,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)  ACPI_BUILD_DIR=$(CURDIR) clean
 
 .PHONY: distclean
 distclean: clean
tools/firmware/hvmloader/ovmf.c +1 -1
index b4bcc93..7878276 100644
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "smbios_types.h"
-#include "acpi/libacpi.h"
+#include "libacpi.h"
 #include "apic_regs.h"
 #include "../rombios/config.h"
 #include "util.h"
tools/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +1 -1
similarity index 98%
rename from tools/firmware/hvmloader/acpi/Makefile
rename to tools/libacpi/Makefile
index 6937ff4..816322f 100644
@@ -12,7 +12,7 @@
 # NU Lesser General Public License for more details.
 #
 
-XEN_ROOT = $(CURDIR)/../../../..
+XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
tools/libacpi/README renamed from tools/firmware/hvmloader/acpi/README +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/README
rename to tools/libacpi/README
tools/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 tools/libacpi/acpi2_0.h
tools/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 tools/libacpi/build.c
tools/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 tools/libacpi/dsdt.asl
tools/libacpi/libacpi.h renamed from tools/firmware/hvmloader/acpi/libacpi.h +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/libacpi.h
rename to tools/libacpi/libacpi.h
tools/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 tools/libacpi/mk_dsdt.c
tools/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 tools/libacpi/ssdt_pm.asl
tools/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 tools/libacpi/ssdt_s3.asl
tools/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 tools/libacpi/ssdt_s4.asl
tools/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 tools/libacpi/ssdt_tpm.asl
tools/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 tools/libacpi/static_tables.c
tools/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 tools/libacpi/x86.h
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 14/23] acpi: Move ACPI code to tools/libacpi

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

There's a dependency this ack has which I came too think of only now:
The move here results in a maintainership change, which should either be avoided (by updating ./MAINTAINERS at the same time), or we should agree on new maintainership (this stuff could likely also go under the ACPI entry).

Jan

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

#39 lore raw

Re: [PATCH v2 14/23] acpi: Move ACPI code to tools/libacpi

Quoted 10 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:

There's a dependency this ack has which I came too think of only now:
The move here results in a maintainership change, which should either be avoided (by updating ./MAINTAINERS at the same time), or we should agree on new maintainership (this stuff could likely also go under the ACPI entry).

If Andrew and you are happy to continue maintaining ACPI related code, I'm happy with that, too.

It is mostly code movement after all.

Wei.

Quoted 2 lines

Jan

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

#40 lore raw

Re: [PATCH v2 14/23] acpi: Move ACPI code to tools/libacpi

In reply to Boris Ostrovsky

Hi,

Quoted 61 lines · Boris Ostrovsky

---
v2:
* Minor cleanup of hvmloader's Makefile

 tools/firmware/hvmloader/Makefile                          | 14 ++++++++------
 tools/firmware/hvmloader/ovmf.c                            |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/Makefile        |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/README          |  0
 tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/build.c         |  0
 tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl        |  0
 tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl    |  0
 tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c |  0
 tools/{firmware/hvmloader/acpi => libacpi}/x86.h           |  0
 15 files changed, 10 insertions(+), 8 deletions(-)
 rename tools/{firmware/hvmloader/acpi => libacpi}/Makefile (98%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/README (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/x86.h (100%)
tools/firmware/hvmloader/Makefile +4 -4
index db64a61..694d9f1 100644
@@ -20,9 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-export ACPI_BUILD_DIR=$(shell pwd)
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 
@@ -67,16 +64,20 @@ ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
 endif
 
 .PHONY: all
-all: subdirs-all
+all: acpi subdirs-all
 	$(MAKE) hvmloader
 
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR)

tools/firmware/hvmloader/Makefile ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS) · line 80

Quoted 10 lines
tools/firmware/hvmloader/Makefile +3 -2
+
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-ACPI_PATH = ./acpi
+ACPI_PATH = ../../libacpi
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I. -DSTDUTILS=\"../util.h\"
+$(ACPI_OBJS): CFLAGS += -I. -DSTDUTILS=\"$(CURDIR)/util.h\"

Not sure if I do something wrong, but I got bellow errors when compiling this series on x86 just using "./autogen.sh;./configure;make tools".

In file included from tcgbios.c:26:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

In file included from tpm_drivers.c:24:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

Thanks,

Signature · 7 lines
Shannon


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

Re: [PATCH v2 14/23] acpi: Move ACPI code to tools/libacpi

On Tue, Aug 16, 2016 at 04:13:06PM +0800, Shannon Zhao wrote:
[...]

Quoted 8 lines

Not sure if I do something wrong, but I got bellow errors when compiling this series on x86 just using "./autogen.sh;./configure;make tools".

In file included from tcgbios.c:26:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

Quoted 5 lines

In file included from tpm_drivers.c:24:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

I don't think this is caused by your environment.

Please rebase everything on top of staging. There is a fix there.

Wei.

Quoted 4 lines

Thanks,

Signature · 1 line
Shannon

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

#42 lore raw

Re: [PATCH v2 14/23] acpi: Move ACPI code to tools/libacpi

Quoted 10 lines · Wei Liu

On Tue, Aug 16, 2016 at 04:13:06PM +0800, Shannon Zhao wrote:
[...]

Quoted 8 lines
Quoted 8 lines

Not sure if I do something wrong, but I got bellow errors when compiling this series on x86 just using "./autogen.sh;./configure;make tools".

In file included from tcgbios.c:26:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

In file included from tpm_drivers.c:24:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

I don't think this is caused by your environment.

Please rebase everything on top of staging. There is a fix there.

You mean the commit "cc38370 hvmloader: include libacpi.h instead of acpi2_0.h in rombios.c", right?

If so, I don't think it's relevant to this problem because this patch moves acpi2_0.h under tools/libacpi/ but it doesn't update in the path in tools/firmware/rombios/32bit/util.h

Thanks,

Signature · 7 lines
Shannon


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

Re: [PATCH v2 14/23] acpi: Move ACPI code to tools/libacpi

Quoted 18 lines · Shannon Zhao
Quoted 15 lines · Wei Liu

On Tue, Aug 16, 2016 at 04:13:06PM +0800, Shannon Zhao wrote:
[...]

Quoted 13 lines
Quoted 13 lines

Not sure if I do something wrong, but I got bellow errors when compiling this series on x86 just using "./autogen.sh;./configure;make tools".

In file included from tcgbios.c:26:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

In file included from tpm_drivers.c:24:0:
../util.h:4:39: fatal error: ../hvmloader/acpi/acpi2_0.h: No such file or directory
#include "../hvmloader/acpi/acpi2_0.h"

Quoted 5 lines
Quoted 3 lines

I don't think this is caused by your environment.

Please rebase everything on top of staging. There is a fix there.

You mean the commit "cc38370 hvmloader: include libacpi.h instead of acpi2_0.h in rombios.c", right?

Yes, that one.

But you're right. That one won't fix it for you.

Quoted 5 lines

If so, I don't think it's relevant to this problem because this patch moves acpi2_0.h under tools/libacpi/ but it doesn't update in the path in tools/firmware/rombios/32bit/util.h

I think this is a bug in Boris's series. You can maybe work around it by changing the include to point to the new location.

Wei.

Quoted 4 lines

Thanks,

Signature · 1 line
Shannon

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

#44 lore raw

PATCH v2 15/23 x86: Add more checks verifying that PIT/PIC/IOAPIC are emulated

In reply to Boris Ostrovsky

---
v2:
* Added ASSERT(has_vpic(d))
* This patch can go in independent of the rest of the series.

 xen/arch/x86/hvm/vlapic.c | 14 ++++++++++++--
 xen/arch/x86/hvm/vpt.c    |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vlapic.c +12 -2
index ba9b293..1d5d287 100644
@@ -1114,7 +1114,14 @@ static int __vlapic_accept_pic_intr(struct vcpu *v)
     struct domain *d = v->domain;
     struct vlapic *vlapic = vcpu_vlapic(v);
     uint32_t lvt0 = vlapic_get_reg(vlapic, APIC_LVT0);
-    union vioapic_redir_entry redir0 = domain_vioapic(d)->redirtbl[0];
+    union vioapic_redir_entry redir0;
+
+    ASSERT(has_vpic(d));
+
+    if ( !has_vioapic(d) )
+        return 0;
+
+    redir0 = domain_vioapic(d)->redirtbl[0];
 
     /* We deliver 8259 interrupts to the appropriate CPU as follows. */
     return ((/* IOAPIC pin0 is unmasked and routing to this LAPIC? */
@@ -1130,7 +1137,7 @@ static int __vlapic_accept_pic_intr(struct vcpu *v)
 
 int vlapic_accept_pic_intr(struct vcpu *v)
 {
-    if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
+    if ( vlapic_hw_disabled(vcpu_vlapic(v)) || !has_vpic(v->domain) )
         return 0;
 
     TRACE_2D(TRC_HVM_EMUL_LAPIC_PIC_INTR,
@@ -1145,6 +1152,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;
xen/arch/x86/hvm/vpt.c +1 -1
index 358ec57..c90aa95 100644
@@ -496,7 +496,7 @@ void pt_adjust_global_vcpu_target(struct vcpu *v)
     struct pl_time *pl_time;
     int i;
 
-    if ( v == NULL )
+    if ( v == NULL || !has_vpit(v->domain) )
         return;
 
     vpit = &v->domain->arch.vpit;
Signature · 7 lines
1.8.3.1


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

PATCH v2 16/23 x86: Allow LAPIC-only emulation_flags for HVM guests

In reply to Boris Ostrovsky

PVHv2 guests may request LAPIC emulation (and nothing else)

---
v2:
* Note: I kept the code as is (with minor style adjustments). Roger's version (with emulation_flags_ok()) has slighly more logic to account for dom0. Without that I didn't feel it's worth factoring this code into a separate routine.

 xen/arch/x86/domain.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
xen/arch/x86/domain.c +16 -10
index 1133ea2..34a4eb5 100644
@@ -545,25 +545,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 )
         {
             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)) )
+
+        /* PVHv2 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
1.8.3.1


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

PATCH v2 17/23 libacpi: Build DSDT for PVH guests

In reply to Boris Ostrovsky

PVH guests require DSDT with only ACPI INFO (Xen-specific) and Processor objects. We separate ASL's ACPI INFO definition into dsdt_acpi_info.asl so that it can be included in ASLs for both HVM and PVH2.

---
 tools/libacpi/Makefile           | 21 +++++++++++++++++----
 tools/libacpi/dsdt.asl           | 20 --------------------
 tools/libacpi/dsdt_acpi_info.asl | 23 +++++++++++++++++++++++
 tools/libacpi/mk_dsdt.c          | 10 ++++++++++
 4 files changed, 50 insertions(+), 24 deletions(-)
 create mode 100644 tools/libacpi/dsdt_acpi_info.asl
tools/libacpi/Makefile +17 -4
index 816322f..d741ac5 100644
@@ -18,7 +18,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
 # Sources to be generated
-C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
+C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
@@ -34,13 +34,15 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
 $(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
+	cat dsdt_acpi_info.asl >> $@
 	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl $(MK_DSDT)
+$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
+	cat dsdt_acpi_info.asl >> $@
 	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
 
 $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
@@ -49,6 +51,17 @@ $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
 	echo "int $*_len=sizeof($*);" >>$@
 	rm -f $(ACPI_BUILD_DIR)/$*.aml $(ACPI_BUILD_DIR)/$*.hex
 
+$(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
+	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@
+	cat dsdt_acpi_info.asl >> $@
+	$(MK_DSDT) --debug=$(debug) --maxcpu any --no-dm >> $@
+
+$(ACPI_BUILD_DIR)/dsdt_pvh.c: iasl $(ACPI_BUILD_DIR)/dsdt_pvh.asl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/dsdt_pvh.asl
+	sed -e 's/AmlCode/dsdt_pvh/g' $(ACPI_BUILD_DIR)/$*.hex >$@
+	echo "int dsdt_pvh_len=sizeof(dsdt_pvh);" >>$@
+	rm -f $(ACPI_BUILD_DIR)/$*.aml $(ACPI_BUILD_DIR)/$*.hex
+
 iasl:
 	@echo
 	@echo "ACPI ASL compiler (iasl) is needed"
@@ -58,7 +71,7 @@ iasl:
 	@exit 1
 
 clean:
-	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC))
+	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC)) $(ACPI_BUILD_DIR)/dsdt_pvh.c
 
 distclean: clean
 
tools/libacpi/dsdt.asl +0 -20
index 895a8e5..715bd7a 100644
@@ -41,26 +41,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
 
     Scope (\_SB)
     {
-       /* ACPI_INFO_PHYSICAL_ADDRESS == 0xFC000000 */
-       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
-       Field(BIOS, ByteAcc, NoLock, Preserve) {
-           UAR1, 1,
-           UAR2, 1,
-           LTP1, 1,
-           HPET, 1,
-           Offset(2),
-           NCPU, 16,
-           PMIN, 32,
-           PLEN, 32,
-           MSUA, 32, /* MADT checksum address */
-           MAPA, 32, /* MADT LAPIC0 address */
-           VGIA, 32, /* VM generation id address */
-           LMIN, 32,
-           HMIN, 32,
-           LLEN, 32,
-           HLEN, 32
-       }
-
         /* Fix HCT test for 0x400 pci memory:
          * - need to report low 640 MB mem as motherboard resource
          */
tools/libacpi/dsdt_acpi_info.asl new file +23 -0
new file mode 100644
index 0000000..eeecd49
@@ -0,0 +1,23 @@
+
+    Scope (\_SB)
+    {
+       /* ACPI_INFO_PHYSICAL_ADDRESS == 0xFC000000 */
+       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
+       Field(BIOS, ByteAcc, NoLock, Preserve) {
+           UAR1, 1,
+           UAR2, 1,
+           LTP1, 1,
+           HPET, 1,
+           Offset(2),
+           NCPU, 16,
+           PMIN, 32,
+           PLEN, 32,
+           MSUA, 32, /* MADT checksum address */
+           MAPA, 32, /* MADT LAPIC0 address */
+           VGIA, 32, /* VM generation id address */
+           LMIN, 32,
+           HMIN, 32,
+           LLEN, 32,
+           HLEN, 32
+       }
+    }
tools/libacpi/mk_dsdt.c +10 -0
index bc414bf..7d76784 100644
@@ -98,6 +98,7 @@ static struct option options[] = {
     { "maxcpu", 1, 0, 'c' },
     { "dm-version", 1, 0, 'q' },
     { "debug", 1, 0, 'd' },
+    { "no-dm", 0, 0, 'n' },
     { 0, 0, 0, 0 }
 };
 
@@ -105,6 +106,7 @@ int main(int argc, char **argv)
 {
     unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
+    bool no_dm = 0;
 
     for ( ; ; )
     {
@@ -140,6 +142,9 @@ int main(int argc, char **argv)
                 return -1;
             }
             break;
+        case 'n':
+            no_dm = 1;
+            break;
         case 'd':
             if (*optarg == 'y')
                 debug = true;
@@ -252,6 +257,11 @@ int main(int argc, char **argv)
 
     pop_block();
 
+    if (no_dm) {
+        pop_block();
+        return 0;
+    }
+
     /* Define GPE control method. */
     push_block("Scope", "\\_GPE");
     push_block("Method",
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 17/23] libacpi: Build DSDT for PVH guests

tools/libacpi/Makefile $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl · line 40

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/libacpi/Makefile +2 -1
@@ -34,13 +34,15 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
 $(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
+	cat dsdt_acpi_info.asl >> $@
 	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@

I understand the problem is pre-existing, but unfortunately you make it worse: Repeatedly redirecting into the destination file is prone to problems when someone interrupts a build. There should be a temporary file created, and as the last step that one should be mv-ed to the destination.

tools/libacpi/Makefile iasl: · line 74

Quoted 6 lines
tools/libacpi/Makefile +1 -1
@@ -58,7 +71,7 @@ iasl:
 	@exit 1
 
 clean:
-	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC))
+	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC)) $(ACPI_BUILD_DIR)/dsdt_pvh.c

Isn't this already being taken care of by $(C_SRC)?

Quoted 16 lines
tools/libacpi/dsdt_acpi_info.asl new file +13 -0
@@ -0,0 +1,23 @@
+
+    Scope (\_SB)
+    {
+       /* ACPI_INFO_PHYSICAL_ADDRESS == 0xFC000000 */
+       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
+       Field(BIOS, ByteAcc, NoLock, Preserve) {
+           UAR1, 1,
+           UAR2, 1,
+           LTP1, 1,
+           HPET, 1,
+           Offset(2),
+           NCPU, 16,
+           PMIN, 32,

tools/libacpi/dsdt_acpi_info.asl line 23

Quoted 10 lines
tools/libacpi/dsdt_acpi_info.asl new file +10 -0
+           PLEN, 32,
+           MSUA, 32, /* MADT checksum address */
+           MAPA, 32, /* MADT LAPIC0 address */
+           VGIA, 32, /* VM generation id address */
+           LMIN, 32,
+           HMIN, 32,
+           LLEN, 32,
+           HLEN, 32
+       }
+    }

While moving it, could you please extend the comment to add an xref note similar to the one ahead of the struct acpi_info declaration (but pointing in the opposite direction)?

tools/libacpi/mk_dsdt.c static struct option options[] = { · line 101

Quoted 7 lines
tools/libacpi/mk_dsdt.c +1 -0
@@ -98,6 +98,7 @@ static struct option options[] = {
     { "maxcpu", 1, 0, 'c' },
     { "dm-version", 1, 0, 'q' },
     { "debug", 1, 0, 'd' },
+    { "no-dm", 0, 0, 'n' },

Please, instead of going this route, add support for --dm-version none,
...

tools/libacpi/mk_dsdt.c int main(int argc, char **argv) · line 109

Quoted 5 lines
tools/libacpi/mk_dsdt.c +1 -0
@@ -105,6 +106,7 @@ int main(int argc, char **argv)
 {
     unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
+    bool no_dm = 0;

... at once extending the dm_version enum (and presumably that enumerator would preferably become the first one, i.e. with value zero, so you could - if you want - use an expression like !dm_version).

Jan

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

#48 lore raw

PATCH v2 18/23 libxc/libxl: Allow multiple ACPI modules

In reply to Boris Ostrovsky

Provide ability to load multiple ACPI modules. Thie feature is needed by PVHv2 guests and will be used in subsequent patches.

We assume that PVHv2 guests do not load their ACPI modules specified in the configuration file. We can extend support for that in the future if desired.

---
v2:
* New patch. PVH uses 3 modules:
- rsdp (8 bytes that store RSDT address)
- acpi_info (1 page, Xen-specific)
- ACPI tables (multiple pages)
As an alternative, we could add rsdp_val and rsdp_ptr and keep acpi_module as a scalar (acpi_info and ACPI tables are usually laid out contiguously). This patch provides a more general solution (IMO).

 tools/libxc/include/xc_dom.h   |  5 +++--
 tools/libxc/xc_dom_hvmloader.c |  3 ++-
 tools/libxl/libxl_dom.c        | 26 ++++++++++++++++++--------
 3 files changed, 23 insertions(+), 11 deletions(-)
tools/libxc/include/xc_dom.h +3 -2
index de7dca9..608cbc2 100644
@@ -212,8 +212,9 @@ struct xc_dom_image {
     /* BIOS/Firmware passed to HVMLOADER */
     struct xc_hvm_firmware_module system_firmware_module;
 
-    /* Extra ACPI tables passed to HVMLOADER */
-    struct xc_hvm_firmware_module acpi_module;
+    /* Extra ACPI tables */
+#define MAX_ACPI_MODULES        4
+    struct xc_hvm_firmware_module acpi_modules[MAX_ACPI_MODULES];
 
     /* Extra SMBIOS structures passed to HVMLOADER */
     struct xc_hvm_firmware_module smbios_module;
tools/libxc/xc_dom_hvmloader.c +2 -1
index 6eb8516..59f94e5 100644
@@ -172,7 +172,8 @@ static int modules_init(struct xc_dom_image *dom)
     rc = module_init_one(dom, &dom->system_firmware_module,
                          "System Firmware module");
     if ( rc ) goto err;
-    rc = module_init_one(dom, &dom->acpi_module, "ACPI module");
+    /* Only one module can be added */
+    rc = module_init_one(dom, &dom->acpi_modules[0], "ACPI module");
     if ( rc ) goto err;
     rc = module_init_one(dom, &dom->smbios_module, "SMBIOS module");
     if ( rc ) goto err;
tools/libxl/libxl_dom.c +18 -8
index 2a1793d..22d6868 100644
@@ -818,7 +818,8 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
 
 static int hvm_build_set_xs_values(libxl__gc *gc,
                                    uint32_t domid,
-                                   struct xc_dom_image *dom)
+                                   struct xc_dom_image *dom,
+                                   libxl_domain_build_info *info)
 {
     char *path = NULL;
     int ret = 0;
@@ -839,18 +840,20 @@ static int hvm_build_set_xs_values(libxl__gc *gc,
             goto err;
     }
 
-    if (dom->acpi_module.guest_addr_out) {
+    /* Only one module can be passed. PVHv2 guests do not support this. */
+    if (dom->acpi_modules[0].guest_addr_out && 
+        info->device_model_version !=LIBXL_DEVICE_MODEL_VERSION_NONE) {
         path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_ADDRESS, domid);
 
         ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%"PRIx64,
-                               dom->acpi_module.guest_addr_out);
+                               dom->acpi_modules[0].guest_addr_out);
         if (ret)
             goto err;
 
         path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_LENGTH, domid);
 
         ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%x",
-                               dom->acpi_module.length);
+                               dom->acpi_modules[0].length);
         if (ret)
             goto err;
     }
@@ -994,6 +997,13 @@ static int libxl__domain_firmware(libxl__gc *gc,
     }
 
     if (info->u.hvm.acpi_firmware) {
+
+        if (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE) {
+            LOGE(ERROR, "PVH guests do not allow loading ACPI modules");
+            rc = ERROR_FAIL;
+            goto out;
+        }
+
         data = NULL;
         e = libxl_read_file_contents(ctx, info->u.hvm.acpi_firmware,
                                      &data, &datalen);
@@ -1005,9 +1015,9 @@ static int libxl__domain_firmware(libxl__gc *gc,
         }
         libxl__ptr_add(gc, data);
         if (datalen) {
-            /* Only accept non-empty files */
-            dom->acpi_module.data = data;
-            dom->acpi_module.length = (uint32_t)datalen;
+            /* Only accept a non-empty file */
+            dom->acpi_modules[0].data = data;
+            dom->acpi_modules[0].length = (uint32_t)datalen;
         }
     }
 
@@ -1143,7 +1153,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
-    rc = hvm_build_set_xs_values(gc, domid, dom);
+    rc = hvm_build_set_xs_values(gc, domid, dom, info);
     if (rc != 0) {
         LOG(ERROR, "hvm build set xenstore values failed");
         goto out;
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 18/23] libxc/libxl: Allow multiple ACPI modules

Quoted 59 lines · Boris Ostrovsky

Provide ability to load multiple ACPI modules. Thie feature is needed by PVHv2 guests and will be used in subsequent patches.

We assume that PVHv2 guests do not load their ACPI modules specified in the configuration file. We can extend support for that in the future if desired.

---
v2:
* New patch. PVH uses 3 modules:
- rsdp (8 bytes that store RSDT address)
- acpi_info (1 page, Xen-specific)
- ACPI tables (multiple pages)
As an alternative, we could add rsdp_val and rsdp_ptr and keep acpi_module as a scalar (acpi_info and ACPI tables are usually laid out contiguously). This patch provides a more general solution (IMO).

 tools/libxc/include/xc_dom.h   |  5 +++--
 tools/libxc/xc_dom_hvmloader.c |  3 ++-
 tools/libxl/libxl_dom.c        | 26 ++++++++++++++++++--------
 3 files changed, 23 insertions(+), 11 deletions(-)
tools/libxc/include/xc_dom.h +3 -2
index de7dca9..608cbc2 100644
@@ -212,8 +212,9 @@ struct xc_dom_image {
     /* BIOS/Firmware passed to HVMLOADER */
     struct xc_hvm_firmware_module system_firmware_module;
 
-    /* Extra ACPI tables passed to HVMLOADER */
-    struct xc_hvm_firmware_module acpi_module;
+    /* Extra ACPI tables */
+#define MAX_ACPI_MODULES        4
+    struct xc_hvm_firmware_module acpi_modules[MAX_ACPI_MODULES];
 
     /* Extra SMBIOS structures passed to HVMLOADER */
     struct xc_hvm_firmware_module smbios_module;
tools/libxc/xc_dom_hvmloader.c +2 -1
index 6eb8516..59f94e5 100644
@@ -172,7 +172,8 @@ static int modules_init(struct xc_dom_image *dom)
     rc = module_init_one(dom, &dom->system_firmware_module,
                          "System Firmware module");
     if ( rc ) goto err;
-    rc = module_init_one(dom, &dom->acpi_module, "ACPI module");
+    /* Only one module can be added */
+    rc = module_init_one(dom, &dom->acpi_modules[0], "ACPI module");
     if ( rc ) goto err;
     rc = module_init_one(dom, &dom->smbios_module, "SMBIOS module");
     if ( rc ) goto err;
tools/libxl/libxl_dom.c +0 -0
index 2a1793d..22d6868 100644

tools/libxl/libxl_dom.c static int hvm_build_set_params(xc_interface *handle, uint32_t domid, · line 822

Quoted 6 lines
tools/libxl/libxl_dom.c +2 -1
@@ -818,7 +818,8 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
 
 static int hvm_build_set_xs_values(libxl__gc *gc,
                                    uint32_t domid,
-                                   struct xc_dom_image *dom)
+                                   struct xc_dom_image *dom,
+                                   libxl_domain_build_info *info)

My slight preference is that if only device_model_version is needed you pass that directly to this function. But I don't feel too strong about this. If you're going to pass info please constify it.

Code-wise, looks good.

Wei.

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

#50 lore raw

PATCH v2 19/23 libxl/acpi: Add ACPI e820 entry

In reply to Boris Ostrovsky

Add entry for ACPI tables created for PVHv2 guests to e820 map.

---
v2:
* Deal with multiple acpi_modules.

 tools/libxl/libxl_dom.c |  8 ++++----
 tools/libxl/libxl_x86.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)
tools/libxl/libxl_dom.c +4 -4
index 22d6868..4d2bc0c 100644
@@ -1134,16 +1134,16 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
             dom->vnode_to_pnode[i] = info->vnuma_nodes[i].pnode;
     }
 
+    rc = libxl__build_dom(gc, domid, info, state, dom);
+    if (rc != 0)
+        goto out;
+
     rc = libxl__arch_domain_construct_memmap(gc, d_config, domid, dom);
     if (rc != 0) {
         LOG(ERROR, "setting domain memory map failed");
         goto out;
     }
 
-    rc = libxl__build_dom(gc, domid, info, state, dom);
-    if (rc != 0)
-        goto out;
-
     rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
                                &state->console_mfn, state->store_domid,
tools/libxl/libxl_x86.c +15 -0
index 46cfafb..7654e20 100644
@@ -492,6 +492,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     uint64_t highmem_size =
                     dom->highmem_end ? dom->highmem_end - (1ull << 32) : 0;
     uint32_t lowmem_start = dom->device_model ? GUEST_LOW_MEM_START_DEFAULT : 0;
+    unsigned page_size = XC_DOM_PAGE_SIZE(dom);
 
     /* Add all rdm entries. */
     for (i = 0; i < d_config->num_rdms; i++)
@@ -503,6 +504,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     if (highmem_size)
         e820_entries++;
 
+    for (i=0; i<MAX_ACPI_MODULES; i++)
+        if ( dom->acpi_modules[i].length)
+            e820_entries++;
+
     if (e820_entries >= E820MAX) {
         LOG(ERROR, "Ooops! Too many entries in the memory map!");
         rc = ERROR_INVAL;
@@ -528,6 +533,16 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         nr++;
     }
 
+    for (i=0; i<MAX_ACPI_MODULES; i++) {
+        if (dom->acpi_modules[i].length) {
+            e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size - 1);
+            e820[nr].size = dom->acpi_modules[i].length +
+                (dom->acpi_modules[i].guest_addr_out & (page_size - 1));
+            e820[nr].type = E820_ACPI;
+            nr++;
+        }
+    }
+
     /* High memory */
     if (highmem_size) {
         e820[nr].addr = ((uint64_t)1 << 32);
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 19/23] libxl/acpi: Add ACPI e820 entry

Quoted 49 lines · Boris Ostrovsky

Add entry for ACPI tables created for PVHv2 guests to e820 map.

---
v2:
* Deal with multiple acpi_modules.

 tools/libxl/libxl_dom.c |  8 ++++----
 tools/libxl/libxl_x86.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)
tools/libxl/libxl_dom.c +4 -4
index 22d6868..4d2bc0c 100644
@@ -1134,16 +1134,16 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
             dom->vnode_to_pnode[i] = info->vnuma_nodes[i].pnode;
     }
 
+    rc = libxl__build_dom(gc, domid, info, state, dom);
+    if (rc != 0)
+        goto out;
+
     rc = libxl__arch_domain_construct_memmap(gc, d_config, domid, dom);
     if (rc != 0) {
         LOG(ERROR, "setting domain memory map failed");
         goto out;
     }
 
-    rc = libxl__build_dom(gc, domid, info, state, dom);
-    if (rc != 0)
-        goto out;
-
     rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
                                &state->console_mfn, state->store_domid,
tools/libxl/libxl_x86.c +1 -0
index 46cfafb..7654e20 100644
@@ -492,6 +492,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     uint64_t highmem_size =
                     dom->highmem_end ? dom->highmem_end - (1ull << 32) : 0;
     uint32_t lowmem_start = dom->device_model ? GUEST_LOW_MEM_START_DEFAULT : 0;
+    unsigned page_size = XC_DOM_PAGE_SIZE(dom);
 
     /* Add all rdm entries. */
     for (i = 0; i < d_config->num_rdms; i++)

tools/libxl/libxl_x86.c int libxl__arch_domain_construct_memmap(libxl__gc *gc, · line 507

Quoted 4 lines
tools/libxl/libxl_x86.c +1 -0
@@ -503,6 +504,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     if (highmem_size)
         e820_entries++;
 
+    for (i=0; i<MAX_ACPI_MODULES; i++)
       for (i = 0; i < MAX_ACPI_MODULES; i++)

tools/libxl/libxl_x86.c int libxl__arch_domain_construct_memmap(libxl__gc *gc, · line 508

Quoted 1 line
tools/libxl/libxl_x86.c +1 -0
+        if ( dom->acpi_modules[i].length)

^
extraneous space here

tools/libxl/libxl_x86.c int libxl__arch_domain_construct_memmap(libxl__gc *gc, · line 536

Quoted 10 lines
tools/libxl/libxl_x86.c +3 -0
+            e820_entries++;
+
     if (e820_entries >= E820MAX) {
         LOG(ERROR, "Ooops! Too many entries in the memory map!");
         rc = ERROR_INVAL;
@@ -528,6 +533,16 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         nr++;
     }
 
+    for (i=0; i<MAX_ACPI_MODULES; i++) {

Ditto.

Quoted 15 lines
tools/libxl/libxl_x86.c +9 -0
+        if (dom->acpi_modules[i].length) {
+            e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size - 1);
+            e820[nr].size = dom->acpi_modules[i].length +
+                (dom->acpi_modules[i].guest_addr_out & (page_size - 1));
+            e820[nr].type = E820_ACPI;
+            nr++;
+        }
+    }
+
     /* High memory */
     if (highmem_size) {
         e820[nr].addr = ((uint64_t)1 << 32);
Signature · 1 line
1.8.3.1

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

#52 lore raw

PATCH v2 20/23 libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests

In reply to Boris Ostrovsky
---
 tools/libxl/Makefile    |  2 ++
 tools/libxl/libxl_dom.c | 22 ++++++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
tools/libxl/Makefile +2 -0
index 9fee752..3a2d64a 100644
@@ -165,6 +165,8 @@ $(XL_OBJS) $(TEST_PROG_OBJS) _libxl.api-for-check: \
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
 $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
 
+libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
+
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
 
tools/libxl/libxl_dom.c +18 -4
index 4d2bc0c..3a1daae 100644
@@ -24,6 +24,9 @@
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/e820.h>
+#if defined(__i386__) || defined(__x86_64__)
+#include <libacpi/x86.h>
+#endif
 
 #include "_paths.h"
 
@@ -1077,10 +1080,21 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         dom->target_pages = mem_size >> XC_PAGE_SHIFT;
     if (dom->mmio_size == 0 && device_model)
         dom->mmio_size = HVM_BELOW_4G_MMIO_LENGTH;
-    else if (dom->mmio_size == 0 && !device_model)
-        dom->mmio_size = GB(4) -
-                    ((X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES)
-                    << XC_PAGE_SHIFT);
+    else if (dom->mmio_size == 0 && !device_model) {
+#if defined(__i386__) || defined(__x86_64__)
+        if (libxl_defbool_val(info->u.hvm.apic)) {
+            /* Make sure LAPIC_BASE_ADDRESS is below special pages */
+            assert(((((X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES)
+                      << XC_PAGE_SHIFT) - LAPIC_BASE_ADDRESS)) >= XC_PAGE_SIZE);
+            dom->mmio_size = GB(4) - LAPIC_BASE_ADDRESS;
+        } else
+            dom->mmio_size = GB(4) -
+                ((X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES)
+                 << XC_PAGE_SHIFT);
+#else
+        assert(1);
+#endif
+    }
     lowmem_end = mem_size;
     highmem_end = 0;
     mmio_start = (1ull << 32) - dom->mmio_size;
Signature · 7 lines
1.8.3.1


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

PATCH v2 21/23 ilibxl: Initialize domain build info before calling libxl__domain_make

In reply to Boris Ostrovsky

libxl__domain_make() may want to use b_info so we should set defaults a little earlier.

---
v2:
* New patch. The need for this patch was triggered by commit b173750d2bc2

 tools/libxl/libxl_create.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
tools/libxl/libxl_create.c +11 -11
index 828f254..08822e3 100644
@@ -883,17 +883,6 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
-    ret = libxl__domain_make(gc, d_config, &domid, &state->config);
-    if (ret) {
-        LOG(ERROR, "cannot make domain: %d", ret);
-        dcs->guest_domid = domid;
-        ret = ERROR_FAIL;
-        goto error_out;
-    }
-
-    dcs->guest_domid = domid;
-    dcs->sdss.dm.guest_domid = 0; /* means we haven't spawned */
-
     ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info);
     if (ret) {
         LOG(ERROR, "Unable to set domain build info defaults");
@@ -907,6 +896,17 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
+    ret = libxl__domain_make(gc, d_config, &domid, &state->config);
+    if (ret) {
+        LOG(ERROR, "cannot make domain: %d", ret);
+        dcs->guest_domid = domid;
+        ret = ERROR_FAIL;
+        goto error_out;
+    }
+
+    dcs->guest_domid = domid;
+    dcs->sdss.dm.guest_domid = 0; /* means we haven't spawned */
+
     /*
      * Set the dm version quite early so that libxl doesn't have to pass the
      * build info around just to know if the domain has a device model or not.
Signature · 7 lines
1.8.3.1


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

PATCH v2 22/23 libxl/acpi: Build ACPI tables for HVMlite guests

In reply to Boris Ostrovsky

---
v2:
* Only initialize ACPI tables here but don't load them just yet (store them in acpi_modeuls[])
* Reorder .gitignore changes

 .gitignore                   |  12 ++-
 tools/libacpi/build.c        |   7 +-
 tools/libacpi/libacpi.h      |  15 +++-
 tools/libxl/Makefile         |  17 +++-
 tools/libxl/libxl_arch.h     |   3 +
 tools/libxl/libxl_dom.c      |   1 +
 tools/libxl/libxl_x86.c      |  29 +++++--
 tools/libxl/libxl_x86_acpi.c | 199 +++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_x86_acpi.h |  35 ++++++++
 9 files changed, 298 insertions(+), 20 deletions(-)
 create mode 100644 tools/libxl/libxl_x86_acpi.c
 create mode 100644 tools/libxl/libxl_x86_acpi.h
.gitignore +8 -4
index d6ba3dd..cf6ede9 100644
@@ -170,15 +170,19 @@ tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libxl/libxlu_cfg_y.output
+tools/libxl/_libxl.api-for-check
+tools/libxl/*.api-ok
 tools/libxl/*.pc
 tools/libxl/*.pc.in
-tools/libxl/xl
+tools/libxl/dsdt*.c
+tools/libxl/dsdt_*.asl
+tools/libxl/libxlu_cfg_y.output
+tools/libxl/mk_dsdt
+tools/libxl/ssdt_*.h
 tools/libxl/testenum
 tools/libxl/testenum.c
 tools/libxl/tmp.*
-tools/libxl/_libxl.api-for-check
-tools/libxl/*.api-ok
+tools/libxl/xl
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
tools/libacpi/build.c +4 -3
index 2432eb9..1778b88 100644
@@ -21,6 +21,7 @@
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
 #include "x86.h"
+#include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
@@ -491,7 +492,7 @@ static int new_vm_gid(struct acpi_ctxt *ctxt,
     return 1;
 }
 
-void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
+int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -626,11 +627,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     if ( !new_vm_gid(ctxt, config, acpi_info) )
         goto oom;
 
-    return;
+    return 0;
 
 oom:
     printf("unable to build ACPI tables: out of memory\n");
-
+    return -1;
 }
 
 /*
tools/libacpi/libacpi.h +12 -3
index ce2d50b..da20278 100644
@@ -48,6 +48,15 @@ struct acpi_ctxt {
         void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
         unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
     } mem_ops;
+
+    unsigned int page_size;
+    unsigned int page_shift;
+
+    /* Memory allocator */
+    unsigned long alloc_base_paddr;
+    unsigned long alloc_base_vaddr;
+    unsigned long alloc_currp;
+    unsigned long alloc_end;
 };
 
 struct acpi_config {
@@ -80,13 +89,13 @@ struct acpi_config {
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
      * definition in the DSDT
      */
-    unsigned int infop;
+    unsigned long infop;
 
     /* RSDP address */
-    unsigned int rsdp;
+    unsigned long rsdp;
 };
 
-void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
+int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
 
 #endif /* __LIBACPI_H__ */
 
tools/libxl/Makefile +16 -1
index 3a2d64a..a148374 100644
@@ -75,7 +75,20 @@ else
 LIBXL_OBJS-y += libxl_no_colo.o
 endif
 
-LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
+ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
+ACPI_FILES = dsdt_pvh.c
+ACPI_OBJS  = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
+$(ACPI_FILES): acpi
+$(ACPI_OBJS): CFLAGS += -I. -DSTDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
+vpath build.c $(ACPI_PATH)/
+vpath static_tables.c $(ACPI_PATH)/
+LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
+
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(shell pwd)
+
+LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
 
 ifeq ($(CONFIG_NetBSD),y)
@@ -166,6 +179,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
 $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
 
 libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
+libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
 
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
@@ -308,6 +322,7 @@ clean:
 	$(RM) -f testidl.c.new testidl.c *.api-ok
 	$(RM) -f xenlight.pc
 	$(RM) -f xlutil.pc
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(shell pwd) clean
 
 distclean: clean
 	$(RM) -f xenlight.pc.in xlutil.pc.in
tools/libxl/libxl_arch.h +3 -0
index 34a853c..7c6536b 100644
@@ -62,4 +62,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
                                         uint32_t domid,
                                         struct xc_dom_image *dom);
 
+int libxl__dom_load_acpi(libxl__gc *gc,
+			 libxl_domain_build_info *info,
+			 struct xc_dom_image *dom);
 #endif
tools/libxl/libxl_dom.c +1 -0
index 3a1daae..7dbf614 100644
@@ -657,6 +657,7 @@ static int libxl__build_dom(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "xc_dom_build_image failed");
         goto out;
     }
+
     if ( (ret = xc_dom_boot_image(dom)) != 0 ) {
         LOGE(ERROR, "xc_dom_boot_image failed");
         goto out;
tools/libxl/libxl_x86.c +20 -9
index 7654e20..42f2139 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 if (libxl_defbool_val(d_config->b_info.u.hvm.apic))
+            /*
+             * HVM guests without device model may want
+             * to have LAPIC emulation.
+             */
+            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
+    } else 
         xc_config->emulation_flags = 0;
-    }
 
     return 0;
 }
@@ -366,7 +369,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
                                                libxl_domain_build_info *info,
                                                struct xc_dom_image *dom)
 {
-    return 0;
+    int ret = 0;
+
+    if ((info->type == LIBXL_DOMAIN_TYPE_HVM) &&
+        (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE)) {
+        if ( (ret = libxl__dom_load_acpi(gc, info, dom)) != 0 )
+            LOGE(ERROR, "libxl_dom_load_acpi failed");
+    }
+
+    return ret;
 }
 
 /* Return 0 on success, ERROR_* on failure. */
tools/libxl/libxl_x86_acpi.c new file +199 -0

199 lines not on this page · raw message

tools/libxl/libxl_x86_acpi.h new file +35 -0
new file mode 100644
index 0000000..17a8bd4
@@ -0,0 +1,35 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef LIBXL_X86_ACPI_H
+#define LIBXL_X86_ACPI_H
+
+#include "libxl_internal.h"
+
+#define ASSERT(x) assert(x)
+
+static inline int test_bit(unsigned int b, void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}
+
+#endif /* LIBXL_X_86_ACPI_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 22/23] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/libxl/libxl_x86_acpi.c new file +12 -0
+    if (dom->nr_vnodes) {
+        struct acpi_numa *numa = &config->numa;
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, NULL, NULL, NULL);
+	if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+

tools/libxl/libxl_x86_acpi.c line 106

Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10 -0
+        numa->vmemrange = libxl__zalloc(gc, dom->nr_vmemranges *
+                                        sizeof(*numa->vmemrange));
+        numa->vdistance = libxl__zalloc(gc, dom->nr_vnodes *
+                                         sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = libxl__zalloc(gc, config->hvminfo->nr_vcpus *
+                                             sizeof(*numa->vcpu_to_vnode));
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);

I guess that's the code portion you refer to as requiring the NUMA pointers to be to non-const? If so I have to disagree: By using local variables you can still have them have the const qualifiers, and I'd very much prefer them to be that way.

Jan

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

#56 lore raw

Re: [PATCH v2 22/23] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 04.08.16 at 23:06, <[email protected]> wrote:
tools/libxl/libxl_x86_acpi.c new file +18 -0
+    if (dom->nr_vnodes) {
+        struct acpi_numa *numa = &config->numa;
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, NULL, NULL, NULL);
+	if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+
+        numa->vmemrange = libxl__zalloc(gc, dom->nr_vmemranges *
+                                        sizeof(*numa->vmemrange));
+        numa->vdistance = libxl__zalloc(gc, dom->nr_vnodes *
+                                         sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = libxl__zalloc(gc, config->hvminfo->nr_vcpus *
+                                             sizeof(*numa->vcpu_to_vnode));
Quoted 8 lines

tools/libxl/libxl_x86_acpi.c line 106

Quoted 4 lines
tools/libxl/libxl_x86_acpi.c new file +4 -0
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);

I guess that's the code portion you refer to as requiring the NUMA pointers to be to non-const? If so I have to disagree: By using local variables you can still have them have the const qualifiers, and I'd very much prefer them to be that way.

Ah, OK, this will work. (xc_domain_getvnuma() wouldn't take constified parameters, which is what I was referring to. Haven't considered using local variables).

-boris

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

#57 lore raw

Re: [PATCH v2 22/23] libxl/acpi: Build ACPI tables for HVMlite guests

In reply to Boris Ostrovsky

On Thu, Aug 04, 2016 at 05:06:50PM -0400, Boris Ostrovsky wrote:
[...]

Quoted 20 lines

distclean: clean

tools/libxl/Makefile +0 -0
 	$(RM) -f xenlight.pc.in xlutil.pc.in
tools/libxl/libxl_arch.h +3 -0
index 34a853c..7c6536b 100644
@@ -62,4 +62,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
                                         uint32_t domid,
                                         struct xc_dom_image *dom);
 
+int libxl__dom_load_acpi(libxl__gc *gc,
+			 libxl_domain_build_info *info,
+			 struct xc_dom_image *dom);
 #endif
tools/libxl/libxl_dom.c +0 -0
index 3a1daae..7dbf614 100644

tools/libxl/libxl_dom.c static int libxl__build_dom(libxl__gc *gc, uint32_t domid, · line 660

Quoted 4 lines
tools/libxl/libxl_dom.c +1 -0
@@ -657,6 +657,7 @@ static int libxl__build_dom(libxl__gc *gc, uint32_t domid,
         LOGE(ERROR, "xc_dom_build_image failed");
         goto out;
     }
+

Stray blank line.

Quoted 19 lines
tools/libxl/libxl_dom.c +0 -0
     if ( (ret = xc_dom_boot_image(dom)) != 0 ) {
         LOGE(ERROR, "xc_dom_boot_image failed");
         goto out;
tools/libxl/libxl_x86.c +1 -7
index 7654e20..42f2139 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) {

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

Quoted 10 lines
tools/libxl/libxl_x86.c +10 -0
+        if (d_config->b_info.device_model_version !=
+            LIBXL_DEVICE_MODEL_VERSION_NONE)
+            xc_config->emulation_flags = XEN_X86_EMU_ALL;
+        else if (libxl_defbool_val(d_config->b_info.u.hvm.apic))
+            /*
+             * HVM guests without device model may want
+             * to have LAPIC emulation.
+             */
+            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
+    } else 

Please retain {} for the else branch. We recently updated the CODING_STYLE a bit.

tools/libxl/libxl_x86_acpi.c

Quoted 27 lines
tools/libxl/libxl_x86.c +9 -2
         xc_config->emulation_flags = 0;
-    }
 
     return 0;
 }
@@ -366,7 +369,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
                                                libxl_domain_build_info *info,
                                                struct xc_dom_image *dom)
 {
-    return 0;
+    int ret = 0;
+
+    if ((info->type == LIBXL_DOMAIN_TYPE_HVM) &&
+        (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE)) {
+        if ( (ret = libxl__dom_load_acpi(gc, info, dom)) != 0 )
+            LOGE(ERROR, "libxl_dom_load_acpi failed");
+    }
+
+    return ret;
 }
 
 /* Return 0 on success, ERROR_* on failure. */
tools/libxl/libxl_x86_acpi.c new file +0 -0
new file mode 100644
index 0000000..88e69e2

I only skimmed this file. I think it's mostly code movement and believe the bug here should be easy to fix.

Quoted 43 lines
tools/libxl/libxl_x86_acpi.c new file +42 -0
@@ -0,0 +1,199 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "libxl_internal.h"
+#include "libxl_arch.h"
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/e820.h>
+#include "libacpi/libacpi.h"
+
+#include <xc_dom.h>
+
+ /* Number of pages holding ACPI tables */
+#define NUM_ACPI_PAGES 16
+/* Store RSDP in the last 64 bytes of BIOS RO memory */
+#define RSDP_ADDRESS (0x100000 - 64)
+#define ACPI_INFO_PHYSICAL_ADDRESS 0xfc000000
+
+extern const unsigned char dsdt_pvh[];
+extern const unsigned int dsdt_pvh_len;
+
+/* Assumes contiguous physical space */
+static unsigned long virt_to_phys(struct acpi_ctxt *ctxt, void *v)
+{
+    return (((unsigned long)v - ctxt->alloc_base_vaddr) +
+            ctxt->alloc_base_paddr);
+}
+
+static void *mem_alloc(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align)
+{
+    unsigned long s, e;
+

tools/libxl/libxl_x86_acpi.c line 52

Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10 -0
+    /* Align to at least 16 bytes. */
+    if (align < 16)
+        align = 16;
+
+    s = (ctxt->alloc_currp + align) & ~((unsigned long)align - 1);
+    e = s + size - 1;
+
+    /* TODO: Reallocate memory */
+    if ((e < s) || (e >= ctxt->alloc_end)) return NULL;
+

Please put return NULL on a new line.

Quoted 33 lines
tools/libxl/libxl_x86_acpi.c new file +33 -0
+    while (ctxt->alloc_currp >> ctxt->page_shift != 
+           e >> ctxt->page_shift)
+        ctxt->alloc_currp += ctxt->page_size;
+
+    ctxt->alloc_currp = e;
+
+    return (void *)s;
+}
+
+static int init_acpi_config(libxl__gc *gc, 
+                            struct xc_dom_image *dom,
+                            libxl_domain_build_info *b_info,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_pvh;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_pvh_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if (rc < 0) {
+        LOG(ERROR, "%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->hvminfo = libxl__zalloc(gc, sizeof(*config->hvminfo));
+
+    config->hvminfo->apic_mode = libxl_defbool_val(b_info->u.hvm.apic);
+
+    if (dom->nr_vnodes) {

tools/libxl/libxl_x86_acpi.c line 95

Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10 -0
+        struct acpi_numa *numa = &config->numa;
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, NULL, NULL, NULL);
+	if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }

Indentation.

Quoted 19 lines
tools/libxl/libxl_x86_acpi.c new file +19 -0
+
+        numa->vmemrange = libxl__zalloc(gc, dom->nr_vmemranges *
+                                        sizeof(*numa->vmemrange));
+        numa->vdistance = libxl__zalloc(gc, dom->nr_vnodes *
+                                         sizeof(*numa->vdistance));
+        numa->vcpu_to_vnode = libxl__zalloc(gc, config->hvminfo->nr_vcpus *
+                                             sizeof(*numa->vcpu_to_vnode));
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, numa->vmemrange,
+                                numa->vdistance, numa->vcpu_to_vnode);
+	if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+    }
+    else
+        config->hvminfo->nr_vcpus = info.max_vcpu_id + 1;

tools/libxl/libxl_x86_acpi.c line 124

Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10 -0
+
+    for (i=0; i<config->hvminfo->nr_vcpus; i++)
+        config->hvminfo->vcpu_online[i / 8] |= 1 << (i & 7);
+
+    return 0;
+}
+
+int libxl__dom_load_acpi(libxl__gc *gc,
+ 			  libxl_domain_build_info *info,
+			  struct xc_dom_image *dom)

Indentation.

And please constify stuff that don't get changed -- info.

Wei.

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

#58 lore raw

Re: [PATCH v2 22/23] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 8 lines · Wei Liu

tools/libxl/libxl_x86_acpi.c

Quoted 6 lines
tools/libxl/libxl_x86_acpi.c new file +0 -0
new file mode 100644
index 0000000..88e69e2

I only skimmed this file. I think it's mostly code movement and believe the bug here should be easy to fix.

This is actually all new code. If you mean that it's code movement relative to previous version of this series then yes, kind of --- some code has been moved to the next patch. But there were some non-trivial changes as part of the split.

-boris

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

#59 lore raw

PATCH v2 23/23 libxc/xc_dom_core: Copy ACPI tables to guest space

In reply to Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +92 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %lx\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+
+        num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
+                       XC_PAGE_SHIFT;
+        extents = malloc(num_pages * sizeof(*extents));
+        if ( !extents )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            goto err;
+        }
+
+        base = dom->acpi_modules[i].guest_addr_out >> XC_PAGE_SHIFT;
+        for (j=0; j<num_pages; j++)
+            extents[j] = base + j;
+        if ( populate_acpi_pages(dom, extents, num_pages) )
+        {
+            DOMPRINTF("%s: Can populate ACPI pages", __FUNCTION__);
+            goto err;
+        }
+
+        ptr = xc_map_foreign_range(dom->xch, dom->guest_domid,
+                                      XC_PAGE_SIZE * num_pages,
+                                      PROT_READ | PROT_WRITE, base);
+        if ( !ptr )
+        {
+            DOMPRINTF("%s: Can't map %d pages at 0x%lx",
+                      __FUNCTION__, num_pages, base);
+            goto err;
+        }
+
+        memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+
+        free(extents);
+        i++;
+    }
+
+    return 0;
+
+err:
+    free(extents);
+    return -1;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;
@@ -1097,6 +1185,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
+    /* load ACPI tables */
+    if ( xc_dom_load_acpi(dom) != 0 )
+        goto err;
+
     /* allocate other pages */
     if ( !dom->arch_hooks->p2m_base_supported ||
          dom->parms.p2m_base >= dom->parms.virt_base ||
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 17 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +0 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1051

Quoted 10 lines
tools/libxc/xc_dom_core.c +9 -0
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+

Maybe eliminate these magic numbers?

Quoted 28 lines
tools/libxc/xc_dom_core.c +28 -0
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1089

Quoted 10 lines
tools/libxc/xc_dom_core.c +10 -0
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %lx\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+

AIUI this would spam console. Maybe use DPRINTF here?

Wei.

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

#61 lore raw

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 19 lines · Wei Liu
Quoted 18 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +0 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
Quoted 10 lines

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1051

Quoted 9 lines
tools/libxc/xc_dom_core.c +9 -0
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+

Maybe eliminate these magic numbers?

Well, at least 12 was supposed to be PAGE_SHIFT.

Quoted 32 lines
Quoted 32 lines
tools/libxc/xc_dom_core.c +31 -0
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
Quoted 8 lines

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1089

Quoted 7 lines
tools/libxc/xc_dom_core.c +7 -0
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %lx\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+

AIUI this would spam console. Maybe use DPRINTF here?

I was following (what I thought was) xc_dom_core.c's convention --- everyone seems to be using DOMPRINTF. I don't think there is any danger to the console: MAX_ACPI_MODULES is 4. In fact, I can change this to a 'for' loop.

-boris

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

#62 lore raw

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 30 lines · Boris Ostrovsky
Quoted 19 lines · Wei Liu
Quoted 18 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +0 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
Quoted 10 lines

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1051

Quoted 9 lines
tools/libxc/xc_dom_core.c +9 -0
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+

Maybe eliminate these magic numbers?

Quoted 1 line

Well, at least 12 was supposed to be PAGE_SHIFT.

looks like this should be s/idx/pfn/g and (GB(4) >> PAGE_SHIFT)

~Andrew

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

#63 lore raw

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 31 lines · Andrew Cooper
Quoted 30 lines · Boris Ostrovsky
Quoted 29 lines · Wei Liu
Quoted 17 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +0 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1051

Quoted 10 lines
tools/libxc/xc_dom_core.c +9 -0
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+

Maybe eliminate these magic numbers?

Quoted 2 lines
Quoted 1 line

Well, at least 12 was supposed to be PAGE_SHIFT.

looks like this should be s/idx/pfn/g

I used idx because the value ends up in xen_add_to_physmap.idx (by way of xc_domain_add_to_physmap(..., idx, ..).

Quoted 1 line

and (GB(4) >> PAGE_SHIFT)

Yes.

-boris

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

#64 lore raw

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

In reply to Boris Ostrovsky

Hi Boris

Quoted 110 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +88 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %lx\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+
+        num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
+                       XC_PAGE_SHIFT;
+        extents = malloc(num_pages * sizeof(*extents));
+        if ( !extents )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            goto err;
+        }
+
+        base = dom->acpi_modules[i].guest_addr_out >> XC_PAGE_SHIFT;
+        for (j=0; j<num_pages; j++)
+            extents[j] = base + j;
+        if ( populate_acpi_pages(dom, extents, num_pages) )
+        {
+            DOMPRINTF("%s: Can populate ACPI pages", __FUNCTION__);
+            goto err;
+        }
+
+        ptr = xc_map_foreign_range(dom->xch, dom->guest_domid,
+                                      XC_PAGE_SIZE * num_pages,
+                                      PROT_READ | PROT_WRITE, base);
+        if ( !ptr )
+        {
+            DOMPRINTF("%s: Can't map %d pages at 0x%lx",
+                      __FUNCTION__, num_pages, base);
+            goto err;
+        }
+
+        memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+
+        free(extents);
+        i++;
+    }
+
+    return 0;
+
+err:
+    free(extents);
+    return -1;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;

tools/libxc/xc_dom_core.c int xc_dom_build_image(struct xc_dom_image *dom) · line 1190

Quoted 6 lines
tools/libxc/xc_dom_core.c +3 -0
@@ -1097,6 +1185,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
+    /* load ACPI tables */
+    if ( xc_dom_load_acpi(dom) != 0 )
+        goto err;

I think it needs to move the definition of xc_dom_load_acpi() to xc_dom_x86.c while I will move the corresponding one of ARM to xc_dom_arm.c.

Thanks,

Signature · 7 lines
Shannon


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

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 116 lines · Shannon Zhao

Hi Boris

Quoted 113 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +88 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %lx\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+
+        num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
+                       XC_PAGE_SHIFT;
+        extents = malloc(num_pages * sizeof(*extents));
+        if ( !extents )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            goto err;
+        }
+
+        base = dom->acpi_modules[i].guest_addr_out >> XC_PAGE_SHIFT;
+        for (j=0; j<num_pages; j++)
+            extents[j] = base + j;
+        if ( populate_acpi_pages(dom, extents, num_pages) )
+        {
+            DOMPRINTF("%s: Can populate ACPI pages", __FUNCTION__);
+            goto err;
+        }
+
+        ptr = xc_map_foreign_range(dom->xch, dom->guest_domid,
+                                      XC_PAGE_SIZE * num_pages,
+                                      PROT_READ | PROT_WRITE, base);
+        if ( !ptr )
+        {
+            DOMPRINTF("%s: Can't map %d pages at 0x%lx",
+                      __FUNCTION__, num_pages, base);
+            goto err;
+        }
+
+        memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+
+        free(extents);
+        i++;
+    }
+
+    return 0;
+
+err:
+    free(extents);
+    return -1;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;
@@ -1097,6 +1185,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
Quoted 5 lines

tools/libxc/xc_dom_core.c int xc_dom_build_image(struct xc_dom_image *dom) · line 1190

Quoted 3 lines
tools/libxc/xc_dom_core.c +3 -0
+    /* load ACPI tables */
+    if ( xc_dom_load_acpi(dom) != 0 )
+        goto err;

I think it needs to move the definition of xc_dom_load_acpi() to xc_dom_x86.c while I will move the corresponding one of ARM to xc_dom_arm.c.

You don't think both x86 and ARM can use the same definition? This looks very similar to what you had in your series.

-boris

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

#66 lore raw

Re: [PATCH v2 23/23] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 124 lines · Boris Ostrovsky
Quoted 116 lines · Shannon Zhao

Hi Boris

Quoted 113 lines · Boris Ostrovsky

Load ACPI modules into guest space

---
v2:
* New patch, loosely based on Shannon's ARM patch

 tools/libxc/xc_dom_core.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tools/libxc/xc_dom_core.c +88 -0
index ebada89..00d870f 100644
@@ -1040,6 +1040,94 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx, first_high_idx = (1ull << (32 - 12));
+
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %lx\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+
+        num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
+                       XC_PAGE_SHIFT;
+        extents = malloc(num_pages * sizeof(*extents));
+        if ( !extents )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            goto err;
+        }
+
+        base = dom->acpi_modules[i].guest_addr_out >> XC_PAGE_SHIFT;
+        for (j=0; j<num_pages; j++)
+            extents[j] = base + j;
+        if ( populate_acpi_pages(dom, extents, num_pages) )
+        {
+            DOMPRINTF("%s: Can populate ACPI pages", __FUNCTION__);
+            goto err;
+        }
+
+        ptr = xc_map_foreign_range(dom->xch, dom->guest_domid,
+                                      XC_PAGE_SIZE * num_pages,
+                                      PROT_READ | PROT_WRITE, base);
+        if ( !ptr )
+        {
+            DOMPRINTF("%s: Can't map %d pages at 0x%lx",
+                      __FUNCTION__, num_pages, base);
+            goto err;
+        }
+
+        memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+
+        free(extents);
+        i++;
+    }
+
+    return 0;
+
+err:
+    free(extents);
+    return -1;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;
@@ -1097,6 +1185,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
Quoted 5 lines

tools/libxc/xc_dom_core.c int xc_dom_build_image(struct xc_dom_image *dom) · line 1190

Quoted 3 lines
tools/libxc/xc_dom_core.c +3 -0
+    /* load ACPI tables */
+    if ( xc_dom_load_acpi(dom) != 0 )
+        goto err;

I think it needs to move the definition of xc_dom_load_acpi() to xc_dom_x86.c while I will move the corresponding one of ARM to xc_dom_arm.c.

Quoted 3 lines

You don't think both x86 and ARM can use the same definition? This looks very similar to what you had in your series.

So I have to use dom->acpi_modules[i] in my series instead of dom->acpitable_blob. I think it's fine to reuse what x86 uses.

Thanks,

Signature · 7 lines
Shannon


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#67 lore raw
In reply to Boris Ostrovsky
Quoted 9 lines · Boris Ostrovsky

The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.

This version is built on top of Anthony's
git://xenbits.xen.org/people/aperard/xen-unstable.git:hvmloader-with-separated-bios-v7

It also requires (still not fully ACKed, sigh) ACPI relicensing patch
https://lists.xenproject.org/archives/html/xen-devel/2016-07/msg01975.html

Hi Boris,
Is there a git repo from which I cloud fetch this series? I didn't find them in https://oss.oracle.com/git/?p=bostrovs/xen.git;a=summary

Thanks,

Signature · 7 lines
Shannon


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#68 lore raw
Quoted 8 lines · Shannon Zhao
Quoted 6 lines · Boris Ostrovsky

The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.

This version is built on top of Anthony's
git://xenbits.xen.org/people/aperard/xen-unstable.git:hvmloader-with-separated-bios-v7

Quoted 6 lines
Quoted 3 lines

It also requires (still not fully ACKed, sigh) ACPI relicensing patch
https://lists.xenproject.org/archives/html/xen-devel/2016-07/msg01975.html

Hi Boris,
Is there a git repo from which I cloud fetch this series? I didn't find them in https://oss.oracle.com/git/?p=bostrovs/xen.git;a=summary

I am having trouble pulling Anthony's branch for some reason (I need it before pushing my patches). I'll try to see what's going on but not sure I'll be able to resolve it before I leave for vacation tomorrow. I can resend patches to you directly if that helps.

-boris

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