[PATCH] bitops/32: Convert variable_ffs() and fls() zero-case handling to C

2025-04-27 Thread Ingo Molnar
* Linus Torvalds wrote: > On Sun, 27 Apr 2025 at 12:17, Andrew Cooper wrote: > > > > ffs/fls are commonly found inside loops where x is the loop condition > > too. Therefore, using statically_true() to provide a form without the > > zero compatibility turns out to be a win. > > We already ha

Re: [PATCH v2 1/3] xen/console: cleanup conring management

2025-04-27 Thread Jan Beulich
On 26.04.2025 20:50, dm...@proton.me wrote: > From: Denis Mukhin > > Move console_locks_busted handling inside conring_puts() to remove > tasklet code duplication. > > Signed-off-by: Denis Mukhin > Reviewed-by: Stefano Stabellini > --- > Changes v1->v2: > - added Stefano's R-b > --- > xen/dri

Re: [PATCH v1 1/3] xen/console: cleanup conring management

2025-04-27 Thread Jan Beulich
On 26.04.2025 00:18, Stefano Stabellini wrote: > On Thu, 3 Apr 2025, dm...@proton.me wrote: >> From: Denis Mukhin >> >> Move console_locks_busted handling inside conring_puts() to remove >> tasklet code duplication. >> >> Signed-off-by: Denis Mukhin > > This patch is a good cleanup but makes one

Re: [RFC 33/38] x86/boot: refactor bzimage parser to be re-enterant

2025-04-27 Thread Jan Beulich
On 26.04.2025 03:53, Daniel P. Smith wrote: > On 4/23/25 15:27, Jason Andryuk wrote: >> On 2025-04-19 18:08, Daniel P. Smith wrote: >>> The bzimage logic uses the unit global orig_image_len to hold the >>> original >>> module length for the kernel when the headroom is calculated. It then >>> uses

Re: [PATCH v1 10/14] xen/riscv: implementation of aplic and imsic operations

2025-04-27 Thread Jan Beulich
On 25.04.2025 21:31, Oleksii Kurochko wrote: > > On 4/22/25 9:02 AM, Jan Beulich wrote: >> On 18.04.2025 12:43, Oleksii Kurochko wrote: >>> On 4/15/25 4:53 PM, Jan Beulich wrote: On 08.04.2025 17:57, Oleksii Kurochko wrote: > --- a/xen/arch/riscv/imsic.c > +++ b/xen/arch/riscv/imsic.c

Re: [PATCH v1 06/14] xen/riscv: riscv_of_processor_hartid() implementation

