Skip to content

Commit 432a8b3

Browse files
danielhbavpatel
authored andcommitted
RISC-V: KVM: do not EOPNOTSUPP in set KVM_REG_RISCV_TIMER_REG
The KVM_REG_RISCV_TIMER_REG can be read via get_one_reg(). But trying to write anything in this reg via set_one_reg() results in an EOPNOTSUPP. Change the API to behave like cbom_block_size: instead of always erroring out with EOPNOTSUPP, allow userspace to write the same value (riscv_timebase) back, throwing an EINVAL if a different value is attempted. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent e29f579 commit 432a8b3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/riscv/kvm/vcpu_timer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ int kvm_riscv_vcpu_set_reg_timer(struct kvm_vcpu *vcpu,
218218

219219
switch (reg_num) {
220220
case KVM_REG_RISCV_TIMER_REG(frequency):
221-
ret = -EOPNOTSUPP;
221+
if (reg_val != riscv_timebase)
222+
return -EINVAL;
222223
break;
223224
case KVM_REG_RISCV_TIMER_REG(time):
224225
gt->time_delta = reg_val - get_cycles64();

0 commit comments

Comments
 (0)