Re: [PATCH 3/3] x86/pci: Fix racy accesses to MSI-X Control register

2022-12-13 Thread David Vrabel
On 13/12/2022 11:50, Jan Beulich wrote: On 13.12.2022 12:34, David Vrabel wrote: On 12/12/2022 17:04, Jan Beulich wrote: On 10.11.2022 17:59, David Vrabel wrote: --- a/xen/arch/x86/include/asm/msi.h +++ b/xen/arch/x86/include/asm/msi.h @@ -237,7 +237,10 @@ struct arch_msix { int

Re: [PATCH 3/3] x86/pci: Fix racy accesses to MSI-X Control register

2022-12-13 Thread David Vrabel
On 12/12/2022 17:04, Jan Beulich wrote: On 10.11.2022 17:59, David Vrabel wrote: --- a/xen/arch/x86/include/asm/msi.h +++ b/xen/arch/x86/include/asm/msi.h @@ -237,7 +237,10 @@ struct arch_msix { int table_refcnt[MAX_MSIX_TABLE_PAGES]; int table_idx[MAX_MSIX_TABLE_PAGES

Re: [PATCH] xen-pciback: Consider MSI-X enabled only when MASKALL bit is cleared

2022-11-17 Thread David Vrabel
On 17/11/2022 11:41, Marek Marczykowski-Górecki wrote: Linux enables MSI-X before disabling INTx, but keeps MSI-X masked until the table is filled. Then it disables INTx just before clearing MASKALL bit. Currently this approach is rejected by xen-pciback. Allow setting PCI_MSIX_FLAGS_ENABLE

Re: [PATCH 2/3] x86/msi: remove return value from msi_set_mask_bit()

2022-11-11 Thread David Vrabel
? David From 837649a70d44455f4fd98e2eaa46dcf35a56d00a Mon Sep 17 00:00:00 2001 From: David Vrabel Date: Fri, 11 Nov 2022 14:30:16 + Subject: [PATCH] x86: Always enable memory space decodes when using MSI-X Instead of the numerous (racy) checks for memory space accesses being enabled before

[PATCH 3/3] x86/pci: Fix racy accesses to MSI-X Control register

2022-11-10 Thread David Vrabel
) enabled. Signed-off-by: David Vrabel SIM: https://t.corp.amazon.com/P63914633 CR: https://code.amazon.com/reviews/CR-79020945 --- xen/arch/x86/include/asm/msi.h | 3 + xen/arch/x86/msi.c | 215 + xen/drivers/passthrough/msi.c | 1 + 3 files changed

[PATCH 0/3] x86: Fix racy accesses to MSI-X Control register

2022-11-10 Thread David Vrabel
The main patch in this series is 3/3 with some preparatory patches to simplify the implementation. To summarize: Concurrent access the the MSI-X control register are not serialized with a suitable lock. For example, in msix_capability_init() access use the pcidevs_lock() but some

[PATCH 1/3] x86/msi: consistently handle BAR mapping failures in MSI-X setup

2022-11-10 Thread David Vrabel
r path is not necessary as the per-vector mask is still still set. Signed-off-by: David Vrabel CR: https://code.amazon.com/reviews/CR-79020908 --- xen/arch/x86/msi.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index d0bf

[PATCH 2/3] x86/msi: remove return value from msi_set_mask_bit()

2022-11-10 Thread David Vrabel
-X table is not accessible) has a useful warning message. Signed-off-by: David Vrabel CR: https://code.amazon.com/reviews/CR-79020927 --- xen/arch/x86/msi.c | 34 +- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/xen/arch/x86/msi.c b/xen/arch/x86

Re: Regression with CET: [PATCH v1] x86/mm: avoid inadvertently degrading a TLB flush to local only

2022-04-27 Thread David Vrabel
On 27/04/2022 19:03, Andrew Cooper wrote: On 19/04/2022 16:03, David Vrabel wrote: From: David Vrabel If the direct map is incorrectly modified with interrupts disabled, the required TLB flushes are degraded to flushing the local CPU only. This could lead to very hard to diagnose problems

Re: [PATCH v4] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-26 Thread David Vrabel
On 26/04/2022 15:14, Julien Grall wrote: Hi, On 26/04/2022 15:01, Jan Beulich wrote: On 25.04.2022 15:28, David Vrabel wrote: --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -162,6 +162,13 @@   static char __initdata opt_badpage[100] = "";   string_para

Re: [PATCH v4] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-25 Thread David Vrabel
On 25/04/2022 14:43, Julien Grall wrote: Hi Jan, On 25/04/2022 14:37, Jan Beulich wrote: On 25.04.2022 15:34, Julien Grall wrote: On 25/04/2022 14:28, David Vrabel wrote: --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -162,6 +162,13 @@    static char __initdata opt_badpage

[PATCH v4] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-25 Thread David Vrabel
From: David Vrabel Heap pages can only be safely allocated and freed with interuupts enabled as they may require a TLB flush which will send IPIs (on x86). Normally spinlock debugging would catch calls from the incorrect context, but not from stop_machine_run() action functions

[PATCH v3] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-22 Thread David Vrabel
From: David Vrabel Heap pages can only be safely allocated and freed with interuupts enabled as they may require a TLB flush which will send IPIs. Normally spinlock debugging would catch calls from the incorrect context, but not from stop_machine_run() action functions as these are called

Re: [PATCH v2] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-21 Thread David Vrabel
On 21/04/2022 12:38, Jan Beulich wrote: On 21.04.2022 12:43, David Vrabel wrote: --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -984,6 +984,8 @@ void __init start_xen(unsigned long boot_phys_offset, console_init_postirq(); +system_state = SYS_STATE_smp_boot

[PATCH v2] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-21 Thread David Vrabel
From: David Vrabel Heap pages can only be safely allocated and freed with interuupts enabled as they may require a TLB flush which will send IPIs. Normally spinlock debugging would catch calls from the incorrect context, but not from stop_machine_run() action functions as these are called

Re: [PATCH v1] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-20 Thread David Vrabel
On 20/04/2022 07:26, Jan Beulich wrote: On 19.04.2022 17:01, David Vrabel wrote: From: David Vrabel Heap pages can only be safely allocated and freed with interuupts enabled as they may require a TLB flush which will send IPIs. Enhance the assertions in alloc_xenheap_pages

[PATCH v1] x86/mm: avoid inadvertently degrading a TLB flush to local only

2022-04-19 Thread David Vrabel
From: David Vrabel If the direct map is incorrectly modified with interrupts disabled, the required TLB flushes are degraded to flushing the local CPU only. This could lead to very hard to diagnose problems as different CPUs will end up with different views of memory. Although, no such issues

[PATCH v1] page_alloc: assert IRQs are enabled in heap alloc/free

2022-04-19 Thread David Vrabel
From: David Vrabel Heap pages can only be safely allocated and freed with interuupts enabled as they may require a TLB flush which will send IPIs. Enhance the assertions in alloc_xenheap_pages() and alloc_domheap_pages() to check interrupts are enabled. For consistency the same asserts are used

Re: [PATCH] xen/evtchn: Add design for static event channel signaling for domUs..

2022-03-24 Thread David Vrabel
On 23/03/2022 15:43, Rahul Singh wrote: in dom0less system. This patch introduce the new feature to support the signaling between two domUs in dom0less system. Signed-off-by: Rahul Singh --- docs/designs/dom0less-evtchn.md | 96 + 1 file changed, 96

Re: [XEN PATCH] evtchn/fifo: Don't set PENDING bit if guest misbehaves

2022-03-21 Thread David Vrabel
of these cases. Reviewed-by: David Vrabel David

Re: [XEN PATCH] evtchn/fifo: Don't set PENDING bit if guest misbehaves

2022-03-17 Thread David Vrabel
On 17/03/2022 06:28, Juergen Gross wrote: On 16.03.22 19:38, Raphael Ning wrote: From: Raphael Ning Currently, evtchn_fifo_set_pending() will mark the event as PENDING even if it fails to lock the FIFO event queue(s), or if the guest has not initialized the FIFO control block for the

Re: [PATCH] x86/kexec: Fix kexec-reboot with CET active

2022-03-07 Thread David Vrabel
masking/faulting. Move both pieces of logic from machine_crash_shutdown() to machine_kexec(), the latter being common for all kexec transitions. Adjust the condition for CET being considered active to check in CR4, which is simpler and more robust. Reviewed-by: David Vrabel Fixes: 311434bfc9d1

CET-IBT and kexec?

2022-03-07 Thread David Vrabel
kexec_reloc (see xen/arch/x86/x86_64/kexec_reloc.S) has an indirect branch as part of switching page tables. I understand that if CET-IBT is enabled this will raise an exception since there's no ENDBR64 instruction and (as far as I could tell) CET-IBT has not been disabled in machine_kexec()

Re: [PATCH 2/2] xen/x86: Livepatch: support patching CET-enhanced functions

2022-03-07 Thread David Vrabel
On 07/03/2022 14:03, Jan Beulich wrote: On 07.03.2022 12:53, Bjoern Doebel wrote: @@ -104,18 +122,36 @@ void noinline arch_livepatch_revive(void) int arch_livepatch_verify_func(const struct livepatch_func *func) { +BUILD_BUG_ON(sizeof(struct x86_livepatch_meta) !=

Re: [PATCH v2 21/70] xen/evtchn: CFI hardening

2022-02-14 Thread David Vrabel
On 14/02/2022 12:50, Andrew Cooper wrote: Control Flow Integrity schemes use toolchain and optionally hardware support to help protect against call/jump/return oriented programming attacks. Use cf_check to annotate function pointer targets for the toolchain. [...] -static void

Re: [PATCH] x86/time: further improve TSC / CPU freq calibration accuracy

2022-01-18 Thread David Vrabel
On 18/01/2022 08:50, Jan Beulich wrote: On 13.01.2022 14:41, Jan Beulich wrote: Calibration logic assumes that the platform timer (HPET or ACPI PM timer) and the TSC are read at about the same time. This assumption may not hold when a long latency event (e.g. SMI or NMI) occurs between the

Re: [PATCH] x86/hvm: reserve another HVM context save record ID for Amazon

2022-01-14 Thread David Vrabel
On 14/01/2022 07:08, Jan Beulich wrote: On 07.01.2022 13:55, David Vrabel wrote: Amazon's guest transparent live migration work needs another save record (for event channel upcall vectors). Reserve another HVM context save record ID for this. I have to admit that I have reservations: I

Re: [XEN PATCH 1/7] xen: introduce XENFEAT_xenstore_late_init

2022-01-11 Thread David Vrabel
On 10/01/2022 22:55, Stefano Stabellini wrote: I have a patch for Linux that if XENFEAT_xenstore_late_init is present makes Linux wait for an event notification before initializing xenstore: https://marc.info/?l=xen-devel=164160299315589 So with v1 of the Xen and Linux patches series: - Xen

Re: [PATCHv2] x86/hvm: add more callback/upcall info to 'I' debug key

2022-01-07 Thread David Vrabel
On 07/01/2022 13:45, Andrew Cooper wrote: printk("Callback via PCI dev %u INTx %u%s\n", PCI 00:%02x.0  ? Is this correct? If I remember right, the INTx lines are associated with a PCI device, with the function then reporting which line it uses. So Xen neither knows (nor cares) what

Re: [PATCH] x86/hvm: save/restore per-VCPU event channel upcall vector

2022-01-07 Thread David Vrabel
On 06/01/2022 16:48, Jan Beulich wrote: On 06.01.2022 16:54, David Vrabel wrote: The Windows XENBUS driver sets the per-VCPU LAPIC vector for event channel interrupts using the HVMOP_set_evtchn_upcall_vector hypercall (rather than using a vector-type callback in the CALLBACK_IRQ HVM parameter

[PATCH] x86/hvm: reserve another HVM context save record ID for Amazon

2022-01-07 Thread David Vrabel
Amazon's guest transparent live migration work needs another save record (for event channel upcall vectors). Reserve another HVM context save record ID for this. Signed-off-by: David Vrabel --- I've added it to the end, keeping the unused ID at 21. --- xen/include/public/arch-x86/hvm/save.h | 2

[PATCHv2] x86/hvm: add more callback/upcall info to 'I' debug key

2022-01-07 Thread David Vrabel
Include the type of the callback via and the per-VCPU upcall vector. Signed-off-by: David Vrabel --- v2: - fix style - make upcall vector output distinguishable from logs prior to this patch - use fewer lines for callback via. --- xen/arch/x86/hvm/irq.c | 49

[PATCH] x86/hvm: save/restore per-VCPU event channel upcall vector

2022-01-06 Thread David Vrabel
. Signed-off-by: David Vrabel --- xen/arch/x86/hvm/hvm.c | 50 -- xen/include/public/arch-x86/hvm/save.h | 12 ++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 350dc396e3..be2e676c4a

[PATCH] x86/hvm: add more callback/upcall info to 'I' debug key

2022-01-06 Thread David Vrabel
Include the type of the callback via and the per-VCPU upcall vector. Signed-off-by: David Vrabel --- xen/arch/x86/hvm/irq.c | 31 +++ 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c index 52aae4565f