2025-04-27 Thread Jan Beulich
On 25.04.2025 19:07, Oleksii Kurochko wrote: > > On 4/15/25 3:45 PM, Jan Beulich wrote: >> On 15.04.2025 15:39, Oleksii Kurochko wrote: >>> On 4/10/25 5:53 PM, Jan Beulich wrote: On 08.04.2025 17:57, Oleksii Kurochko wrote: > +{ > +const __be32 *cell; > +int ac; > +

Re: [PATCH v1] misra: add deviation for rules 21.1 and 21.2

2025-04-27 Thread Jan Beulich
On 25.04.2025 17:53, Nicola Vetrini wrote: > On 2025-04-25 10:07, Jan Beulich wrote: >> On 24.04.2025 23:45, Stefano Stabellini wrote: >>> On Thu, 24 Apr 2025, Jan Beulich wrote: On 23.04.2025 19:54, victorm.l...@amd.com wrote: > From: Nicola Vetrini > > MISRA C Rules 21.1 ("#defi

Re: [PATCH v1 2/3] xen/console: introduce console_puts()

2025-04-27 Thread dmkhn
On Fri, Apr 25, 2025 at 03:47:53PM -0700, Stefano Stabellini wrote: > On Thu, 3 Apr 2025, dm...@proton.me wrote: > > From: Denis Mukhin > > > > guest_console_write() duplicates the code from __putstr(), eliminate code > > duplication. > > > > Introduce console_puts() for writing a buffer to consol

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread H. Peter Anvin
On April 27, 2025 6:24:59 AM PDT, Arnd Bergmann wrote: >On Sat, Apr 26, 2025, at 21:09, Ingo Molnar wrote: >> * Arnd Bergmann wrote: >> >>> CMOV is missing not just on old Socket 5/7 CPUs (Pentium MMX, AMD K6, >>> Cyrix MII) but also newer embedded Via C3, Geode GX and >>> Vortex86DX/MX/EX/DX2.

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread H. Peter Anvin
On April 27, 2025 12:34:46 PM PDT, Linus Torvalds wrote: >On Sun, 27 Apr 2025 at 12:17, Andrew Cooper wrote: >> >> ffs/fls are commonly found inside loops where x is the loop condition >> too. Therefore, using statically_true() to provide a form without the >> zero compatibility turns out to be

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread Linus Torvalds
On Sun, 27 Apr 2025 at 12:17, Andrew Cooper wrote: > > ffs/fls are commonly found inside loops where x is the loop condition > too. Therefore, using statically_true() to provide a form without the > zero compatibility turns out to be a win. We already have the version without the zero capability

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread Andrew Cooper
On 26/04/2025 8:55 pm, Linus Torvalds wrote: > So I think that manual cmov pattern for x86-32 should be replaced with > > bool zero; > > asm("bsfl %[in],%[out]" > CC_SET(z) > : CC_OUT(z) (zero), > [out]"=r" (r) > : [in] "rm" (x)); >

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread Arnd Bergmann
On Sat, Apr 26, 2025, at 21:09, Ingo Molnar wrote: > * Arnd Bergmann wrote: > >> CMOV is missing not just on old Socket 5/7 CPUs (Pentium MMX, AMD K6, >> Cyrix MII) but also newer embedded Via C3, Geode GX and >> Vortex86DX/MX/EX/DX2. The replacement Nehemiah (2003), GeodeLX (2005) >> and Vorte

[PATCH v4 01/15] x86/msr: Add missing includes of

2025-04-27 Thread Xin Li (Intel)
For some reason, there are some TSC-related functions in the MSR header even though there is a tsc.h header. To facilitate the relocation of rdtsc{,_ordered}() from to and to eventually eliminate the inclusion of in , add to the source files that reference definitions from . Signed-off-by: Xi

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread Ingo Molnar
* H. Peter Anvin wrote: > The undefined zero case applies to family < 6 as far as I know... the > same platforms which don't have cmov... So, technically, these are family 5 CPUs with CMOV support, if Kconfig.cpu can be believed: MGEODE_LX MCRUSOE Right? Ingo

Re: [PATCH] [RFC] x86/cpu: rework instruction set selection

2025-04-27 Thread Ingo Molnar
* Linus Torvalds wrote: > On Sat, 26 Apr 2025 at 11:59, Arnd Bergmann wrote: > > > > Right. With the current set of features, CMOV is almost the > > same as 686. My reasoning was that support for CMOV has a > > very clear definition, with the instruction either being > > available or not. > >

[PATCH v4 02/15] x86/msr: Move rdtsc{,_ordered}() to

2025-04-27 Thread Xin Li (Intel)
For some reason, there are some TSC-related functions in the MSR header even though there is a tsc.h header. Relocate rdtsc{,_ordered}() from to , and subsequently remove the inclusion of in . Signed-off-by: Xin Li (Intel) Acked-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) --- Change in

[PATCH v4 08/15] x86/msr: Add the native_rdmsrq() helper

2025-04-27 Thread Xin Li (Intel)
__rdmsr() is the lowest-level primitive MSR read API, implemented in assembly code and returning an MSR value in a u64 integer, on top of which a convenience wrapper native_rdmsr() is defined to return an MSR value in two u32 integers. For some reason, native_rdmsrq() is not defined and __rdmsr()

Re: [PATCH v3 09/14] x86/xen/msr: Remove calling native_{read,write}_msr{,_safe}() in pmu_msr_{read,write}()

2025-04-27 Thread Xin Li
On 4/27/2025 2:21 AM, Mi, Dapeng wrote: Reviewed-by: Dapeng Mi Thanks! I just sent out v4, so unless a v5 is needed, leave it to our x86 maintainers.

[PATCH v4 11/15] x86/xen/msr: Remove pmu_msr_{read,write}()

2025-04-27 Thread Xin Li (Intel)
As pmu_msr_{read,write}() are now wrappers of pmu_msr_chk_emulated(), remove them and use pmu_msr_chk_emulated() directly. As pmu_msr_chk_emulated() could easily return false in the cases where it would set *emul to false, remove the "emul" argument and use the return value instead. While at it,

[PATCH v4 03/15] x86/msr: Remove rdpmc()

2025-04-27 Thread Xin Li (Intel)
rdpmc() is not used anywhere, remove it. Signed-off-by: Xin Li (Intel) Acked-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/msr.h | 7 --- arch/x86/include/asm/paravirt.h | 7 --- 2 files changed, 14 deletions(-) diff --git a/arch/x86/include/asm/msr.h

[PATCH v4 04/15] x86/msr: Rename rdpmcl() to rdpmc()

2025-04-27 Thread Xin Li (Intel)
Now that rdpmc() is gone, i.e. rdpmcl() is the sole PMC read helper, simply rename rdpmcl() to rdpmc(). Signed-off-by: Xin Li (Intel) Acked-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) --- Changes in v3: *) Explain the reason of the renaming in the changelog (Dave Hansen). *) Use shorter n

[PATCH v4 09/15] x86/msr: Convert __rdmsr() uses to native_rdmsrq() uses

