[PATCH v9 01/36] Documentation/x86/64: Add documentation for FRED

2023-07-31 Thread Xin Li
Briefly introduce FRED, its advantages compared to IDT, and its Linux enabling. Signed-off-by: Xin Li --- Documentation/arch/x86/x86_64/fred.rst | 102 Documentation/arch/x86/x86_64/index.rst | 1 + 2 files changed, 103 insertions(+) create mode 100644 Documentation/

[PATCH v9 05/36] x86/opcode: Add ERETU, ERETS instructions to x86-opcode-map

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add instruction opcodes used by FRED ERETU/ERETS to x86-opcode-map. Opcode numbers are per FRED spec v5.0. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/lib/x86-opcode-map.txt | 2 +- tools/arch/x86/lib/x86

[PATCH v9 11/36] x86/fred: Reserve space for the FRED stack frame

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" When using FRED, reserve space at the top of the stack frame, just like i386 does. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/thread_info.h | 12 +--- 1 file changed, 9 insertions(+), 3 dele

[PATCH v9 04/36] x86/cpufeatures: Add the cpu feature bit for FRED

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add the CPU feature bit for FRED. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/cpufeatures.h | 1 + tools/arch/x86/include/asm/cpufeatures.h | 1 + 2 files changed, 2 insertions(+) diff --git a

[PATCH v9 16/36] x86/fred: Allow single-step trap and NMI when starting a new task

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Entering a new task is logically speaking a return from a system call (exec, fork, clone, etc.). As such, if ptrace enables single stepping a single step exception should be allowed to trigger immediately upon entering user space. This is not optional. NMI should *

[PATCH v9 06/36] x86/objtool: Teach objtool about ERETU and ERETS

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Update the objtool decoder to know about the ERETU and ERETS instructions (type INSN_CONTEXT_SWITCH). Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- tools/objtool/arch/x86/decode.c | 19 ++- 1 file changed,

[PATCH v9 00/36] x86: enable FRED for x86-64

2023-07-31 Thread Xin Li
This patch set enables the Intel flexible return and event delivery (FRED) architecture for x86-64. The FRED architecture defines simple new transitions that change privilege level (ring transitions). The FRED architecture was designed with the following goals: 1) Improve overall performance and

[PATCH v9 03/36] x86/fred: Disable FRED support if CONFIG_X86_FRED is disabled

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add CONFIG_X86_FRED to to make cpu_feature_enabled() work correctly with FRED. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/disabled-features.h | 8 +++- tools/arc

[PATCH v9 02/36] x86/fred: Add Kconfig option for FRED (CONFIG_X86_FRED)

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add the configuration option CONFIG_X86_FRED to enable FRED. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/Kconfig | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig i

[PATCH v9 07/36] x86/cpu: Add X86_CR4_FRED macro

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit should be a pinned bit, not to be changed after initialization. CR4 macros are defined in arch/x86/include/uapi/asm/processor-flags.h, which is uapi, and thus cannot depend on CONFIG_X86_64. Using _BITUL()

[PATCH v9 09/36] x86/fred: Make unions for the cs and ss fields in struct pt_regs

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Make the cs and ss fields in struct pt_regs unions between the actual selector and the unsigned long stack slot. FRED uses this space to store additional flags. The printk changes are simply due to the cs and ss fields changed to unsigned short from unsigned long.

[PATCH v9 08/36] x86/cpu: Add MSR numbers for FRED configuration

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add MSR numbers for the FRED configuration registers. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/msr-index.h | 13 - tools/arch/x86/include/asm/msr-index.

[PATCH v9 10/36] x86/fred: Add a new header file for FRED definitions

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add a header file for FRED prototypes and definitions. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v6: * Replace pt_regs csx flags prefix FRED_CSL_ with FRED_CSX_. --- arch/x86/include/asm/fred.h | 104 +++

[PATCH v9 18/36] x86/fred: Add a page fault entry stub for FRED

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add a page fault entry stub for FRED. On a FRED system, the faulting address (CR2) is passed on the stack, to avoid the problem of transient state. Thus we get the page fault address from the stack instead of CR2. Signed-off-by: H. Peter Anvin (Intel) Tested-by:

[PATCH v9 22/36] x86/fred: Add a double fault entry stub for FRED

2023-07-31 Thread Xin Li
The IDT event delivery of a double fault pushes an error code into the orig_ax member of the pt_regs structure, and the error code is passed as the second argument of its C-handler exc_double_fault(), although the pt_regs structure is already passed as the first argument. The existing IDT double f

[PATCH v9 20/36] x86/fred: Add a NMI entry stub for FRED

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" On a FRED system, NMIs nest both with themselves and faults, transient information is saved into the stack frame, and NMI unblocking only happens when the stack frame indicates that so should happen. Thus, the NMI entry stub for FRED is really quite small... Signe

