From: Jan Kiszka <[email protected]>

Expand the Jailhouse-specific setup data structure we pass to the Linux
kernel on boot by the calibrated TSC and APIC timer frequencies. Also
switch the type to a value we are going to reserve officially in the
upstream kernel, rather than using the large magic value.

Although this is a change that should normally increase the version of
the struct, we keep it untouched as we didn't release the previous
structure version yet. Specifically, there is no official kernel out
there expecting the old structure.

Signed-off-by: Jan Kiszka <[email protected]>
---
 inmates/tools/x86/linux-loader.c | 8 ++++++--
 tools/jailhouse-cell-linux       | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/inmates/tools/x86/linux-loader.c b/inmates/tools/x86/linux-loader.c
index b621b076..cca6056b 100644
--- a/inmates/tools/x86/linux-loader.c
+++ b/inmates/tools/x86/linux-loader.c
@@ -21,7 +21,7 @@ struct boot_params {
        u64     setup_data;
        u8      padding3[8];
        u32     init_size;
-};
+} __attribute__((packed));
 
 struct setup_data {
        u64     next;
@@ -32,9 +32,11 @@ struct setup_data {
        u16     pm_timer_address;
        u16     num_cpus;
        u64     pci_mmconfig_base;
+       u32     tsc_khz;
+       u32     apic_khz;
        u8      standard_ioapic;
        u8      cpu_ids[SMP_MAX_CPUS];
-};
+} __attribute__((packed));
 
 void inmate_main(void)
 {
@@ -50,6 +52,8 @@ void inmate_main(void)
        setup_data = (struct setup_data *)boot_params->setup_data;
        setup_data->pm_timer_address = comm_region->pm_timer_address;
        setup_data->pci_mmconfig_base = comm_region->pci_mmconfig_base;
+       setup_data->tsc_khz = comm_region->tsc_khz;
+       setup_data->apic_khz = comm_region->apic_khz;
        setup_data->num_cpus = comm_region->num_cpus;
 
        smp_wait_for_all_cpus();
diff --git a/tools/jailhouse-cell-linux b/tools/jailhouse-cell-linux
index e693bd02..086d5982 100755
--- a/tools/jailhouse-cell-linux
+++ b/tools/jailhouse-cell-linux
@@ -718,13 +718,14 @@ class JailhouseCell:
 
 
 def x86_gen_setup_data(config):
+    SETUP_TYPE_JAILHOUSE = 6
     MAX_CPUS = 255
     SETUP_DATA_VERSION = 1
     standard_ioapic = 0
     for irqchip in config.irqchips:
         if irqchip.is_standard():
             standard_ioapic = 1
-    return struct.pack('8x4sIHH12xB', b'JLHS', 17 + MAX_CPUS,
+    return struct.pack('8xIIHH12x8xB', SETUP_TYPE_JAILHOUSE, 25 + MAX_CPUS,
                        SETUP_DATA_VERSION, SETUP_DATA_VERSION,
                        standard_ioapic) + \
         bytearray(MAX_CPUS)
-- 
2.12.3

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to