]> xenbits.xensource.com Git - people/royger/xen.git/log
people/royger/xen.git
17 months agox86/mem_access: make function static
Nicola Vetrini [Tue, 21 Nov 2023 09:09:17 +0000 (10:09 +0100)]
x86/mem_access: make function static

The function is used only within this file, and therefore can be static.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
17 months agoxen/console: remove stub definition in consoled.h
Nicola Vetrini [Tue, 21 Nov 2023 09:08:46 +0000 (10:08 +0100)]
xen/console: remove stub definition in consoled.h

The stub definition of 'consoled_guest_tx' can be removed, since its
its single caller uses the implementation built with PV_SHIM enabled.

Fixes: 5ef49f185c2d ("x86/pv-shim: shadow PV console's page for L2 DomU")
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agox86/vm_event: add missing include for hvm_vm_event_do_resume
Nicola Vetrini [Tue, 21 Nov 2023 09:08:15 +0000 (10:08 +0100)]
x86/vm_event: add missing include for hvm_vm_event_do_resume

The missing header makes the declaration visible when the function
is defined, thereby fixing a violation of MISRA C:2012 Rule 8.4.

Fixes: 1366a0e76db6 ("x86/vm_event: add hvm/vm_event.{h,c}")
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
17 months agox86/grant: switch included header to make declarations visible
Nicola Vetrini [Tue, 21 Nov 2023 09:07:51 +0000 (10:07 +0100)]
x86/grant: switch included header to make declarations visible

The declarations for {create,replace}_grant_p2m_mapping are
not visible when these functions are defined, therefore the right
header needs to be included to allow them to be visible.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen: modify or add declarations for variables where needed
Nicola Vetrini [Tue, 21 Nov 2023 09:06:57 +0000 (10:06 +0100)]
xen: modify or add declarations for variables where needed

Some variables with external linkage used in C code do not have
a visible declaration where they are defined. Other variables
can be made static, thereby eliminating the need for a declaration.
Doing so also resolves violations of MISRA C:2012 Rule 8.4.

Fix typo s/mcinfo_dumpped/mcinfo_dumped/ while making
the variable static.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoSUPPORT.md: change current version to 4.19-unstable
Juergen Gross [Tue, 21 Nov 2023 09:06:16 +0000 (10:06 +0100)]
SUPPORT.md: change current version to 4.19-unstable

The version in SUPPORT.md is still "4.18-rc".

Change it to "4.19-unstable".

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxenstored: use correct conversion specifier in the tracing function
Volodymyr Babchuk [Tue, 21 Nov 2023 09:05:58 +0000 (10:05 +0100)]
xenstored: use correct conversion specifier in the tracing function

Previous change to xenstored used "%d" to format conn->id while in fact
conn->id has "unsigned int" type, so "%u" should be used.

Fixes: 97f8555acbf3 ("xenstored: print domain id in traces")
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
17 months agoxen/spinlock: fix coding style issues
Juergen Gross [Tue, 21 Nov 2023 09:05:15 +0000 (10:05 +0100)]
xen/spinlock: fix coding style issues

Fix some coding style issues in spinlock coding:

- Instead of u64 etc. use the preferred uint64_t etc. types
- Remove some trailing spaces
- Add missing spaces in "if" statements
- Add some missing blank lines

While modifying the line, add const for the observed_head() parameter.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen/arm32: head Split and move MMU-specific head.S to mmu/head.S
Ayan Kumar Halder [Mon, 20 Nov 2023 14:48:59 +0000 (14:48 +0000)]
xen/arm32: head 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. Few 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.
 - Realigned ".macro ret" so that the alignment matches to the other
   macros.
 - Rename puts to asm_puts, putn to asm_putn (this denotes that the
   macros are used within the context of assembly only).
 - Use ENTRY() for enable_secondary_cpu_mm, enable_boot_cpu_mm,
   setup_fixmap, asm_puts, asm_putn  as they will be used externally.
 - Removed early_puts() function definition when EARLY_PRINTK is not
   enabled.

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

This is based on 6734327d76be ("xen/arm64: Split and move MMU-specific head.S to mmu/head.S").

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
17 months agoxen/arm32: head: Introduce enable_{boot,secondary}_cpu_mm()
Ayan Kumar Halder [Mon, 20 Nov 2023 14:48:58 +0000 (14:48 +0000)]
xen/arm32: head: Introduce enable_{boot,secondary}_cpu_mm()

All the MMU related functionality have been clubbed together in
enable_boot_cpu_mm() for booting primary cpu and enable_secondary_cpu_mm() for
booting secondary cpus.
This is done in preparation for moving the code related to MMU in MMU specific
file and in order to support non MMU cpus in future.

This is based on d2f8df5b3ede ("xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm()").

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: mmu: move MMU specific P2M code to mmu/p2m.{c,h}
Penny Zheng [Thu, 16 Nov 2023 14:50:32 +0000 (22:50 +0800)]
xen/arm: mmu: move MMU specific P2M code to mmu/p2m.{c,h}

Current P2M implementation is designed for MMU system only.
We move the MMU-specific codes into mmu/p2m.c, and only keep generic
codes in p2m.c, like VMID allocator, etc. We also move MMU-specific
definitions and declarations to mmu/p2m.h, such as p2m_tlb_flush_sync().
Also expose previously static functions p2m_vmid_allocator_init(),
p2m_alloc_vmid() for further MPU usage. Since with the code movement
p2m_free_vmid() is now used in two files, also expose p2m_free_vmid().

With the code movement, global variable max_vmid is used in multiple
files instead of a single file (and will be used in MPU P2M
implementation), declare it in the header and remove the "static" of
this variable.

Also, since p2m_invalidate_root() should be MMU only and after the
code movement the only caller of p2m_invalidate_root() outside of
mmu/p2m.c is arch_domain_creation_finished(), creating a new function
named p2m_domain_creation_finished() in mmu/p2m.c for the original
code in arch_domain_creation_finished(), and marking
p2m_invalidate_root() as static.

Take the opportunity to fix the incorrect coding style when possible.
When there is bit shift in macros, take the opportunity to add the
missing 'U' as a compliance of MISRA.

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Rename init_secondary_pagetables() to prepare_secondary_mm()
Penny Zheng [Thu, 16 Nov 2023 14:50:31 +0000 (22:50 +0800)]
xen/arm: Rename init_secondary_pagetables() to prepare_secondary_mm()

init_secondary_pagetables() is a function in the common code path
of both MMU and future MPU support. Since "page table" is a MMU
specific concept, rename init_secondary_pagetables() to a generic
name prepare_secondary_mm() as the preparation for MPU support.

