Re: [PATCH 5/8] automation/cirrus-ci: build XTF

2025-03-18 Thread Roger Pau Monné
On Mon, Mar 17, 2025 at 05:07:22PM -0700, Stefano Stabellini wrote: > On Mon, 17 Mar 2025, Roger Pau Monne wrote: > > In preparation for using the XTF selftests to smoke test the FreeBSD based > > Xen builds. > > > > Signed-off-by: Roger Pau Monné > > --- > > I've used the current version of Free

Re: [PATCH 2/7] x86/mkelf32: account for offset when detecting note segment placement

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > mkelf32 attempt to check that the program header defined NOTE segment falls > inside of the LOAD segment, as the build-id should be loaded for Xen at > runtime to check. > > However the current code doesn't take into account the LOAD program header >

[PATCH 6/7] x86/efi: do not merge all .init sections

2025-03-18 Thread Roger Pau Monne
As a result of relocations now being applied after the trampoline has been copied into the low 1MB region, there's no need for a single .init section that's writable, as .init.text is no longer modified. Remove the bodge and fallback to the layout used by ELF images with an .init.text and .init.da

Re: [PATCH 3/7] xen: remove -N from the linker command line

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > It's unclear why -N is being used in the first place. It was added by > commit 40828c657dd0c back in 2004 without any justification. > > When building a PE image it's actually detrimental to forcefully set the > .text section as writable. The GNU LD

Re: [PATCH] xen: Drop __text_section()

2025-03-18 Thread Andrew Cooper
On 17/03/2025 5:15 pm, Andrew Cooper wrote: > On 17/03/2025 8:43 am, Jan Beulich wrote: >> On 14.03.2025 18:59, Andrew Cooper wrote: >>> This is an unnecessary indirection. >>> >>> Signed-off-by: Andrew Cooper >> Reviewed-by: Jan Beulich > So, this is the patch causing build chaos.  I've reproduc

Re: [PATCH 6/7] x86/efi: do not merge all .init sections

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > As a result of relocations now being applied after the trampoline has been > copied into the low 1MB region, there's no need for a single .init section > that's writable, as .init.text is no longer modified. > > Remove the bodge and fallback to the la

Re: [PATCH v2 2/5] x86/vga: fix mapping of the VGA text buffer

2025-03-18 Thread Jan Beulich
On 18.03.2025 14:11, Andrew Cooper wrote: > On 18/03/2025 9:19 am, Roger Pau Monne wrote: >> The call to ioremap_wc() in video_init() will always fail, because >> video_init() is called ahead of vm_init_type(), and so the underlying >> __vmap() call will fail to allocate the linear address space. >

Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV

2025-03-18 Thread Stefano Stabellini
On Tue, 18 Mar 2025, Jan Beulich wrote: > On 18.03.2025 00:55, Stefano Stabellini wrote: > > On Mon, 17 Mar 2025, Jason Andryuk wrote: > >> On 2025-03-17 10:22, Jan Beulich wrote: > >>> On 06.03.2025 23:03, Jason Andryuk wrote: > --- a/xen/include/xsm/dummy.h > +++ b/xen/include/xsm/dummy

[PATCH v2 1/5] x86/wait: prevent duplicated assembly labels

2025-03-18 Thread Roger Pau Monne
When enabling UBSAN with clang, the following error is triggered during the build: common/wait.c:154:9: error: symbol '.L_wq_resume' is already defined 154 | "push %%rbx; push %%rbp; push %%r12;" | ^ :1:121: note: instantiated into assembly here 1 | push %rbx; p

[PATCH v2 5/5] kconfig/randconfig: enable UBSAN for randconfig

2025-03-18 Thread Roger Pau Monne
Introduce an additional Kconfig check to only offer the option if the compiler supports -fsanitize=undefined. We no longer use Travis CI, so the original motivation for not enabling UBSAN might no longer present. Regardless, the option won't be present in the first place if the compiler doesn't s

[PATCH v2 4/5] x86/shadow: fix UB pointer arithmetic in sh_mfn_is_a_page_table()

2025-03-18 Thread Roger Pau Monne
UBSAN complains with: UBSAN: Undefined behaviour in arch/x86/mm/shadow/private.h:515:30 pointer operation overflowed 82e0 to 82dfffe0 [...] Xen call trace: [] R common/ubsan/ubsan.c#ubsan_epilogue+0xa/0xc0 [] F lib/xxhash64.c#__ubsan_handle_pointer_overflow+0xcb/0x100

[PATCH v2 2/5] x86/vga: fix mapping of the VGA text buffer

2025-03-18 Thread Roger Pau Monne
The call to ioremap_wc() in video_init() will always fail, because video_init() is called ahead of vm_init_type(), and so the underlying __vmap() call will fail to allocate the linear address space. Fix by reverting to the previous behavior and using ioremap() for the VGA text buffer. Fixes: 81d1

[PATCH v2 0/5] x86/ubsan: fix ubsan on clang + code fixes

