]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/log
people/andrewcoop/xen-test-framework.git
7 months agoIntroduce addr_t for linear addresses in hardware registers/datastructrues devel-misc
Andrew Cooper [Mon, 13 May 2019 10:26:22 +0000 (10:26 +0000)]
Introduce addr_t for linear addresses in hardware registers/datastructrues

Update write_dr[0-3]() to use the new functionality, and drop the casts at the
callsites.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 months agoXTF: Use fastcall by default for 32bit devel
Andrew Cooper [Fri, 13 Sep 2024 14:41:46 +0000 (15:41 +0100)]
XTF: Use fastcall by default for 32bit

This passes up to 3 parameters in registers, rather than on the stack.  Most
transformations are easy.

The exec_user() infrastructure took two parameters on the stack and used an
ad-hoc %eax/%ecx arrangement with %edx as a scratch register. Fastcall uses
%eax/%edx, so switch the scratch regsiter to %ecx instead.

memop-seg was already using %eax, and needs a bit of care now that addr isn't
on the stack.  However, it does remove the need for stack_adj which simplifies
the result.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 months agomemop-seg: Have %fs/%gs loaded unconditionally
Andrew Cooper [Fri, 13 Sep 2024 16:25:30 +0000 (17:25 +0100)]
memop-seg: Have %fs/%gs loaded unconditionally

There are a lot of testcase steps; it's safe and faster.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 months agoselftest: Fix test_unhandled_exception_hook()
Andrew Cooper [Fri, 13 Sep 2024 14:52:45 +0000 (15:52 +0100)]
selftest: Fix test_unhandled_exception_hook()

When the hook was replaced with a week function, selftest's
do_unhandled_exception() became active for all unhandled exceptions, not just
the one under test.

Re-limit it to only test_unhandled_exception_hook().

Fixes: 7c575dc9c353 ("Simplify the unhandled_exception handling for tests")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 months agoCI: Update FreeBSD 13 to 13.3
Andrew Cooper [Fri, 30 Aug 2024 18:30:15 +0000 (19:30 +0100)]
CI: Update FreeBSD 13 to 13.3

13.2 is no longer available.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 months agoCI: Drop GCC-13
Andrew Cooper [Fri, 30 Aug 2024 18:20:31 +0000 (19:20 +0100)]
CI: Drop GCC-13

It seems to be missing in action in the ubuntu-22.04 container now.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 months agoCI: Reduce the CodeQL schedule from weekly to monthly
Andrew Cooper [Fri, 30 Aug 2024 18:26:59 +0000 (19:26 +0100)]
CI: Reduce the CodeQL schedule from weekly to monthly

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 months agoxtf-runner: Spelling fix
Bernhard Kaindl [Fri, 6 Jan 2023 11:00:00 +0000 (12:00 +0100)]
xtf-runner: Spelling fix

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 months agobuild: Use `command -v` in preference to `which`
Andrew Cooper [Sun, 25 Feb 2024 18:00:45 +0000 (18:00 +0000)]
build: Use `command -v` in preference to `which`

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 months agoXSA-454 PoC
Manuel Andreas [Thu, 11 Apr 2024 15:58:51 +0000 (16:58 +0100)]
XSA-454 PoC

Original PoC from Manuel.  Adjusted to XTF norms by myself.

Signed-off-by: Manuel Andreas <manuel.andreas@tum.de>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 months agoSwitch to python3 shebangs
Andrew Cooper [Wed, 24 Jul 2024 17:33:13 +0000 (18:33 +0100)]
Switch to python3 shebangs

This is a better default for an average dev environment these days.  Anyone
stuck with python 2 and just run `python ./xtf-runner` manually and take the
hint that they should upgrade.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoXTF: Drop test_wants_user_mappings
Andrew Cooper [Sat, 2 Mar 2024 22:54:27 +0000 (22:54 +0000)]
XTF: Drop test_wants_user_mappings

This was a giant bodge around several bugs in Xen, all of which have been
fixed since Xen 4.8, and around XTF deficiences, now fixed with __text_user.

Xen 4.8 is a perfectly old enough minimum baseline now.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoXTF: Drop exlog
Andrew Cooper [Sat, 2 Mar 2024 23:01:58 +0000 (23:01 +0000)]
XTF: Drop exlog