Reword the in-code comment on top of prepare_secondary_mm() because
this function is now supposed to be MMU/MPU agnostic.

Take the opportunity to fix the incorrect coding style of the in-code
comments.

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>
17 months agoxen/arm: Fold pmap and fixmap into MMU system
Henry Wang [Thu, 16 Nov 2023 14:50:30 +0000 (22:50 +0800)]
xen/arm: Fold pmap and fixmap into MMU system

fixmap and pmap are MMU-specific features, so fold them to the
MMU system. Do the folding for pmap by moving the HAS_PMAP Kconfig
selection under MMU. Since none of the definitions in asm/fixmap.h
actually makes sense for the MPU, so do the folding for fixmap by
limiting the inclusion of asm/fixmap.h for MPU code when necessary.
To guarantee that, moving the implementation of copy_from_paddr()
from kernel.c to mmu/setup.c, so that inclusion of asm/fixmap.h in
the kernel.c can be dropped.

Take the opportunity to add a missing space before and after '-' in
"s = paddr & (PAGE_SIZE-1);" of copy_from_paddr().

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <wei.chen@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Split MMU-specific setup_mm() and related code out
Henry Wang [Thu, 16 Nov 2023 14:50:29 +0000 (22:50 +0800)]
xen/arm: Split MMU-specific setup_mm() and related code out

setup_mm() is used for Xen to setup memory management subsystem,
such as boot allocator, direct-mapping, xenheap initialization,
frametable and static memory pages, at boot time.

We could inherit some components seamlessly for MPU support, such
as the setup of boot allocator, whilst we need to implement some
components differently for MPU, such as xenheap, etc. Also, there
are some components that is specific to MMU only, for example the
direct-mapping.

Therefore in this commit, we split the MMU-specific setup_mm() and
related code out. Since arm32 and arm64 have completely different
setup_mm() implementation, take the opportunity to split the
arch-specific setup_mm() to arch-specific files, so that we can
avoid #ifdef. Also, make init_pdx(), init_staticmem_pages(), and
populate_boot_allocator() public as these functions are now called
from two different units, and make setup_mm() public for future MPU
implementation.

With above code movement, mark setup_directmap_mappings() as static
because the only caller of this function is now in the same file
with it. Drop the original setup_directmap_mappings() declaration
and move the in-code comment on top of the declaration on top of
the function implementation.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <wei.chen@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Extract MMU-specific MM code
Henry Wang [Thu, 16 Nov 2023 14:50:28 +0000 (22:50 +0800)]
xen/arm: Extract MMU-specific MM code

Currently, most of the code is in arm/mm.{c,h} and arm/arm64/mm.c
is MMU-specific. To make the MM code extendable, this commit extracts
the MMU-specific MM code.

Extract the boot CPU MM bringup code from arm/mm.c to mmu/setup.c.
While moving, mark pte_of_xenaddr() as __init to make clear that
this helper is only intended to be used during early boot.

Move arm/arm64/mm.c to arm/arm64/mmu/mm.c. Since the function
setup_directmap_mappings() has different implementations between
arm32 and arm64, move their arch-specific implementation to
arch-specific arm{32,64}/mmu/mm.c instead using #ifdef again.

For header files, move MMU-related function declarations in
asm/mm.h, declaration of global variable init_ttbr and the
declaration of dump_pt_walk() in asm/page.h to asm/mmu/mm.h

Also modify the build system (Makefiles in this case) to pick above
mentioned code changes.

Take the opportunity to fix the in-code comment coding styles when
possible, and drop the unnecessary #include headers in the original
arm/mm.c.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Fold mmu_init_secondary_cpu() to head.S
Henry Wang [Thu, 16 Nov 2023 14:50:27 +0000 (22:50 +0800)]
xen/arm: Fold mmu_init_secondary_cpu() to head.S

Currently mmu_init_secondary_cpu() only enforces the page table
should not contain mapping that are both Writable and eXecutables
after boot. To ease the arch/arm/mm.c split work, fold this function
to head.S.

For arm32, the WXN bit cannot be set early because at the point when
the MMU is enabled, the page-tables may still contain mapping which
are writable and executable. Therefore, introduce an assembly macro
pt_enforce_wxn. The macro is called before secondary CPUs jumping
into the C world.

For arm64, set the SCTLR_Axx_ELx_WXN flag right when the MMU is
enabled. This would avoid the extra TLB flush and SCTLR dance.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Co-authored-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Split MMU system SMP MM bringup code to mmu/smpboot.c
Henry Wang [Thu, 16 Nov 2023 14:50:26 +0000 (22:50 +0800)]
xen/arm: Split MMU system SMP MM bringup code to mmu/smpboot.c

Move the code related to secondary page table initialization, clear
boot page tables and the global variable definitions of these boot
page tables from arch/arm/mm.c to arch/arm/mmu/smpboot.c

Since arm32 global variable cpu0_pgtable will be used by both
arch/arm/mm.c and arch/arm/mmu/smpboot.c, to avoid exporting this
variable, change the variable usage in arch/arm/mmu/smpboot.c to
per_cpu(xen_pgtable, 0).

To avoid exposing global variable phys_offset, use virt_to_maddr()
to calculate init_ttbr for arm64.

Take the opportunity to fix the in-code comment coding styles when
possible.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Split page table related code to mmu/pt.c
Henry Wang [Thu, 16 Nov 2023 14:50:25 +0000 (22:50 +0800)]
xen/arm: Split page table related code to mmu/pt.c

The extraction of MMU related code is the basis of MPU support.
This commit starts this work by firstly splitting the page table
related code to mmu/pt.c, so that we will not end up with again
massive mm.c files.

Introduce a mmu specific directory and setup the Makefiles for it.
Move the page table related functions and macros from arch/arm/mm.c
to arch/arm/mmu/pt.c.

Take the opportunity to fix the in-code comment coding styles when
possible, and drop the unnecessary #include headers in the original
arch/arm/mm.c.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
17 months agoamd/iommu: fully initialize array in 'flush_command_buffer'
Nicola Vetrini [Mon, 20 Nov 2023 09:55:12 +0000 (10:55 +0100)]
amd/iommu: fully initialize array in 'flush_command_buffer'