[PATCH v9 13/36] x86/fred: Let ret_from_fork_asm() jmp to fred_exit_user when FRED is enabled

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Let ret_from_fork_asm() jmp to fred_exit_user when FRED is enabled, otherwise the existing IDT code is chosen. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_64.S | 6 ++ 1 file changed, 6 insertion

[PATCH v9 24/36] x86/idtentry: Incorporate definitions/declarations of the FRED external interrupt handler type

2023-07-31 Thread Xin Li
FRED operates differently from IDT in terms of interrupt handling. Instead of directly dispatching an interrupt to its handler based on the interrupt vector, FRED requires the software to dispatch an event to its handler based on both the event's type and vector. Therefore, an event dispatch framew

[PATCH v9 19/36] x86/fred: Add a debug fault entry stub for FRED

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add a debug fault entry stub for FRED. On a FRED system, the debug trap status information (DR6) is passed on the stack, to avoid the problem of transient state. Furthermore, FRED transitions avoid a lot of ugly corner cases the handling of which can, and should be

[PATCH v9 12/36] x86/fred: Update MSR_IA32_FRED_RSP0 during task switch

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" MSR_IA32_FRED_RSP0 is used during ring 3 event delivery, and needs to be updated to point to the top of next task stack during task switch. Update MSR_IA32_FRED_RSP0 with WRMSR instruction for now, and will use WRMSRNS/WRMSRLIST for performance once it gets upstrea

[PATCH v9 15/36] x86/fred: No ESPFIX needed when FRED is enabled

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" Because FRED always restores the full value of %rsp, ESPFIX is no longer needed when it's enabled. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/espfix_64.c | 8 1 file changed, 8 insertions(+) di

[PATCH v9 23/36] x86/entry: Remove idtentry_sysvec from entry_{32,64}.S

2023-07-31 Thread Xin Li
idtentry_sysvec is really just DECLARE_IDTENTRY defined in , no need to define it separately. Signed-off-by: Xin Li --- arch/x86/entry/entry_32.S | 4 arch/x86/entry/entry_64.S | 8 arch/x86/include/asm/idtentry.h | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-)

[PATCH v9 25/36] x86/traps: Add a system interrupt handler table for system interrupt dispatch

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" On x86, external interrupts can be categorized into two groups: 1) System interrupts 2) External device interrupts All external device interrupts are directed to the common_interrupt(), which, in turn, dispatches these external device interrupts using a per-CPU

[PATCH v9 14/36] x86/fred: Disallow the swapgs instruction when FRED is enabled

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" The FRED architecture establishes the full supervisor/user through: 1) FRED event delivery from ring 3 swaps the value of the GS base address and that of the IA32_KERNEL_GS_BASE MSR. 2) ERETU swaps the value of the GS base address and that of the IA32_KERNEL_G

[PATCH v9 17/36] x86/fred: Define a common function type fred_handler

2023-07-31 Thread Xin Li
FRED event delivery establishes a full supervisor context by saving the essential information about an event to a FRED stack frame, e.g., the faulting linear address of a #PF is saved as event data of a FRED stack frame. Thus a struct pt_regs has all the needed data to handle an event and it's the

[PATCH v9 21/36] x86/fred: Add a machine check entry stub for FRED

2023-07-31 Thread Xin Li
Add a machine check entry stub for FRED. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v5: * Disallow #DB inside #MCE for robustness sake (Peter Zijlstra). --- arch/x86/include/asm/fred.h| 1 + arch/x86/kernel/cpu/mce/core.c | 15 +++ 2 files changed, 16 inserti

[PATCH v9 26/36] x86/traps: Add sysvec_install() to install a system interrupt handler

2023-07-31 Thread Xin Li
Add sysvec_install() to install a system interrupt handler into both the IDT and system_interrupt_handlers. The latter is used to dispatch system interrupts to their respective handlers when FRED is enabled. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v8: * Introduce a macro sy

[PATCH v9 27/36] x86/traps: Add external_interrupt() to dispatch external interrupts

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" external_interrupt() dispatches all external interrupts: it checks if an external interrupt is a system interrupt, if yes it dipatches it through the system_interrupt_handlers table, otherwise to dispatch_common_interrupt(). Signed-off-by: H. Peter Anvin (Intel) C

[PATCH v9 28/36] x86/idtentry: Incorporate declaration/definition of the FRED exception handler type

2023-07-31 Thread Xin Li
The existing IDT exception C-handlers of X86_TRAP_TS, X86_TRAP_NP, X86_TRAP_SS, X86_TRAP_GP, X86_TRAP_AC and X86_TRAP_CP take an error code as the second argument, thus their FRED version handlers simply call the corresponding existing IDT handlers with orig_ax from the pt_regs structure as the sec

