From: Dan Carpenter <dan.carpenter@linaro.org>
To: maz@kernel.org
Cc: kvmarm@lists.linux.dev
Subject: [bug report] KVM: arm64: nv: Handle ERETA[AB] instructions
Date: Wed, 24 Apr 2024 09:39:53 +0300 [thread overview]
Message-ID: <e23f90d2-306d-4290-8247-845472eeb860@moroto.mountain> (raw)
Hello Marc Zyngier,
Commit 213b3d1ea161 ("KVM: arm64: nv: Handle ERETA[AB] instructions")
from Apr 19, 2024 (linux-next), leads to the following Smatch static
checker warning:
arch/arm64/kvm/emulate-nested.c:2209 kvm_emulate_nested_eret()
error: uninitialized symbol 'elr'.
arch/arm64/kvm/emulate-nested.c
2173 void kvm_emulate_nested_eret(struct kvm_vcpu *vcpu)
2174 {
2175 u64 spsr, elr, esr;
2176
2177 /*
2178 * Forward this trap to the virtual EL2 if the virtual
2179 * HCR_EL2.NV bit is set and this is coming from !EL2.
2180 */
2181 if (forward_traps(vcpu, HCR_NV))
2182 return;
2183
2184 /* Check for an ERETAx */
2185 esr = kvm_vcpu_get_esr(vcpu);
2186 if (esr_iss_is_eretax(esr) && !kvm_auth_eretax(vcpu, &elr)) {
2187 /*
2188 * Oh no, ERETAx failed to authenticate. If we have
2189 * FPACCOMBINE, deliver an exception right away. If we
2190 * don't, then let the mangled ELR value trickle down the
2191 * ERET handling, and the guest will have a little surprise.
2192 */
2193 if (kvm_has_pauth(vcpu->kvm, FPACCOMBINE)) {
2194 esr &= ESR_ELx_ERET_ISS_ERETA;
2195 esr |= FIELD_PREP(ESR_ELx_EC_MASK, ESR_ELx_EC_FPAC);
2196 kvm_inject_nested_sync(vcpu, esr);
2197 return;
2198 }
2199 }
2200
2201 preempt_disable();
2202 kvm_arch_vcpu_put(vcpu);
2203
2204 spsr = __vcpu_sys_reg(vcpu, SPSR_EL2);
2205 spsr = kvm_check_illegal_exception_return(vcpu, spsr);
2206 if (!esr_iss_is_eretax(esr))
2207 elr = __vcpu_sys_reg(vcpu, ELR_EL2);
elr is unitialized on else path
2208
--> 2209 trace_kvm_nested_eret(vcpu, elr, spsr);
2210
2211 /*
2212 * Note that the current exception level is always the virtual EL2,
2213 * since we set HCR_EL2.NV bit only when entering the virtual EL2.
2214 */
2215 *vcpu_pc(vcpu) = elr;
^^^
2216 *vcpu_cpsr(vcpu) = spsr;
2217
2218 kvm_arch_vcpu_load(vcpu, smp_processor_id());
2219 preempt_enable();
2220 }
regards,
dan carpenter
next reply other threads:[~2024-04-24 6:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 6:39 Dan Carpenter [this message]
2024-04-24 12:28 ` [bug report] KVM: arm64: nv: Handle ERETA[AB] instructions Marc Zyngier
2024-04-24 12:47 ` Dan Carpenter
2024-04-24 13:02 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e23f90d2-306d-4290-8247-845472eeb860@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).