This was the original exception tracking infrastructure, but
exinfo_t/ex_record is far more convenient for tests to use.

The selftest already had a non-handler form extable.  Update
test_NULL_unmapped() to use the handler form, and drop test_exlog().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-swint: Update to avoid using test_wants_user_mappings
Andrew Cooper [Sat, 2 Mar 2024 22:49:49 +0000 (22:49 +0000)]
test-swint: Update to avoid using test_wants_user_mappings

Create a second set stubs, and place them in .text.user.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-swint: Update to use ex_record rather than exlog
Andrew Cooper [Sat, 2 Mar 2024 21:14:54 +0000 (21:14 +0000)]
test-swint: Update to use ex_record rather than exlog

This is both more precise and consice.

As this test pertains to mixing up faults and traps, introduce EXINFO_TRAP and
ex_record_trap_eax() to distinguish which EXTABLE entry was used.  This in
turn means we don't need to export the trap/fault labels to C.

Change the nomeclature for instruction prefixes, because "red" is fairly
meaningless and confusing in context.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-swint: Update to use exinfo_t
Andrew Cooper [Sat, 2 Mar 2024 13:39:04 +0000 (13:39 +0000)]
test-swint: Update to use exinfo_t

This is a more consise way of passing vector/error information around.

As cleanup:
 * Introduce enum mode to remove the global boolean
 * Introduce COND to avoid ifdefary
 * Rename struct sequence to struct insn

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-pv-iopl: Update to avoid using test_wants_user_mappings
Andrew Cooper [Sat, 2 Mar 2024 01:41:28 +0000 (01:41 +0000)]
test-pv-iopl: Update to avoid using test_wants_user_mappings

Create a second set stubs, and place them in .text.user.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-pv-iopl: Update to using exinto_t rather than exlog
Andrew Cooper [Sat, 2 Mar 2024 01:48:48 +0000 (01:48 +0000)]
test-pv-iopl: Update to using exinto_t rather than exlog

This is both more precise and concise.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-pv-iopl: Misc improvements
Andrew Cooper [Sat, 2 Mar 2024 01:34:40 +0000 (01:34 +0000)]
test-pv-iopl: Misc improvements

Introduce enum KERN/USER to replace bool user.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-umip: Update to avoid using test_wants_user_mappings
Andrew Cooper [Fri, 1 Mar 2024 21:20:43 +0000 (21:20 +0000)]
test-umip: Update to avoid using test_wants_user_mappings

Create a second set stubs, and place them in .text.user.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-umip: Misc improvements, mostly for 32bit
Andrew Cooper [Fri, 1 Mar 2024 21:41:45 +0000 (21:41 +0000)]
test-umip: Misc improvements, mostly for 32bit

 * Record the fault in %eax to avoid forcing a spill of %edi
 * Use testb $1 so %[fep] can be a memory operand referencing the parameter
   directly on the stack.
 * Render UMIP and FEP in the failure message.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-cpuid-faulting: Update to avoid using test_wants_user_mappings
Andrew Cooper [Sat, 2 Mar 2024 02:28:45 +0000 (02:28 +0000)]
test-cpuid-faulting: Update to avoid using test_wants_user_mappings

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agotest-nmi-ts-priv: Update to avoid using test_wants_user_mappings
Andrew Cooper [Fri, 1 Mar 2024 21:07:13 +0000 (21:07 +0000)]
test-nmi-ts-priv: Update to avoid using test_wants_user_mappings

user_inject_nmi() was already __user_text.  The only other thing needing
fixing is the mapping of the APIC MMIO window, so do that explicitly.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoxsa-170/196: Update to avoid using test_wants_user_mappings
Andrew Cooper [Fri, 1 Mar 2024 20:52:15 +0000 (20:52 +0000)]
xsa-170/196: Update to avoid using test_wants_user_mappings

The capability is going away.  Move stubs into .text.user.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoxsa-204: Update to use exinfo_t and avoid test_wants_user_mappings
Andrew Cooper [Sat, 2 Mar 2024 00:01:24 +0000 (00:01 +0000)]
xsa-204: Update to use exinfo_t and avoid test_wants_user_mappings