[PATCH v9 29/36] x86/fred: FRED entry/exit and dispatch code

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" The code to actually handle kernel and event entry/exit using FRED. It is split up into two files thus: - entry_64_fred.S contains the actual entrypoints and exit code, and saves and restores registers. - entry_fred.c contains the two-level event dispatch code fo

[PATCH v9 32/36] x86/fred: Export fred_entrypoint_kernel() for handling NMI in NMI induced VM exits

2023-07-31 Thread Xin Li
Export fred_entrypoint_kernel() for handling NMI in NMI induced VM exits. Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_64_fred.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/entry/entry_64_fred.S b/arch/x86/entry/entry_64_fred.S index d24bf7f10ac8..12063

[PATCH v9 31/36] x86/traps: Export external_interrupt() for handling IRQ in IRQ induced VM exits

2023-07-31 Thread Xin Li
Export external_interrupt() for handling IRQ in IRQ induced VM exits. Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/traps.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 90fdfcccee7a..6143ad56008e 100644 --- a/a

[PATCH v9 34/36] x86/syscall: Split IDT syscall setup code into idt_syscall_init()

2023-07-31 Thread Xin Li
Split IDT syscall setup code into idt_syscall_init() to make it cleaner to add FRED syscall setup code. Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/cpu/common.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/a

[PATCH v9 33/36] KVM: VMX: Add VMX_DO_FRED_EVENT_IRQOFF for IRQ/NMI handling

2023-07-31 Thread Xin Li
Compared to an IDT stack frame, a FRED stack frame has extra 16 bytes of information pushed at the regular stack top and 8 bytes of error code _always_ pushed at the regular stack bottom, add VMX_DO_FRED_EVENT_IRQOFF to generate FRED stack frames with event type and vector properly set. Thus, IRQ/N

[PATCH v9 30/36] x86/fred: Fixup fault on ERETU by jumping to fred_entrypoint_user