2025-04-27 Thread Xin Li (Intel)
__rdmsr() is the lowest level MSR write API, with native_rdmsr() and native_rdmsrq() serving as higher-level wrappers around it. #define native_rdmsr(msr, val1, val2) \ do {\ u64 __val = __rdmsr((msr));

[PATCH v4 00/15] MSR code cleanup part one

2025-04-27 Thread Xin Li (Intel)
This patch set is the first part of the patch set: MSR refactor with new MSR instructions support @ https://lore.kernel.org/lkml/20250422082216.1954310-1-...@zytor.com/T/#m5a34be7d4ed55f0baca965cb65452a08e9ad7c8a It's getting *WAY* too big, and whether to zap the pv_ops MSR APIs is still und

[PATCH v4 06/15] x86/xen/msr: Return u64 consistently in Xen PMC read functions

2025-04-27 Thread Xin Li (Intel)
The pv_ops PMC read API is defined as: u64 (*read_pmc)(int counter); But Xen PMC read functions return unsigned long long, make them return u64 consistently. Signed-off-by: Xin Li (Intel) Reviewed-by: Juergen Gross Acked-by: Peter Zijlstra (Intel) --- arch/x86/xen/pmu.c | 6 +++---

[PATCH v4 12/15] x86/xen/msr: Remove the error pointer argument from set_seg()

2025-04-27 Thread Xin Li (Intel)
set_seg() is used to write the following MSRs on Xen: MSR_FS_BASE MSR_KERNEL_GS_BASE MSR_GS_BASE But none of these MSRs are written using any MSR write safe API. Therefore there is no need to pass an error pointer argument to set_seg() for returning an error code to be used in MSR saf

[PATCH v4 13/15] x86/pvops/msr: refactor pv_cpu_ops.write_msr{,_safe}()

2025-04-27 Thread Xin Li (Intel)
An MSR value is represented as a 64-bit unsigned integer, with existing MSR instructions storing it in EDX:EAX as two 32-bit segments. The new immediate form MSR instructions, however, utilize a 64-bit general-purpose register to store the MSR value. To unify the usage of all MSR instructions, le

[PATCH v4 15/15] x86/msr: Change the function type of native_read_msr_safe()

2025-04-27 Thread Xin Li (Intel)
Modify the function type of native_read_msr_safe() to: int native_read_msr_safe(u32 msr, u64 *val) This change makes the function return an error code instead of the MSR value, aligning it with the type of native_write_msr_safe(). Consequently, their callers can check the results in the same

[PATCH v4 10/15] x86/xen/msr: Remove calling native_{read,write}_msr{,_safe}() in pmu_msr_{read,write}()

2025-04-27 Thread Xin Li (Intel)
hpa found that pmu_msr_write() is actually a completely pointless function [1]: all it does is shuffle some arguments, then calls pmu_msr_chk_emulated() and if it returns true AND the emulated flag is clear then does *exactly the same thing* that the calling code would have done if pmu_msr_write()

Re: [PATCH v3 09/14] x86/xen/msr: Remove calling native_{read,write}_msr{,_safe}() in pmu_msr_{read,write}()

2025-04-27 Thread Mi, Dapeng
On 4/25/2025 4:34 PM, Xin Li (Intel) wrote: > hpa found that pmu_msr_write() is actually a completely pointless > function [1]: all it does is shuffle some arguments, then calls > pmu_msr_chk_emulated() and if it returns true AND the emulated flag > is clear then does *exactly the same thing* tha

[PATCH v4 07/15] x86/msr: Convert __wrmsr() uses to native_wrmsr{,q}() uses

2025-04-27 Thread Xin Li (Intel)
__wrmsr() is the lowest level MSR write API, with native_wrmsr() and native_wrmsrq() serving as higher-level wrappers around it: #define native_wrmsr(msr, low, high)\ __wrmsr(msr, low, high) #define native_wrmsrl(msr, val) \ __wr

[PATCH v4 14/15] x86/msr: Replace wrmsr(msr, low, 0) with wrmsrq(msr, low)

2025-04-27 Thread Xin Li (Intel)
The third argument in wrmsr(msr, low, 0) is unnecessary. Instead, use wrmsrq(msr, low), which automatically sets the higher 32 bits of the MSR value to 0. Signed-off-by: Xin Li (Intel) Acked-by: Peter Zijlstra (Intel) --- arch/x86/hyperv/hv_apic.c | 6 +++--- arch/x86/include/a

[PATCH v4 05/15] x86/msr: Convert the rdpmc() macro into an always inline function

2025-04-27 Thread Xin Li (Intel)
Functions offer type safety and better readability compared to macros. Additionally, always inline functions can match the performance of macros. Converting the rdpmc() macro into an always inline function is simple and straightforward, so just make the change. Moreover, the read result is now th