RISC-V: KVM: fix PMU snapshot_set_shmem on 32-bit hosts
Subsystems (3)
PATCH 1/1 RISC-V: KVM: fix PMU snapshot_set_shmem on 32-bit hosts
When saddr_high != 0 on RV32, the goto out was unconditional, causing valid 64-bit addresses to be rejected. Only goto out when the address is invalid (64-bit host with saddr_high != 0).
--- arch/riscv/kvm/vcpu_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/riscv/kvm/vcpu_pmu.c +3 -2
@@ -425,9 +425,10 @@ int kvm_riscv_vcpu_pmu_snapshot_set_shmem(struct kvm_vcpu *vcpu, unsigned long sif (saddr_high !=0 ) {if (IS_ENABLED (CONFIG_32BIT )) saddr |= ((gpa_t )saddr_high <<32 ); -else +else { sbiret =SBI_ERR_INVALID_ADDRESS ; - goto out; + goto out; + } } kvpmu->sdata =kzalloc (snapshot_area_size,GFP_ATOMIC );
Signature · 1 line
2.43.0
Quoted 15 lines · Osama Abdelkader
When
saddr_high!= 0 on RV32, the goto out was unconditional, causing valid 64-bit addresses to be rejected. Only goto out when the address is invalid (64-bit host withsaddr_high!= 0).Fixes c2f41ddbcdd7 ("RISC-V: KVM: Implement SBI PMU Snapshot feature")Signed-off-by Osama Abdelkader <[email protected]>--- arch/riscv/kvm/vcpu_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/riscv/kvm/vcpu_pmu.c +0
-0
arch/riscv/kvm/vcpu_pmu.c int kvm_riscv_vcpu_pmu_snapshot_set_shmem(struct kvm_vcpu *vcpu, unsigned long s · line 431
Quoted 9 lines
arch/riscv/kvm/vcpu_pmu.c +3
-2@@ -425,9 +425,10 @@ int kvm_riscv_vcpu_pmu_snapshot_set_shmem(struct kvm_vcpu *vcpu, unsigned long sif (saddr_high !=0 ) {if (IS_ENABLED (CONFIG_32BIT )) saddr |= ((gpa_t )saddr_high <<32 ); -else +else { sbiret =SBI_ERR_INVALID_ADDRESS ; - goto out; + goto out; + }
nit: Could add the {} to the if-arm too in order to keep things balanced. Otherwise,
Thanks,
drew
Quoted 11 lines
arch/riscv/kvm/vcpu_pmu.c +0
-0} kvpmu->sdata =kzalloc (snapshot_area_size,GFP_ATOMIC );Signature · 7 lines
2.43.0 -- kvm-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kvm-riscv
Quoted 29 lines · Andrew Jones
Quoted 15 lines · Osama Abdelkader
When
saddr_high!= 0 on RV32, the goto out was unconditional, causing valid 64-bit addresses to be rejected. Only goto out when the address is invalid (64-bit host withsaddr_high!= 0).Fixes c2f41ddbcdd7 ("RISC-V: KVM: Implement SBI PMU Snapshot feature")Signed-off-by Osama Abdelkader <[email protected]>--- arch/riscv/kvm/vcpu_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/riscv/kvm/vcpu_pmu.c +0
-0arch/riscv/kvm/vcpu_pmu.c int kvm_riscv_vcpu_pmu_snapshot_set_shmem(struct kvm_vcpu *vcpu, unsigned long s · line 431
Quoted 9 lines
arch/riscv/kvm/vcpu_pmu.c +3
-2@@ -425,9 +425,10 @@ int kvm_riscv_vcpu_pmu_snapshot_set_shmem(struct kvm_vcpu *vcpu, unsigned long sif (saddr_high !=0 ) {if (IS_ENABLED (CONFIG_32BIT )) saddr |= ((gpa_t )saddr_high <<32 ); -else +else { sbiret =SBI_ERR_INVALID_ADDRESS ; - goto out; + goto out; + }nit: Could add the {} to the if-arm too in order to keep things balanced. Otherwise,
Quoted 5 lines
Reviewed-by Andrew Jones <[email protected]>Thanks,
drew
Hi Andrew,
I'm going to do that in v2, thanks.
Thanks,
Osama
Quoted 11 lines
Quoted 11 lines
arch/riscv/kvm/vcpu_pmu.c +0
-0} kvpmu->sdata =kzalloc (snapshot_area_size,GFP_ATOMIC );Signature · 7 lines
2.43.0 -- kvm-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kvm-riscv