]> xenbits.xensource.com Git - xen.git/log
xen.git
19 months agox86/spec-ctrl: Issue VERW during IST exit to Xen
Andrew Cooper [Wed, 13 Sep 2023 12:53:33 +0000 (13:53 +0100)]
x86/spec-ctrl: Issue VERW during IST exit to Xen

There is a corner case where e.g. an NMI hitting an exit-to-guest path after
SPEC_CTRL_EXIT_TO_* would have run the entire NMI handler *after* the VERW
flush to scrub potentially sensitive data from uarch buffers.

In order to compensate, issue VERW when exiting to Xen from an IST entry.

SPEC_CTRL_EXIT_TO_XEN already has two reads of spec_ctrl_flags off the stack,
and we're about to add a third.  Load the field into %ebx, and list the
register as clobbered.

%r12 has been arranged to be the ist_exit signal, so add this as an input
dependency and use it to identify when to issue a VERW.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/entry: Track the IST-ness of an entry for the exit paths
Andrew Cooper [Wed, 13 Sep 2023 11:20:12 +0000 (12:20 +0100)]
x86/entry: Track the IST-ness of an entry for the exit paths

Use %r12 to hold an ist_exit boolean.  This register is zero elsewhere in the
entry/exit asm, so it only needs setting in the IST path.

As this is subtle and fragile, add check_ist_exit() to be used in debugging
builds to cross-check that the ist_exit boolean matches the entry vector.

Write check_ist_exit() it in C, because it's debug only and the logic more
complicated than I care to maintain in asm.

For now, we only need to use this signal in the exit-to-Xen path, but some
exit-to-guest paths happen in IST context too.  Check the correctness in all
exit paths to avoid the logic bit-rotting.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/entry: Adjust restore_all_xen to hold stack_end in %r14
Andrew Cooper [Wed, 13 Sep 2023 12:48:16 +0000 (13:48 +0100)]
x86/entry: Adjust restore_all_xen to hold stack_end in %r14

All other SPEC_CTRL_{ENTRY,EXIT}_* helpers hold stack_end in %r14.  Adjust it
for consistency.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/spec-ctrl: Improve all SPEC_CTRL_{ENTER,EXIT}_* comments
Andrew Cooper [Wed, 30 Aug 2023 19:11:50 +0000 (20:11 +0100)]
x86/spec-ctrl: Improve all SPEC_CTRL_{ENTER,EXIT}_* comments

... to better explain how they're used.

Doing so highlights that SPEC_CTRL_EXIT_TO_XEN is missing a VERW flush for the
corner case when e.g. an NMI hits late in an exit-to-guest path.

Leave a TODO, which will be addressed in subsequent patches which arrange for
VERW flushing to be safe within SPEC_CTRL_EXIT_TO_XEN.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/spec-ctrl: Turn the remaining SPEC_CTRL_{ENTRY,EXIT}_* into asm macros
Andrew Cooper [Fri, 1 Sep 2023 10:38:44 +0000 (11:38 +0100)]
x86/spec-ctrl: Turn the remaining SPEC_CTRL_{ENTRY,EXIT}_* into asm macros

These have grown more complex over time, with some already having been
converted.

Provide full Requires/Clobbers comments, otherwise missing at this level of
indirection.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/spec-ctrl: Fold DO_SPEC_CTRL_EXIT_TO_XEN into it's single user
Andrew Cooper [Tue, 12 Sep 2023 16:03:16 +0000 (17:03 +0100)]
x86/spec-ctrl: Fold DO_SPEC_CTRL_EXIT_TO_XEN into it's single user

With the SPEC_CTRL_EXIT_TO_XEN{,_IST} confusion fixed, it's now obvious that
there's only a single EXIT_TO_XEN path.  Fold DO_SPEC_CTRL_EXIT_TO_XEN into
SPEC_CTRL_EXIT_TO_XEN to simplify further fixes.

When merging labels, switch the name to .L\@_skip_sc_msr as "skip" on its own
is going to be too generic shortly.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/spec-ctrl: Fix confusion between SPEC_CTRL_EXIT_TO_XEN{,_IST}
Andrew Cooper [Tue, 12 Sep 2023 14:06:49 +0000 (15:06 +0100)]
x86/spec-ctrl: Fix confusion between SPEC_CTRL_EXIT_TO_XEN{,_IST}

c/s 3fffaf9c13e9 ("x86/entry: Avoid using alternatives in NMI/#MC paths")
dropped the only user, leaving behind the (incorrect) implication that Xen had
split exit paths.

Delete the unused SPEC_CTRL_EXIT_TO_XEN and rename SPEC_CTRL_EXIT_TO_XEN_IST
to SPEC_CTRL_EXIT_TO_XEN for consistency.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen/ppc: Implement bitops.h
Shawn Anastasio [Thu, 14 Sep 2023 19:03:31 +0000 (14:03 -0500)]
xen/ppc: Implement bitops.h

Implement bitops.h, based on Linux's implementation as of commit
5321d1b1afb9a17302c6cec79f0cbf823eb0d3fc. Though it is based off of
Linux's implementation, this code diverges significantly in a number of
ways:
  - Bitmap entries changed to 32-bit words to match X86 and Arm on Xen
  - PPC32-specific code paths dropped
  - Formatting completely re-done to more closely line up with Xen.
    Including 4 space indentation.
  - Use GCC's __builtin_popcount* for hweight* implementation

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/amd: do not expose HWCR.TscFreqSel to guests
Roger Pau Monné [Mon, 18 Sep 2023 13:07:49 +0000 (15:07 +0200)]
x86/amd: do not expose HWCR.TscFreqSel to guests

OpenBSD 7.3 will unconditionally access HWCR if the TSC is reported as
Invariant, and it will then attempt to also unconditionally access PSTATE0 if
HWCR.TscFreqSel is set (currently the case on Xen).

The motivation for exposing HWCR.TscFreqSel was to avoid warning messages from
Linux.  It has been agreed that Linux should be changed instead to not
complaint about missing HWCR.TscFreqSel when running virtualized.

The relation between HWCR.TscFreqSel and PSTATE0 is not clearly written down in
the PPR, but it's natural for OSes to attempt to fetch the P0 frequency if the
TSC is stated to increment at the P0 frequency.

Exposing PSTATEn (PSTATE0 at least) with all zeroes is not a suitable solution
because the PstateEn bit is read-write, and OSes could legitimately attempt to
set PstateEn=1 which Xen couldn't handle.

Furthermore, the TscFreqSel bit is model specific and was never safe to expose
like this in the first place.  At a minimum it should have had a toolstack
adjustment to know not to migrate such a VM.

Therefore, simply remove the bit.  Note the HWCR itself is an architectural
register, and does need to be accessible by the guest.  Since HWCR contains
both architectural and non-architectural bits, going forward care must be taken
to assert the exposed value is correct on newer CPU families.

Reported-by: Solène Rapenne <solene@openbsd.org>
Link: https://github.com/QubesOS/qubes-issues/issues/8502
Fixes: 14b95b3b8546 ('x86/AMD: expose HWCR.TscFreqSel to guests')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agotimer: fix NR_CPUS=1 build with gcc13
Jan Beulich [Mon, 18 Sep 2023 13:06:59 +0000 (15:06 +0200)]
timer: fix NR_CPUS=1 build with gcc13

