The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	kvm-riscv@lists.infradead.org
Cc: kvm@vger.kernel.org, palmer@dabbelt.com, pjw@kernel.org,
	anup@brainfault.org, atish.patra@linux.dev,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH] RISC-V: KVM: fix __le64 type assignments
Date: Tue,  6 Jan 2026 16:28:48 +0000	[thread overview]
Message-ID: <20260106162848.22866-1-ben.dooks@codethink.co.uk> (raw)

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
fix by using __force and assuming the code is correct.

Fixes a number of:

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]

Signed-off-by: Ben Dooks <ben.dooks@codethink.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


             reply	other threads:[~2026-01-06 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 16:28 Ben Dooks [this message]
2026-01-06 16:34 ` [PATCH] RISC-V: KVM: fix __le64 type assignments Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260106162848.22866-1-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=anup@brainfault.org \
    --cc=atish.patra@linux.dev \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox