[PATCH v2] RISC-V: KVM: add KVM_CAP_RISCV_SET_HGATP_MODE
fangyu.yu at linux.alibaba.com
fangyu.yu at linux.alibaba.com
Tue Jan 20 06:22:10 PST 2026
>...
>> + case KVM_CAP_RISCV_SET_HGATP_MODE:
>> +#ifdef CONFIG_64BIT
>> + if (cap->args[0] < HGATP_MODE_SV39X4 ||
>> + cap->args[0] > kvm_riscv_gstage_max_mode)
>> + return -EINVAL;
>> + if (kvm->arch.gstage_mode_initialized)
>> + return 0;
>> + kvm->arch.gstage_mode_initialized = true;
>> + kvm->arch.kvm_riscv_gstage_mode = cap->args[0];
>> + kvm->arch.kvm_riscv_gstage_pgd_levels = 3 +
>> + kvm->arch.kvm_riscv_gstage_mode - HGATP_MODE_SV39X4;
>> + kvm_info("using SV%lluX4 G-stage page table format\n",
>> + 39 + (cap->args[0] - HGATP_MODE_SV39X4) * 9);
>
>I don't think we want this kvm_info line, particularly if it doesn't also
>include a VM ID in some form to allow readers to know which VM is using
>the selected format. Let's either drop it or change it to kvm_debug and
>include a VM ID.
Agreed, I will switch it to kvm_debug() and include a VM ID.
>
>Thanks,
>drew
>
>> +#endif
>> + return 0;
>> default:
>> return -EINVAL;
>> }
>> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
>> index dddb781b0507..00c02a880518 100644
>> --- a/include/uapi/linux/kvm.h
>> +++ b/include/uapi/linux/kvm.h
>> @@ -974,6 +974,7 @@ struct kvm_enable_cap {
>> #define KVM_CAP_GUEST_MEMFD_FLAGS 244
>> #define KVM_CAP_ARM_SEA_TO_USER 245
>> #define KVM_CAP_S390_USER_OPEREXEC 246
>> +#define KVM_CAP_RISCV_SET_HGATP_MODE 247
>>
>> struct kvm_irq_routing_irqchip {
>> __u32 irqchip;
>> --
>> 2.50.1
>
>
More information about the linux-riscv
mailing list