Gcc13 apparently infers from "if ( old_cpu < new_cpu )" that "new_cpu"
is >= 1, and then (on x86) complains about "per_cpu(timers, new_cpu)"
exceeding __per_cpu_offset[]'s bounds (being an array of 1 in such a
configuration). Make the code conditional upon there being at least 2
CPUs configured (otherwise there simply is nothing to migrate [to]).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
19 months agoxen/libelf: address violations of MISRA C:2012 Rules 8.2 and 8.3
Federico Serafini [Mon, 18 Sep 2023 13:05:55 +0000 (15:05 +0200)]
xen/libelf: address violations of MISRA C:2012 Rules 8.2 and 8.3

Add missing parameter names and make function declarations and
definitions consistent. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
19 months agoxen/arm: Skip Xen specific nodes/properties from hwdom /chosen node
Michal Orzel [Tue, 12 Sep 2023 10:53:41 +0000 (12:53 +0200)]
xen/arm: Skip Xen specific nodes/properties from hwdom /chosen node

Skip the following Xen specific host device tree nodes/properties
from being included into hardware domain /chosen node:
 - xen,static-heap: this property informs Xen about memory regions
   reserved exclusively as static heap,
 - xen,domain-shared-memory-v1: node with this compatible informs Xen
   about static shared memory region for a domain. Xen exposes a different
   node (under /reserved-memory with compatible "xen,shared-memory-v1") to
   let domain know about the shared region,
 - xen,evtchn-v1: node with this compatible informs Xen about static
   event channel configuration for a domain. Xen does not expose
   information about static event channels to domUs and dom0 case was
   overlooked (by default nodes from host dt are copied to dom0 fdt unless
   explicitly marked to be skipped), since the author's idea was not to
   expose it (refer docs/misc/arm/device-tree/booting.txt, "Static Event
   Channel"). Even if we wanted to expose the static event channel
   information, the current node is in the wrong format (i.e. contains
   phandle to domU node not visible by dom0). Lastly, this feature is
   marked as tech-preview and there is no Linux dt binding in place.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Julien Grall <jgrall@amazon.com>
19 months agodocs/misra: accept 11.7 and 11.8
Stefano Stabellini [Wed, 13 Sep 2023 23:16:17 +0000 (16:16 -0700)]
docs/misra: accept 11.7 and 11.8

As per the last MISRA C group discussion, let's accept 11.7 (for which
we have no violations) and 11.8.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen/ppc: Implement atomic.h
Shawn Anastasio [Wed, 13 Sep 2023 07:50:07 +0000 (09:50 +0200)]
xen/ppc: Implement atomic.h

Implement atomic.h for PPC, based off of the original Xen 3.2
implementation. This implementation depends on some functions that are
not yet defined (notably __cmpxchg), so it can't yet be used.

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/efi: address violations of MISRA C:2012 Rule 7.2
Simone Ballarin [Wed, 13 Sep 2023 07:49:14 +0000 (09:49 +0200)]
x86/efi: address violations of MISRA C:2012 Rule 7.2

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants
that are represented in an unsigned type".

Addi the 'U' suffix to integers literals with unsigned type.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/mcheck: address violations of MISRA C:2012 Rule 7.2
Simone Ballarin [Wed, 13 Sep 2023 07:48:49 +0000 (09:48 +0200)]
x86/mcheck: address violations of MISRA C:2012 Rule 7.2

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants
that are represented in an unsigned type".

Add the 'U' suffix to integers literals with unsigned type.

For the sake of uniformity, the following change is made:
- add the 'U' suffix to all first macro's arguments

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen/lib: address violations of MISRA C:2012 Rule 7.2
Simone Ballarin [Wed, 13 Sep 2023 07:48:25 +0000 (09:48 +0200)]
xen/lib: address violations of MISRA C:2012 Rule 7.2

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants
that are represented in an unsigned type".

Add the 'U' suffix to integers literals with unsigned type.

For the sake of uniformity, the following change is made:
- add the 'U' suffix to switch cases in 'cpuid.c'

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen/IOMMU: address violations of MISRA C:2012 Rules 8.2 and 8.3
Federico Serafini [Wed, 13 Sep 2023 07:48:00 +0000 (09:48 +0200)]
xen/IOMMU: address violations of MISRA C:2012 Rules 8.2 and 8.3

Add missing parameter names and make function declarations and
definitions consistent. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agox86/msi: rearrange read_pci_mem_bar slightly
Stewart Hildebrand [Wed, 13 Sep 2023 07:47:36 +0000 (09:47 +0200)]
x86/msi: rearrange read_pci_mem_bar slightly

Use pdev->sbdf instead of the PCI_SBDF macro in calls to pci_* functions
where appropriate. Move NULL check earlier.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen/pci: convert pci_find_*cap* to pci_sbdf_t
Stewart Hildebrand [Wed, 13 Sep 2023 07:47:00 +0000 (09:47 +0200)]
xen/pci: convert pci_find_*cap* to pci_sbdf_t

Convert pci_find_*cap* functions and call sites to pci_sbdf_t, and remove some
now unused local variables. Also change to more appropriate types on lines that
are already being modified as a result of the pci_sbdf_t conversion.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
19 months agox86/hvm: address violations of MISRA C:2012 Rule 7.3
Gianluca Luparini [Wed, 13 Sep 2023 07:44:49 +0000 (09:44 +0200)]
x86/hvm: address violations of MISRA C:2012 Rule 7.3

The xen sources contain violations of MISRA C:2012 Rule 7.3 whose headline
states:
"The lowercase character 'l' shall not be used in a literal suffix".

Use the "L" suffix instead of the "l" suffix, to avoid potential ambiguity.
If the "u" suffix is used near "L", use the "U" suffix instead, for consistency.

The changes in this patch are mechanical.

Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Paul Durrant <paul@xen.org>
19 months agoxen/ioreq: address violations of MISRA C:2012 Rule 7.3
Gianluca Luparini [Wed, 13 Sep 2023 07:43:51 +0000 (09:43 +0200)]
xen/ioreq: address violations of MISRA C:2012 Rule 7.3

The xen sources contain violations of MISRA C:2012 Rule 7.3 whose headline
states:
"The lowercase character 'l' shall not be used in a literal suffix".

Use the "L" suffix instead of the "l" suffix, to avoid potential ambiguity.
If the "u" suffix is used near "L", use the "U" suffix instead, for consistency.

The changes in this patch are mechanical.

Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Paul Durrant <paul@xen.org>
19 months agoxen/arm: Handle empty grant table region in find_unallocated_memory()
Michal Orzel [Thu, 24 Aug 2023 09:06:40 +0000 (11:06 +0200)]
xen/arm: Handle empty grant table region in find_unallocated_memory()

When creating dom0 with grant table support disabled in Xen and no IOMMU,
the following assert is triggered (debug build):
"Assertion 's <= e' failed at common/rangeset.c:189"

(XEN) Xen call trace:
(XEN)    [<0000020000218568>] rangeset_remove_range+0xbc/0x2cc (PC)
(XEN)    [<00000200002c76bc>] domain_build.c#make_hypervisor_node+0x294/0x7c4 (LR)
(XEN)    [<00000200002ca240>] domain_build.c#handle_node+0x7ec/0x924
(XEN)    [<00000200002ca7ac>] domain_build.c#construct_dom0+0x434/0x4d8