Fully explicit initialization of the cmd array resolves a violation of
MISRA C:2012 Rule 9.3.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/sysctl: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:54:46 +0000 (10:54 +0100)]
x86/sysctl: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/platform_hypercall: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:54:15 +0000 (10:54 +0100)]
x86/platform_hypercall: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/physdev: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:53:51 +0000 (10:53 +0100)]
x86/physdev: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/pci: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:53:17 +0000 (10:53 +0100)]
x86/pci: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/smp: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:52:43 +0000 (10:52 +0100)]
x86/smp: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/vpmu: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:52:10 +0000 (10:52 +0100)]
x86/vpmu: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/mmconfig: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:51:41 +0000 (10:51 +0100)]
x86/mmconfig: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/hvm: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 20 Nov 2023 09:51:13 +0000 (10:51 +0100)]
x86/hvm: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen/sched: fix sched_move_domain()
Juergen Gross [Mon, 20 Nov 2023 09:49:29 +0000 (10:49 +0100)]
xen/sched: fix sched_move_domain()

When moving a domain out of a cpupool running with the credit2
scheduler and having multiple run-queues, the following ASSERT() can
be observed:

(XEN) Xen call trace:
(XEN)    [<ffff82d04023a700>] R credit2.c#csched2_unit_remove+0xe3/0xe7
(XEN)    [<ffff82d040246adb>] S sched_move_domain+0x2f3/0x5b1
(XEN)    [<ffff82d040234cf7>] S cpupool.c#cpupool_move_domain_locked+0x1d/0x3b
(XEN)    [<ffff82d040236025>] S cpupool_move_domain+0x24/0x35
(XEN)    [<ffff82d040206513>] S domain_kill+0xa5/0x116
(XEN)    [<ffff82d040232b12>] S do_domctl+0xe5f/0x1951
(XEN)    [<ffff82d0402276ba>] S timer.c#timer_lock+0x69/0x143
(XEN)    [<ffff82d0402dc71b>] S pv_hypercall+0x44e/0x4a9
(XEN)    [<ffff82d0402012b7>] S lstar_enter+0x137/0x140
(XEN)
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 1:
(XEN) Assertion 'svc->rqd == c2rqd(sched_unit_master(unit))' failed at common/sched/credit2.c:1159
(XEN) ****************************************

This is happening as sched_move_domain() is setting a different cpu
for a scheduling unit without telling the scheduler. When this unit is
removed from the scheduler, the ASSERT() will trigger.

In non-debug builds the result is usually a clobbered pointer, leading
to another crash a short time later.

Fix that by swapping the two involved actions (setting another cpu and
removing the unit from the scheduler).

Link: https://github.com/Dasharo/dasharo-issues/issues/488
Fixes: 70fadc41635b ("xen/cpupool: support moving domain between cpupools with different granularity")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: George Dunlap <george.dunlap@cloud.com>
17 months agoxen: introduce function type bug_fn_t.
Federico Serafini [Fri, 17 Nov 2023 08:28:26 +0000 (09:28 +0100)]
xen: introduce function type bug_fn_t.

Introduce function type bug_fn_t. This improves readability and could be
used to help validating that the function passed to
run_in_exception_handle() has the expected prototype.

Use the newly-intoduced type to address a violation of MISRA
C:2012 Rule 8.2.

Suggested-by: Julien Grall <julien@xen.org>
Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
[stefano: minor commit improvement]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
17 months agoautomation/eclair: add a deviation for MISRA C:2012 Rule 8.6
Federico Serafini [Sat, 18 Nov 2023 02:16:34 +0000 (18:16 -0800)]
automation/eclair: add a deviation for MISRA C:2012 Rule 8.6

Update ECLAIR configuration to take into account the search
procedure adopted by Unix linkers.
Update deviations.rst accordingly and tag Rule 8.6 as "clean".

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agoxen: address violations of Rule 11.9
Nicola Vetrini [Sat, 18 Nov 2023 02:11:11 +0000 (18:11 -0800)]
xen: address violations of Rule 11.9

The constant 0 is used instead of NULL in '__ACCESS_ONCE' as a
compile-time check to detect non-scalar types; its usage for this
purpose is deviated.

Furthermore, the 'typeof_field' macro is introduced as a general way
to access the type of a struct member without declaring a variable
of struct type. Both this macro and 'sizeof_field' are moved to
'xen/macros.h'.

No functional change intended.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agoautomation/eclair: update deviations and accepted guidelines
Simone Ballarin [Fri, 13 Oct 2023 10:14:52 +0000 (12:14 +0200)]
automation/eclair: update deviations and accepted guidelines

Remove deviations for ERROR_EXIT, ERROR_EXIT_DOM and PIN_FAIL:
the aforementioned macros have been removed.
Add deviation for Rule 2.1 for pure declarations.
Remove legacy text-based deviations: these are now implemented
with SAF comments.
Add deviations for Rules 8.4, 10.1, 13.5, 14.2, 14.3.
Remove deviations for guidelines not yet accepted or rejected.

Add MC3R1.R11.7, MC3R1.R11.8, MC3R1.R11.9, MC3R1.R15.3 and MC3R1.R14.2
to the accepted guidelines selector.

Update clean guidelines selector.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agoxen/string: address violations of MISRA C:2012 Rules 8.2 and 8.3
Federico Serafini [Fri, 10 Nov 2023 08:50:13 +0000 (09:50 +0100)]
xen/string: address violations of MISRA C:2012 Rules 8.2 and 8.3

Add missing parameter names to address violations of
MISRA C:2012 Rule 8.2.

Resolve mismatches between parameter name "count" used in
"xen/lib/mem{cpy,move,set}.c" and parameter name "n" used in
"xen/arch/x86/string.c" 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>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agoxen/compat: use BUILD_BUG_ON in CHECK_SIZE macros
Nicola Vetrini [Fri, 27 Oct 2023 13:34:15 +0000 (15:34 +0200)]
xen/compat: use BUILD_BUG_ON in CHECK_SIZE macros

BUILD_BUG_ON is the preferred way to induce a build error
upon statically determined incorrect conditions.

This also fixes a MISRA C:2012 Rule 10.1 violation in the
previous formulation.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen/types: address Rule 10.1 for DECLARE_BITMAP use
Nicola Vetrini [Fri, 27 Oct 2023 13:34:14 +0000 (15:34 +0200)]
xen/types: address Rule 10.1 for DECLARE_BITMAP use

Given its use in the declaration
'DECLARE_BITMAP(features, IOMMU_FEAT_count)' the argument
'bits' has essential type 'enum iommu_feature', which is not
allowed by the Rule as an operand to the addition operator
in macro 'BITS_TO_LONGS'.

This construct is deviated with a deviation comment.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agox86/io_apic: address violation of MISRA C:2012 Rule 10.1
Nicola Vetrini [Fri, 27 Oct 2023 13:34:12 +0000 (15:34 +0200)]
x86/io_apic: address violation of MISRA C:2012 Rule 10.1