exinfo_t is a newer and more precise capability.  test_wants_user_mappings is
going away.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoBump copyright year
Andrew Cooper [Sun, 3 Mar 2024 00:00:37 +0000 (00:00 +0000)]
Bump copyright year

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoCI: Bump action versions
Andrew Cooper [Wed, 28 Feb 2024 17:38:16 +0000 (17:38 +0000)]
CI: Bump action versions

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
14 months agoXSA-451 PoC
Andrew Cooper [Wed, 21 Feb 2024 16:59:29 +0000 (16:59 +0000)]
XSA-451 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoFix some typos in comments
Frediano Ziglio [Thu, 1 Feb 2024 14:59:43 +0000 (14:59 +0000)]
Fix some typos in comments

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoCI: Add Cirrus-CI FreeBSD testing
Andrew Cooper [Sat, 13 Jan 2024 13:29:24 +0000 (13:29 +0000)]
CI: Add Cirrus-CI FreeBSD testing

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoDocs: Mention the bintuils 2.41 regression and point at the fix
Andrew Cooper [Sat, 13 Jan 2024 13:21:28 +0000 (13:21 +0000)]
Docs: Mention the bintuils 2.41 regression and point at the fix

Update the other git short hashes to be 12 chars too.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoXSA-296: Don't rely on PV-L1TF side effects
Andrew Cooper [Tue, 9 Jan 2024 20:51:18 +0000 (20:51 +0000)]
XSA-296: Don't rely on PV-L1TF side effects

When CONFIG_SHADOW_PAGING is compiled out, PV-L1TF defaults to domain_crash()
on vulnerable hardware.  While this has technically demonstrated that Xen
isn't vulnerable to XSA-296, it's an unclean exit.

The pv64 case can already spot and correct the race condition, while the
pv32pae test is no different to running on non-L1TF vulnerable hardware
already.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agobuild: Express XSA-168/173 as single-variation tests
Andrew Cooper [Tue, 9 Jan 2024 20:08:56 +0000 (20:08 +0000)]
build: Express XSA-168/173 as single-variation tests

This allows xtf-runner to check for the presence of shadow before running
them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Use virt caps to identify whether a test can run
Andrew Cooper [Tue, 9 Jan 2024 11:59:14 +0000 (11:59 +0000)]
runner: Use virt caps to identify whether a test can run

Right now, --host filters a test selection using xen_caps to exclude full
environments.  Furthermore, without passing --host, xtf-runner will try to
start a test even when we know it can't be constructed, leaving an xl error to
the user and reporting CRASH.

The virt capabilities are more fine grained, and include other information
such as the availability of hap and shadow paging.

Split run_test() out of run_tests() and use the test's required caps to short
circuit to SKIP.

Rework the existing --host filtering in terms of virt caps, which simplifies
the invocation of tests_from_selection().

This causes ~hap and ~shadow variation tests to SKIP rather than CRASH when
run on hardware without HAP (or with HAP disabled in firmware), or with Shadow
compiled out.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Collect the host virt capabilities
Andrew Cooper [Tue, 9 Jan 2024 11:09:07 +0000 (11:09 +0000)]
runner: Collect the host virt capabilities

Use the test environment and variation to calculate a set of required virt
capabilities.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoCI: Use reorder-python-imports
Andrew Cooper [Mon, 8 Jan 2024 14:35:39 +0000 (14:35 +0000)]
CI: Use reorder-python-imports

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Misc pylint fixups
Andrew Cooper [Mon, 8 Jan 2024 13:48:40 +0000 (13:48 +0000)]
runner: Misc pylint fixups

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Use context managers to simplify get_all_test_info()
Andrew Cooper [Fri, 5 Jan 2024 20:15:49 +0000 (20:15 +0000)]
runner: Use context managers to simplify get_all_test_info()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: More extensive Python 3 universal_newline fixes
Andrew Cooper [Fri, 5 Jan 2024 21:48:39 +0000 (21:48 +0000)]
runner: More extensive Python 3 universal_newline fixes

When pv32pae is disabled e.g. due to CET being active, under Python 3, we
still get:

  Executing 'xl create -p tests/example/test-pv32pae-example.cfg'
  b'Parsing config from tests/example/test-pv32pae-example.cfg\nlibxl: error: ...\n'
  Error: Failed to create VM