This is because find_unallocated_memory() (used to find memory holes
for extended regions) calls rangeset_remove_range() for an empty
grant table region. Fix it by checking if the size of region is not 0.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
19 months agox86/viridian: address violations of MISRA C:2012 Rule 7.2
Gianluca Luparini [Tue, 12 Sep 2023 09:02:51 +0000 (11:02 +0200)]
x86/viridian: address violations of MISRA C:2012 Rule 7.2

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants
that are represented in an unsigned type".

Add the 'U' suffix to integers literals with unsigned type and also to other
literals used in the same contexts or near violations, when their positive
nature is immediately clear. The latter changes are done for the sake of
uniformity.

Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Paul Durrant <paul@xen.org>
19 months agobuild: restrict gcc11 workaround to versions earlier than 11.3.0
Jan Beulich [Tue, 12 Sep 2023 09:02:16 +0000 (11:02 +0200)]
build: restrict gcc11 workaround to versions earlier than 11.3.0

The fix for this issue was backported to 11.3, so let's not unduly
engage the workaround.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
19 months agox86/viridian: address violations of MISRA C:2012 Rule 7.3
Gianluca Luparini [Tue, 12 Sep 2023 09:01:19 +0000 (11:01 +0200)]
x86/viridian: address violations of MISRA C:2012 Rule 7.3

The xen sources contain violations of MISRA C:2012 Rule 7.3 whose headline
states:
"The lowercase character 'l' shall not be used in a literal suffix".

Use the "L" suffix instead of the "l" suffix, to avoid potential ambiguity.
If the "u" suffix is used near "L", use the "U" suffix instead, for consistency.

The changes in this patch are mechanical.

Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Paul Durrant <paul@xen.org>
19 months agotools/xentrace/xentrace_format: Add python 3 compatibility
Javi Merino [Mon, 11 Sep 2023 16:07:02 +0000 (17:07 +0100)]
tools/xentrace/xentrace_format: Add python 3 compatibility

Resolves: xen-project/xen#155
Signed-off-by: Javi Merino <javi.merino@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agox86: Fix calculation of %dr6/dr7 reserved bits
Andrew Cooper [Thu, 31 May 2018 15:16:37 +0000 (16:16 +0100)]
x86: Fix calculation of %dr6/dr7 reserved bits

RTM debugging and BusLock Detect have both introduced conditional behaviour
into the %dr6/7 calculations which Xen's existing logic doesn't account for.

Introduce the CPUID bit for BusLock Detect, so we can get the %dr6 behaviour
correct from the outset.

Implement x86_adj_dr{6,7}_rsvd() fully, and use them in place of the plain
bitmasks.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agox86: Introduce new debug.c for debug register infrastructure
Andrew Cooper [Tue, 29 Aug 2023 11:01:49 +0000 (12:01 +0100)]
x86: Introduce new debug.c for debug register infrastructure

Broken out of the subsequent patch for clarity.

Add stub x86_adj_dr{6,7}_rsvd() functions which will be extended in the
following patch to fix bugs, and adjust debugreg.h to compile with a more
minimal set of includes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agox86: Reject bad %dr6/%dr7 values when loading guest state
Andrew Cooper [Tue, 29 Aug 2023 10:16:11 +0000 (11:16 +0100)]
x86: Reject bad %dr6/%dr7 values when loading guest state

Right now, bad PV state is silently dropped and zeroed, while bad HVM state is
passed directly to hardware and can trigger VMEntry/VMRUN failures.  e.g.

  (XEN) d12v0 vmentry failure (reason 0x80000021): Invalid guest state (0)
  ...
  (XEN) RFLAGS=0x00000002 (0x00000002)  DR7 = 0x4000000000000001

Furthermore, prior to c/s 30f43f4aa81e ("x86: Reorganise and rename debug
register fields in struct vcpu") in Xen 4.11 where v->arch.dr6 was reduced in
width, the toolstack can cause a host crash by loading a bad %dr6 value on
VT-x hardware.

Reject any %dr6/7 values with upper bits set.  For PV guests, also audit
%dr0..3 using the same logic as in set_debugreg() so they aren't silently
zeroed later in the function.  Leave a comment behind explaing how %dr4/5
handling changed, and why they're ignored now.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen/PCI: address violations of MISRA C:2012 Rules 8.2 and 8.3
Federico Serafini [Mon, 11 Sep 2023 15:31:26 +0000 (17:31 +0200)]
xen/PCI: address violations of MISRA C:2012 Rules 8.2 and 8.3

Add missing parameter names and make function declarations and
definitions consistent. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoinclude: make domain_page.h's stubs properly use type-unsafe MFN <-> virt helpers
Jan Beulich [Mon, 11 Sep 2023 15:30:34 +0000 (17:30 +0200)]
include: make domain_page.h's stubs properly use type-unsafe MFN <-> virt helpers

The first of the commits referenced below didn't go far enough, and the
2nd of them, while trying to close (some of) the gap, wrongly kept using
the potentially type-safe variant. This is getting in the way of new
ports preferably not having any type-unsafe private code (and in
particular not having a need for any overrides in newly introduced
files).

Fixes: 41c48004d1d8 ("xen/mm: Use __virt_to_mfn in map_domain_page instead of virt_to_mfn")
Fixes: f46b6197344f ("xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN")
Reported-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
19 months agocoverage: update gcov info for newer versions of gcc
Javi Merino [Mon, 11 Sep 2023 15:29:45 +0000 (17:29 +0200)]
coverage: update gcov info for newer versions of gcc

Shamelessly copy changes to gcov_info structures from linux so that we
can capture coverage for xen built with newer compilers.

Signed-off-by: Javi Merino <javi.merino@cloud.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agocoverage: simplify the logic of choosing the number of gcov counters depending on...
Javi Merino [Mon, 11 Sep 2023 15:26:05 +0000 (17:26 +0200)]
coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version

The current structure of choosing the correct file based on the
compiler version makes us make 33 line files just to define a
constant.  The changes after gcc 4.7 are minimal, just the number of
counters.

Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
remove a lot of the boilerplate and keep the logic of choosing the
GCOV_COUNTER in gcc_4_7.c.

Signed-off-by: Javi Merino <javi.merino@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
19 months agocmdline: move irq-max-guests doc entry
Jan Beulich [Mon, 11 Sep 2023 15:24:51 +0000 (17:24 +0200)]
cmdline: move irq-max-guests doc entry

... to adhere to intended sorting.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
19 months agotools/misc/xencov_split: Add python 3 compatibility
Javi Merino [Mon, 11 Sep 2023 15:23:56 +0000 (17:23 +0200)]
tools/misc/xencov_split: Add python 3 compatibility

Resolves: xen-project/xen#154

Signed-off-by: Javi Merino <javi.merino@cloud.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
19 months agox86: change parameter name in {hap,shadow}_track_dirty_vram()
Federico Serafini [Mon, 11 Sep 2023 07:39:57 +0000 (09:39 +0200)]
x86: change parameter name in {hap,shadow}_track_dirty_vram()

Make function declarations consistent with the corresponding
definitions to address violations of MISRA C:2012 Rule 8.3.
No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoxen: move arm/include/asm/vm_event.h to asm-generic
Oleksii Kurochko [Mon, 11 Sep 2023 07:39:05 +0000 (09:39 +0200)]
xen: move arm/include/asm/vm_event.h to asm-generic

asm/vm_event.h is common for ARM and RISC-V so it will be moved to
asm-generic dir.

Original asm/vm_event.h from ARM was updated:
 * use SPDX-License-Identifier.
 * update comment messages of stubs.
 * update #ifdef
 * instead of "include <public/domctl.h>" -> "public/vm_event.h"

As vm_event.h was moved to asm-generic then it is needed to create
Makefile in arm/include/asm/ and add generated-y += vm_event.h to
it.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
19 months agoxen: asm-generic support
Oleksii Kurochko [Mon, 11 Sep 2023 07:37:33 +0000 (09:37 +0200)]
xen: asm-generic support

Some headers are shared between individual architectures or are empty.
To avoid duplication of these headers, asm-generic is introduced.

With the following patch, an architecture uses generic headers
mentioned in the file arch/$(ARCH)/include/asm/Makefile

To use a generic header is needed to add to
arch/$(ARCH)/include/asm/Makefile :
generic-y += <name-of-header-file.h>

For each mentioned header in arch/$(ARCH)/include/asm/Makefile,
the necessary wrapper in arch/$(ARCH)/include/generated/asm will be
generated.

As the base Makefile.asm-generic from Linux kernel was taken.
06c2afb862f9da8 "Linux 6.5-rc1" ).

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 months agoMAINTAINERS: generalize vm-event/monitor entry
Jan Beulich [Mon, 11 Sep 2023 07:34:12 +0000 (09:34 +0200)]
MAINTAINERS: generalize vm-event/monitor entry