The definition of IO_APIC_BASE contains a sum of an essentially enum
value (FIX_IO_APIC_BASE_0) that is positive with an index that, in all
instances, is unsigned, therefore the former is cast to unsigned, so that
the operands are of the same essential type.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen: Add deviations for MISRA C:2012 Rule 7.1
Nicola Vetrini [Fri, 3 Nov 2023 14:50:36 +0000 (15:50 +0100)]
xen: Add deviations for MISRA C:2012 Rule 7.1

As specified in rules.rst, these constants can be used
in the code.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen/x86: address violations of MISRA C:2012 Rule 7.2
Simone Ballarin [Thu, 19 Oct 2023 13:11:52 +0000 (15:11 +0200)]
xen/x86: 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: Gianluca Luparini <gianluca.luparini@bugseng.com>
Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/hvm: address violations of MISRA C:2012 Rule 7.2
Simone Ballarin [Thu, 19 Oct 2023 13:11:51 +0000 (15:11 +0200)]
x86/hvm: 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 'U' suffixes to 'mask16' in 'stdvga.c'

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: Jan Beulich <jbeulich@suse.com>
17 months agox86/vmx: address violations of MISRA C:2012 Rule 7.2
Gianluca Luparini [Thu, 19 Oct 2023 13:11:50 +0000 (15:11 +0200)]
x86/vmx: 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 changes are made:
- add the 'U' suffix to macros near
  'CPU_BASED_ACTIVATE_SECONDARY_CONTROLS' and
  'SECONDARY_EXEC_NOTIFY_VM_EXITING' macros in 'vmcs.h'
- add the 'U' suffix to macros near 'INTR_INFO_VALID_MASK'
  macro in 'vmx.h'

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: Jan Beulich <jbeulich@suse.com>
17 months agoxenstored: print domain id in traces
Volodymyr Babchuk [Thu, 16 Nov 2023 20:56:45 +0000 (20:56 +0000)]
xenstored: print domain id in traces

It is very helpful to see domain id why analyzing xenstored
traces. Especially when you are trying to understand which exactly
domain performs an action.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
[jgrall: Use %u rather than %d]
Signed-off-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm: Enlarge identity map space to 10TB
Leo Yan [Fri, 13 Oct 2023 12:26:58 +0000 (20:26 +0800)]
xen/arm: Enlarge identity map space to 10TB

On ADLink AVA platform (Ampere Altra SoC with 32 Arm Neoverse N1 cores),
the physical memory regions are:

  DRAM memory regions:
    Node[0] Region[0]: 0x000080000000 - 0x0000ffffffff
    Node[0] Region[1]: 0x080000000000 - 0x08007fffffff
    Node[0] Region[2]: 0x080100000000 - 0x0807ffffffff

The UEFI loads Xen hypervisor and DTB into the high memory, the kernel
and ramdisk images are loaded into the low memory space:

  (XEN) MODULE[0]: 00000807f6df0000 - 00000807f6f3e000 Xen
  (XEN) MODULE[1]: 00000807f8054000 - 00000807f8056000 Device Tree
  (XEN) MODULE[2]: 00000000fa834000 - 00000000fc5de1d5 Ramdisk
  (XEN) MODULE[3]: 00000000fc5df000 - 00000000ffb3f810 Kernel

In this case, the Xen binary is loaded above 8TB, which exceeds the
maximum supported identity map space of 2TB in Xen. Consequently, the
system fails to boot.

This patch enlarges identity map space to 10TB, allowing module loading
within the range of [0x0 .. 0x000009ff_ffff_ffff].

Fixes: 1c78d76b67 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable")
Reported-by: Alexey Klimov <alexey.klimov@linaro.org>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Henry Wang <Henry.Wang@arm.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
17 months agoxen/arm: Add macro XEN_VM_MAPPING
Leo Yan [Fri, 13 Oct 2023 12:26:57 +0000 (20:26 +0800)]
xen/arm: Add macro XEN_VM_MAPPING

Xen maps the virtual memory space starting from L0 slot 4, so it's open
coded for macros with the offset '4'.

For more readable, add a new macro XEN_VM_MAPPING which defines the
start slot for Xen virtual memory mapping, and all virtual memory
regions are defined based on it.

Acked-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
17 months agoarm32: head: Add missing hunk from previous commit
Julien Grall [Thu, 16 Nov 2023 14:15:33 +0000 (14:15 +0000)]
arm32: head: Add missing hunk from previous commit

