All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Yu-Wei Hsu <betterman5240@gmail.com>
To: anup@brainfault.org
Cc: atishp@atishpatra.org, paul.walmsley@sifive.com,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, kvm@vger.kernel.org,
	kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Yu-Wei Hsu <betterman5240@gmail.com>
Subject: [PATCH] RISC-V:KVM: Add AMO load/store access fault traps to redirect to guest
Date: Mon, 29 Apr 2024 09:21:13 +0000	[thread overview]
Message-ID: <20240429092113.70695-1-betterman5240@gmail.com> (raw)

When unhandled AMO load/store access fault traps are not delegated to
VS mode (hedeleg), M mode redirects them back to S mode.
However, upon returning from M mode,the KVM executed in HS mode terminates
VS mode software.
KVM should redirect traps back to VS mode and let the VS mode trap handler
determine the next steps.
This is one approach to handling access fault traps in KVM,
not only redirecting them to VS mode or terminating it.

Signed-off-by: Yu-Wei Hsu <betterman5240@gmail.com>
---
 arch/riscv/kvm/vcpu_exit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/kvm/vcpu_exit.c b/arch/riscv/kvm/vcpu_exit.c
index 2415722c01b8..ef8c5e3ec8a0 100644
--- a/arch/riscv/kvm/vcpu_exit.c
+++ b/arch/riscv/kvm/vcpu_exit.c
@@ -185,6 +185,8 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
 	case EXC_INST_ILLEGAL:
 	case EXC_LOAD_MISALIGNED:
 	case EXC_STORE_MISALIGNED:
+	case EXC_LOAD_ACCESS:
+	case EXC_STORE_ACCESS:
 		if (vcpu->arch.guest_context.hstatus & HSTATUS_SPV) {
 			kvm_riscv_vcpu_trap_redirect(vcpu, trap);
 			ret = 1;
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Yu-Wei Hsu <betterman5240@gmail.com>
To: anup@brainfault.org
Cc: atishp@atishpatra.org, paul.walmsley@sifive.com,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, kvm@vger.kernel.org,
	kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Yu-Wei Hsu <betterman5240@gmail.com>
Subject: [PATCH] RISC-V:KVM: Add AMO load/store access fault traps to redirect to guest
Date: Mon, 29 Apr 2024 09:21:13 +0000	[thread overview]
Message-ID: <20240429092113.70695-1-betterman5240@gmail.com> (raw)

When unhandled AMO load/store access fault traps are not delegated to
VS mode (hedeleg), M mode redirects them back to S mode.
However, upon returning from M mode,the KVM executed in HS mode terminates
VS mode software.
KVM should redirect traps back to VS mode and let the VS mode trap handler
determine the next steps.
This is one approach to handling access fault traps in KVM,
not only redirecting them to VS mode or terminating it.

Signed-off-by: Yu-Wei Hsu <betterman5240@gmail.com>
---
 arch/riscv/kvm/vcpu_exit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/kvm/vcpu_exit.c b/arch/riscv/kvm/vcpu_exit.c
index 2415722c01b8..ef8c5e3ec8a0 100644
--- a/arch/riscv/kvm/vcpu_exit.c
+++ b/arch/riscv/kvm/vcpu_exit.c
@@ -185,6 +185,8 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
 	case EXC_INST_ILLEGAL:
 	case EXC_LOAD_MISALIGNED:
 	case EXC_STORE_MISALIGNED:
+	case EXC_LOAD_ACCESS:
+	case EXC_STORE_ACCESS:
 		if (vcpu->arch.guest_context.hstatus & HSTATUS_SPV) {
 			kvm_riscv_vcpu_trap_redirect(vcpu, trap);
 			ret = 1;
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2024-04-29  9:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29  9:21 Yu-Wei Hsu [this message]
2024-04-29  9:21 ` [PATCH] RISC-V:KVM: Add AMO load/store access fault traps to redirect to guest Yu-Wei Hsu

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=20240429092113.70695-1-betterman5240@gmail.com \
    --to=betterman5240@gmail.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.