[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <282a765a-3b42-4175-8d9f-58456d13a37d@arm.com>
Date: Thu, 22 Aug 2024 16:06:16 +0100
From: Steven Price <steven.price@....com>
To: "Aneesh Kumar K.V" <aneesh.kumar@...nel.org>, kvm@...r.kernel.org,
kvmarm@...ts.linux.dev
Cc: Catalin Marinas <catalin.marinas@....com>, Marc Zyngier <maz@...nel.org>,
Will Deacon <will@...nel.org>, James Morse <james.morse@....com>,
Oliver Upton <oliver.upton@...ux.dev>,
Suzuki K Poulose <suzuki.poulose@....com>, Zenghui Yu
<yuzenghui@...wei.com>, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, Joey Gouly <joey.gouly@....com>,
Alexandru Elisei <alexandru.elisei@....com>,
Christoffer Dall <christoffer.dall@....com>, Fuad Tabba <tabba@...gle.com>,
linux-coco@...ts.linux.dev,
Ganapatrao Kulkarni <gankulkarni@...amperecomputing.com>,
Gavin Shan <gshan@...hat.com>, Shanker Donthineni <sdonthineni@...dia.com>,
Alper Gun <alpergun@...gle.com>
Subject: Re: [PATCH v4 18/43] arm64: RME: Handle realm enter/exit
On 22/08/2024 05:04, Aneesh Kumar K.V wrote:
> Steven Price <steven.price@....com> writes:
>
> ....
>
>> +static int rec_exit_ripas_change(struct kvm_vcpu *vcpu)
>> +{
>> + struct kvm *kvm = vcpu->kvm;
>> + struct realm *realm = &kvm->arch.realm;
>> + struct realm_rec *rec = &vcpu->arch.rec;
>> + unsigned long base = rec->run->exit.ripas_base;
>> + unsigned long top = rec->run->exit.ripas_top;
>> + unsigned long ripas = rec->run->exit.ripas_value & 1;
>> + unsigned long top_ipa;
>> + int ret = -EINVAL;
>> +
>> + if (realm_is_addr_protected(realm, base) &&
>> + realm_is_addr_protected(realm, top - 1)) {
>> + kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_page_cache,
>> + kvm_mmu_cache_min_pages(vcpu->arch.hw_mmu));
>> + write_lock(&kvm->mmu_lock);
>> + ret = realm_set_ipa_state(vcpu, base, top, ripas, &top_ipa);
>> + write_unlock(&kvm->mmu_lock);
>> + }
>> +
>> + WARN(ret && ret != -ENOMEM,
>> + "Unable to satisfy SET_IPAS for %#lx - %#lx, ripas: %#lx\n",
>> + base, top, ripas);
>> +
>> + /* Exit to VMM to complete the change */
>> + kvm_prepare_memory_fault_exit(vcpu, base, top_ipa - base, false, false,
>> + ripas == 1);
>> +
>> + return 0;
>> +}
>> +
>
> arch/arm64/kvm/rme-exit.c:100:6: warning: variable 'top_ipa' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> if (realm_is_addr_protected(realm, base) &&
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/arm64/kvm/rme-exit.c:114:44: note: uninitialized use occurs here
> kvm_prepare_memory_fault_exit(vcpu, base, top_ipa - base, false, false,
> ^~~~~~~
I'm not sure why I didn't notice this before, if the condition is false
then we're hitting the WARN (i.e. this shouldn't happen), but I should
fix that up to handle the situation better.
Steve
Powered by blists - more mailing lists