2025-03-18 Thread Roger Pau Monne
Hello, This started as a series to fix UBSAN when using clang, and the first patch do fix that. Finally patches 2 to 4 fix bugs in the code highlighted by the clang UB pointer arithmetic detection. Patch 5 was the original goal of the series: be able to enable UBSAN for randconfig. Thanks, Roge

Re: [PATCH 2/2] xen/dm: arm: Introduce inject_msi2 DM op

2025-03-18 Thread Jan Beulich
On 18.03.2025 10:10, Mykyta Poturai wrote: > On 15.01.24 11:35, Jan Beulich wrote: >> On 14.01.2024 11:01, Mykyta Poturai wrote: >>> --- a/xen/include/public/hvm/dm_op.h >>> +++ b/xen/include/public/hvm/dm_op.h >>> @@ -444,6 +444,17 @@ struct xen_dm_op_nr_vcpus { >>> }; >>> typedef struct xen_d

Re: [PATCH v2 5/5] kconfig/randconfig: enable UBSAN for randconfig

2025-03-18 Thread Andrew Cooper
On 18/03/2025 9:19 am, Roger Pau Monne wrote: > Introduce an additional Kconfig check to only offer the option if the > compiler supports -fsanitize=undefined. > > We no longer use Travis CI, so the original motivation for not enabling > UBSAN might no longer present. Regardless, the option won't

Re: [PATCH v3 6/7] xen: introduce Kconfig ARCH_PAGING_MEMPOOL

2025-03-18 Thread Oleksii Kurochko
On 3/17/25 9:07 PM, Luca Fancellu wrote: From: Penny Zheng ARM MPU system doesn't need to use paging memory pool, as MPU memory mapping table at most takes only one 4KB page, which is enough to manage the maximum 255 MPU memory regions, for all EL2 stage 1 translation and EL1 stage 2 translatio

Re: [PATCH v2 2/5] x86/vga: fix mapping of the VGA text buffer

2025-03-18 Thread Andrew Cooper
On 18/03/2025 9:19 am, Roger Pau Monne wrote: > The call to ioremap_wc() in video_init() will always fail, because > video_init() is called ahead of vm_init_type(), and so the underlying > __vmap() call will fail to allocate the linear address space. > > Fix by reverting to the previous behavior an

Re: [PATCH 01/11] xen/memory: Mask XENMEMF_node() to 8 bits

2025-03-18 Thread Alejandro Vallejo
For the record, the rest of the series doesn't require this patch. I just thought it was a strictly net-positive improvement on the current behaviour. On Mon Mar 17, 2025 at 4:33 PM GMT, Jan Beulich wrote: > On 14.03.2025 18:24, Alejandro Vallejo wrote: > > As it is, it's incredibly easy for a bug

Re: [PATCH] x86/msi: always propagate MSI writes when not in active system mode

2025-03-18 Thread Marek Marczykowski-Górecki
On Tue, Mar 18, 2025 at 09:29:45AM +0100, Roger Pau Monne wrote: > Relax the limitation on MSI register writes, and only apply it when the > system is in active state. For example AMD IOMMU drivers rely on using > set_msi_affinity() to force an MSI register write on resume from > suspension. > >

