tools: config-create: drop line numbers in parse_iomem_tree()

Previously we defined the children of a MemRegion-Tree as set. This
caused the order of the children to be undefined as soon as they got
added to this structure. But the using function of parse_iomem_tree()
wanted the list of regions returned to be sorted like in the file, so we
had to maintain a separate list of line numbers.

By changing the set to a list, the order is always maintained and
because parse_iomem_tree() only adds to his private regions-list and
never inserts or reorders, this private structure will also always have
the same order as in the file. With this we can remove the
line numbers list. This structure was never use for anything else, so it
will make the code more readable.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Reviewed-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools: config-create: exclude kernel-area from mem-allocation

When allocating memory for jailhouse, we currently don't look at where
the kernel lives on the system. In case our `memmap` overlaps with this
area, the kernel will just ignore the kernel-cmd-option and out generated
configuration will be invalid.

To fix this, the script now looks out for any kernel-region while
parsing the tree from /proc/iomem and splits the parent-region on the
kernels boundaries. This region will then not be considered anymore and
could additionally be handled special in other cases in the future. The
config will contain it as extra memory-region with all rights.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Reviewed-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools: config-create: drop line numbers from IOMemRegionTree object

The line numbers are not used anymore, so drop the code dealing with
them.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools: Detect HPET also in case of deeper nesting

Do not stop searching for the HPET on the first level of a reserved
region, it may hide deeper inside. Seen on an AMD-G series evaluation
system:

  fed00000-fed00fff : reserved
    fed00000-fed00fff : pnp 00:10
      fed00000-fed003ff : HPET 0

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Break up PERCPU_SIZE_SHIFT

Rename PERCPU_SIZE_SHIFT to PERCPU_SIZE_SHIFT_ASM, the currently
still manually defined version of this constant. PERCPU_SIZE_SHIFT is
now defined via a C expression and can thus only be used outside
assembler code.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Introduce FIELD_SIZEOF

Will be used for asm-defines soon.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Add asm-defines.h generation

Adapted Linux kernel tools to generate asm-offset.h for Jailhouse.
This is meant to generate common defines (C structure member offsets
and other compile-time expressions) in a way accessible from the
assembly code.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: moved to include/generated, added copyright headers, fix typo]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Use asm-defines.h for struct per_cpu members

PERCPU_* defines are now generated from C sources rather than being
hard-coded, which makes the code less fragile. CHECK_ASSUMPTION
infrastructure is now gone.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: remove split-up of percpu.h, use FIELD_SIZEOF]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>