The documentation change was meant to be part of 9b807e23e7c5
("xen/arm32: head: Replace load_paddr with adr_l when they are
equivalent") but was missed when preparing to commit.

So add it separately.

Signed-off-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm32: head: Replace load_paddr with adr_l when they are equivalent
Ayan Kumar Halder [Fri, 27 Oct 2023 18:07:15 +0000 (19:07 +0100)]
xen/arm32: head: Replace load_paddr with adr_l when they are equivalent

Before the MMU is turned on, PC uses physical address. Thus, one can use adr_l
instead of load_paddr to obtain the physical address of a symbol.

The only exception (for this replacement) is create_table_entry() which is
called before and after MMU is turned on.

Also, in lookup_processor_type() "r10" is no longer used. The reason being
__lookup_processor_type uses adr_l (thus r10 is no longer used to obtain the
physical address offset). Consequently, there is no need to save/restore r10.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
[jgrall: Reword comment on top of __lookup_processor_type]
Signed-off-by: Julien Grall <jgrall@amazon.com>
17 months agoxen/arm64: head: only use the macro load_paddr() in the MMU code
Julien Grall [Tue, 17 Oct 2023 12:52:19 +0000 (13:52 +0100)]
xen/arm64: head: only use the macro load_paddr() in the MMU code

The macro load_paddr() requires to know the offset between the
physical location of Xen and the virtual location.

When using the MPU, x20 will always be 0. Rather than wasting
a register for a compile-time constant value, it would be best if
we can avoid using load_paddr() altogether in the common head.S code.

The current use of load_paddr() are equivalent to adr_l() because
the MMU is off.

All the use of load_paddr() in arm64/head.S are now replaced with
adr_l(). With that, load_paddr() can now be moved in arm64/mmu/head.S.

For now, x20 is still unconditionally set. But this could change
in the future if needed.

Signed-off-by: Julien Grall <julien@xen.org>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
17 months agoxen/arm: Skip memory nodes if not enabled
Leo Yan [Fri, 13 Oct 2023 12:04:42 +0000 (20:04 +0800)]
xen/arm: Skip memory nodes if not enabled

Currently, Xen doesn't check the status property of memory/reserved
memory nodes, which may lead to the following issues:

- If a memory node has a status "disabled" it implies that it should
  not be used. Xen does not handle the status property for the memory
  node and ends up using it.

- If a reserved memory node has a status "disabled", it means that this
  region is no longer reserved and can be used, but the "disabled"
  status is not handled by Xen.

  Xen passes the intact device tree binding of the reserved memory nodes
  to Dom0 and creates a memory node to cover reserved regions. Disabled
  reserved memory nodes are ignored by the Dom0 Linux kernel, thus the
  Dom0 Linux kernel will continue to allocate pages from such a region.

  On the other hand, since the disabled status is not handled by Xen,
  the disabled reserved memory regions are excluded from the page
  management in Xen which results in Xen being unable to obtain the
  corresponding MFN, in the end, Xen reports error like:

  (XEN) arch/arm/p2m.c:2202: d0v0: Failing to acquire the MFN 0x1a02dc

This patch introduces a function device_tree_node_is_available(). If it
detects a memory node is not enabled, Xen will not add the memory region
into the memory lists. In the end, this avoids to generate the memory
node for the disabled memory regions sent to the kernel and the kernel
cannot use the disabled memory nodes any longer.

Since this patch adds checking device node's status in the
device_tree_get_meminfo() function, except it checks for memory nodes
and reserved memory nodes, it also supports status for static memory
and static heap.

Suggested-by: Michal Orzel <michal.orzel@amd.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
17 months agoxen/include: add macro ISOLATE_LSB
Nicola Vetrini [Thu, 16 Nov 2023 08:18:23 +0000 (09:18 +0100)]
xen/include: add macro ISOLATE_LSB

The purpose of this macro is to encapsulate the well-known expression
'x & -x' that in 2's complement architectures on unsigned integers will
give a mask where only the least significant nonzero bit of 'x' is set,
or 0 if none are set.

A deviation for ECLAIR is also introduced.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
17 months agox86/hpet: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:12:43 +0000 (09:12 +0100)]
x86/hpet: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. While there also switch a type name. No
functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/vmce: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:12:19 +0000 (09:12 +0100)]
x86/vmce: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/mcaction: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:11:55 +0000 (09:11 +0100)]
x86/mcaction: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/cpuidle: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:11:30 +0000 (09:11 +0100)]
x86/cpuidle: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/domain: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:10:54 +0000 (09:10 +0100)]
x86/domain: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/mtrr: address violation of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:10:14 +0000 (09:10 +0100)]
x86/mtrr: address violation of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/mctelem: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Thu, 16 Nov 2023 08:09:38 +0000 (09:09 +0100)]
x86/mctelem: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agomisra: add R21.1 R21.2
Stefano Stabellini [Tue, 14 Nov 2023 22:59:06 +0000 (14:59 -0800)]
misra: add R21.1 R21.2

Add 21.1 and 21.2, with a longer comment to explain how strategy with
leading underscores and why we think we are safe today.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agodocs/misra: add R11.1 R11.2 R11.3 R11.6
Stefano Stabellini [Thu, 16 Nov 2023 00:01:55 +0000 (16:01 -0800)]
docs/misra: add R11.1 R11.2 R11.3 R11.6

Add MISRA C Rules 11.1, 11.2, 11.3, 11.6 as discussed.

Explicitly add in the notes that conversions to integer types are
permitted if the destination type has enough bits to hold the entire
value. GCC gives enough guarantees in terms of preserving the bit
content in such situations.

Also allow for bool conversions (e.g. to check if a function point is
valid).

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/boot: tidy #include-s
Jan Beulich [Wed, 15 Nov 2023 10:42:28 +0000 (11:42 +0100)]
x86/boot: tidy #include-s

As of d58a509e01c4 ("build,x86: remove the need for build32.mk") we
don't need to use non-standard #include forms anymore in the sources for
the boot code helper blobs. The only place where this kind of #include
needs to remain (for the time being) is mkelf32.c.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
17 months agotools: Remove all DECLARE_* op macros in xc
Alejandro Vallejo [Wed, 15 Nov 2023 10:41:50 +0000 (11:41 +0100)]
tools: Remove all DECLARE_* op macros in xc

These macros were hiding that the ops are not zero-initialized by the
toolstack. This is needlessly opaque for something so simple, so this patch
removes them and replaces them with explicit zero-initialising versions.

The patch also removes PHYSDEV_OP from there, as that seems to be an old
dead macro.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
17 months agox86/psr: address a violation of MISRA C:2012 Rule 8.3
Federico Serafini [Wed, 15 Nov 2023 10:41:23 +0000 (11:41 +0100)]
x86/psr: address a violation of MISRA C:2012 Rule 8.3

Make function declaration and definition consistent.
No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/xstate: address a violation of MISRA C:2012 Rule 8.3
Federico Serafini [Wed, 15 Nov 2023 10:40:58 +0000 (11:40 +0100)]
x86/xstate: address a violation of MISRA C:2012 Rule 8.3

Make function declaration and definition consistent.
No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/uaccess: address violations of MISRA C:2012 Rule 8.3
Federico Serafini [Wed, 15 Nov 2023 10:40:13 +0000 (11:40 +0100)]
x86/uaccess: address violations of MISRA C:2012 Rule 8.3

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>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/spec-ctrl: Remove conditional IRQs-on-ness for INT $0x80/0x82 paths
Andrew Cooper [Thu, 26 Oct 2023 13:37:38 +0000 (14:37 +0100)]
x86/spec-ctrl: Remove conditional IRQs-on-ness for INT $0x80/0x82 paths

Before speculation defences, some paths in Xen could genuinely get away with
being IRQs-on at entry.  But XPTI invalidated this property on most paths, and
attempting to maintain it on the remaining paths was a mistake.

Fast forward, and DO_SPEC_CTRL_COND_IBPB (protection for AMD BTC/SRSO) is not
IRQ-safe, running with IRQs enabled in some cases.  The other actions taken on
these paths happen to be IRQ-safe.

Make entry_int82() and int80_direct_trap() unconditionally Interrupt Gates
rather than Trap Gates.  Remove the conditional re-adjustment of
int80_direct_trap() in smp_prepare_cpus(), and have entry_int82() explicitly
enable interrupts when safe to do so.

In smp_prepare_cpus(), with the conditional re-adjustment removed, the
clearing of pv_cr3 is the only remaining action gated on XPTI, and it is out
of place anyway, repeating work already done by smp_prepare_boot_cpu().  Drop
the entire if() condition to avoid leaving an incorrect vestigial remnant.