out, rather than `xl create`'s stdout/stderr rendered nicely.

All subprocess invocations we make will want universal_newlines, so wrap the
functions to have it active by default, but still allow it to be explicitly
turned off by passing universal_newlines = None.

Reinstate the use of check_output() now that we've upped the minimum python
version to 2.7.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Use set-literal notation
Andrew Cooper [Fri, 5 Jan 2024 21:47:35 +0000 (21:47 +0000)]
runner: Use set-literal notation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agobuild: Don't force mkinfo/mkcfg
Andrew Cooper [Wed, 3 Jan 2024 21:49:21 +0000 (21:49 +0000)]
build: Don't force mkinfo/mkcfg

Instead, depend on Makefile.  This reduces the incremental rebuild time from
~5s down to ~1s.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoRevert "CI: Run CodeQL in main repo only"
Andrew Cooper [Mon, 8 Jan 2024 14:17:16 +0000 (14:17 +0000)]
Revert "CI: Run CodeQL in main repo only"

This reverts commit c35f2eda069bbcd16cb4ede094001f547f311486.  It doesn't work as intended.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoCI: More pre-commit hooks along with fixes
Bernhard Kaindl [Fri, 5 Jan 2024 11:00:00 +0000 (12:00 +0100)]
CI: More pre-commit hooks along with fixes

Fix executable permissions, and remove trailing whitespace.

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoCI: Add basic pre-commit integration and hook into Github Actions
Bernhard Kaindl [Fri, 5 Jan 2024 11:00:00 +0000 (12:00 +0100)]
CI: Add basic pre-commit integration and hook into Github Actions

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agoCI: Run CodeQL in main repo only
Bernhard Kaindl [Fri, 6 Jan 2023 11:00:00 +0000 (12:00 +0100)]
CI: Run CodeQL in main repo only

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Remove the use of simplejson
Andrew Cooper [Sat, 6 Jan 2024 23:51:43 +0000 (23:51 +0000)]
runner: Remove the use of simplejson

This became part of the standard library in Python 2.6

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 months agorunner: Update minimum python version to 2.7
Andrew Cooper [Fri, 5 Jan 2024 21:47:35 +0000 (21:47 +0000)]
runner: Update minimum python version to 2.7

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
16 months agoXSA-444 PoC
Andrew Cooper [Tue, 19 Sep 2023 13:01:27 +0000 (14:01 +0100)]
XSA-444 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
16 months agotests/lm-ts: Fix Doxygen syntax in description
Andrew Cooper [Thu, 28 Dec 2023 14:11:45 +0000 (14:11 +0000)]
tests/lm-ts: Fix Doxygen syntax in description

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
16 months agoDoxygen: Update to 1.9.1
Andrew Cooper [Thu, 28 Dec 2023 14:16:54 +0000 (14:16 +0000)]
Doxygen: Update to 1.9.1

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agoCI: Allow manual invocation of CodeQL
Andrew Cooper [Wed, 4 Oct 2023 12:17:17 +0000 (13:17 +0100)]
CI: Allow manual invocation of CodeQL

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agoFixes from Github Code Scanning
Andrew Cooper [Tue, 3 Oct 2023 11:55:31 +0000 (12:55 +0100)]
Fixes from Github Code Scanning

In XSA-122, "Array offset used before range check".

In traps.c "Declaration hides variable".

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agoCI: Add GCC-13
Andrew Cooper [Tue, 3 Oct 2023 10:45:43 +0000 (11:45 +0100)]
CI: Add GCC-13

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agoWork around Clang IAS error with XSA-304
Andrew Cooper [Tue, 3 Oct 2023 10:05:22 +0000 (11:05 +0100)]
Work around Clang IAS error with XSA-304

Clang complains:

  <inline asm>:1:19: error: expected assembly-time absolute expression
  .align 4096;.skip 4096 - (stub_page_boundary - stub_fn);
                    ^

Opencode the je

Links: https://github.com/llvm/llvm-project/issues/68086
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agoTest Long Mode #TS
Andrew Cooper [Tue, 12 Oct 2021 22:47:49 +0000 (23:47 +0100)]
Test Long Mode #TS

