aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/kvm
diff options
context:
space:
mode:
authorGravatar Andrew Jones <ajones@ventanamicro.com> 2023-12-20 17:00:19 +0100
committerGravatar Anup Patel <anup@brainfault.org> 2023-12-30 11:26:26 +0530
commit38b3390ee4880140b6245fe3273fe9ce53f65bde (patch)
tree66c6a64af72cdecd051cf7b5bb5d17c582ef278c /arch/riscv/kvm
parentRISC-V: KVM: Add steal-update vcpu request (diff)
downloadlinux-38b3390ee4880140b6245fe3273fe9ce53f65bde.tar.gz
linux-38b3390ee4880140b6245fe3273fe9ce53f65bde.tar.bz2
linux-38b3390ee4880140b6245fe3273fe9ce53f65bde.zip
RISC-V: KVM: Add SBI STA info to vcpu_arch
KVM's implementation of SBI STA needs to track the address of each VCPU's steal-time shared memory region as well as the amount of stolen time. Add a structure to vcpu_arch to contain this state and make sure that the address is always set to INVALID_GPA on vcpu reset. And, of course, ensure KVM won't try to update steal- time when the shared memory address is invalid. Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'arch/riscv/kvm')
-rw-r--r--arch/riscv/kvm/vcpu.c2
-rw-r--r--arch/riscv/kvm/vcpu_sbi_sta.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
index 6995b8b641e4..b5ca9f2e98ac 100644
--- a/arch/riscv/kvm/vcpu.c
+++ b/arch/riscv/kvm/vcpu.c
@@ -83,6 +83,8 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu)
vcpu->arch.hfence_tail = 0;
memset(vcpu->arch.hfence_queue, 0, sizeof(vcpu->arch.hfence_queue));
+ kvm_riscv_vcpu_sbi_sta_reset(vcpu);
+
/* Reset the guest CSRs for hotplug usecase */
if (loaded)
kvm_arch_vcpu_load(vcpu, smp_processor_id());
diff --git a/arch/riscv/kvm/vcpu_sbi_sta.c b/arch/riscv/kvm/vcpu_sbi_sta.c
index e28351c9488b..6592d287fc4e 100644
--- a/arch/riscv/kvm/vcpu_sbi_sta.c
+++ b/arch/riscv/kvm/vcpu_sbi_sta.c
@@ -8,8 +8,18 @@
#include <asm/kvm_vcpu_sbi.h>
#include <asm/sbi.h>
+void kvm_riscv_vcpu_sbi_sta_reset(struct kvm_vcpu *vcpu)
+{
+ vcpu->arch.sta.shmem = INVALID_GPA;
+ vcpu->arch.sta.last_steal = 0;
+}
+
void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu)
{
+ gpa_t shmem = vcpu->arch.sta.shmem;
+
+ if (shmem == INVALID_GPA)
+ return;
}
static int kvm_sbi_sta_steal_time_set_shmem(struct kvm_vcpu *vcpu)