Skip to content

Commit 2a1f6bf

Browse files
Andrew Jonesavpatel
authored andcommitted
RISC-V: KVM: Add steal-update vcpu request
Add a new vcpu request to inform a vcpu that it should record its steal-time information. The request is made each time it has been detected that the vcpu task was not assigned a cpu for some time, which is easy to do by making the request from vcpu-load. The record function is just a stub for now and will be filled in with the rest of the steal-time support functions in following patches. 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>
1 parent 5fed84a commit 2a1f6bf

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

arch/riscv/include/asm/kvm_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
KVM_ARCH_REQ_FLAGS(4, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
4242
#define KVM_REQ_HFENCE \
4343
KVM_ARCH_REQ_FLAGS(5, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
44+
#define KVM_REQ_STEAL_UPDATE KVM_ARCH_REQ(6)
4445

4546
enum kvm_riscv_hfence_type {
4647
KVM_RISCV_HFENCE_UNKNOWN = 0,
@@ -372,4 +373,6 @@ bool kvm_riscv_vcpu_has_interrupts(struct kvm_vcpu *vcpu, u64 mask);
372373
void kvm_riscv_vcpu_power_off(struct kvm_vcpu *vcpu);
373374
void kvm_riscv_vcpu_power_on(struct kvm_vcpu *vcpu);
374375

376+
void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu);
377+
375378
#endif /* __RISCV_KVM_HOST_H__ */

arch/riscv/kvm/vcpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
541541

542542
kvm_riscv_vcpu_aia_load(vcpu, cpu);
543543

544+
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
545+
544546
vcpu->cpu = cpu;
545547
}
546548

@@ -614,6 +616,9 @@ static void kvm_riscv_check_vcpu_requests(struct kvm_vcpu *vcpu)
614616

615617
if (kvm_check_request(KVM_REQ_HFENCE, vcpu))
616618
kvm_riscv_hfence_process(vcpu);
619+
620+
if (kvm_check_request(KVM_REQ_STEAL_UPDATE, vcpu))
621+
kvm_riscv_vcpu_record_steal_time(vcpu);
617622
}
618623
}
619624

arch/riscv/kvm/vcpu_sbi_sta.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <asm/kvm_vcpu_sbi.h>
99
#include <asm/sbi.h>
1010

11+
void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu)
12+
{
13+
}
14+
1115
static int kvm_sbi_sta_steal_time_set_shmem(struct kvm_vcpu *vcpu)
1216
{
1317
return SBI_ERR_FAILURE;

0 commit comments

Comments
 (0)