lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhSdy1w485+mTNCmX+KgQVnLr5iyDyPLm5+w2QwA+SxQ-2mVw@mail.gmail.com>
Date: Tue, 6 Jan 2026 22:04:55 +0530
From: Anup Patel <anup@...infault.org>
To: Ben Dooks <ben.dooks@...ethink.co.uk>
Cc: linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org, 
	kvm-riscv@...ts.infradead.org, kvm@...r.kernel.org, palmer@...belt.com, 
	pjw@...nel.org, atish.patra@...ux.dev
Subject: Re: [PATCH] RISC-V: KVM: fix __le64 type assignments

On Tue, Jan 6, 2026 at 9:59 PM Ben Dooks <ben.dooks@...ethink.co.uk> wrote:
>
> The two swaps from le32/le64 in arch/riscv/include/asm/kvm_nacl.h
> are generating a number of type assingment warnings in sparse, so

s/assingment/assignment/

> fix by using __force and assuming the code is correct.
>
> Fixes a number of:

s/... number of:/... number of sparse warnings:/

>
> arch/riscv/kvm/vcpu.c:371:21: warning: cast to restricted __le64
> arch/riscv/kvm/vcpu.c:374:16: warning: cast to restricted __le64
> arch/riscv/kvm/vcpu.c:586:17: warning: incorrect type in assignment (different base types)
> arch/riscv/kvm/vcpu.c:586:17:    expected unsigned long
> arch/riscv/kvm/vcpu.c:586:17:    got restricted __le64 [usertype]
>

Please add a Fixes tag.

> Signed-off-by: Ben Dooks <ben.dooks@...ethink.co.uk>
> ---
>  arch/riscv/include/asm/kvm_nacl.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/include/asm/kvm_nacl.h b/arch/riscv/include/asm/kvm_nacl.h
> index 4124d5e06a0f..2483738029cb 100644
> --- a/arch/riscv/include/asm/kvm_nacl.h
> +++ b/arch/riscv/include/asm/kvm_nacl.h
> @@ -58,11 +58,11 @@ void kvm_riscv_nacl_exit(void);
>  int kvm_riscv_nacl_init(void);
>
>  #ifdef CONFIG_32BIT
> -#define lelong_to_cpu(__x)     le32_to_cpu(__x)
> -#define cpu_to_lelong(__x)     cpu_to_le32(__x)
> +#define lelong_to_cpu(__x)     le32_to_cpu((__force __le32)__x)
> +#define cpu_to_lelong(__x)     (__force unsigned long)cpu_to_le32(__x)
>  #else
> -#define lelong_to_cpu(__x)     le64_to_cpu(__x)
> -#define cpu_to_lelong(__x)     cpu_to_le64(__x)
> +#define lelong_to_cpu(__x)     le64_to_cpu((__force __le64)__x)
> +#define cpu_to_lelong(__x)     (__force unsigned long)cpu_to_le64(__x)
>  #endif
>
>  #define nacl_shmem()                                                   \
> --
> 2.37.2.352.g3c44437643
>

Regards,
Anup

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