mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	linux-s390@vger.kernel.org, frankja@linux.ibm.com,
	david@kernel.org, seiden@linux.ibm.com, nrb@linux.ibm.com,
	schlameuss@linux.ibm.com, gra@linux.ibm.com, hca@linux.ibm.com,
	gerald.schaefer@linux.ibm.com, gor@linux.ibm.com,
	agordeev@linux.ibm.com, svens@linux.ibm.com
Subject: Re: [PATCH v5 9/9] KVM: s390: Return failure in case of failure in kvm_s390_set_cmma_bits()
Date: Tue, 23 Jun 2026 12:33:57 +0200	[thread overview]
Message-ID: <20260623123357.677d98c5@p-imbrenda> (raw)
In-Reply-To: <117d0a80-345f-43d0-9b8d-b86c12eafc05@de.ibm.com>

On Tue, 23 Jun 2026 11:30:24 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> Am 22.06.26 um 18:07 schrieb Claudio Imbrenda:
> > If the allocation of the bits array failed, kvm_s390_set_cmma_bits()
> > would return 0 instead of an error code.
> > 
> > Rework the function to use the __free() macros and thus simplify the
> > code flow; when the above mentioned allocation fails, simply return
> > -ENOMEM.
> > 
> > Fixes: e38c884df921 ("KVM: s390: Switch to new gmap")
> > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > ---
> >   arch/s390/kvm/kvm-s390.c | 18 +++++++-----------
> >   1 file changed, 7 insertions(+), 11 deletions(-)
> > 
> > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> > index cdd8b41d24ed..27d6004132d2 100644
> > --- a/arch/s390/kvm/kvm-s390.c
> > +++ b/arch/s390/kvm/kvm-s390.c
> > @@ -2282,8 +2282,8 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,
> >   static int kvm_s390_set_cmma_bits(struct kvm *kvm,
> >   				  const struct kvm_s390_cmma_log *args)
> >   {
> > -	struct kvm_s390_mmu_cache *mc;
> > -	u8 *bits = NULL;
> > +	struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
> > +	u8 *bits __free(kvfree) = NULL;  
> 
> why kvfree and not vfree?

because vfree does not exist as cleanup macro: __free(vfree) would not
compile

adding vfree would be outside the scope of this patch

> 
> >   	int r = 0;
> >   
> >   	if (!kvm->arch.use_cmma)
> > @@ -2303,18 +2303,16 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
> >   		return -ENOMEM;
> >   	bits = vmalloc(array_size(sizeof(*bits), args->count));
> >   	if (!bits)
> > -		goto out;
> > +		return -ENOMEM;
> >   
> >   	r = copy_from_user(bits, (void __user *)args->values, args->count);
> > -	if (r) {
> > -		r = -EFAULT;
> > -		goto out;
> > -	}
> > +	if (r)
> > +		return -EFAULT;
> >   
> >   	do {
> >   		r = kvm_s390_mmu_cache_topup(mc);
> >   		if (r)
> > -			break;
> > +			return r;
> >   		scoped_guard(read_lock, &kvm->mmu_lock) {
> >   			r = dat_set_cmma_bits(mc, kvm->arch.gmap->asce, args->start_gfn,
> >   					      args->count, args->mask, bits);
> > @@ -2322,9 +2320,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
> >   	} while (r == -ENOMEM);
> >   
> >   	set_bit(GMAP_FLAG_USES_CMM, &kvm->arch.gmap->flags);
> > -out:
> > -	kvm_s390_free_mmu_cache(mc);
> > -	vfree(bits);
> > +
> >   	return r;
> >   }
> >     
> 


  reply	other threads:[~2026-06-23 10:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 16:07 [PATCH v5 0/9] KVM: s390: A bunch of gmap-related fixes Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 1/9] s390/mm: Fix handling of _PAGE_UNUSED pte bit Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 2/9] KVM: s390: Fix dat_peek_cmma() overflow Claudio Imbrenda
2026-06-22 16:18   ` Christian Borntraeger
2026-06-22 16:07 ` [PATCH v5 3/9] KVM: s390: Do not set special large pages dirty Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 4/9] KVM: s390: Fix code typo in gmap_protect_asce_top_level() Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 5/9] KVM: s390: Fix handle_{sske,pfmf} under memory pressure Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 6/9] KVM: s390: Fix locking in kvm_s390_set_mem_control() Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 7/9] KVM: s390: Fix cmma dirty tracking Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 8/9] KVM: s390: selftests: Fix cmma selftest Claudio Imbrenda
2026-06-22 16:07 ` [PATCH v5 9/9] KVM: s390: Return failure in case of failure in kvm_s390_set_cmma_bits() Claudio Imbrenda
2026-06-23  9:30   ` Christian Borntraeger
2026-06-23 10:33     ` Claudio Imbrenda [this message]
2026-06-23 10:35       ` Christian Borntraeger

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=20260623123357.677d98c5@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=david@kernel.org \
    --cc=frankja@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gra@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=schlameuss@linux.ibm.com \
    --cc=seiden@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

all inboxes | Powered by JetHome®