Replace Arm- and x86-specific lines with wildcard ones, thus covering
all architectures. Uniformly permit an extra sub-directory level to be
used, as is already the case for xen/include/.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
20 months agoxen/arm64: Fold setup_fixmap() to create_page_tables()
Henry Wang [Mon, 28 Aug 2023 01:32:16 +0000 (09:32 +0800)]
xen/arm64: Fold setup_fixmap() to create_page_tables()

The original assembly setup_fixmap() is actually doing two seperate
tasks, one is enabling the early UART when earlyprintk on, and the
other is to set up the fixmap (even when earlyprintk is off).

Per discussion in [1], since commit
9d267c049d92 ("xen/arm64: Rework the memory layout"), there is no
chance that the fixmap and the mapping of early UART will clash with
the 1:1 mapping. Therefore the mapping of both the fixmap and the
early UART can be moved to the end of create_pagetables().

[1] https://lore.kernel.org/xen-devel/78862bb8-fd7f-5a51-a7ae-3c5b5998ed80@xen.org/

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm: Move MMU related definitions from config.h to mmu/layout.h
Wei Chen [Mon, 28 Aug 2023 01:32:15 +0000 (09:32 +0800)]
xen/arm: Move MMU related definitions from config.h to mmu/layout.h

Xen defines some global configuration macros for Arm in config.h.
However there are some address layout related definitions that are
defined for MMU systems only, and these definitions could not be
used by MPU systems. Adding ifdefs to differentiate the MPU from MMU
layout will result in a messy and hard-to-read/maintain code.

So move all memory layout definitions to a new file, i.e. mmu/layout.h
to avoid spreading "#ifdef" everywhere.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm64: Split and move MMU-specific head.S to mmu/head.S
Henry Wang [Mon, 28 Aug 2023 01:32:14 +0000 (09:32 +0800)]
xen/arm64: Split and move MMU-specific head.S to mmu/head.S

The MMU specific code in head.S will not be used on MPU systems.
Instead of introducing more #ifdefs which will bring complexity
to the code, move MMU related code to mmu/head.S and keep common
code in head.S. Two notes while moving:
- As "fail" in original head.S is very simple and this name is too
  easy to be conflicted, duplicate it in mmu/head.S instead of
  exporting it.
- Use ENTRY() for enable_secondary_cpu_mm, enable_boot_cpu_mm and
  setup_fixmap as they will be used externally.

Also move the assembly macros shared by head.S and mmu/head.S to
macros.h.

Note that, only the first 4KB of Xen image will be mapped as
identity (PA == VA). At the moment, Xen guarantees this by having
everything that needs to be used in the identity mapping in
.text.header section of head.S, and the size will be checked by
_idmap_start and _idmap_end at link time if this fits in 4KB.
Since we are introducing a new head.S in this patch, although
we can add .text.header to the new file to guarantee all identity
map code still in the first 4KB. However, the order of these two
files on this 4KB depends on the build toolchains. Hence, introduce
a new section named .text.idmap in the region between _idmap_start
and _idmap_end. And in Xen linker script, we force the .text.idmap
contents to linked after .text.header. This will ensure code of
head.S always be at the top of Xen binary.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Signed-off-by: Wei Chen <wei.chen@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm: Introduce CONFIG_MMU Kconfig option
Henry Wang [Mon, 28 Aug 2023 01:32:13 +0000 (09:32 +0800)]
xen/arm: Introduce CONFIG_MMU Kconfig option

There are two types of memory system architectures available for
Arm-based systems, namely the Virtual Memory System Architecture (VMSA)
and the Protected Memory System Architecture (PMSA). According to
ARM DDI 0487G.a, A VMSA provides a Memory Management Unit (MMU) that
controls address translation, access permissions, and memory attribute
determination and checking, for memory accesses made by the PE. And
refer to ARM DDI 0600A.c, the PMSA supports a unified memory protection
scheme where an Memory Protection Unit (MPU) manages instruction and
data access. Currently, Xen only supports VMSA.

Introduce a Kconfig option CONFIG_MMU, which is currently default
set to y and unselectable because currently only VMSA is supported.
CONFIG_MMU will be used in follow-up patches.

Suggested-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm()
Wei Chen [Mon, 28 Aug 2023 01:32:12 +0000 (09:32 +0800)]
xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm()

At the moment, on MMU system, enable_mmu() will return to an
address in the 1:1 mapping, then each path is responsible to
switch to virtual runtime mapping. Then remove_identity_mapping()
is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system,
and we also avoid creating empty function for Non-MMU system, trying
to keep only one codeflow in arm64/head.S, we move path switch and
remove_identity_mapping() in enable_mmu() on MMU system.

As the remove_identity_mapping should only be called for the boot
CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and
enable_secondary_cpu_mm() for secondary CPUs in this patch.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Ayan Kumar Halder <ayankuma@amd.com>
20 months agoxen/arm: ioreq: add header for 'handle_ioserv' and 'try_fwd_ioserv'
Nicola Vetrini [Mon, 4 Sep 2023 15:36:06 +0000 (17:36 +0200)]
xen/arm: ioreq: add header for 'handle_ioserv' and 'try_fwd_ioserv'

The functions referenced by this patch should have had a compatible
declaration visible prior to their definition. This is achieved by
including the arch-specific header in 'xen/arch/arm/ioreq.c'

Fixes: cb9953d2f2bc ("arm/ioreq: Introduce arch specific bits for IOREQ/DM features")
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/ppc: Drop support for pseries/OpenFirmware
Shawn Anastasio [Thu, 7 Sep 2023 19:40:48 +0000 (14:40 -0500)]
xen/ppc: Drop support for pseries/OpenFirmware

Since QEMU's PowerNV support has matured to the point where it is
now suitable for development, drop support for booting on the
paravirtualized pseries machine type and its associated interfaces.

