kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KVM: s390/mm: Clarification for two return value checks in gmap_shadow()
@ 2020-05-02 15:43 Markus Elfring
  2020-05-02 17:27 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2020-05-02 15:43 UTC (permalink / raw)
  To: linux-s390, kvm, Christian Bornträger, Claudio Imbrenda,
	Cornelia Huck, David Hildenbrand, Heiko Carstens, Janosch Frank,
	Vasily Gorbik
  Cc: LKML

Hello,

I have tried another small script out for the semantic patch language.
This source code analysis approach points out that the function “gmap_find_shadow”
is called two times by the function “gmap_shadow”.
https://elixir.bootlin.com/linux/v5.7-rc3/source/arch/s390/mm/gmap.c#L1628
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/arch/s390/mm/gmap.c

Null pointer checks are performed at these places.
The function “gmap_find_shadow” is documented in the same source file
that the pointer “ERR_PTR(-EAGAIN)” can eventually be returned.
Are the referenced gmap data structures always initialised here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: KVM: s390/mm: Clarification for two return value checks in gmap_shadow()
  2020-05-02 15:43 KVM: s390/mm: Clarification for two return value checks in gmap_shadow() Markus Elfring
@ 2020-05-02 17:27 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2020-05-02 17:27 UTC (permalink / raw)
  To: Markus Elfring, linux-s390, kvm, Christian Bornträger,
	Claudio Imbrenda, Cornelia Huck, Heiko Carstens, Janosch Frank,
	Vasily Gorbik
  Cc: LKML

On 02.05.20 17:43, Markus Elfring wrote:
> Hello,
> 
> I have tried another small script out for the semantic patch language.
> This source code analysis approach points out that the function “gmap_find_shadow”
> is called two times by the function “gmap_shadow”.
> https://elixir.bootlin.com/linux/v5.7-rc3/source/arch/s390/mm/gmap.c#L1628
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/arch/s390/mm/gmap.c
> 
> Null pointer checks are performed at these places.

Right, in case we have already a shadow, we return it. In case we are
just concurrently creating/initializing another one, we return -EINVAL
so the caller will retry (and find the fully initialized one). In case
we get NULL, we have to create a new one.

> The function “gmap_find_shadow” is documented in the same source file
> that the pointer “ERR_PTR(-EAGAIN)” can eventually be returned.
> Are the referenced gmap data structures always initialised here?

-EAGAIN makes sure that we are not touching partially initialized one.
In case we find a valid gmap shadow, it is fully initialized. That's
what we have the ->initialized field for.

Hope that answers your question.

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-02 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 15:43 KVM: s390/mm: Clarification for two return value checks in gmap_shadow() Markus Elfring
2020-05-02 17:27 ` David Hildenbrand

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 NNTP newsgroup(s).