Message ID | 20230526102540.105013-3-ajones@ventanamicro.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | RISC-V: KVM: Ensure SBI extension is enabled | expand |
Context | Check | Description |
---|---|---|
conchuod/cover_letter | success | Series has a cover letter |
conchuod/tree_selection | success | Guessed tree name to be for-next at HEAD ac9a78681b92 |
conchuod/fixes_present | success | Fixes tag not required for -next series |
conchuod/maintainers_pattern | success | MAINTAINERS pattern errors before the patch: 6 and now 6 |
conchuod/verify_signedoff | success | Signed-off-by tag matches author and committer |
conchuod/kdoc | success | Errors and warnings before: 2 this patch: 2 |
conchuod/build_rv64_clang_allmodconfig | success | Errors and warnings before: 8 this patch: 8 |
conchuod/module_param | success | Was 0 now: 0 |
conchuod/build_rv64_gcc_allmodconfig | success | Errors and warnings before: 24 this patch: 24 |
conchuod/build_rv32_defconfig | success | Build OK |
conchuod/dtb_warn_rv64 | success | Errors and warnings before: 3 this patch: 3 |
conchuod/header_inline | success | No static functions without inline keyword in header files |
conchuod/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 42 lines checked |
conchuod/build_rv64_nommu_k210_defconfig | success | Build OK |
conchuod/verify_fixes | success | No Fixes tag |
conchuod/build_rv64_nommu_virt_defconfig | success | Build OK |
On Fri, May 26, 2023 at 3:55 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > 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: Andrew Jones <ajones@ventanamicro.com> > --- > arch/riscv/include/asm/kvm_vcpu_sbi.h | 7 ++++++- > arch/riscv/kvm/vcpu_sbi.c | 9 ++++++--- > 2 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi.h b/arch/riscv/include/asm/kvm_vcpu_sbi.h > index 4278125a38a5..cda99fc3d897 100644 > --- a/arch/riscv/include/asm/kvm_vcpu_sbi.h > +++ b/arch/riscv/include/asm/kvm_vcpu_sbi.h > @@ -14,9 +14,14 @@ > #define KVM_SBI_VERSION_MAJOR 1 > #define KVM_SBI_VERSION_MINOR 0 > > +enum KVM_RISCV_SBI_EXT_STATUS { This upper-case name of enum looks odd. > + KVM_RISCV_SBI_EXT_AVAILABLE, > + KVM_RISCV_SBI_EXT_UNAVAILABLE, > +}; > + > struct kvm_vcpu_sbi_context { > 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 { > diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c > index 6aa15f1b97d9..28e55ba023dc 100644 > --- a/arch/riscv/kvm/vcpu_sbi.c > +++ b/arch/riscv/kvm/vcpu_sbi.c > @@ -155,7 +155,8 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu, > if (!sext) > 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; > } > @@ -180,7 +181,8 @@ static int riscv_vcpu_get_sbi_ext_single(struct kvm_vcpu *vcpu, > if (!sext) > 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; > } > @@ -316,7 +318,8 @@ const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext( > if (sext->ext_ptr->extid_start <= extid && > sext->ext_ptr->extid_end >= extid) { > 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 sbi_ext[i].ext_ptr; > } > -- > 2.40.1 > Otherwise, this looks good to me. Reviewed-by: Anup Patel <anup@brainfault.org> Regards, Anup
On Tue, May 30, 2023 at 10:28:16PM +0530, Anup Patel wrote: > On Fri, May 26, 2023 at 3:55 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > > > 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: Andrew Jones <ajones@ventanamicro.com> > > --- > > arch/riscv/include/asm/kvm_vcpu_sbi.h | 7 ++++++- > > arch/riscv/kvm/vcpu_sbi.c | 9 ++++++--- > > 2 files changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi.h b/arch/riscv/include/asm/kvm_vcpu_sbi.h > > index 4278125a38a5..cda99fc3d897 100644 > > --- a/arch/riscv/include/asm/kvm_vcpu_sbi.h > > +++ b/arch/riscv/include/asm/kvm_vcpu_sbi.h > > @@ -14,9 +14,14 @@ > > #define KVM_SBI_VERSION_MAJOR 1 > > #define KVM_SBI_VERSION_MINOR 0 > > > > +enum KVM_RISCV_SBI_EXT_STATUS { > > This upper-case name of enum looks odd. I agree. I saw the uppercase enum names in the uapi and matched that, but now I see the non-uapi enums have normal lowercase names. I'll send a v3 with a lowercase name. > > > + KVM_RISCV_SBI_EXT_AVAILABLE, > > + KVM_RISCV_SBI_EXT_UNAVAILABLE, > > +}; > > + > > struct kvm_vcpu_sbi_context { > > 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 { > > diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c > > index 6aa15f1b97d9..28e55ba023dc 100644 > > --- a/arch/riscv/kvm/vcpu_sbi.c > > +++ b/arch/riscv/kvm/vcpu_sbi.c > > @@ -155,7 +155,8 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu, > > if (!sext) > > 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; > > } > > @@ -180,7 +181,8 @@ static int riscv_vcpu_get_sbi_ext_single(struct kvm_vcpu *vcpu, > > if (!sext) > > 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; > > } > > @@ -316,7 +318,8 @@ const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext( > > if (sext->ext_ptr->extid_start <= extid && > > sext->ext_ptr->extid_end >= extid) { > > 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 sbi_ext[i].ext_ptr; > > } > > -- > > 2.40.1 > > > > Otherwise, this looks good to me. > > Reviewed-by: Anup Patel <anup@brainfault.org> > Thanks, drew
diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi.h b/arch/riscv/include/asm/kvm_vcpu_sbi.h index 4278125a38a5..cda99fc3d897 100644 --- a/arch/riscv/include/asm/kvm_vcpu_sbi.h +++ b/arch/riscv/include/asm/kvm_vcpu_sbi.h @@ -14,9 +14,14 @@ #define KVM_SBI_VERSION_MAJOR 1 #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 { 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 { diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c index 6aa15f1b97d9..28e55ba023dc 100644 --- a/arch/riscv/kvm/vcpu_sbi.c +++ b/arch/riscv/kvm/vcpu_sbi.c @@ -155,7 +155,8 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu, if (!sext) 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; } @@ -180,7 +181,8 @@ static int riscv_vcpu_get_sbi_ext_single(struct kvm_vcpu *vcpu, if (!sext) 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; } @@ -316,7 +318,8 @@ const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext( if (sext->ext_ptr->extid_start <= extid && sext->ext_ptr->extid_end >= extid) { 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 sbi_ext[i].ext_ptr; }
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: Andrew Jones <ajones@ventanamicro.com> --- arch/riscv/include/asm/kvm_vcpu_sbi.h | 7 ++++++- arch/riscv/kvm/vcpu_sbi.c | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-)