Also drop comments which make incorrect statements about when its safe to
enable interrupts.

This is XSA-446 / CVE-2023-46836

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
17 months agoiommu/amd-vi: use correct level for quarantine domain page tables
Roger Pau Monne [Wed, 11 Oct 2023 11:14:21 +0000 (13:14 +0200)]
iommu/amd-vi: use correct level for quarantine domain page tables

The current setup of the quarantine page tables assumes that the quarantine
domain (dom_io) has been initialized with an address width of
DEFAULT_DOMAIN_ADDRESS_WIDTH (48).

However dom_io being a PV domain gets the AMD-Vi IOMMU page tables levels based
on the maximum (hot pluggable) RAM address, and hence on systems with no RAM
above the 512GB mark only 3 page-table levels are configured in the IOMMU.

On systems without RAM above the 512GB boundary amd_iommu_quarantine_init()
will setup page tables for the scratch page with 4 levels, while the IOMMU will
be configured to use 3 levels only.  The page destined to be used as level 1,
and to contain a directory of PTEs ends up being the address in a PTE itself,
and thus level 1 page becomes the leaf page.  Without the level mismatch it's
level 0 page that should be the leaf page instead.

The level 1 page won't be used as such, and hence it's not possible to use it
to gain access to other memory on the system.  However that page is not cleared
in amd_iommu_quarantine_init() as part of re-initialization of the device
quarantine page tables, and hence data on the level 1 page can be leaked
between device usages.

Fix this by making sure the paging levels setup by amd_iommu_quarantine_init()
match the number configured on the IOMMUs.

Note that IVMD regions are not affected by this issue, as those areas are
mapped taking the configured paging levels into account.

This is XSA-445 / CVE-2023-46835

Fixes: ea38867831da ('x86 / iommu: set up a scratch page in the quarantine domain')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
17 months agodocs/sphinx: Fix indexing
Andrew Cooper [Wed, 8 Nov 2023 14:53:23 +0000 (14:53 +0000)]
docs/sphinx: Fix indexing

sphinx-build reports:

  docs/designs/launch/hyperlaunch.rst: WARNING: document isn't included in any toctree
  docs/designs/launch/hyperlaunch-devicetree.rst: WARNING: document isn't included in any toctree
  docs/misc/xen-makefiles/makefiles.rst: WARNING: document isn't included in any toctree
  docs/misra/C-language-toolchain.rst: WARNING: document isn't included in any toctree
  docs/misra/C-runtime-failures.rst: WARNING: document isn't included in any toctree
  docs/misra/documenting-violations.rst: WARNING: document isn't included in any toctree
  docs/misra/exclude-list.rst: WARNING: document isn't included in any toctree
  docs/misra/xen-static-analysis.rst: WARNING: document isn't included in any toctree

Create an up-to-date index.rst in misra/ create an "unsorted docs" section at
the top level to contain everything else.  They can be re-filed at a later
date.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
17 months agodocs/sphinx: Fix syntax issues in exclude-list.rst
Andrew Cooper [Wed, 8 Nov 2023 14:47:10 +0000 (14:47 +0000)]
docs/sphinx: Fix syntax issues in exclude-list.rst

sphinx-build reports:

  docs/misra/exclude-list.rst:47: WARNING: Unexpected indentation.
  docs/misra/exclude-list.rst:50: WARNING: Inline emphasis start-string without end-string.

Nested lists require newlines as delimiters, and * either needs escaping, or
put in a literal block.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
17 months agodocs/sphinx: Fix syntax issues in hyperlaunch.rst
Andrew Cooper [Wed, 8 Nov 2023 14:38:33 +0000 (14:38 +0000)]
docs/sphinx: Fix syntax issues in hyperlaunch.rst

sphinx-build reports:

  docs/designs/launch/hyperlaunch.rst:111: WARNING: Title underline too short.
  docs/designs/launch/hyperlaunch.rst:203: WARNING: Unexpected indentation.
  docs/designs/launch/hyperlaunch.rst:216: WARNING: Unexpected indentation.

Nested lists require newlines as delimiters.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
17 months agodocs: Delete kconfig docs to fix licensing violation
Andrew Cooper [Wed, 8 Nov 2023 14:23:46 +0000 (14:23 +0000)]
docs: Delete kconfig docs to fix licensing violation

These 3 Kconfig docs were imported from Linux erroneously.  They are
GPL-2.0-only in Linux, but have no SPDX tag and were placed in such a way to
be included by the blanket statement saying that all RST files are CC-BY-4.0.

We should not be carrying a shadow copy of these docs.  They aren't even wired
into our Sphinx docs, and anyone wanting to refer to Kconfig docs is going to
look at the Linux docs anyway.  These, and more docs can be found at:

  https://www.kernel.org/doc/html/latest/kbuild/

which also have corrections vs the snapshot we took.

Fixes: f80fe2b34f08 ("xen: Update Kconfig to Linux v5.4")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
17 months agodocs/misra: Add missing SPDX tags
Andrew Cooper [Wed, 8 Nov 2023 13:51:37 +0000 (13:51 +0000)]
docs/misra: Add missing SPDX tags

Two files are missing SDPX tags, but are covered by the blanketing license
statement in docs/README.sources saying that RST files are CC-BY-4.0

Fixes: 3c911be55f1c ("docs/misra: document the C dialect and translation toolchain assumptions.")
Fixes: 7211904e09bd ("docs/misra: add documentation skeleton for MISRA C:2012 Dir 4.1")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
17 months agoxen/set_{c,p}x_pminfo: address violations od MISRA C:2012 Rule 8.3
Federico Serafini [Mon, 13 Nov 2023 14:05:35 +0000 (15:05 +0100)]
xen/set_{c,p}x_pminfo: address violations od MISRA C:2012 Rule 8.3

Make function definitions and declarations consistent.
No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen/sched: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Mon, 13 Nov 2023 14:05:03 +0000 (15:05 +0100)]
xen/sched: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: George Dunlap <george.dunlap@cloud.com>
17 months agox86/msi: address violations of MISRA C:2012 Rules 8.2 and 8.3
Federico Serafini [Mon, 13 Nov 2023 14:01:54 +0000 (15:01 +0100)]
x86/msi: 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>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agox86/intel: fix indentation
Roger Pau Monné [Mon, 13 Nov 2023 14:01:26 +0000 (15:01 +0100)]
x86/intel: fix indentation

Adjust line to use a hard tab and align using spaces afterwards, instead of
using all spaces.

