Commit 9f9e3ebe authored by Andrew Jones's avatar Andrew Jones Committed by Anup Patel

RISC-V: KVM: Convert extension_disabled[] to ext_status[]

Change the boolean extension_disabled[] array to an array of enums,
ext_status[]. For now, the enum only has two states, which correspond
to the previous boolean states, so this patch has no intended
functional change. The next patch will add another state, expanding
the purpose of ext_status[].
Signed-off-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent ae328dad
...@@ -14,9 +14,14 @@ ...@@ -14,9 +14,14 @@
#define KVM_SBI_VERSION_MAJOR 1 #define KVM_SBI_VERSION_MAJOR 1
#define KVM_SBI_VERSION_MINOR 0 #define KVM_SBI_VERSION_MINOR 0
enum kvm_riscv_sbi_ext_status {
KVM_RISCV_SBI_EXT_AVAILABLE,
KVM_RISCV_SBI_EXT_UNAVAILABLE,
};
struct kvm_vcpu_sbi_context { struct kvm_vcpu_sbi_context {
int return_handled; int return_handled;
bool extension_disabled[KVM_RISCV_SBI_EXT_MAX]; enum kvm_riscv_sbi_ext_status ext_status[KVM_RISCV_SBI_EXT_MAX];
}; };
struct kvm_vcpu_sbi_return { struct kvm_vcpu_sbi_return {
......
...@@ -155,7 +155,8 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu, ...@@ -155,7 +155,8 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu,
if (!sext) if (!sext)
return -ENOENT; return -ENOENT;
scontext->extension_disabled[sext->ext_idx] = !reg_val; scontext->ext_status[sext->ext_idx] = reg_val ?
KVM_RISCV_SBI_EXT_AVAILABLE : KVM_RISCV_SBI_EXT_UNAVAILABLE;
return 0; return 0;
} }
...@@ -180,7 +181,8 @@ static int riscv_vcpu_get_sbi_ext_single(struct kvm_vcpu *vcpu, ...@@ -180,7 +181,8 @@ static int riscv_vcpu_get_sbi_ext_single(struct kvm_vcpu *vcpu,
if (!sext) if (!sext)
return -ENOENT; return -ENOENT;
*reg_val = !scontext->extension_disabled[sext->ext_idx]; *reg_val = scontext->ext_status[sext->ext_idx] ==
KVM_RISCV_SBI_EXT_AVAILABLE;
return 0; return 0;
} }
...@@ -316,7 +318,8 @@ const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext( ...@@ -316,7 +318,8 @@ const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(
if (sext->ext_ptr->extid_start <= extid && if (sext->ext_ptr->extid_start <= extid &&
sext->ext_ptr->extid_end >= extid) { sext->ext_ptr->extid_end >= extid) {
if (sext->ext_idx < KVM_RISCV_SBI_EXT_MAX && if (sext->ext_idx < KVM_RISCV_SBI_EXT_MAX &&
scontext->extension_disabled[sext->ext_idx]) scontext->ext_status[sext->ext_idx] ==
KVM_RISCV_SBI_EXT_UNAVAILABLE)
return NULL; return NULL;
return sbi_ext[i].ext_ptr; return sbi_ext[i].ext_ptr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment