From: Heiko Carstens <hca@linux.ibm.com>
To: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
kernel test robot <lkp@intel.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
David Hildenbrand <david@redhat.com>,
Sven Schnelle <svens@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: s390: Pass initialized arg even if unused
Date: Thu, 25 Aug 2022 10:30:25 +0200 [thread overview]
Message-ID: <YwczITkxvvghyvWq@osiris> (raw)
In-Reply-To: <20220824153011.4004573-1-scgl@linux.ibm.com>
On Wed, Aug 24, 2022 at 05:30:11PM +0200, Janis Schoetterl-Glausch wrote:
> This silences smatch warnings reported by kbuild bot:
> arch/s390/kvm/gaccess.c:859 guest_range_to_gpas() error: uninitialized symbol 'prot'.
> arch/s390/kvm/gaccess.c:1064 access_guest_with_key() error: uninitialized symbol 'prot'.
>
> This is because it cannot tell that the value is not used in this case.
> The trans_exc* only examine prot if code is PGM_PROTECTION.
> Pass a dummy value for other codes.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
> ---
> arch/s390/kvm/gaccess.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
...
> @@ -503,6 +505,7 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
>
> switch (code) {
> case PGM_PROTECTION:
> + WARN(unlikely(prot == PROT_NONE), "Invalid prot argument");
The WARN macro comes with unlikely, please get rid of unlikely here. Also:
> + case PROT_NONE:
> + /* We should never get here, acts like termination */
Why not put it here? And make it WARN_ON_ONCE() in addition?
> gpa = kvm_s390_real_to_abs(vcpu, ga);
> - if (kvm_is_error_gpa(vcpu->kvm, gpa))
> + if (kvm_is_error_gpa(vcpu->kvm, gpa)) {
> rc = PGM_ADDRESSING;
> + prot = PROT_NONE;
> + }
...
> + if (rc == PGM_PROTECTION)
> + prot = PROT_TYPE_KEYC;
> + else
> + prot = PROT_NONE;
For both cases I would suggest to preinitialize prot with PROT_NONE in
order to keep the code smaller - but not my call.
next prev parent reply other threads:[~2022-08-25 8:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 15:30 [PATCH] KVM: s390: Pass initialized arg even if unused Janis Schoetterl-Glausch
2022-08-25 8:30 ` Heiko Carstens [this message]
2022-08-25 19:27 ` Janis Schoetterl-Glausch
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=YwczITkxvvghyvWq@osiris \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=dan.carpenter@oracle.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lkp@intel.com \
--cc=scgl@linux.ibm.com \
--cc=svens@linux.ibm.com \
/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