public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <ajones@ventanamicro.com>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: anup@brainfault.org, atishp@atishpatra.org,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, cleger@rivosinc.com
Subject: [PATCH 2/5] riscv: KVM: Fix hart suspend_type use
Date: Mon, 17 Feb 2025 09:45:09 +0100	[thread overview]
Message-ID: <20250217084506.18763-9-ajones@ventanamicro.com> (raw)
In-Reply-To: <20250217084506.18763-7-ajones@ventanamicro.com>

The spec says suspend_type is 32 bits wide and "In case the data is
defined as 32bit wide, higher privilege software must ensure that it
only uses 32 bit data." Mask off upper bits of suspend_type before
using it.

Fixes: 763c8bed8c05 ("RISC-V: KVM: Implement SBI HSM suspend call")
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/kvm/vcpu_sbi_hsm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kvm/vcpu_sbi_hsm.c b/arch/riscv/kvm/vcpu_sbi_hsm.c
index 13a35eb77e8e..3070bb31745d 100644
--- a/arch/riscv/kvm/vcpu_sbi_hsm.c
+++ b/arch/riscv/kvm/vcpu_sbi_hsm.c
@@ -9,6 +9,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/kvm_host.h>
+#include <linux/wordpart.h>
 #include <asm/sbi.h>
 #include <asm/kvm_vcpu_sbi.h>
 
@@ -109,7 +110,7 @@ static int kvm_sbi_ext_hsm_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,
 		}
 		return 0;
 	case SBI_EXT_HSM_HART_SUSPEND:
-		switch (cp->a0) {
+		switch (lower_32_bits(cp->a0)) {
 		case SBI_HSM_SUSPEND_RET_DEFAULT:
 			kvm_riscv_vcpu_wfi(vcpu);
 			break;
-- 
2.48.1


  parent reply	other threads:[~2025-02-17  8:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17  8:45 [PATCH 0/5] riscv: KVM: Fix a few SBI issues Andrew Jones
2025-02-17  8:45 ` [PATCH 1/5] riscv: KVM: Fix hart suspend status check Andrew Jones
2025-02-17 10:36   ` Anup Patel
2025-02-17  8:45 ` Andrew Jones [this message]
2025-02-17 10:37   ` [PATCH 2/5] riscv: KVM: Fix hart suspend_type use Anup Patel
2025-02-17  8:45 ` [PATCH 3/5] riscv: KVM: Fix SBI IPI error generation Andrew Jones
2025-02-17 10:43   ` Anup Patel
2025-02-17  8:45 ` [PATCH 4/5] riscv: KVM: Fix SBI TIME " Andrew Jones
2025-02-17 10:44   ` Anup Patel
2025-02-17  8:45 ` [PATCH 5/5] riscv: KVM: Fix SBI sleep_type use Andrew Jones
2025-02-17 10:57   ` Anup Patel
2025-02-20 12:17 ` [PATCH 0/5] riscv: KVM: Fix a few SBI issues 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=20250217084506.18763-9-ajones@ventanamicro.com \
    --to=ajones@ventanamicro.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=cleger@rivosinc.com \
    --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=paul.walmsley@sifive.com \
    /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