Support for booting on pseries was broken by 74b725a64d80 ('xen/ppc:
Implement initial Radix MMU support'), and since there is little
practical value in continuing to support pseries as a target, just drop
support for it entirely.

Fixes: 74b725a64d80 ('xen/ppc: Implement initial Radix MMU support')
Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoautomation: Switch ppc64le tests to PowerNV machine type
Shawn Anastasio [Thu, 7 Sep 2023 19:40:47 +0000 (14:40 -0500)]
automation: Switch ppc64le tests to PowerNV machine type

Run ppc64le tests with the PowerNV machine type (bare metal) instead of
the paravirtualized pseries machine. This requires a more modern version
of QEMU than is present in debian bullseye's repository, so update the
dockerfile to build QEMU from source.

Support for booting on pseries was broken by 74b725a64d80 ('xen/ppc:
Implement initial Radix MMU support') which resulted in CI failures. In
preparation for removing pseries support entirely, switch the CI
infrastructure to the PowerNV machine type.

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoautomation: add awk to opensuse images
Olaf Hering [Mon, 4 Sep 2023 07:50:08 +0000 (09:50 +0200)]
automation: add awk to opensuse images

Some awk binary is used in many places during build,
make sure it is part of the image.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agox86/io_apic: address violations of MISRA C:2012 Rules 8.2 and 8.3
Federico Serafini [Thu, 7 Sep 2023 13:46:24 +0000 (15:46 +0200)]
x86/io_apic: address violations of MISRA C:2012 Rules 8.2 and 8.3

Add missing parameter names and make function declarations and
definitions consistent.

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agox86/io: address violations of MISRA C:2012 Rule 8.3
Federico Serafini [Thu, 7 Sep 2023 13:46:10 +0000 (15:46 +0200)]
x86/io: address violations of MISRA C:2012 Rule 8.3

Make declarations consistent, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agox86/genapic: address a violation of MISRA C:2012 Rule 8.3
Federico Serafini [Thu, 7 Sep 2023 13:45:51 +0000 (15:45 +0200)]
x86/genapic: address a violation of MISRA C:2012 Rule 8.3

Make function delcaration consistent with the corresponding definition.
No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoautomation: execute SAF translation before the analysis with ECLAIR
Nicola Vetrini [Thu, 7 Sep 2023 07:24:41 +0000 (09:24 +0200)]
automation: execute SAF translation before the analysis with ECLAIR

This allows local MISRA deviation comments to be translated into
the format recognized by ECLAIR.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen: apply deviation for Rule 8.4 (asm-only definitions)
Nicola Vetrini [Thu, 7 Sep 2023 07:23:50 +0000 (09:23 +0200)]
xen: apply deviation for Rule 8.4 (asm-only definitions)

As stated in 'docs/misra/rules.rst' the functions that are used only by
asm modules do not need to conform to MISRA C:2012 Rule 8.4.
The deviations are carried out with a SAF comment.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoArm: constrain {,u}int64_aligned_t in public header
Jan Beulich [Thu, 7 Sep 2023 07:22:40 +0000 (09:22 +0200)]
Arm: constrain {,u}int64_aligned_t in public header

For using a GNU extension, it may not be exposed in general, just like
is done on x86 (except that here we need to also work around not all of
the tool stack actually defining __XEN_TOOLS__). External consumers (not
using gcc or a compatible compiler) need to make this type available up
front (just like we expect {,u}int<N>_t to be supplied) - unlike on x86
the type is actually needed outside of tools-only interfaces, because
guest handle definitions use it.

While there also add underscores around "aligned".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoRevert "MAINTAINERS: consolidate vm-event/monitor entry"
Jan Beulich [Thu, 7 Sep 2023 07:21:02 +0000 (09:21 +0200)]
Revert "MAINTAINERS: consolidate vm-event/monitor entry"

This reverts commit f805cf3e9b87584e16b03b5059b1163fd22bf5a0. It
was based on wrong assumptions about get_maintainers.pl behavior.

20 months agoxen/arm: Fix printk specifiers and arguments in iomem_remove_cb()
Michal Orzel [Wed, 6 Sep 2023 10:30:14 +0000 (12:30 +0200)]
xen/arm: Fix printk specifiers and arguments in iomem_remove_cb()

When building Xen for arm32 with CONFIG_DTB_OVERLAY, the following
error is printed:

common/dt-overlay.c: In function ‘iomem_remove_cb’:
././include/xen/config.h:55:24: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]

Function parameters s and e (denoting MMIO region) are of type unsigned
long and indicate frame numbers and not addresses. This also means that
the arguments passed to printk() are incorrect (using PAGE_ALIGN() or
PAGE_MASK ANDed with a frame number results in unwanted output). Fix it.

Take the opportunity to switch to %pd specifier to print domain id in
a consolidated way.

Fixes: 7e5c4a8b86f1 ("xen/arm: Implement device tree node removal functionalities")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Vikram Garhwal <vikram.garhwal@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/arm: ffa: fix guest map RX/TX error code
Jens Wiklander [Mon, 4 Sep 2023 14:58:14 +0000 (16:58 +0200)]
xen/arm: ffa: fix guest map RX/TX error code

FFA_RXTX_MAP is currently limited to mapping only one 4k page for each
RX and TX buffer. If a guest tries to map more than one page, an error
is returned. Until this patch, we have been using FFA_RET_NOT_SUPPORTED.
However, that error code is reserved in the FF-A specification to report
that the function is not implemented. Of all the other defined error
codes, the least bad is FFA_RET_INVALID_PARAMETERS, so use that instead.

Fixes: 38d81e7ccb11 ("xen/arm: ffa: support mapping guest RX/TX buffers")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
20 months agotools/xl: Guard main_dt_overlay() with LIBXL_HAVE_DT_OVERLAY
Michal Orzel [Wed, 6 Sep 2023 12:56:09 +0000 (14:56 +0200)]
tools/xl: Guard main_dt_overlay() with LIBXL_HAVE_DT_OVERLAY

main_dt_overlay() makes a call to libxl_dt_overlay() which is for now
only compiled for Arm. This causes the build failure as reported by
gitlab CI and OSSTEST. Fix it by guarding the function, prototype and
entry in cmd_table[] using LIBXL_HAVE_DT_OVERLAY. This has an advantage
over regular Arm guard so that the code will not need to be modified again
if other architecture gain support for this feature.

Fixes: 61765a07e3d8 ("tools/xl: Add new xl command overlay for device tree overlay support")
Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
20 months agoxen: Change parameter of generic_{fls,ffs}() to unsigned int
Michal Orzel [Wed, 6 Sep 2023 12:54:48 +0000 (14:54 +0200)]
xen: Change parameter of generic_{fls,ffs}() to unsigned int

When running with SMMUv3 and UBSAN enabled on arm64, there are a lot of
warnings printed related to shifting into sign bit in generic_fls()
as it takes parameter of type int.

Example:
(XEN) UBSAN: Undefined behaviour in ./include/xen/bitops.h:69:11
(XEN) left shift of 134217728 by 4 places cannot be represented in type 'int'

It does not make a lot of sense to ask for the last set bit of a negative
value. We don't have a direct user of this helper and all the wrappers
pass value of type unsigned {int,long}.

Linux did the same as part of commit:
3fc2579e6f16 ("fls: change parameter to unsigned int")

To keep consistency between the helpers, take the opportunity to:
 - replace __inline__ with inline,
 - modify generic_ffs() to take parameter of type unsigned int as well
   (currently no user and the only wrapper generic_ffsl() passes unsigned
   long).

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
20 months agoxen/arm: smmuv3: Add missing U for shifted constant
Michal Orzel [Wed, 6 Sep 2023 12:54:22 +0000 (14:54 +0200)]
xen/arm: smmuv3: Add missing U for shifted constant

When running with SMMUv3 and UBSAN enabled, the following is printed:

(XEN) UBSAN: Undefined behaviour in drivers/passthrough/arm/smmu-v3.c:297:12
(XEN) left shift of 1 by 31 places cannot be represented in type 'int'

This refers to shift in Q_OVERFLOW_FLAG that is missing 'U' suffix.
While there, also fix the same in GBPA_UPDATE.

This should address MISRA Rule 7.2:
    A "u" or "U" suffix shall be applied to all integer constants that
    are represented in an unsigned type

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
20 months agoxen/pci: update PCI_STATUS_* constants
Stewart Hildebrand [Wed, 6 Sep 2023 12:54:04 +0000 (14:54 +0200)]
xen/pci: update PCI_STATUS_* constants

Interrupt status introduced in PCI 2.3
Immediate readiness introduced in PCIe 4.0

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
20 months agotools/xl: Add new xl command overlay for device tree overlay support
Vikram Garhwal [Wed, 6 Sep 2023 01:16:30 +0000 (18:16 -0700)]
tools/xl: Add new xl command overlay for device tree overlay support

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
20 months agotools/libs/light: Implement new libxl functions for device tree overlay ops
Vikram Garhwal [Wed, 6 Sep 2023 01:16:29 +0000 (18:16 -0700)]
tools/libs/light: Implement new libxl functions for device tree overlay ops

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
20 months agotools/libs/ctrl: Implement new xc interfaces for dt overlay
Vikram Garhwal [Wed, 6 Sep 2023 01:16:28 +0000 (18:16 -0700)]
tools/libs/ctrl: Implement new xc interfaces for dt overlay

xc_dt_overlay() sends the device tree binary overlay, size of .dtbo and overlay
operation type i.e. add or remove to xen.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
20 months agoxen/arm: Implement device tree node addition functionalities
Vikram Garhwal [Wed, 6 Sep 2023 01:16:27 +0000 (18:16 -0700)]
xen/arm: Implement device tree node addition functionalities

Update sysctl XEN_SYSCTL_dt_overlay to enable support for dtbo nodes addition
using device tree overlay.

xl dt-overlay add file.dtbo:
    Each time overlay nodes are added using .dtbo, a new fdt(memcpy of
    device_tree_flattened) is created and updated with overlay nodes. This
    updated fdt is further unflattened to a dt_host_new. Next, it checks if any
    of the overlay nodes already exists in the dt_host. If overlay nodes doesn't
    exist then find the overlay nodes in dt_host_new, find the overlay node's
    parent in dt_host and add the nodes as child under their parent in the
    dt_host. The node is attached as the last node under target parent.

    Finally, add IRQs, add device to IOMMUs, set permissions and map MMIO for the
    overlay node.

When a node is added using overlay, a new entry is allocated in the
overlay_track to keep the track of memory allocation due to addition of overlay
node. This is helpful for freeing the memory allocated when a device tree node
is removed.

The main purpose of this to address first part of dynamic programming i.e.
making xen aware of new device tree node which means updating the dt_host with
overlay node information. Here we are adding/removing node from dt_host, and
checking/setting IOMMU and IRQ permission but never mapping them to any domain.
Right now, mapping/Un-mapping will happen only when a new domU is
created/destroyed using "xl create".

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/arm: Implement device tree node removal functionalities
Vikram Garhwal [Wed, 6 Sep 2023 01:16:26 +0000 (18:16 -0700)]
xen/arm: Implement device tree node removal functionalities

Introduce sysctl XEN_SYSCTL_dt_overlay to remove device-tree nodes added using
device tree overlay.

xl dt-overlay remove file.dtbo:
    Removes all the nodes in a given dtbo.
    First, removes IRQ permissions and MMIO accesses. Next, it finds the nodes
    in dt_host and delete the device node entries from dt_host.

    The nodes get removed only if it is not used by any of dom0 or domio.

Also, added overlay_track struct to keep the track of added node through device
tree overlay. overlay_track has dt_host_new which is unflattened form of updated
fdt and name of overlay nodes. When a node is removed, we also free the memory
used by overlay_track for the particular overlay node.

Nested overlay removal is supported in sequential manner only i.e. if
overlay_child nests under overlay_parent, it is assumed that user first removes
overlay_child and then removes overlay_parent.
Also, this is an experimental feature so it is expected from user to make sure
correct device tree overlays are used when adding nodes and making sure devices
are not being used by other domain before removing them from Xen tree.
Partially added/removed i.e. failures while removing the overlay may cause other
failures and might need a system reboot.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoarm/asm/setup.h: Update struct map_range_data to add rangeset.
Vikram Garhwal [Wed, 6 Sep 2023 01:16:25 +0000 (18:16 -0700)]
arm/asm/setup.h: Update struct map_range_data to add rangeset.

Add rangesets for IRQs and IOMEMs. This was done to accommodate dynamic overlay
node addition/removal operations. With overlay operations, new IRQs and IOMEMs
are added in dt_host and routed. While removing overlay nodes, nodes are removed
from dt_host and their IRQs and IOMEMs routing is also removed. Storing IRQs and
IOMEMs in the rangeset will avoid re-parsing the device tree nodes to get the
IOMEM and IRQ ranges for overlay remove ops.

Dynamic overlay node add/remove will be introduced in follow-up patches.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agocommon/device_tree: Add rwlock for dt_host
Vikram Garhwal [Wed, 6 Sep 2023 01:16:24 +0000 (18:16 -0700)]
common/device_tree: Add rwlock for dt_host

Dynamic programming ops will modify the dt_host and there might be other
functions which are browsing the dt_host at the same time. To avoid the race
conditions, adding rwlock for browsing the dt_host during runtime. dt_host
writer will be added in the follow-up patch for device tree overlay
functionalities.

Reason behind adding rwlock instead of spinlock:
    For now, dynamic programming is the sole modifier of dt_host in Xen during
    run time. All other access functions like iommu_release_dt_device() are
    just reading the dt_host during run-time. So, there is a need to protect
    others from browsing the dt_host while dynamic programming is modifying
    it. rwlock is better suitable for this task as spinlock won't be able to
    differentiate between read and write access.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoasm/smp.h: Fix circular dependency for device_tree.h and rwlock.h
Vikram Garhwal [Wed, 6 Sep 2023 01:16:23 +0000 (18:16 -0700)]
asm/smp.h: Fix circular dependency for device_tree.h and rwlock.h

Dynamic programming ops will modify the dt_host and there might be other
function which are browsing the dt_host at the same time. To avoid the race
conditions, we will need to add a rwlock to protect access to the dt_host.
However, adding rwlock in device_tree.h causes following circular dependency:
    device_tree.h->rwlock.h->smp.h->asm/smp.h->device_tree.h

To fix this, removed the "#include <xen/device_tree.h> and forward declared
"struct dt_device_node".

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/smmu: Add remove_device callback for smmu_iommu ops
Vikram Garhwal [Wed, 6 Sep 2023 01:16:22 +0000 (18:16 -0700)]
xen/smmu: Add remove_device callback for smmu_iommu ops

Add remove_device callback for removing the device entry from smmu-master using
following steps:
1. Find if SMMU master exists for the device node.
2. Check if device is currently in use.
3. Remove the SMMU master.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/iommu: Introduce iommu_remove_dt_device()
Vikram Garhwal [Wed, 6 Sep 2023 01:16:21 +0000 (18:16 -0700)]
xen/iommu: Introduce iommu_remove_dt_device()

Remove master device from the IOMMU. This will be helpful when removing the
overlay nodes using dynamic programming during run time.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/iommu: protect iommu_add_dt_device() with dtdevs_lock
Vikram Garhwal [Wed, 6 Sep 2023 01:16:20 +0000 (18:16 -0700)]
xen/iommu: protect iommu_add_dt_device() with dtdevs_lock

Protect iommu_add_dt_device() with dtdevs_lock to prevent concurrent access
to add/remove/assign/deassign.
With addition of dynamic programming feature(follow-up patches in this series),
this function can be concurrently accessed by dynamic node add/remove using
device tree overlays.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller
Vikram Garhwal [Wed, 6 Sep 2023 01:16:19 +0000 (18:16 -0700)]
xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller

Rename iommu_dt_device_is_assigned() to iommu_dt_device_is_assigned_locked().

Moving spin_lock to caller was done to prevent the concurrent access to
iommu_dt_device_is_assigned while doing add/remove/assign/deassign. Follow-up
patches in this series introduces node add/remove feature.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agoxen/device-tree: Add dt_find_node_by_path_from() to find nodes in device tree
Vikram Garhwal [Wed, 6 Sep 2023 01:16:18 +0000 (18:16 -0700)]
xen/device-tree: Add dt_find_node_by_path_from() to find nodes in device tree

Add dt_find_node_by_path_from() to find a matching node with path for a
dt_device_node.

Reason behind this function:
    Each time overlay nodes are added using .dtbo, a new fdt (memcpy of
    device_tree_flattened) is created and updated with overlay nodes. This
    updated fdt is further unflattened to a dt_host_new. Next, we need to find
    the overlay nodes in dt_host_new, find the overlay node's parent in dt_host
    and add the nodes as child under their parent in the dt_host. Thus we need
    this function to search for node in different unflattened device trees.

Also, make dt_find_node_by_path() static inline.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agolibfdt: overlay: change overlay_get_target()
Vikram Garhwal [Wed, 6 Sep 2023 01:16:17 +0000 (18:16 -0700)]
libfdt: overlay: change overlay_get_target()

Rename overlay_get_target() to fdt_overlay_target_offset() and remove static
function type.

This is done to get the target path for the overlay nodes which is very useful
in many cases. For example, Xen hypervisor needs it when applying overlays
because Xen needs to do further processing of the overlay nodes, e.g. mapping of
resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc.

Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Origin: git://git.kernel.org/pub/scm/utils/dtc/dtc.git 45f3d1a095dd

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Acked-by: Juline Grall <jgrall@amazon.com>
20 months agolibfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB.
Vikram Garhwal [Wed, 6 Sep 2023 01:16:16 +0000 (18:16 -0700)]
libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB.

This is done to access fdt library function which are required for adding device
tree overlay nodes for dynamic programming of nodes.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm: Add CONFIG_OVERLAY_DTB
Vikram Garhwal [Wed, 6 Sep 2023 01:16:15 +0000 (18:16 -0700)]
xen/arm: Add CONFIG_OVERLAY_DTB

Introduce a config option where the user can enable support for adding/removing
device tree nodes using a device tree binary overlay.

Update SUPPORT.md and CHANGELOG.md to state the Device Tree Overlays support for
Arm.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Acked-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agocommon/device_tree: Export __unflatten_device_tree()
Vikram Garhwal [Wed, 6 Sep 2023 01:16:14 +0000 (18:16 -0700)]
common/device_tree: Export __unflatten_device_tree()

Following changes are done to __unflatten_device_tree():
    1. __unflatten_device_tree() is renamed to unflatten_device_tree().
    2. Remove __init and static function type.

The changes are done to make this function useable for dynamic node programming
where new device tree overlay nodes are added to fdt and further unflattend to
update xen device tree during runtime.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm/device: Remove __init from function type
Vikram Garhwal [Wed, 6 Sep 2023 01:16:13 +0000 (18:16 -0700)]
xen/arm/device: Remove __init from function type

Remove __init from following function to access during runtime:
    1. map_irq_to_domain()
    2. handle_device_interrupts()
    3. map_range_to_domain()
    4. unflatten_dt_node()
    5. handle_device()
    6. map_device_children()
    7. map_dt_irq_to_domain()
Move map_irq_to_domain() prototype from domain_build.h to setup.h.

Above changes will create an error on build as non-init function are still
in domain_build.c file. So, to avoid build fails, following changes are done:
1. Move map_irq_to_domain(), handle_device_interrupts(), map_range_to_domain(),
    handle_device(), map_device_children() and map_dt_irq_to_domain()
    to device.c. After removing __init type,  these functions are not specific
    to domain building, so moving them out of domain_build.c to device.c.
2. Remove static type from handle_device_interrupts().

Also, renamed handle_device_interrupts() to map_device_irqs_to_domain().

Overall, these changes are done to support the dynamic programming of a nodes
where an overlay node will be added to fdt and unflattened node will be added to
dt_host. Furthermore, IRQ and mmio mapping will be done for the added node.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agocommon/device_tree.c: unflatten_device_tree() propagate errors
Vikram Garhwal [Wed, 6 Sep 2023 01:16:12 +0000 (18:16 -0700)]
common/device_tree.c: unflatten_device_tree() propagate errors

This will be useful in dynamic node programming when new dt nodes are unflattend
during runtime. Invalid device tree node related errors should be propagated
back to the caller.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agocommon/device_tree: handle memory allocation failure in __unflatten_device_tree()
Vikram Garhwal [Wed, 6 Sep 2023 01:16:11 +0000 (18:16 -0700)]
common/device_tree: handle memory allocation failure in __unflatten_device_tree()

Change __unflatten_device_tree() return type to integer so it can propagate
memory allocation failure. Add panic() in dt_unflatten_host_device_tree() for
memory allocation failure during boot.

Fixes: fb97eb614acf ("xen/arm: Create a hierarchical device tree")
Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
20 months agoxen/arm: page: Handle cache flush of an element at the top of the address space
Stefano Stabellini [Thu, 17 Aug 2023 12:41:35 +0000 (13:41 +0100)]
xen/arm: page: Handle cache flush of an element at the top of the address space

The region that needs to be cleaned/invalidated may be at the top
of the address space. This means that 'end' (i.e. 'p + size') will
be 0 and therefore nothing will be cleaned/invalidated as the check
in the loop will always be false.

On Arm64, we only support we only support up to 48-bit Virtual
address space. So this is not a concern there. However, for 32-bit,
the mapcache is using the last 2GB of the address space. Therefore
we may not clean/invalidate properly some pages. This could lead
to memory corruption or data leakage (the scrubbed value may
still sit in the cache when the guest could read directly the memory
and therefore read the old content).

Rework invalidate_dcache_va_range(), clean_dcache_va_range(),
clean_and_invalidate_dcache_va_range() to handle a cache flush
with an element at the top of the address space.

This is CVE-2023-34321 / XSA-437.

Reported-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>
20 months agoxen/ppc: Implement initial Radix MMU support
Shawn Anastasio [Tue, 22 Aug 2023 23:03:52 +0000 (18:03 -0500)]
xen/ppc: Implement initial Radix MMU support

Add code to construct early identity-mapped page tables as well as the
required process and partition tables to enable the MMU.

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoMAINTAINERS: consolidate vm-event/monitor entry
Jan Beulich [Fri, 1 Sep 2023 07:17:41 +0000 (09:17 +0200)]
MAINTAINERS: consolidate vm-event/monitor entry

If the F: description is to be trusted, the two xen/arch/x86/hvm/
lines were fully redundant with the earlier wildcard ones. Arch header
files, otoh, were no longer covered by anything as of the move from
include/asm-*/ to arch/*/include/asm/. Further also generalize (by
folding) the x86- and Arm-specific mem_access.c entries.

Finally, again assuming the F: description can be trusted, there's no
point listing arch/, common/, and include/ entries separately. Fold
them all.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
20 months agoxen/ppc: Define bug frames table in linker script
Shawn Anastasio [Fri, 1 Sep 2023 07:17:01 +0000 (09:17 +0200)]
xen/ppc: Define bug frames table in linker script

Define the bug frames table in ppc's linker script as is done by other
architectures.

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoxen/ppc: Add public/arch-ppc.h
Shawn Anastasio [Fri, 1 Sep 2023 07:16:39 +0000 (09:16 +0200)]
xen/ppc: Add public/arch-ppc.h

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoarm64/vfp: address MISRA C:2012 Dir 4.3
Nicola Vetrini [Fri, 25 Aug 2023 14:00:23 +0000 (16:00 +0200)]
arm64/vfp: address MISRA C:2012 Dir 4.3

Directive 4.3 prescribes the following:
"Assembly language shall be encapsulated and isolated",
on the grounds of improved readability and ease of maintenance.

A static inline function is the chosen encapsulation mechanism.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
20 months agodocs/misra: document gcc-specific behavior with shifting signed integers
Stefano Stabellini [Tue, 22 Aug 2023 01:02:28 +0000 (18:02 -0700)]
docs/misra: document gcc-specific behavior with shifting signed integers

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoxen/sched: address violations of MISRA C:2012 Directive 4.10
Simone Ballarin [Mon, 28 Aug 2023 13:20:08 +0000 (15:20 +0200)]
xen/sched: address violations of MISRA C:2012 Directive 4.10

Add inclusion guards to address violations of
MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order
to prevent the contents of a header file being included more than
once").

Mechanical change.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: George Dunlap <george.dunlap@cloud.com>
20 months agodocs/misra: add rules 10.1 10.2 10.3 10.4
Stefano Stabellini [Fri, 25 Aug 2023 21:48:42 +0000 (14:48 -0700)]
docs/misra: add rules 10.1 10.2 10.3 10.4

10.1 with several caveats, described in the notes.
10.3 and 10.4 as "aspirational" guidelines, as clarified in the notes.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
20 months agox86/msi: remove some unused-but-set-variables
Stewart Hildebrand [Wed, 30 Aug 2023 08:04:37 +0000 (10:04 +0200)]
x86/msi: remove some unused-but-set-variables

These were left over after a previous pci_sbdf_t conversion.

Fixes: 0c38c61aad21 ("pci: switch pci_conf_write32 to use pci_sbdf_t")
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
20 months agox86/irq: fix reporting of spurious i8259 interrupts
Roger Pau Monné [Wed, 30 Aug 2023 08:03:53 +0000 (10:03 +0200)]
x86/irq: fix reporting of spurious i8259 interrupts

The return value of bogus_8259A_irq() is wrong: the function will
return `true` when the IRQ is real and `false` when it's a spurious
IRQ.  This causes the "No irq handler for vector ..." message in
do_IRQ() to be printed for spurious i8259 interrupts which is not
intended (and not helpful).

Fix by inverting the return value of bogus_8259A_irq().

Fixes: 132906348a14 ('x86/i8259: Handle bogus spurious interrupts more quietly')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
20 months agoxen/console: Set the default log level to INFO for release builds
Ross Lagerwall [Thu, 24 Aug 2023 09:02:58 +0000 (11:02 +0200)]
xen/console: Set the default log level to INFO for release builds

Not displaying INFO messages by default on release builds is not
helpful, as messages of that level are relevant for hypervisor
operation.  For example messages related to livepatches applied and
reverted are of INFO level.

Custom builds that require less verbose output can adjust it using the
command line, but attempt to provide all relevant information by
default on release builds.

Adjust the loglevel of printks that don't have an associated level to
INFO instead of WARNING, since INFO will now be printed by default on
all builds.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
20 months agox86/ACPI: Ignore entries with invalid APIC IDs when parsing MADT
Simon Gaiser [Mon, 7 Aug 2023 09:38:25 +0000 (11:38 +0200)]
x86/ACPI: Ignore entries with invalid APIC IDs when parsing MADT

It seems some firmwares put dummy entries in the ACPI MADT table for non
existing processors. On my NUC11TNHi5 those have the invalid APIC ID
0xff. Linux already has code to handle those cases both in
acpi_parse_lapic [1] as well as in acpi_parse_x2apic [2]. So add the
same check to Xen.

Link: https://git.kernel.org/torvalds/c/f3bf1dbe64b62a2058dd1944c00990df203e8e7a
Link: https://git.kernel.org/torvalds/c/10daf10ab154e31237a8c07242be3063fb6a9bf4
Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
20 months agoxen/vpci: address violations of MISRA C:2012 Rule 7.2
Gianluca Luparini [Mon, 28 Aug 2023 13:27:51 +0000 (15:27 +0200)]
xen/vpci: address violations of MISRA C:2012 Rule 7.2

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants
that are represented in an unsigned type".

Add the 'U' suffix to integers literals with unsigned type and also to other
literals used in the same contexts or near violations, when their positive
nature is immediately clear. The latter changes are done for the sake of
uniformity.

Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
20 months agoxen/pci: drop remaining uses of bool_t
Nicola Vetrini [Mon, 28 Aug 2023 13:27:16 +0000 (15:27 +0200)]
xen/pci: drop remaining uses of bool_t

The remaining occurrences of the type bool_t in the header file can be
removed. This also resolves violations of MISRA C:2012 Rule 8.3
introduced by 870d5cd9a91f ("xen/IOMMU: Switch bool_t to bool").

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agocommon: Add missing #includes treewide
Shawn Anastasio [Mon, 28 Aug 2023 13:26:41 +0000 (15:26 +0200)]
common: Add missing #includes treewide

A few files treewide depend on defininitions in headers that they
don't include. This works when arch headers end up including the
required headers by chance, but broke on ppc64 with only minimal/stub
arch headers.

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
20 months agoxen/vpci: address violations of MISRA C:2012 Rule 7.3
Gianluca Luparini [Mon, 28 Aug 2023 13:25:54 +0000 (15:25 +0200)]
xen/vpci: address violations of MISRA C:2012 Rule 7.3

The xen sources contain violations of MISRA C:2012 Rule 7.3 whose headline
states:
"The lowercase character 'l' shall not be used in a literal suffix".

Use the "L" suffix instead of the "l" suffix, to avoid potential ambiguity.
If the "u" suffix is used near "L", use the "U" suffix instead, for consistency.

The changes in this patch are mechanical.

Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
20 months agoCI: Always move the bisect build log back
Anthony PERARD [Wed, 23 Aug 2023 15:23:34 +0000 (16:23 +0100)]
CI: Always move the bisect build log back

On failure of "build"-each-commit script, the next command that move
the log back into the build directory isn't executed. Fix that by
using "after_script" which is always executed even if the main
"script" fails. (We would still miss the log when the jobs times out.)

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>