2023-07-31 Thread Xin Li
If the stack frame contains an invalid user context (e.g. due to invalid SS, a non-canonical RIP, etc.) the ERETU instruction will trap (#SS or #GP). >From a Linux point of view, this really should be considered a user space failure, so use the standard fault fixup mechanism to intercept the fault

[PATCH v9 35/36] x86/fred: FRED initialization code

2023-07-31 Thread Xin Li
From: "H. Peter Anvin (Intel)" The code to initialize FRED when it's available and _not_ disabled. cpu_init_fred_exceptions() is the core function to initialize FRED, which 1. Sets up FRED entrypoints for events happening in ring 0 and 3. 2. Sets up a default stack for event handling. 3. S

[PATCH v9 36/36] x86/fred: Disable FRED by default in its early stage

2023-07-31 Thread Xin Li
Disable FRED by default in its early stage. To enable FRED, a new kernel command line option "fred" needs to be added. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v7: * Add a log message when FRED is enabled. --- Documentation/admin-guide/kernel-parameters.txt | 4 arch/

[XEN PATCH v2 0/4] x86: address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
This series aims to address some violations of MISRA C:2012 Rule 5.3: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope". To resolve such violations two strategies have been applied: 1. rename several function parameters or local variables; 2. remov

[XEN PATCH v2 4/4] x86emul: remove local variable to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
The local variable removed by this commit shadowed another declared in an outer scope and thus violates Rule 5.3. It was introduced as part of a refactoring by commit abf5fb62f73d0dbeabc6a8cd6dbb55174b36c8d1. No functional changes. Signed-off-by: Nicola Vetrini --- xen/arch/x86/x86_emulate/x86_

[XEN PATCH v2 2/4] x86/mm: remove variable to avoid shadowing

2023-07-31 Thread Nicola Vetrini
The local variable 'p2mt' shadows a declaration of the same variable in the enclosing scope, but removing the inner declaration does not alter the semantics ('p2mt' is an output for the get_gfn call later on) and this resolves a violation of MISRA C:2012 Rule 5.3. Both variables were last introduc

[XEN PATCH v2 1/4] x86: mechanically rename to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
Rule 5.3 has the following headline: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope" The renames done by this patch avoid shadowing from happening. They are as follows: - s/i/j/ in 'mce_action' (the shadowing here is due to macro 'x86_mcinfo_loo

[XEN PATCH v2 3/4] x86emul: avoid shadowing to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
Rule 5.3 has the following headline: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope" The declaration of local variable 'cpuid_leaf' causes shadowing with the homonymous function to happen, therefore the variable is renamed to avoid this. No funct

Re: [PATCH v2 5/5] pdx: Add CONFIG_HAS_PDX_COMPRESSION as a common Kconfig option

2023-07-31 Thread Jan Beulich
On 28.07.2023 18:58, Andrew Cooper wrote: > On 28/07/2023 5:36 pm, Andrew Cooper wrote: >> On 28/07/2023 8:59 am, Alejandro Vallejo wrote: >>> Adds a new compile-time flag to allow disabling pdx compression and >>> compiles out compression-related code/data. It also shorts the pdx<->pfn >>> convers

Re: [PATCH 3/3] x86: Delete str()

2023-07-31 Thread Jan Beulich
On 28.07.2023 21:43, Andrew Cooper wrote: > This is used in an assertion only, which is somewhat dubious to begin with and > won't surivive the x86-S work (where TR will become be a NUL selector). I'm kind of okay with the removal, but I can't read anything like the above out of the doc. Can you p

[XEN PATCH] EFI: address violations of MISRA C:2012 Rules 8.2 and 8.3

2023-07-31 Thread Federico Serafini
Give a name to unnamed parameters to address violations of MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with named parameters"). Keep consistency between parameter names and types used in function declarations and the ones used in the corresponding function definitions, thus ad

Re: [PATCH 2/3] x86/entry: Rename the exception entrypoints

2023-07-31 Thread Jan Beulich
On 28.07.2023 21:43, Andrew Cooper wrote: > This makes the names match the architectural short names that we use > elsewhere. This avoids 'debug' in particular from being a global symbol > shadowed by many local parameter names. > > Remove the DECLARE_TRAP_HANDLER{,_CONST}() infrastructure. Only

Re: [PATCH] x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()

2023-07-31 Thread Jan Beulich
On 28.07.2023 20:17, Andrew Cooper wrote: > This line: > > val &= ~chickenbit; > > ends up truncating val to 32 bits, and turning off various errata workarounds > in Zen2 systems. > > Fixes: f91c5ea97067 ("x86/amd: Mitigations for Zenbleed") > Signed-off-by: Andrew Cooper > --- > CC: Jan

Re: [PATCH v2 5/5] pdx: Add CONFIG_HAS_PDX_COMPRESSION as a common Kconfig option

2023-07-31 Thread Julien Grall
On 28/07/2023 17:36, Andrew Cooper wrote: On 28/07/2023 8:59 am, Alejandro Vallejo wrote: Adds a new compile-time flag to allow disabling pdx compression and compiles out compression-related code/data. It also shorts the pdx<->pfn conversion macros and creates stubs for masking fucntions. Wh

Re: [PATCH 2/3] x86/entry: Rename the exception entrypoints

2023-07-31 Thread Nicola Vetrini
On 28/07/2023 21:43, Andrew Cooper wrote: This makes the names match the architectural short names that we use elsewhere. This avoids 'debug' in particular from being a global symbol shadowed by many local parameter names. Remove the DECLARE_TRAP_HANDLER{,_CONST}() infrastructure. Only NMI/

Re: [PATCH 3/3] x86: Delete str()

2023-07-31 Thread Nicola Vetrini
On 28/07/2023 21:43, Andrew Cooper wrote: This is used in an assertion only, which is somewhat dubious to begin with and won't surivive the x86-S work (where TR will become be a NUL selector). Delete it now. This avoids many cases where as a global symbol, it shadows local string variables.

Re: [PATCH v9 05/36] x86/opcode: Add ERETU, ERETS instructions to x86-opcode-map

2023-07-31 Thread Google
On Sun, 30 Jul 2023 23:32:46 -0700 Xin Li wrote: > From: "H. Peter Anvin (Intel)" > > Add instruction opcodes used by FRED ERETU/ERETS to x86-opcode-map. > > Opcode numbers are per FRED spec v5.0. > > Signed-off-by: H. Peter Anvin (Intel) > Tested-by: Shan Kang > Signed-off-by: Xin Li Thi

Re: [PATCH v7 04/15] xen/sysctl: Nest cpufreq scaling options

2023-07-31 Thread Anthony PERARD
On Thu, Jul 27, 2023 at 11:05:33AM -0400, Jason Andryuk wrote: > On Thu, Jul 27, 2023 at 6:27 AM Anthony PERARD > wrote: > > > > On Wed, Jul 26, 2023 at 01:09:34PM -0400, Jason Andryuk wrote: > > > Add a union and struct so that most of the scaling variables of struct > > > xen_get_cpufreq_para ar

[linux-linus test] 182083: regressions - FAIL

2023-07-31 Thread osstest service owner
flight 182083 linux-linus real [real] flight 182086 linux-linus real-retest [real] http://logs.test-lab.xenproject.org/osstest/logs/182083/ http://logs.test-lab.xenproject.org/osstest/logs/182086/ Regressions :-( Tests which did not succeed and are blocking, including tests which could not be run

[XEN PATCH v2] x86/hpet: Disable legacy replacement mode after IRQ test

2023-07-31 Thread Simon Gaiser
As far as I understand the HPET legacy mode is not required after the timer IRQ test. For previous discussion see [1] and [2]. Keeping it enabled prevents reaching deeper C-states on some systems and thereby also S0ix residency. So disable it after the timer IRQ test worked. Note that this code pat

Re: [PATCH v3] amd: disable C6 after 1000 days on Zen2

2023-07-31 Thread Jan Beulich
On 28.07.2023 16:47, Roger Pau Monne wrote: > As specified on Errata 1474: > > "A core will fail to exit CC6 after about 1044 days after the last > system reset. The time of failure may vary depending on the spread > spectrum and REFCLK frequency." > > Detect when running on AMD Zen2 and setup a

Re: [XEN PATCH] IOMMU: address violations of MISRA C:2012 Rules 8.2 and 8.3

2023-07-31 Thread Jan Beulich
On 29.07.2023 01:29, Stefano Stabellini wrote: > On Fri, 28 Jul 2023, Federico Serafini wrote: >> Give a name to unnamed parameters to address violations of >> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with >> named parameters"). >> Keep consistency between parameter names a

Re: [XEN PATCH] EFI: address violations of MISRA C:2012 Rules 8.2 and 8.3

2023-07-31 Thread Jan Beulich
On 31.07.2023 10:35, Federico Serafini wrote: > Give a name to unnamed parameters to address violations of > MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with > named parameters"). > Keep consistency between parameter names and types used in function > declarations and the ones

Re: [XEN PATCH v2 2/2] x86/IRQ: address violations of MISRA C: 2012 Rules 8.2 and 8.3

2023-07-31 Thread Jan Beulich
On 29.07.2023 01:13, Stefano Stabellini wrote: > On Fri, 28 Jul 2023, Federico Serafini wrote: >> Give a name to unnamed parameters thus addressing violations of >> MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with >> named parameters"). >> Keep consistency between parameter na

Re: [XEN PATCH v3 1/2] build: evaluate XEN_BUILD_* and XEN_DOMAIN immediately

2023-07-31 Thread Jan Beulich
On 27.07.2023 16:54, Anthony PERARD wrote: > With GNU make 4.4, the number of execution of the command present in > these $(shell ) increased greatly. This is probably because as of make > 4.4, exported variable are also added to the environment of $(shell ) > construct. > > Also, `make -d` shows

Re: [PATCH 01/32] block: Provide blkdev_get_handle_* functions

2023-07-31 Thread Jan Kara
On Wed 12-07-23 18:06:35, Haris Iqbal wrote: > On Thu, Jul 6, 2023 at 5:38 PM Christoph Hellwig wrote: > > > > On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote: > > > Create struct bdev_handle that contains all parameters that need to be > > > passed to blkdev_put() and provide blkdev_get_

Re: [XEN PATCH v3 2/2] Config.mk: evaluate XEN_COMPILE_ARCH and XEN_OS immediately

2023-07-31 Thread Jan Beulich
On 27.07.2023 16:54, Anthony PERARD wrote: > With GNU make 4.4, the number of execution of the command present in > these $(shell ) increased greatly. This is probably because as of make > 4.4, exported variable are also added to the environment of $(shell ) > construct. > > So to avoid having the

Re: [PATCH 01/32] block: Provide blkdev_get_handle_* functions

2023-07-31 Thread Christoph Hellwig
On Mon, Jul 31, 2023 at 12:50:34PM +0200, Jan Kara wrote: > I think the bdev_handle name is fine for the struct. After all it is > equivalent of an open handle for the block device so IMHO bdev_handle > captures that better than bdev_ctx. Agreed.

Re: [XEN PATCH v2 1/4] x86: mechanically rename to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Jan Beulich
On 31.07.2023 09:33, Nicola Vetrini wrote: > Rule 5.3 has the following headline: > "An identifier declared in an inner scope shall not hide an > identifier declared in an outer scope" > > The renames done by this patch avoid shadowing from happening. > They are as follows: > - s/i/j/ in 'mce_acti

Re: [XEN PATCH v2 1/4] x86: mechanically rename to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Jan Beulich
On 31.07.2023 13:15, Jan Beulich wrote: > On 31.07.2023 09:33, Nicola Vetrini wrote: >> --- a/xen/arch/x86/include/asm/hvm/save.h >> +++ b/xen/arch/x86/include/asm/hvm/save.h >> @@ -49,21 +49,21 @@ void _hvm_read_entry(struct hvm_domain_context *h, >> */ >> #define _hvm_load_entry(_x, _h, _dst,

Re: [XEN PATCH v2 2/4] x86/mm: remove variable to avoid shadowing

2023-07-31 Thread Jan Beulich
On 31.07.2023 09:33, Nicola Vetrini wrote: > The local variable 'p2mt' shadows a declaration of the same variable > in the enclosing scope, but removing the inner declaration > does not alter the semantics ('p2mt' is an output for the get_gfn > call later on) and this resolves a violation of > MISR

Re: [XEN PATCH v2 3/4] x86emul: avoid shadowing to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Jan Beulich
On 31.07.2023 09:33, Nicola Vetrini wrote: > Rule 5.3 has the following headline: > "An identifier declared in an inner scope shall not hide an > identifier declared in an outer scope" > > The declaration of local variable 'cpuid_leaf' causes > shadowing with the homonymous function to happen, the

Re: [XEN PATCH v2 4/4] x86emul: remove local variable to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Jan Beulich
On 31.07.2023 09:33, Nicola Vetrini wrote: > The local variable removed by this commit shadowed another declared in > an outer scope and thus violates Rule 5.3. It was introduced as part of > a refactoring by commit abf5fb62f73d0dbeabc6a8cd6dbb55174b36c8d1. > > No functional changes. > > Signed-o

Re: [PATCH] xen/events: Add wakeup support to xen-pirq

2023-07-31 Thread Juergen Gross
On 24.07.23 12:29, Simon Gaiser wrote: Simon Gaiser: This allows entering and exiting s2idle. Actual S0ix residency is another topic [1]. Without this the ACPI code currently ignores the error enable_irq_wake() returns when being used on a xen-pirq and the system goes to idle for ever since the

[XEN PATCH] xen/sched: address violations of MISRA C:2012 Rules 8.2 and 8.3

2023-07-31 Thread Federico Serafini
Give a name to unnamed parameters to address violations of MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with named parameters"). Keep consistency between parameter names and types used in function declarations and the ones used in the corresponding function definitions, thus ad

[xen-unstable test] 182085: tolerable FAIL

2023-07-31 Thread osstest service owner
flight 182085 xen-unstable real [real] http://logs.test-lab.xenproject.org/osstest/logs/182085/ Failures :-/ but no regressions. Tests which are failing intermittently (not blocking): test-amd64-amd64-dom0pvh-xl-amd 14 guest-start fail in 182079 pass in 182085 test-amd64-i386-qemut-rhel6hvm-a

[XEN PATCH v11 00/14] Xen FF-A mediator

2023-07-31 Thread Jens Wiklander
Hi, [Parts of the patchset has been merged already, see the changelog below for details.] This patch set adds an FF-A [1] mediator to the TEE mediator framework already present in Xen. The FF-A mediator implements the subset of the FF-A 1.1 specification needed to communicate with OP-TEE using FF

[XEN PATCH v11 04/14] xen/arm: ffa: support mapping guest RX/TX buffers

2023-07-31 Thread Jens Wiklander
Adds support in the mediator to map and unmap the RX and TX buffers provided by the guest using the two FF-A functions FFA_RXTX_MAP and FFA_RXTX_UNMAP. These buffer are later used to transmit data that cannot be passed in registers only. Signed-off-by: Jens Wiklander --- v10->v11 - Fixing a typo

[XEN PATCH v11 03/14] xen/arm: ffa: send guest events to Secure Partitions

2023-07-31 Thread Jens Wiklander
The FF-A specification defines framework messages sent as direct requests when certain events occurs. For instance when a VM (guest) is created or destroyed. Only SPs which have subscribed to these events will receive them. An SP can subscribe to these messages in its partition properties. Adds a

[XEN PATCH v11 05/14] xen/arm: ffa: support guest FFA_PARTITION_INFO_GET

2023-07-31 Thread Jens Wiklander
Adds support in the mediator to handle FFA_PARTITION_INFO_GET requests from a guest. The requests are forwarded to the SPMC and the response is translated according to the FF-A version in use by the guest. Using FFA_PARTITION_INFO_GET changes the owner of the RX buffer to the caller (the guest in

[XEN PATCH v11 02/14] xen/arm: ffa: map SPMC rx/tx buffers

2023-07-31 Thread Jens Wiklander
When initializing the FF-A mediator map the RX and TX buffers shared with the SPMC. These buffer are later used to to transmit data that cannot be passed in registers only. Adds a check that the SP supports the needed FF-A features FFA_RXTX_MAP_64 and FFA_RXTX_UNMAP. Signed-off-by: Jens Wiklande

[XEN PATCH v11 01/14] xen/arm: ffa: add direct request support

2023-07-31 Thread Jens Wiklander
Adds support for sending a FF-A direct request. Checks that the SP also supports handling a 32-bit direct request. 64-bit direct requests are not used by the mediator itself so there is not need to check for that. Signed-off-by: Jens Wiklander Reviewed-by: Henry Wang --- v10->v11 - In handle_msg

[XEN PATCH v11 07/14] xen/arm: ffa: add defines for sharing memory

2023-07-31 Thread Jens Wiklander
According to DEN0077A version 1.1 REL0 - Section 10.9.2 Memory region handle, page 167 - Table 10.18 at page 175 - Table 10.15 at page 168 - Section 10.11.4 Flags usage, page 184-187 add defines needed for sharing using the function FFA_MEM_SHARE and friends. Also add limits for how many shared bu

[XEN PATCH v11 08/14] xen/arm: ffa: add ABI structs for sharing memory

2023-07-31 Thread Jens Wiklander
Adds the ABI structs used by function FFA_MEM_SHARE and friends for sharing memory. Signed-off-by: Jens Wiklander Reviewed-by: Bertrand Marquis --- v10->v11 - No changes --- xen/arch/arm/tee/ffa.c | 69 ++ 1 file changed, 69 insertions(+) diff --git a/xe

[XEN PATCH v11 09/14] xen/arm: ffa: support sharing memory

2023-07-31 Thread Jens Wiklander
Adds support for a guest to share memory with an SP using FFA_MEM_SHARE. Only memory regions small enough to be shared with a single call to FFA_MEM_SHARE are supported. With this commit we have a FF-A version 1.1 [1] mediator able to communicate with a Secure Partition in secure world using share

[XEN PATCH v11 06/14] xen/arm: move regpair_to_uint64() and uint64_to_regpair() to regs.h

2023-07-31 Thread Jens Wiklander
Moves the two helper functions regpair_to_uint64() and uint64_to_regpair() from xen/arch/arm/tee/optee.c to the common arm specific regs.h. This enables reuse of these functions in the FF-A mediator in a subsequent patch. Signed-off-by: Jens Wiklander Reviewed-by: Michal Orzel Reviewed-by: Bertr

[XEN PATCH v11 11/14] xen/arm: ffa: improve lock granularity

2023-07-31 Thread Jens Wiklander
The single lock in struct ffa_ctx is complemented with rx_lock and tx_lock. The old lock is used for small critical sections, like increasing shm_count or adding another shm to shm_list. rx_lock and tx_lock are only acquired using spin_trylock() which for well-behaving guests should always succee

[XEN PATCH v11 12/14] xen/arm: ffa: list current limitations

2023-07-31 Thread Jens Wiklander
Adds comments with a list of unsupported FF-A interfaces and limitations in the implemented FF-A interfaces. Signed-off-by: Jens Wiklander Reviewed-by: Henry Wang --- v10->v11 - No changes --- xen/arch/arm/tee/ffa.c | 31 +++ 1 file changed, 31 insertions(+) diff --

[XEN PATCH v11 10/14] xen/arm: ffa: add support to reclaim shared memory

2023-07-31 Thread Jens Wiklander
Adds support to reclaim memory previously shared with FFA_MEM_SHARE. A memory region that doesn't need to be shared any longer can be reclaimed with FFA_MEM_RECLAIM once the SP doesn't use it any longer. This is checked by the SPMC and not in control of the mediator. Adds a check that the SP supp

[XEN PATCH v11 14/14] docs: add Arm FF-A mediator

2023-07-31 Thread Jens Wiklander
Describes a FF-A version 1.1 [1] mediator to communicate with a Secure Partition in secure world. [1] https://developer.arm.com/documentation/den0077/latest Signed-off-by: Jens Wiklander Reviewed-by: Henry Wang --- v10->v11 - Add a CHANGELOG.md entry as requested --- CHANGELOG.md |

[XEN PATCH v11 13/14] tools: add Arm FF-A mediator

2023-07-31 Thread Jens Wiklander
Adds a new "ffa" value to the Enumeration "tee_type" to indicate if a guest is trusted to use FF-A. Signed-off-by: Jens Wiklander Reviewed-by: Bertrand Marquis Reviewed-by: Henry Wang --- v10->v11 - No changes --- tools/include/libxl.h| 5 + tools/libs/light/libxl_arm.c | 3

Re: [PATCH] x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()

2023-07-31 Thread Andrew Cooper
On 31/07/2023 10:02 am, Jan Beulich wrote: > On 28.07.2023 20:17, Andrew Cooper wrote: >> This line: >> >> val &= ~chickenbit; >> >> ends up truncating val to 32 bits, and turning off various errata workarounds >> in Zen2 systems. >> >> Fixes: f91c5ea97067 ("x86/amd: Mitigations for Zenbleed")

Re: [XEN PATCH v11 13/14] tools: add Arm FF-A mediator

2023-07-31 Thread Anthony PERARD
On Mon, Jul 31, 2023 at 02:15:35PM +0200, Jens Wiklander wrote: > Adds a new "ffa" value to the Enumeration "tee_type" to indicate if a > guest is trusted to use FF-A. > > Signed-off-by: Jens Wiklander > Reviewed-by: Bertrand Marquis > Reviewed-by: Henry Wang Acked-by: Anthony PERARD Thanks,

Re: [XEN PATCH v11 14/14] docs: add Arm FF-A mediator

2023-07-31 Thread Anthony PERARD
On Mon, Jul 31, 2023 at 02:15:36PM +0200, Jens Wiklander wrote: > Describes a FF-A version 1.1 [1] mediator to communicate with a Secure > Partition in secure world. > > [1] https://developer.arm.com/documentation/den0077/latest > Signed-off-by: Jens Wiklander > Reviewed-by: Henry Wang Reviewed

Re: [XEN PATCH v2 1/4] x86: mechanically rename to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
On 31/07/2023 13:21, Jan Beulich wrote: On 31.07.2023 13:15, Jan Beulich wrote: On 31.07.2023 09:33, Nicola Vetrini wrote: --- a/xen/arch/x86/include/asm/hvm/save.h +++ b/xen/arch/x86/include/asm/hvm/save.h @@ -49,21 +49,21 @@ void _hvm_read_entry(struct hvm_domain_context *h, */ #define _

[XEN PATCH v3] xen/IRQ: address violations of MISRA C: 2012 Rules 8.2 and 8.3

2023-07-31 Thread Federico Serafini
Give a name to unnamed parameters thus addressing violations of MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with named parameters"). Keep consistency between parameter names and types used in function declarations and the ones used in the corresponding function definitions, th

Re: [XEN PATCH v3] xen/IRQ: address violations of MISRA C: 2012 Rules 8.2 and 8.3

2023-07-31 Thread Jan Beulich
On 31.07.2023 15:02, Federico Serafini wrote: > Give a name to unnamed parameters thus addressing violations of > MISRA C:2012 Rule 8.2 ("Function types shall be in prototype form with > named parameters"). > Keep consistency between parameter names and types used in function > declarations and the

Re: [PATCH] x86: avoid Misra Rule 19.1 violations

2023-07-31 Thread Andrew Cooper
On 17/07/2023 3:13 pm, Jan Beulich wrote: > Not exactly overlapping accesses to objects on the left and right hand > sides of an assignment are generally UB, and hence disallowed by Misra. > While in the specific cases we're talking about here no actual UB can > result as long as the compiler doesn

Re: [PATCH v4 1/1] ns16550: add support for polling mode when device tree is used

2023-07-31 Thread Jan Beulich
On 27.07.2023 18:45, Oleksii Kurochko wrote: > @@ -654,6 +674,9 @@ static void ns16550_init_common(struct ns16550 *uart) > > /* Default lsr_mask = UART_LSR_THRE */ > uart->lsr_mask = UART_LSR_THRE; > + > +if ( strstr(opt_com1, "poll") || strstr(opt_com2, "poll") ) > +uart->

[PATCH] x86/HVM: tidy _hvm_load_entry() for style

2023-07-31 Thread Jan Beulich
The primary goal is to eliminate the Misra-non-compliance of "desc" shadowing at least the local variable in hvm_load(). Suffix both local variables with underscores, while also - dropping leading underscores from parameter names (applying this also to the two wrapper macros), - correcting indent

[XEN PATCH 0/4] xen: address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
Rule 5.3 has the following headline: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope". The following two strategies are adopted to deal with som violations of this rule: - renaming of local variables, functions or parameters; - removal of unnecessa

[XEN PATCH 1/4] xen/pci: rename local variable to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
The rename s/pdev_type/pci_dev_type/ is done to avoid shadowing the homonymous function declaration. Signed-off-by: Nicola Vetrini --- xen/drivers/passthrough/pci.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passth

[XEN PATCH 2/4] amd/iommu: rename functions to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
The functions 'machine_bfd' and 'guest_bfd' have gained the prefix 'get_' to avoid the mutual shadowing with the homonymous parameters in these functions. Signed-off-by: Nicola Vetrini --- xen/drivers/passthrough/amd/iommu_guest.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions

[XEN PATCH 3/4] xen: rename variables and parameters to address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
Rule 5.3 has the following headline: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope" Local variables have been suitably renamed to address some violations of this rule: - s/cmp/c/ because it shadows the union declared at line 87. - s/nodes/numa_no

[XEN PATCH 4/4] arm/efi: address MISRA C:2012 Rule 5.3

2023-07-31 Thread Nicola Vetrini
Rule 5.3 has the following headline: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope" The parameter 'fdt' in static function within this file is removed, as they served no purpose and shadowed the homonymous variable. For the same reason the local

Re: [PATCH] x86/HVM: tidy _hvm_load_entry() for style

2023-07-31 Thread Andrew Cooper
On 31/07/2023 2:31 pm, Jan Beulich wrote: > The primary goal is to eliminate the Misra-non-compliance of "desc" > shadowing at least the local variable in hvm_load(). Suffix both local > variables with underscores, while also > - dropping leading underscores from parameter names (applying this also

  1   2   3   >