Re: [PATCH] x86/msi: always propagate MSI writes when not in active system mode

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 09:36:37AM +0100, Jan Beulich wrote: > On 18.03.2025 09:29, Roger Pau Monne wrote: > > --- a/xen/drivers/passthrough/amd/iommu_intr.c > > +++ b/xen/drivers/passthrough/amd/iommu_intr.c > > @@ -546,7 +546,7 @@ int cf_check amd_iommu_msi_msg_update_ire( > > rc = update_in

Re: [PATCH 8/8] automation/cirrus-ci: add smoke tests for the FreeBSD builds

2025-03-18 Thread Roger Pau Monné
On Mon, Mar 17, 2025 at 05:09:25PM -0700, Stefano Stabellini wrote: > On Mon, 17 Mar 2025, Roger Pau Monne wrote: > > Introduce a basic set of smoke tests using the XTF selftest image, and run > > them on QEMU. Use the matrix keyword to create a different task for each > > XTF flavor on each FreeB

Re: [PATCH 2/2] xen/dm: arm: Introduce inject_msi2 DM op

2025-03-18 Thread Mykyta Poturai
On 18.03.25 12:11, Jan Beulich wrote: > On 18.03.2025 10:10, Mykyta Poturai wrote: >> On 15.01.24 11:35, Jan Beulich wrote: >>> On 14.01.2024 11:01, Mykyta Poturai wrote: --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -444,6 +444,17 @@ struct xen_dm_op_n

[PATCH] xen/compiler: Fix the position of the visibility pragma

2025-03-18 Thread Andrew Cooper
This needs to be ahead of everything. Right now, it is after xen/init.h being included for -DINIT_SECTIONS_ONLY # 1 "./include/xen/compiler.h" 1 # 83 "./include/xen/compiler.h" # 1 "./include/xen/init.h" 1 # 62 "./include/xen/init.h" typedef int (*initcall_t)(void); typedef void (*exi

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 04:50:58PM +0100, Jan Beulich wrote: > On 18.03.2025 16:35, Roger Pau Monné wrote: > > On Tue, Mar 18, 2025 at 03:33:03PM +0100, Jan Beulich wrote: > >> On 18.03.2025 10:19, Roger Pau Monne wrote: > >>> --- a/xen/arch/x86/include/asm/x86_64/uaccess.h > >>> +++ b/xen/arch/x86

Re: [PATCH] x86/msi: always propagate MSI writes when not in active system mode

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 11:14:59AM +0100, Jan Beulich wrote: > On 18.03.2025 09:54, Roger Pau Monné wrote: > > On Tue, Mar 18, 2025 at 09:36:37AM +0100, Jan Beulich wrote: > >> On 18.03.2025 09:29, Roger Pau Monne wrote: > >>> --- a/xen/drivers/passthrough/amd/iommu_intr.c > >>> +++ b/xen/drivers/p

Re: [PATCH] tools/arm: Fix nr_spis handling v2

2025-03-18 Thread Luca Fancellu
Hi Michal, > On 18 Mar 2025, at 09:00, Michal Orzel wrote: > > We are missing a way to detect whether a user provided a value for > nr_spis equal to 0 or did not provide any value (default is also 0) which > can cause issues when calculated nr_spis is > 0 and the value from domain > config is 0.

Re: [PATCH] arinc653: move next_switch_time access under lock

2025-03-18 Thread Jan Beulich
On 18.03.2025 16:39, Nathan Studer wrote: > > On 17/03/25 05:31, Jan Beulich wrote: >> Even before its recent movement to the scheduler's private data structure it >> looks >> to have been wrong to update the field under lock, but then read it with the >> lock >> no longer held. >> >> Coverity-I

[PATCH v3 1/3] drivers: Change amd_iommu struct to contain pci_sbdf_t, simplify code

2025-03-18 Thread Andrii Sultanov
Following on from 250d87dc3ff9 ("x86/msi: Change __msi_set_enable() to take pci_sbdf_t"), struct amd_iommu has its seg and bdf fields backwards with relation to pci_sbdf_t. Instead of regenerating sbdf_t from seg+bdf, make the struct contain pci_sbdf_t directly, which simplifies code. I've avoided

Re: [PATCH v2 2/5] x86/vga: fix mapping of the VGA text buffer

2025-03-18 Thread Jan Beulich
On 18.03.2025 16:31, Roger Pau Monné wrote: > On Tue, Mar 18, 2025 at 03:28:32PM +0100, Jan Beulich wrote: >> On 18.03.2025 14:11, Andrew Cooper wrote: >>> On 18/03/2025 9:19 am, Roger Pau Monne wrote: The call to ioremap_wc() in video_init() will always fail, because video_init() is call

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Jan Beulich
On 18.03.2025 16:35, Roger Pau Monné wrote: > On Tue, Mar 18, 2025 at 03:33:03PM +0100, Jan Beulich wrote: >> On 18.03.2025 10:19, Roger Pau Monne wrote: >>> --- a/xen/arch/x86/include/asm/x86_64/uaccess.h >>> +++ b/xen/arch/x86/include/asm/x86_64/uaccess.h >>> @@ -9,9 +9,9 @@ >>> * a secondary m

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Jan Beulich
On 18.03.2025 17:47, Roger Pau Monné wrote: > On Tue, Mar 18, 2025 at 04:50:58PM +0100, Jan Beulich wrote: >> On 18.03.2025 16:35, Roger Pau Monné wrote: >>> On Tue, Mar 18, 2025 at 03:33:03PM +0100, Jan Beulich wrote: On 18.03.2025 10:19, Roger Pau Monne wrote: > --- a/xen/arch/x86/includ

[PATCH v1 2/2] Strip build path directories in tools, xen and xen/arch/x86

2025-03-18 Thread Marek Marczykowski-Górecki
From: Frédéric Pierret (fepitre) Ensure to have a realpath for XEN_ROOT else it fails to substitute properly pathes in strings sections Signed-off-by: Frédéric Pierret (fepitre) [use cc-option-add] Signed-off-by: Marek Marczykowski-Górecki --- tools/Rules.mk| 2 ++ xen/Makefile

[PATCH v1 1/2] docs/xen-headers: use alphabetical sorting for @incontents

2025-03-18 Thread Marek Marczykowski-Górecki
From: Frédéric Pierret (fepitre) It makes the build reproducible with fileordering flags Signed-off-by: Frédéric Pierret (fepitre) --- docs/xen-headers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/xen-headers b/docs/xen-headers index 8c434d77e20e..98ffe814500b 10075

[PATCH v1 0/2] Improve reproducibility of build artifacts

2025-03-18 Thread Marek Marczykowski-Górecki
Few patches from qubes patch queue that improve reproducible builds. Frédéric Pierret (fepitre) (2): docs/xen-headers: use alphabetical sorting for @incontents Strip build path directories in tools, xen and xen/arch/x86 docs/xen-headers | 2 +- tools/Rules.mk| 2 ++ xen/Makefile

Re: [PATCH 7/8] automation/console.exp: do not assume expect is always at /usr/bin/

2025-03-18 Thread Roger Pau Monné
On Mon, Mar 17, 2025 at 04:48:05PM -0700, Stefano Stabellini wrote: > On Mon, 17 Mar 2025, Roger Pau Monne wrote: > > Instead use env to find the location of expect. > > > > Additionally do not use the -f flag, as it's only meaningful when passing > > arguments on the command line, which we never

Re: [PATCH v2 1/5] x86/wait: prevent duplicated assembly labels

2025-03-18 Thread Andrew Cooper
On 18/03/2025 9:19 am, Roger Pau Monne wrote: > When enabling UBSAN with clang, the following error is triggered during the > build: > > common/wait.c:154:9: error: symbol '.L_wq_resume' is already defined > 154 | "push %%rbx; push %%rbp; push %%r12;" > | ^ > :1:121: note: i

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Andrew Cooper
On 18/03/2025 9:19 am, Roger Pau Monne wrote: > UBSAN complains with: > > UBSAN: Undefined behaviour in common/compat/memory.c:90:9 > pointer operation overflowed 82008000 to 02008000 > [...] > Xen call trace: >[] R common/ubsan/ubsan.c#ubsan_epilogue+0xa/0xc0 >[] F > lib/x

[PATCH] tools/arm: Fix nr_spis handling v2

2025-03-18 Thread Michal Orzel
We are missing a way to detect whether a user provided a value for nr_spis equal to 0 or did not provide any value (default is also 0) which can cause issues when calculated nr_spis is > 0 and the value from domain config is 0. Fix it by setting default value for nr_spis to UINT32_MAX (max supporte

Re: [PATCH 15/23] xen/xsm: Add XSM_HW_PRIV

2025-03-18 Thread Jan Beulich
On 18.03.2025 00:55, Stefano Stabellini wrote: > On Mon, 17 Mar 2025, Jason Andryuk wrote: >> On 2025-03-17 10:22, Jan Beulich wrote: >>> On 06.03.2025 23:03, Jason Andryuk wrote: --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -95,7 +95,11 @@ static always_inline int

Re: [PATCH 4/4] x86/traps: Introduce early_traps_init() and simplify setup

2025-03-18 Thread Jan Beulich
On 17.03.2025 20:20, Andrew Cooper wrote: > Something I overlooked when last cleaning up exception handling is that a TSS > is not necessary if IST isn't configured, and IST isn't necessary until we're > running guest code. > > Introduce early_traps_init() which is far more minimal than init_idt_t

Re: [PATCH v2 4/5] x86/shadow: fix UB pointer arithmetic in sh_mfn_is_a_page_table()

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 03:36:45PM +0100, Jan Beulich wrote: > On 18.03.2025 13:53, Andrew Cooper wrote: > > On 18/03/2025 9:19 am, Roger Pau Monne wrote: > >> UBSAN complains with: > >> > >> UBSAN: Undefined behaviour in arch/x86/mm/shadow/private.h:515:30 > >> pointer operation overflowed 82e

[PATCH v3 3/3] drivers: Make ioapic_sbdf and hpet_sbdf contain pci_sbdf_t

2025-03-18 Thread Andrii Sultanov
Following a similar change to amd_iommu struct, make two more structs take pci_sbdf_t directly instead of seg and bdf separately. This lets us drop several conversions from the latter to the former and simplifies several comparisons and assignments. Signed-off-by: Andrii Sultanov --- This parti

Re: [PATCH v2 2/5] x86/vga: fix mapping of the VGA text buffer

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 03:28:32PM +0100, Jan Beulich wrote: > On 18.03.2025 14:11, Andrew Cooper wrote: > > On 18/03/2025 9:19 am, Roger Pau Monne wrote: > >> The call to ioremap_wc() in video_init() will always fail, because > >> video_init() is called ahead of vm_init_type(), and so the underlyi

[PATCH] x86/msi: always propagate MSI writes when not in active system mode

2025-03-18 Thread Roger Pau Monne
Relax the limitation on MSI register writes, and only apply it when the system is in active state. For example AMD IOMMU drivers rely on using set_msi_affinity() to force an MSI register write on resume from suspension. The original patch intention was to reduce the number of MSI register writes

[PATCH v3 0/3] drivers: Simplify handling of pci_sbdf_t in passthrough/amd

2025-03-18 Thread Andrii Sultanov
Step-by-step, use pci_sbdf_t directly where appropriate instead of handling seg and bdf separately. This removes conversions, reduces code size and simplifies code in general. Andrii Sultanov (3): drivers: Change amd_iommu struct to contain pci_sbdf_t, simplify code drivers: Change find_iommu_

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 03:33:03PM +0100, Jan Beulich wrote: > On 18.03.2025 10:19, Roger Pau Monne wrote: > > --- a/xen/arch/x86/include/asm/x86_64/uaccess.h > > +++ b/xen/arch/x86/include/asm/x86_64/uaccess.h > > @@ -9,9 +9,9 @@ > > * a secondary mapping installed, which needs to be used for su

RE: [PATCH] arinc653: move next_switch_time access under lock

2025-03-18 Thread Nathan Studer
On 17/03/25 05:31, Jan Beulich wrote: > Even before its recent movement to the scheduler's private data structure it > looks > to have been wrong to update the field under lock, but then read it with the > lock > no longer held. > > Coverity-ID: 1644500 > Fixes: 9f0c658baedc ("arinc: add cpu-po

Re: [PATCH] x86/msi: always propagate MSI writes when not in active system mode

2025-03-18 Thread Jan Beulich
On 18.03.2025 09:29, Roger Pau Monne wrote: > --- a/xen/drivers/passthrough/amd/iommu_intr.c > +++ b/xen/drivers/passthrough/amd/iommu_intr.c > @@ -546,7 +546,7 @@ int cf_check amd_iommu_msi_msg_update_ire( > rc = update_intremap_entry_from_msi_msg(iommu, bdf, nr, >

[PATCH] x86/msi: always propagate MSI register writes from __setup_msi_irq()

2025-03-18 Thread Roger Pau Monne
After 8e60d47cf011 writes from __setup_msi_irq() will no longer be propagated to the MSI registers if the IOMMU IRTE was already allocated. Given the purpose of __setup_msi_irq() is MSI initialization, always propagate the write to the hardware, regardless of whether the IRTE was already allocated.

Re: [PATCH v2 4/4] xen: balloon: update the NR_BALLOON_PAGES state

2025-03-18 Thread Jürgen Groß
On 14.03.25 22:37, Nico Pache wrote: Update the NR_BALLOON_PAGES counter when pages are added to or removed from the Xen balloon. Signed-off-by: Nico Pache Reviewed-by: Juergen Gross Juergen OpenPGP_0xB0DE9DD628BF132F.asc Description: OpenPGP public key OpenPGP_signature.asc Descriptio

Re: [PATCH v3 6/7] xen: introduce Kconfig ARCH_PAGING_MEMPOOL

2025-03-18 Thread Orzel, Michal
On 17/03/2025 21:07, Luca Fancellu wrote: > > > From: Penny Zheng > > ARM MPU system doesn't need to use paging memory pool, as MPU memory > mapping table at most takes only one 4KB page, which is enough to > manage the maximum 255 MPU memory regions, for all EL2 stage 1 > translation and EL

Re: [PATCH] xen/compiler: Fix the position of the visibility pragma

2025-03-18 Thread Jan Beulich
On 18.03.2025 14:39, Andrew Cooper wrote: > This needs to be ahead of everything. Right now, it is after xen/init.h being > included for -DINIT_SECTIONS_ONLY > > # 1 "./include/xen/compiler.h" 1 > # 83 "./include/xen/compiler.h" > # 1 "./include/xen/init.h" 1 > # 62 "./include/xen/init.h"

Re: [PATCH 2/2] xen/dm: arm: Introduce inject_msi2 DM op

2025-03-18 Thread Jan Beulich
On 18.03.2025 14:31, Mykyta Poturai wrote: > On 18.03.25 12:11, Jan Beulich wrote: >> On 18.03.2025 10:10, Mykyta Poturai wrote: >>> On 15.01.24 11:35, Jan Beulich wrote: On 14.01.2024 11:01, Mykyta Poturai wrote: > --- a/xen/include/public/hvm/dm_op.h > +++ b/xen/include/public/hvm/dm

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Jan Beulich
On 18.03.2025 10:19, Roger Pau Monne wrote: > --- a/xen/arch/x86/include/asm/x86_64/uaccess.h > +++ b/xen/arch/x86/include/asm/x86_64/uaccess.h > @@ -9,9 +9,9 @@ > * a secondary mapping installed, which needs to be used for such accesses in > * the PV case, and will also be used for HVM to avoi

Re: [PATCH v2 4/5] x86/shadow: fix UB pointer arithmetic in sh_mfn_is_a_page_table()

2025-03-18 Thread Andrew Cooper
On 18/03/2025 9:19 am, Roger Pau Monne wrote: > UBSAN complains with: > > UBSAN: Undefined behaviour in arch/x86/mm/shadow/private.h:515:30 > pointer operation overflowed 82e0 to 82dfffe0 > [...] > Xen call trace: >[] R common/ubsan/ubsan.c#ubsan_epilogue+0xa/0xc0 >[] F

Re: [PATCH v2 4/5] x86/shadow: fix UB pointer arithmetic in sh_mfn_is_a_page_table()

2025-03-18 Thread Jan Beulich
On 18.03.2025 13:53, Andrew Cooper wrote: > On 18/03/2025 9:19 am, Roger Pau Monne wrote: >> UBSAN complains with: >> >> UBSAN: Undefined behaviour in arch/x86/mm/shadow/private.h:515:30 >> pointer operation overflowed 82e0 to 82dfffe0 >> [...] >> Xen call trace: >>[] R comm

RE: [PATCH v2] xen/arinc653: call xfree() with local IRQ enabled

2025-03-18 Thread Nathan Studer
On 18/03/25 03:42, Juergen Gross wrote: > On 18.03.25 08:34, Anderson Choi wrote: > > xen panic is observed with the following configuration. > > > > 1. Debug xen build (CONFIG_DEBUG=y) > > 2. dom1 of an ARINC653 domain > > 3. shutdown dom1 with xl command > > > > $ xl shutdown > > > > (XEN) *

Re: S3 regression on AMD in 4.20

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 07:24:31AM +0100, Jan Beulich wrote: > On 17.03.2025 18:38, Roger Pau Monné wrote: > > On Mon, Mar 17, 2025 at 05:11:56PM +0100, Jan Beulich wrote: > >> On 17.03.2025 16:56, Roger Pau Monné wrote: > >>> On Sat, Mar 15, 2025 at 12:02:50AM +, Andrew Cooper wrote: > On

Re: S3 regression on AMD in 4.20

2025-03-18 Thread Roger Pau Monné
On Mon, Mar 17, 2025 at 06:54:06PM +0100, Marek Marczykowski-Górecki wrote: > On Mon, Mar 17, 2025 at 06:35:08PM +0100, Roger Pau Monné wrote: > > On Mon, Mar 17, 2025 at 05:35:51PM +0100, Marek Marczykowski-Górecki wrote: > > > On Mon, Mar 17, 2025 at 04:56:15PM +0100, Roger Pau Monné wrote: > > >

Re: [PATCH v2] xen/arinc653: call xfree() with local IRQ enabled

2025-03-18 Thread Jürgen Groß
On 18.03.25 08:34, Anderson Choi wrote: xen panic is observed with the following configuration. 1. Debug xen build (CONFIG_DEBUG=y) 2. dom1 of an ARINC653 domain 3. shutdown dom1 with xl command $ xl shutdown (XEN) (XEN) Panic on CPU 2: (XEN) Assertion

RE: [EXTERNAL] Re: [PATCH] xen/sched: call xfree() after local IRQ is enabled

2025-03-18 Thread Choi, Anderson
Jan, > EXT email: be mindful of links/attachments. > > On 18.03.2025 05:00, Anderson Choi wrote: >> xen panic is observed with the following configuration. >> >> 1. Debug xen build (CONFIG_DEBUG=y) >> 2. dom1 of an ARINC653 domain >> 3. shutdown dom1 with xl command >> >> $ xl shutdown >> >>

Re: [PATCH 1/4] x86/traps: Move cpu_init() out of trap_init()

2025-03-18 Thread Jan Beulich
On 17.03.2025 20:20, Andrew Cooper wrote: > cpu_init() doesn't particularly belong in trap_init(). This brings the BSP > more in line with the APs. > > No functional change. > > Signed-off-by: Andrew Cooper Acked-by: Jan Beulich

[PATCH 1/7] x86/boot: clarify comment about trampoline_setup usage

2025-03-18 Thread Roger Pau Monne
Clarify that trampoline_setup is only used for EFI when booted using the multiboot2 entry point. Signed-off-by: Roger Pau Monné --- xen/arch/x86/boot/head.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 1b3bd16fe57

[PATCH 2/7] x86/mkelf32: account for offset when detecting note segment placement

2025-03-18 Thread Roger Pau Monne
mkelf32 attempt to check that the program header defined NOTE segment falls inside of the LOAD segment, as the build-id should be loaded for Xen at runtime to check. However the current code doesn't take into account the LOAD program header segment offset when calculating overlap with the NOTE seg

Re: [PATCH 5/7] x86/mkreloc: remove warning about relocations to RO section

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > Relocations are now applied after having moved the trampoline, so there's no > reason to warn about relocations to read-only sections. The logic that > apply the relocations would make sure they are applied against writable > mappings. > > Signed-off

[PATCH 3/7] xen: remove -N from the linker command line

2025-03-18 Thread Roger Pau Monne
It's unclear why -N is being used in the first place. It was added by commit 40828c657dd0c back in 2004 without any justification. When building a PE image it's actually detrimental to forcefully set the .text section as writable. The GNU LD man page contains the following warning regarding the

Re: [PATCH 4/7] x86/boot: apply trampoline relocations at destination position

2025-03-18 Thread Andrew Cooper
On 18/03/2025 7:05 pm, Frediano Ziglio wrote: > On Tue, Mar 18, 2025 at 5:36 PM Roger Pau Monne wrote: >> Change the order relocations are applied. Currently the trampoline is >> patched for relocations before being copied to the low 1MB region. Change >> the order and instead copy the trampolin

[PATCH v1 3/8] xen/domain: introduce domid_top

2025-03-18 Thread dmkhn
Rename max_init_domid to domid_top to align with its usage in the code (Arm), where it represents the upper boundary of the non-system domain ID range. Relocate the domid_top declaration to an architecture-independent location. Signed-off-by: Denis Mukhin --- xen/arch/arm/dom0less-build.c

[PATCH] xen: simplify bitmap_to_xenctl_bitmap for little endian

2025-03-18 Thread Stefano Stabellini
The little endian implementation of bitmap_to_xenctl_bitmap leads to unnecessary xmallocs and xfrees. Given that Xen only supports little endian architectures, it is worth optimizing. This patch removes the need for the xmalloc on little endian architectures. Signed-off-by: Stefano Stabellini d

[PATCH v1 8/8] xen/console: introduce console_get_focus()

2025-03-18 Thread dmkhn
Add console_get_focus() as a console public API to the retrieve current console owner domain ID. Make console_{get,put}_domain() private and simplify vpl011 code a bit. Signed-off-by: Denis Mukhin --- xen/arch/arm/vpl011.c | 5 + xen/drivers/char/console.c | 9 +++-- xen/include/xe

[PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Roger Pau Monne
UBSAN complains with: UBSAN: Undefined behaviour in common/compat/memory.c:90:9 pointer operation overflowed 82008000 to 02008000 [...] Xen call trace: [] R common/ubsan/ubsan.c#ubsan_epilogue+0xa/0xc0 [] F lib/xxhash64.c#__ubsan_handle_pointer_overflow+0xcb/0x100 [] F li

Re: [PATCH 1/7] x86/boot: clarify comment about trampoline_setup usage

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > Clarify that trampoline_setup is only used for EFI when booted using the > multiboot2 entry point. > > Signed-off-by: Roger Pau Monné > --- > xen/arch/x86/boot/head.S | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/xen/arc

Re: [PATCH 7/7] xen/build: warn about RWX load segments

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > After having removed the -N option from the linker script invocation, and > also having removed the merging of the .init.text and .init.data sections > on x86, there should be no remaining RWX load segments. Do not silence the > GNU LD warning. > > S

[PATCH 5/7] x86/mkreloc: remove warning about relocations to RO section

2025-03-18 Thread Roger Pau Monne
Relocations are now applied after having moved the trampoline, so there's no reason to warn about relocations to read-only sections. The logic that apply the relocations would make sure they are applied against writable mappings. Signed-off-by: Roger Pau Monné --- xen/arch/x86/efi/mkreloc.c | 5

[PATCH 4/7] x86/boot: apply trampoline relocations at destination position

2025-03-18 Thread Roger Pau Monne
Change the order relocations are applied. Currently the trampoline is patched for relocations before being copied to the low 1MB region. Change the order and instead copy the trampoline first to the low 1MB region and then apply the relocations. This will allow making .init.text section read-onl

[PATCH 0/7] x86: generate xen.efi image with no write-execute sections

2025-03-18 Thread Roger Pau Monne
Hello, The aim of the series is to generate a Xen image with no write and execute sections, so that the PE binary can be NX_COMPAT. The main change for achieving this is changing the order in which the trampoline relocation are applied. To avoid having write-execute sections apply the trampoline

Re: [PATCH 4/7] x86/boot: apply trampoline relocations at destination position

2025-03-18 Thread Frediano Ziglio
On Tue, Mar 18, 2025 at 5:36 PM Roger Pau Monne wrote: > > Change the order relocations are applied. Currently the trampoline is > patched for relocations before being copied to the low 1MB region. Change > the order and instead copy the trampoline first to the low 1MB region and > then apply th

Re: [PATCH 3/3] x86/irq: introduce APIC_VECTOR_VALID

2025-03-18 Thread Denis Mukhin
On Monday, March 17th, 2025 at 1:30 AM, Jan Beulich wrote: > > > On 15.03.2025 02:00, dm...@proton.me wrote: > > > Add new symbol APIC_VECTOR_VALID to replace open-coded value 16 in > > LAPIC and virtual LAPIC code. > > > First a good name is needed to make such a change. APIC_VECTOR_VALID > coul

[PATCH v1 6/8] xen/console: rename console_rx to console_focus

2025-03-18 Thread dmkhn
Update the symbol name in preparation for the semantic change to the physical console input owner domain identifier. No functional change. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/xen

[PATCH v1 2/8] xen/console: introduce console input permission

2025-03-18 Thread dmkhn
Add new flag in domain structure for marking permission to intercept the physical console input by the domain. Update console input switch logic accordingly. Signed-off-by: Denis Mukhin --- xen/arch/arm/vpl011.c | 2 ++ xen/arch/x86/pv/shim.c | 2 ++ xen/common/domain.c| 2 +

[PATCH v1 4/8] xen/domain: introduce domid_alloc()

2025-03-18 Thread dmkhn
Move domain ID allocation to a dedicated function domid_alloc() and use it during domain creation. Update domid_top within domid_alloc() to reflect the highest known domain ID. Initialize domid_top using the result of get_initial_domain_id(). Allocation algorithm: - If an explicit domain ID is p

[PATCH v1 5/8] xen/console: rename switch_serial_input() to console_switch_focus()

2025-03-18 Thread dmkhn
Update the name to emphasize the physical console input switch to a new owner domain following the naming notation in the console driver. No functional change. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xe

[PATCH v1 7/8] xen/console: introduce console_set_focus()

2025-03-18 Thread dmkhn
Switch console_focus address space from integers mapped to domain IDs to direct domain IDs, simplifying the console input switching code. Introduce console_set_focus() to set the console owner domain identifier. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 81 ---

[PATCH v1 1/8] xen/console: fix trailing whitespaces

2025-03-18 Thread dmkhn
Remove trailing whitespaces in the console driver. No functional change. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index ba428199d2..c3150fbdb7 1006

[PATCH] xen: add kconfig for event_fifo

2025-03-18 Thread Stefano Stabellini
Evtchn fifos are not needed on smaller systems; the older interface is lightweight and sufficient. Make it possible to disable evtchn fifo. Signed-off-by: Stefano Stabellini diff --git a/xen/common/Kconfig b/xen/common/Kconfig index a6aa2c5c14..14d82923c5 100644 --- a/xen/common/Kconfig +++ b/xe

[PATCH v1 0/8] xen/console: cleanup console input switch logic

2025-03-18 Thread dmkhn
Currently, on x86, console input can be rotated in round-robin manner only between dom0, PV shim, and Xen itself. On Arm the input rotation can include domUs with vpl011. The patch series introduces the concept of "console focus", which is defined as the ID of the domain that currently owns the

[PATCH 7/7] xen/build: warn about RWX load segments

2025-03-18 Thread Roger Pau Monne
After having removed the -N option from the linker script invocation, and also having removed the merging of the .init.text and .init.data sections on x86, there should be no remaining RWX load segments. Do not silence the GNU LD warning. Signed-off-by: Roger Pau Monné --- xen/Makefile | 2 --

Re: [PATCH v2 3/5] x86/xlat: fix UB pointer arithmetic in COMPAT_ARG_XLAT_VIRT_BASE

2025-03-18 Thread Roger Pau Monné
On Tue, Mar 18, 2025 at 06:01:46PM +0100, Jan Beulich wrote: > On 18.03.2025 17:47, Roger Pau Monné wrote: > > On Tue, Mar 18, 2025 at 04:50:58PM +0100, Jan Beulich wrote: > >> On 18.03.2025 16:35, Roger Pau Monné wrote: > >>> On Tue, Mar 18, 2025 at 03:33:03PM +0100, Jan Beulich wrote: > On 1

[PATCH] x86/boot: Untangle the trampoline copying/entry logic

2025-03-18 Thread Andrew Cooper
The LRET is detached from the PUSHes which set it up, and this is about to get worse with the changes to trampoline relocation. For the sake of one variable read, the complexity is not worth it. Reorder the logic to copy the trampoline into place, then switch stack and enter the trampoline. No f

Re: [PATCH 4/7] x86/boot: apply trampoline relocations at destination position

2025-03-18 Thread Andrew Cooper
On 18/03/2025 5:35 pm, Roger Pau Monne wrote: > diff --git a/xen/arch/x86/boot/reloc-trampoline.c > b/xen/arch/x86/boot/reloc-trampoline.c > index e35e7c78aa86..ac54aef14eaf 100644 > --- a/xen/arch/x86/boot/reloc-trampoline.c > +++ b/xen/arch/x86/boot/reloc-trampoline.c > @@ -20,19 +20,19 @@ void

Re: [PATCH] x86/msi: always propagate MSI writes when not in active system mode

2025-03-18 Thread Jan Beulich
On 18.03.2025 09:54, Roger Pau Monné wrote: > On Tue, Mar 18, 2025 at 09:36:37AM +0100, Jan Beulich wrote: >> On 18.03.2025 09:29, Roger Pau Monne wrote: >>> --- a/xen/drivers/passthrough/amd/iommu_intr.c >>> +++ b/xen/drivers/passthrough/amd/iommu_intr.c >>> @@ -546,7 +546,7 @@ int cf_check amd_io

Re: [PATCH v2] docs: Add some details on XenServer PCI devices

2025-03-18 Thread Frediano Ziglio
On Tue, Mar 4, 2025 at 1:23 PM Frediano Ziglio wrote: > > Describe the usage of devices 5853:0002 and 5853:C000. > > Signed-off-by: Frediano Ziglio > --- > Changes since v1: > - address minor comments > --- > docs/man/xen-pci-device-reservations.7.pod | 7 +++ > 1 file changed, 7 insertions(