Fixes: fc3090a47b21 ('x86/boot: Clear XD_DISABLE from the early boot path')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
17 months agoxen: avoid generation of stub <asm/pci.h> header
Oleksii Kurochko [Mon, 13 Nov 2023 14:00:06 +0000 (15:00 +0100)]
xen: avoid generation of stub <asm/pci.h> header

Platforms which doesn't have HAS_PCI enabled it is needed to
have <asm/pci.h>, which contains only an empty definition of
struct arch_pci_dev (except Arm, it introduces several Arm-specific
functions ).

Also, for architectures (such as PPC or RISC-V) on initial
stages of adding support, it is needed to generate <asm/pci.h>
for only define the mentioned above arch_pci_dev structure.

For the Arm-only stubs (mentioned in <asm/pci.h> for disabled
HAS_PCI and Arm-specific) will be needed
to add <asm/pci.h> directly alongside <xen/pci.h>. Only to
<arm/domain.c> <asm/pci.h> was added.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
17 months agox86: don't allow Dom0 access to ELCR ports
Jan Beulich [Mon, 13 Nov 2023 13:58:29 +0000 (14:58 +0100)]
x86: don't allow Dom0 access to ELCR ports

Much like the other PIC ports, Dom0 has no business touching these. Even
our own uses are somewhat questionable, as the corresponding IO-APIC
code in Linux is enclosed in a CONFIG_EISA conditional; I don't think
there are any x86-64 EISA systems.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
18 months agoexclude-list: generalise exclude-list
Luca Fancellu [Thu, 26 Oct 2023 10:32:43 +0000 (11:32 +0100)]
exclude-list: generalise exclude-list

Currently exclude-list.json is used by the xen-analysis tool to
remove from the report (cppcheck for now) violations from the
files listed in it, however that list can be used by different
users that might want to exclude some of the files from their
computation for many reasons.

So add a new field that can be part of each entry to link
the tool supposed to consider that exclusion.

Update exclusion_file_list.py to implement the logic and update
the documentation to reflect this change.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agocppcheck: rework exclusion_file_list.py code
Luca Fancellu [Thu, 26 Oct 2023 10:32:42 +0000 (11:32 +0100)]
cppcheck: rework exclusion_file_list.py code

Rework the exclusion_file_list.py code to have the function
load_exclusion_file_list() detached from the xen-analysis.py tool,
in a way so that other modules can use the function.
The xen-analysis tool and in particular its module cppcheck_analysis.py
will use a new function cppcheck_exclusion_file_list().

No functional changes are intended.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/gic: add missing parameter names and uniform function declarations
Federico Serafini [Wed, 18 Oct 2023 13:14:39 +0000 (15:14 +0200)]
arm/gic: add missing parameter names and uniform function declarations

Add missing parameter names and remove inconsistencies between GICv3
and GICv2. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoxen/domain_page: address violations of MISRA C:2012 Rule 8.3
Federico Serafini [Tue, 31 Oct 2023 09:25:41 +0000 (10:25 +0100)]
xen/domain_page: address violations of MISRA C:2012 Rule 8.3

Make function definitions and declarations consistent. Use "ptr" as
const void* parameter to match the definitions on x86.

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
[stefano: drop blank, improve commit message]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
18 months agobuild: Allow setting KBUILD_DEFCONFIG in the environment
Michal Orzel [Wed, 25 Oct 2023 08:28:34 +0000 (10:28 +0200)]
build: Allow setting KBUILD_DEFCONFIG in the environment

At the moment, in order to use a different defconfig target than default,
one needs to specify KBUILD_DEFCONFIG=<target> on the command line.
Switch to weak assignment, so that it can be also obtained from
environment similar to other KCONFIG/KBUILD variables.

This change will activate the use of KBUILD_DEFCONFIG variable in CI
build jobs that so far would have had no effect if they didn't match the
default anyway.

Note, that we will deviate from Linux in this regard.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
[stefano: adjust commit message]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
18 months agoxen/arm64: domctl: Avoid unreachable code in subarch_do_domctl()
Julien Grall [Mon, 23 Oct 2023 17:52:20 +0000 (18:52 +0100)]
xen/arm64: domctl: Avoid unreachable code in subarch_do_domctl()

The 'break' the XEN_DOMCTL_set_address_size is unreachable and tools
like Eclair will report as a violation of Misra Rule 2.1.

Furthermore, the nested switch is not very easy to read. So move
out the nested switch in a separate function to improve the
readability and hopefully address the MISRA violation.

Reported-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
18 months agoarm/cpufeature: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Wed, 18 Oct 2023 12:50:46 +0000 (14:50 +0200)]
arm/cpufeature: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
18 months agobitmap: fix nbits signess
Stefano Stabellini [Tue, 17 Oct 2023 21:04:36 +0000 (14:04 -0700)]
bitmap: fix nbits signess

To avoid potentially dangerous sign conversions in bitmap_switch, all
the callers of the bitmap_switch macro (which are all within bitmap.h)
should pass an unsigned int as first parameter.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
18 months agoarm/smmu: address violation of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:40 +0000 (17:24 +0200)]
arm/smmu: address violation of MISRA C:2012 Rule 8.2

Add missing parameter names, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/domain: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:39 +0000 (17:24 +0200)]
arm/domain: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names, no funtional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/vgic-v3: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:38 +0000 (17:24 +0200)]
arm/vgic-v3: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/cmpxchg: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:36 +0000 (17:24 +0200)]
arm/cmpxchg: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/p2m: address a violation of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:35 +0000 (17:24 +0200)]
arm/p2m: address a violation of MISRA C:2012 Rule 8.2

Add missing parameter name, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/setup: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:34 +0000 (17:24 +0200)]
arm/setup: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoarm/smpboot: address violations of MISRA C:2012 Rule 8.2
Federico Serafini [Fri, 13 Oct 2023 15:24:33 +0000 (17:24 +0200)]
arm/smpboot: address violations of MISRA C:2012 Rule 8.2

Add missing parameter name, no functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agoautomation/eclair: update accepted and clean guidelines
Simone Ballarin [Fri, 29 Sep 2023 16:35:10 +0000 (18:35 +0200)]
automation/eclair: update accepted and clean guidelines

This patch updates accepted and clean guidelines selectors.

Align accepted selector with docs/misra/rules.txt.
Add rule 7.3 in the clean selector for ARM.
Avoid regular expressions in all service selectors: usign them
requires escaping dots, which make selectors hard to read.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
18 months agox86/spec-ctrl: Add SRSO whitepaper URL
Andrew Cooper [Wed, 9 Aug 2023 15:07:03 +0000 (16:07 +0100)]
x86/spec-ctrl: Add SRSO whitepaper URL