Introduce TSS_SEL and clean up nmi-taskswitch-priv to use it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agodebug-regs: Check MSR_DR_ADDR_MASK state too
Andrew Cooper [Fri, 29 Sep 2023 17:44:31 +0000 (18:44 +0100)]
debug-regs: Check MSR_DR_ADDR_MASK state too

Broken currently as PV regressed MSR_DEBUGCTL.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
20 months agoxtf-runner: python3 fix
Anthony PERARD [Thu, 17 Aug 2023 10:51:11 +0000 (11:51 +0100)]
xtf-runner: python3 fix

issue:
  File "/home/xtf/xtf-runner", line 410, in interpret_selection
    if not line.startswith("xen_caps"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Adding `universal_newlines` open stdout as text file, so line should
be a `str`. `universal_newlines` is available on python 2.7. A new
alias `text` is only available in python 3.7.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agoXSA-304 PoC
Andrew Cooper [Wed, 28 Nov 2018 18:27:02 +0000 (18:27 +0000)]
XSA-304 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agolink: Move the linker script to being common
Andrew Cooper [Wed, 4 Jan 2023 23:19:26 +0000 (23:19 +0000)]
link: Move the linker script to being common

... now that all x86-ism have been removed.  Fix some style bugs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agolink: Move x86-ism out of the linker script
Andrew Cooper [Wed, 4 Jan 2023 23:19:26 +0000 (23:19 +0000)]
link: Move x86-ism out of the linker script

... in preparation to reuse it for all architectures.  In order to keep
various parts of the linker script all together, use a multi-include file with
header and footer delineations.

While moving things, drop the alignment check for the two stacks.  Neither
need page alignment architecturally.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: Move -nostdinc from COMMON_CFLAGS to COMMON_FLAGS
Andrew Cooper [Thu, 5 Jan 2023 01:17:27 +0000 (01:17 +0000)]
build: Move -nostdinc from COMMON_CFLAGS to COMMON_FLAGS

It needs to find its way into COMMON_AFLAGS too.

Also fix a latent bug introduced at the same time.  PRIx32 is used by
PSE_PRIpte.

Fixes: 8e3394a51e08 ("Drop dependency on gcc-multilib")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agoCI: Refresh github actions
Andrew Cooper [Tue, 27 Dec 2022 19:39:15 +0000 (19:39 +0000)]
CI: Refresh github actions

Use a fixed container version when when specific compiler versions are
referenced.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: Drop -no-pie from CFLAGS
Andrew Cooper [Mon, 3 Oct 2022 11:34:17 +0000 (12:34 +0100)]
build: Drop -no-pie from CFLAGS

This is a GCC-only option which controls how GCC involves the linker, but we
don't use $(CC) for linking any more.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: silence GNU ld 2.39 warning about executable stacks
Jan Beulich [Thu, 29 Sep 2022 10:04:51 +0000 (12:04 +0200)]
build: silence GNU ld 2.39 warning about executable stacks

While for C files the compiler is supposed to arrange for emitting
respective information, for assembly sources we're responsible ourselves.

For the new use of cc-option to work we cannot pass -S to the compiler
anymore. We need the compiler to actually invoke the assembler, so switch
to using -c.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: suppress GNU ld 2.39 warning about RWX load segments
Jan Beulich [Thu, 29 Sep 2022 10:04:28 +0000 (12:04 +0200)]
build: suppress GNU ld 2.39 warning about RWX load segments

We cannot really avoid such and we're also not really at risk because of
them, as we control page table permissions ourselves rather than relying
on a loader of some sort.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: Fix build with GCC 4.8.5
Andrew Cooper [Tue, 31 May 2022 16:37:10 +0000 (17:37 +0100)]
build: Fix build with GCC 4.8.5

GCC 4.8.5 complains:

  xtf/arch/x86/pv/traps.c: In function 'init_callbacks':
  xtf/arch/x86/pv/traps.c:126:13: error: initializer element is not constant
               .address = INIT_XEN_CALLBACK(__KERN_CS, _u(entry_EVTCHN)),
               ^
  xtf/arch/x86/pv/traps.c:126:13: error: (near initialization for 'cb[0].address')

Drop the static const.

Reported-by: Samuel Verschelde <stormi-xcp@ylix.fr>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Rename obj-perarch to obj-perbits
Andrew Cooper [Tue, 29 Mar 2022 12:19:26 +0000 (13:19 +0100)]
build: Rename obj-perarch to obj-perbits

As part of adding ARM support, we'll want to have something else named arch in
the build system.  obj-perbits is a better name anyway for what this actually
does.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Make head.S invariant to link order
Andrew Cooper [Sat, 5 Feb 2022 17:28:16 +0000 (17:28 +0000)]
build: Make head.S invariant to link order

Introduce .text.head, ensure it is linked first, and use it in
{hvm,pv}/head.S.  This removes the need for head-$(env).o to be linked first,
removing all head special casing in the build system.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Fix notes
Andrew Cooper [Fri, 4 Feb 2022 17:01:03 +0000 (17:01 +0000)]
build: Fix notes

Notes worked largely by chance.  Give the note section a proper ELF type, and
add a program header to capture the notes section too.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Remove multiple definitions of _start
Andrew Cooper [Fri, 4 Feb 2022 17:14:29 +0000 (17:14 +0000)]
build: Remove multiple definitions of _start

Use _elf_start for entrypoints, and leave _start paired with _end for the
image.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agoxsa-227: Fix link to XSA-227 web page
Michal Orzel [Thu, 30 Sep 2021 06:52:30 +0000 (08:52 +0200)]
xsa-227: Fix link to XSA-227 web page

Current link is invalid and gives the following error:
"The requested URL was not found on this server."
Fix it.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
XSA-227 was first written before c/s 487bce87eda33 "Docs: Fix the generated
advisory links" but upstreamed later, hence the missing of the tree-wide
cleanup.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agoxsa-265: Fix link to a web page
Michal Orzel [Thu, 30 Sep 2021 07:26:43 +0000 (09:26 +0200)]
xsa-265: Fix link to a web page

Currently, link points to XSA-264 and not XSA-265.
Fix it.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Trivial cleanup ahead supporting new architectures
Michal Orzel [Wed, 18 Aug 2021 11:58:29 +0000 (12:58 +0100)]
build: Trivial cleanup ahead supporting new architectures

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
[Broken out of series]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agognttab: drop GNTMAP_can_fail
Jan Beulich [Thu, 26 Aug 2021 10:21:08 +0000 (12:21 +0200)]
gnttab: drop GNTMAP_can_fail

See https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=d07b7ed8b564f48ff14922ac20347fb33bb27ffb

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Include Makefile.local earlier
Andrew Cooper [Thu, 19 Aug 2021 11:41:34 +0000 (12:41 +0100)]
build: Include Makefile.local earlier

... to allow overriding variables as well as rules.  Explicitly default to
all: rule to retain the previous behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agocommon: Move {BITS,BYTES}_PER_LONG into limits.h
Andrew Cooper [Tue, 17 Aug 2021 20:55:01 +0000 (21:55 +0100)]
common: Move {BITS,BYTES}_PER_LONG into limits.h

We're already using compiler-provided __*_TYPE__ macros, so instead of basing
BYTES_PER_LONG on __i386__ or __x86_64__, just use __SIZEOF_LONG__ directly.

This form doesn't require editing to add different architectures.

Add some build assertions that we have a half-way sane compile environment.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agocommon: Make a weak default for arch_fmt_pointer()
Andrew Cooper [Tue, 17 Aug 2021 19:00:56 +0000 (20:00 +0100)]
common: Make a weak default for arch_fmt_pointer()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agocommon: Make a weak default for arch_crash_hard()
Andrew Cooper [Mon, 10 May 2021 17:03:09 +0000 (18:03 +0100)]
common: Make a weak default for arch_crash_hard()

arch_crash_hard() is used from common code, and in the most basic case can
just be an infinite loop.  Both x86 PV and HVM keep their more specific
implementations.

Move the declaration from arch/traps.h to framework.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agocommon: Introduce weak defaults for interfaces used by common code
Andrew Cooper [Tue, 17 Aug 2021 18:10:24 +0000 (19:10 +0100)]
common: Introduce weak defaults for interfaces used by common code

This avoids each architecture needing to implement stubs for possibly optional
functionality.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agobuild: Fix build when only python3 is available
Andrew Cooper [Thu, 1 Jul 2021 12:12:34 +0000 (13:12 +0100)]
build: Fix build when only python3 is available

The shebang lines in the python scrips - xtf-runner in particular - still need
work, but this at least fixes `make` on systems without `python` on $PATH.

Default to python3 in CI too.

Reported-by: Pranjal Singh <008pranjalsingh@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Pranjal Singh <008pranjalsingh@gmail.com>
3 years agoUtility for classifying the current RTM behaviour
Andrew Cooper [Mon, 4 Nov 2019 13:42:39 +0000 (13:42 +0000)]
Utility for classifying the current RTM behaviour

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agoWork around GCC issue 99578
Andrew Cooper [Wed, 19 May 2021 21:08:59 +0000 (22:08 +0100)]
Work around GCC issue 99578

GCC 11.1 objects to pointers derived from a constant:

  error: '__builtin_memcpy' offset [0, 7] is out of the bounds [0, 0]  [-Werror=array-bounds]

This is a GCC bug, but work around it rather than turning array-bounds
checking off generally.

Reported-by: Damien Thenot <damien.thenot@vates.fr>
Reported-by: Christopher Clark <christopher.w.clark@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Christopher Clark <christopher.w.clark@gmail.com>
3 years agobuild: Fix build with binutils 2.36
Andrew Cooper [Mon, 17 May 2021 09:48:57 +0000 (10:48 +0100)]
build: Fix build with binutils 2.36

Passing -no-pie to ld has never been correct, and binutils 2.36 now objects
properly to it.  https://sourceware.org/bugzilla/show_bug.cgi?id=27050

When this workaround was introduced, we used $(CC) to link, but this was
adjusted back to $(LD) with c/s 8486a388e2 ("build: Use LD").

However, the adjustment should always have been passed to the compile step,
not the link step.  Move the adjustment into COMMON_CFLAGS.

Fixes: c92015f8ab ("build: disable PIE during linking if necessary")
Fixes: 8486a388e2 ("build: Use LD")
Reported-by: Damien Thenot <damien.thenot@vates.fr>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoFix issue with clang --target when cross compiling using LLVM
Michal Orzel [Wed, 5 May 2021 06:34:16 +0000 (08:34 +0200)]
Fix issue with clang --target when cross compiling using LLVM

When using LLVM and cross compiling, the CC expands to:
clang --target=<target_triple>
Example of target triple: aarch64-linux-gnu.

However the current code assigning --target based on the
cross compiler does not work if we pass the full path to
CROSS_COMPILE. In this case the build fails.

Fix the issue so that when cross compiling using LLVM
only the basename of cross compiler path is used.

Closes #2

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoCI/build: Explicitly specify the packages to install
Michal Orzel [Thu, 22 Apr 2021 07:59:03 +0000 (09:59 +0200)]
CI/build: Explicitly specify the packages to install

... so that we can test the workflows on different
docker images.

Closes #1

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoCI: Expand matrix for more toolchain combinations
Andrew Cooper [Wed, 21 Apr 2021 22:37:55 +0000 (23:37 +0100)]
CI: Expand matrix for more toolchain combinations

In particular, this now checks LLVM= options for full LLVM toolchains.
Organised to allow arm32/64 support to slot in easily in due couse.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agobuild: Support LLVM=y for full LLVM toolchain
Andrew Cooper [Mon, 19 Apr 2021 15:30:22 +0000 (16:30 +0100)]
build: Support LLVM=y for full LLVM toolchain

Also allow e.g. LLVM=-9 for the explicitly suffixed binaries.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agobuild: Use LD
Andrew Cooper [Mon, 19 Apr 2021 15:06:38 +0000 (16:06 +0100)]
build: Use LD

This is going to matter for proper LLVM support, where we want to default to
ld.lld

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agobuild: Drop lto
Andrew Cooper [Mon, 19 Apr 2021 15:05:12 +0000 (16:05 +0100)]
build: Drop lto

It's experimental, fairly broken, and getting in the way of the build system
overhaul to support non-x86 architectures.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoCodeQL: Two trivial fixes
Andrew Cooper [Mon, 19 Apr 2021 14:16:07 +0000 (15:16 +0100)]
CodeQL: Two trivial fixes

 * xsa-173: Short global name
 * vsnprintf.c: Suspicious 'sizeof' use

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoCI: Add Github Action for CodeQL analysis
Andrew Cooper [Fri, 16 Apr 2021 23:43:16 +0000 (00:43 +0100)]
CI: Add Github Action for CodeQL analysis

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoCI: Add Github Actions for running scan-build
Andrew Cooper [Thu, 15 Apr 2021 01:23:08 +0000 (02:23 +0100)]
CI: Add Github Actions for running scan-build

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agovarious: Fix scan-build deadcode.DeadStores issues
Andrew Cooper [Thu, 15 Apr 2021 01:03:00 +0000 (02:03 +0100)]
various: Fix scan-build deadcode.DeadStores issues

Scan-build complains:

  main.c:164:15: warning: Although the value stored to 'cr4' is used in the enclosing expression, the value is never actually read from 'cr4' [deadcode.DeadStores]
      write_cr4(cr4 &= ~X86_CR4_DE);
                ^      ~~~~~~~~~~~

Rework all impacted logic avoid dead stores of this form.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agognttab: Fix scan-build core.CallAndMessage issues
Andrew Cooper [Thu, 15 Apr 2021 00:36:20 +0000 (01:36 +0100)]
gnttab: Fix scan-build core.CallAndMessage issues

scan-build complains:

  arch/x86/grant_table.c:41:17: warning: 1st function call argument is an uninitialized value [core.CallAndMessage]
                  pte_from_gfn(gnttab_gfns[i], PF_SYM(AD, RW, P)), UVMF_INVLPG);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

