tools: update to seabios rel-1.7.5

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen: arm: dump vcpu gic info in arch_dump_vcpu_info

Instead of looping over vcpus in arch_dump_domain_info

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
tools/libxc: pull min/max_t into xc_private.h

There are generally useful.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools: arm: allocate large pages to guests.

Tries to allocate as many large (1G or 2M) pages as it can to the guest and tries
to align to the next larger size on each attempt so that we can attempt to
allocate even larger pages on the next iteration (this is currently only
exercised via a compile time debug option, which is left in place under a #if
0).

Since ARM page tables are consistent at each level there is a common helper
function which tries to allocate a levels worth of pages. The exception to this
consistency is level 0 which does not support table mappings (0.5TB
superpages!).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen: arm: only put_page for p2m operations which require it.

In particular do not do it for CACHEFLUSH.

INSERT, RELINQUISH and REMOVE should all put the page (if the current pte is
valid). ALLOCATE doesn't need to since it asserts the current PTE must be
invalid.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: handle superpage mappings in p2m_lookup

Currently none are actually created, but they will be shortly.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: add some helpers for assessing p2m pte

Not terribly helpful right now, since they aren't widely used, but makes future
patches easier to read.

p2m_mapping is unused for the time-being and is therefore commented out
(otherwise the compiler complains about an unused function).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
tools/xenctx: Correct use of xc_domain_{, un}pause()

The previous code never worked correctly.  There was a TOCTOU race between
checking dominfo and pausing the domain.

Since c/s 3eb1c708, Xen properly reference counts pause hypercalls, so
unconditionally pause and unpause the domain.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: Don't save/restore context for idle VCPU

When an idle VCPU is running, Xen will never exit the hypervisor mode.
Futhermore, some part of the VCPU/domain initialization is already skipped for
them to avoid memory consumption.

Actually each save/restore functions are checking themself if the vcpu is
an idle one or not. We can safely skipped the context switch in one place
and gain a bit of time when we {,un}schedule idle VCPU. This is because
the saving part will take care of disabling anything related to guest (such
as GICv).

Also replace every check of and idle VCPU in save/restore functions by an
ASSERT, to know if someone is calling them with an idle VCPU in argument.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen: Install arch-arm directory headers

Some headers for ARM are not installed on the host. This may make external
software relying on Xen headers failed to compile on ARM.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/python: Improve .gitignore and clean Makefile rule

Ignore all intermediate python files, and use find in the clean rule as there
are no Makefiles in subdirectories to participate in a recursive clean.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: Some clean up in time.c

The file xen/arm/time.c contains some unused code:
    - calibrate_timer: firmware already set correctly CNTFRQ. If it's
    not the case the device tree will containt a property clock-frequency
    in the timer node
    - USE_HYP_TIMER: It's set unconditionally to 1. I didn't see any
    recent model having issue with the hyp timer. I think we can drop
    it safely.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: introduce PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI

GICH_LR_HW doesn't work as expected on X-Gene: request maintenance
interrupts and perform EOIs in the hypervisor for hardware interrupts as
a workaround.  Trigger this behaviour with a per platform option.

This patch assumes that GICC_DIR can be written on any pcpu for a given
SPI, not matter where GICC_IAR has been read before.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
CC: psawargaonkar@apm.com
CC: apatel@apm.com
libxl_internal: functions to check default values for builtin types

They will be used in later patch to determine whether we should generate
JSON output for a type. If that type has default value we just skip
generating JSON output.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxl/gentypes.py: don't generate default values

If a field:
    0. is not of aggregate type
and
    1. is of array type and the array is not empty
or  2. is of a type which has init_val and has been set to init_val,
or  3. is of builtin type and has been set to internal default value,
or  4. is of a type which has no init_val and has been set to 0

then there's no need to generate output for that field in JSON
output.

Note that 0 can result in output like
  {
    ...
    FOO : { }
    ...
  }
where FOO is aggregate type but all its fields are set to default, hence
no JSON output in {} at all. This is not pretty, but it's still valid
JSON. And the parser should be able to skip touching those fields in the
resulting C structures. When the parser consumes that generated JSON
object, all default values should be automatically filled in.

Also change some non-zero init_vals to LIBXL_* for better readability in
generated C code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxl: clean up namespace violation

In 752f181f ("libxl_json: introduce parser functions for builtin types")
a bunch of parser functions were introduced. Unfortunately they
polluted the public namespace with a prefix "libxl_", while they should
be internal functions.

This patch changes the prefix to "libxl__". No functional change
introduced.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxl IDL: generate code to parse libxl__json_object to libxl_FOO struct

libxl_FOO_parse_json functions are generated.

Note that these functions are used to parse libxl__json_object to
libxl__FOO struct. They don't consume JSON string.

The new function definitions are generated to new header files called
__libxl_types_*_private.h so that they don't contaminate public header.
The suffix "private is chosen so we can avoid clashing with
libxl_types_internal.idl stuffs.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxl/gentest.py: test JSON parser

The test is done in following steps:

1. initialise libxl_FOO struct
2. generate JSON string A for libxl_FOO struct FOO1
3. convert JSON string A to libxl_FOO struct FOO2
4. generate JSON string B for libxl_FOO struct FOO2
5. compare A and B

If A and B are identical then we are good.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxl: copy function for builtin types

These functions will be used in later patch to deep-copy a structure.

Functions introduced:
 * libxl_string_list_copy
 * libxl_key_value_list_copy
 * libxl_hwcap_copy
 * libxl_mac_copy
 * libxl_cpuid_policy_list_copy
 * libxl_string_copy
 * libxl_bitmap_copy_alloc
 * libxl_ms_vm_genid_copy

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxl IDL: generate deep copy functions

Introduces copy_fn for a type.

For most builtin types we can use direct assignment. For those builtin
types which cannot use direct assignment we use the copy functions in
previous patch.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>