... now that it exists in public.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
18 months agoubsan: Fix pointer overflow error message
Michal Orzel [Tue, 7 Nov 2023 09:14:17 +0000 (10:14 +0100)]
ubsan: Fix pointer overflow error message

In __ubsan_handle_pointer_overflow(), fix the condition for determining
whether a pointer operation overflowed or underflowed. Currently, the
function reports "underflowed" when it should be reporting "overflowed"
and vice versa.

Example of incorrect error reporting:
void *foo = (void *)__UINTPTR_MAX__;
foo += 1;

UBSAN:
pointer operation underflowed ffffffff to 00000000

Fixes: 4e3fb2fb47d6 ("ubsan: add clang 5.0 support")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
18 months agox86/x2apic: introduce a mixed physical/cluster mode
Roger Pau Monne [Mon, 6 Nov 2023 14:27:39 +0000 (15:27 +0100)]
x86/x2apic: introduce a mixed physical/cluster mode

The current implementation of x2APIC requires to either use Cluster Logical or
Physical mode for all interrupts.  However the selection of Physical vs Logical
is not done at APIC setup, an APIC can be addressed both in Physical or Logical
destination modes concurrently.

Introduce a new x2APIC mode called Mixed, which uses Logical Cluster mode for
IPIs, and Physical mode for external interrupts, thus attempting to use the
best method for each interrupt type.

Using Physical mode for external interrupts allows more vectors to be used, and
interrupt balancing to be more accurate.

Using Logical Cluster mode for IPIs allows fewer accesses to the ICR register
when sending those, as multiple CPUs can be targeted with a single ICR register
write.

A simple test calling flush_tlb_all() 10000 times on a tight loop on AMD EPYC
9754 with 512 CPUs gives the following figures in nano seconds:

x mixed
+ phys
* cluster
    N           Min           Max        Median           Avg        Stddev
x  25 3.5131328e+08 3.5716441e+08 3.5410987e+08 3.5432659e+08     1566737.4
+  12  1.231082e+09  1.238824e+09 1.2370528e+09 1.2357981e+09     2853892.9
Difference at 95.0% confidence
8.81472e+08 +/- 1.46849e+06
248.774% +/- 0.96566%
(Student's t, pooled s = 2.05985e+06)
*  11 3.5099276e+08 3.5561459e+08 3.5461234e+08 3.5415668e+08     1415071.9
No difference proven at 95.0% confidence

So Mixed has no difference when compared to Cluster mode, and Physical mode is
248% slower when compared to either Mixed or Cluster modes with a 95%
confidence.

Note that Xen uses Cluster mode by default, and hence is already using the
fastest way for IPI delivery at the cost of reducing the amount of vectors
available system-wide.

Make the newly introduced mode the default one.

Note the printing of the APIC addressing mode done in connect_bsp_APIC() has
been removed, as with the newly introduced mixed mode this would require more
fine grained printing, or else would be incorrect.  The addressing mode can
already be derived from the APIC driver in use, which is printed by different
helpers.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Henry Wang <Henry.Wang@arm.com>
18 months agoMAINTAINERS: add xen/drivers/char/imx-lpuart.c to ARM section
Michal Orzel [Mon, 6 Nov 2023 13:19:22 +0000 (14:19 +0100)]
MAINTAINERS: add xen/drivers/char/imx-lpuart.c to ARM section

Add it to the list next to other Arm serial drivers, so it does not fall
back to THE REST.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
18 months agogolang: Fix bindings after XSA-443
Jason Andryuk [Fri, 3 Nov 2023 19:45:51 +0000 (15:45 -0400)]
golang: Fix bindings after XSA-443

The new bootloader_restrict and bootloader_user fields in the libxl idl
change the bindings.  Update them.

Fixes: 1f762642d2ca ("libxl: add support for running bootloader in restricted mode")
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
18 months agogolang: Fixup binding for Arm FF-A
Jason Andryuk [Fri, 3 Nov 2023 19:45:50 +0000 (15:45 -0400)]
golang: Fixup binding for Arm FF-A

The new FF-A TEE type changed the go bindings.  Update them.

Fixes: 8abdd8d52862 ("tools: add Arm FF-A mediator")
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
18 months agoAMD/IOMMU: drop tasklet handler forward declaration
Jan Beulich [Fri, 3 Nov 2023 10:28:09 +0000 (11:28 +0100)]
AMD/IOMMU: drop tasklet handler forward declaration

do_amd_iommu_irq()'s forward declaration uses a parameter name different
from what the definition uses, thus vioating Misra C:2012 rule 8.3. We
can get away without such a forward declaration if instead we forward-
declare amd_iommu_irq_tasklet, putting its initialization past the
handler function's definition.

No functional change.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
18 months agox86/hvm/dom0: fix PVH initrd and metadata placement
Xenia Ragiadakou [Fri, 3 Nov 2023 10:27:29 +0000 (11:27 +0100)]
x86/hvm/dom0: fix PVH initrd and metadata placement

Zephyr image consists of multiple non-contiguous load segments
that reside in different RAM regions. For instance:
ELF: phdr: paddr=0x1000 memsz=0x8000
ELF: phdr: paddr=0x100000 memsz=0x28a90
ELF: phdr: paddr=0x128aa0 memsz=0x7560
ELF: memory: 0x1000 -> 0x130000

However, the logic that determines the best placement for dom0
initrd and metadata, assumes that the image is fully contained
in a single RAM region, not taking into account the cases where:
(1) start > kernel_start && end > kernel_end
(2) start < kernel_start && end < kernel_end
(3) start > kernel_start && end < kernel_end

In case (1), the evaluation will result in end = kernel_start,
i.e. end < start, and will load initrd in the middle of the kernel.
In case (2), the evaluation will result in start = kernel_end,
i.e. end < start, and will load initrd at kernel_end, that is out
of the memory region under evaluation.
In case (3), the evaluation will result in either end = kernel_start
or start = kernel_end but in both cases will be end < start, and
will either load initrd in the middle of the image, or arbitrarily
at kernel_end.

This patch reorganizes the conditionals to include so far unconsidered
cases as well, uniformly returning the lowest available address.

Fixes: 73b47eea2104 ('x86/dom0: improve PVH initrd and metadata placement')
Signed-off-by: Xenia Ragiadakou <xenia.ragiadakou@amd.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
18 months agoarch: drop get_processor_id()
Jan Beulich [Fri, 3 Nov 2023 10:26:29 +0000 (11:26 +0100)]
arch: drop get_processor_id()

smp_processor_id() is what we commonly use; there's no need for it to
have an alias.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> # arm
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>