because it can't observe that GNTTABOP_setup_table fills the variable on its
success path.

Initialising the array (which is currently one entry) isn't trivial because
the array is variadic.  Drop the nr_frames variable and use the sizeof()
expression directly, to create compile-time constant size.

A similar issue is reported against xsa-255, but this is trivial to resolve.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoCI: Add Github Actions for building
Andrew Cooper [Wed, 7 Apr 2021 22:56:04 +0000 (23:56 +0100)]
CI: Add Github Actions for building

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoDrop dependency on gcc-multilib
Andrew Cooper [Thu, 15 Apr 2021 15:55:09 +0000 (16:55 +0100)]
Drop dependency on gcc-multilib

inttypes.h in particular isn't a freestanding header, and certain distros have
problems providing suitable freestanding headers anyway.  This also gets more
complicated as we start supporting other architectures.

Take the plunge and switch to entirely local headers only.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoFix LGTM static analysis issues
Andrew Cooper [Thu, 15 Apr 2021 17:05:05 +0000 (18:05 +0100)]
Fix LGTM static analysis issues

 * xtf-runner: Class TestInstance implements __hash__ but does not define __eq__.
 * mkinfo.py: Import of 'os' is not used.

LGTM also complains about gdt/idt/tss being global symbols with too-short
names.  As they're the most appropriate architectural names, insert
suppression comments.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoxtf: Perform misc code cleanup
Michal Orzel [Wed, 10 Mar 2021 10:43:32 +0000 (11:43 +0100)]
xtf: Perform misc code cleanup

 * Define macro ALIGN to set alignment.  Header file asm_macros.h should not
   contain architecture specific code.  Replace hardcoded alignment value with
   a call to macro ALIGN.

 * Move declaration of shared_info into xtf/traps.h.  Declaration of
   shared_info structure should be placed in xtf/traps.h as it is a common
   declaration for all the possible architectures.

 * Do not protect including <arch/barrier.h>.  We should always include
   <arch/barrier.h> and rely on the compiler to throw an error. This would
   avoid increasing #if protection each time we would add a new architecture.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agoAdd HYPERCALL5 and hypercall_argo_op()
Christopher Clark [Thu, 28 Jan 2021 06:26:35 +0000 (22:26 -0800)]
Add HYPERCALL5 and hypercall_argo_op()

[Split out from argo patch]

Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
[Also implement HYPERCALL0 as it is frequently opencoded]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
4 years agohypercall: Refine fix for Clang code generation bug github/master
Andrew Cooper [Wed, 11 Nov 2020 12:57:45 +0000 (12:57 +0000)]
hypercall: Refine fix for Clang code generation bug

It was incorrect to switch "=a" to "+a" and set up hcall, as the hypercall
number is encoded in the offset within hypercall_page.  Switch res back to
just an output.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>