lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210818163114.7f45646e@p-imbrenda>
Date:   Wed, 18 Aug 2021 16:31:14 +0200
From:   Claudio Imbrenda <imbrenda@...ux.ibm.com>
To:     "Maciej S. Szmigiero" <mail@...iej.szmigiero.name>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Igor Mammedov <imammedo@...hat.com>,
        Marc Zyngier <maz@...nel.org>,
        James Morse <james.morse@....com>,
        Julien Thierry <julien.thierry.kdev@...il.com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Huacai Chen <chenhuacai@...nel.org>,
        Aleksandar Markovic <aleksandar.qemu.devel@...il.com>,
        Paul Mackerras <paulus@...abs.org>,
        Christian Borntraeger <borntraeger@...ibm.com>,
        Janosch Frank <frankja@...ux.ibm.com>,
        David Hildenbrand <david@...hat.com>,
        Cornelia Huck <cohuck@...hat.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 10/13] KVM: s390: Introduce kvm_s390_get_gfn_end()

On Fri, 13 Aug 2021 21:33:23 +0200
"Maciej S. Szmigiero" <mail@...iej.szmigiero.name> wrote:

> From: "Maciej S. Szmigiero" <maciej.szmigiero@...cle.com>
> 
> And use it where s390 code would just access the memslot with the highest
> gfn directly.
> 
> No functional change intended.
> 
> Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@...cle.com>

Reviewed-by: Claudio Imbrenda <imbrenda@...ux.ibm.com>

> ---
>  arch/s390/kvm/kvm-s390.c |  2 +-
>  arch/s390/kvm/kvm-s390.h | 12 ++++++++++++
>  arch/s390/kvm/pv.c       |  4 +---
>  3 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 6b3f05086fae..9c3a85793ba4 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -2006,7 +2006,7 @@ static int kvm_s390_get_cmma(struct kvm *kvm, struct kvm_s390_cmma_log *args,
>  	if (!ms)
>  		return 0;
>  	next_gfn = kvm_s390_next_dirty_cmma(slots, cur_gfn + 1);
> -	mem_end = slots->memslots[0].base_gfn + slots->memslots[0].npages;
> +	mem_end = kvm_s390_get_gfn_end(slots);
>  
>  	while (args->count < bufsize) {
>  		hva = gfn_to_hva(kvm, cur_gfn);
> diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
> index 9fad25109b0d..5787b12aff7e 100644
> --- a/arch/s390/kvm/kvm-s390.h
> +++ b/arch/s390/kvm/kvm-s390.h
> @@ -208,6 +208,18 @@ static inline int kvm_s390_user_cpu_state_ctrl(struct kvm *kvm)
>  	return kvm->arch.user_cpu_state_ctrl != 0;
>  }
>  
> +/* get the end gfn of the last (highest gfn) memslot */
> +static inline unsigned long kvm_s390_get_gfn_end(struct kvm_memslots *slots)
> +{
> +	struct kvm_memory_slot *ms;
> +
> +	if (WARN_ON(!slots->used_slots))
> +		return 0;
> +
> +	ms = slots->memslots;
> +	return ms->base_gfn + ms->npages;
> +}
> +
>  /* implemented in pv.c */
>  int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);
>  int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);
> diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
> index c8841f476e91..e51cccfded25 100644
> --- a/arch/s390/kvm/pv.c
> +++ b/arch/s390/kvm/pv.c
> @@ -117,7 +117,6 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
>  	unsigned long base = uv_info.guest_base_stor_len;
>  	unsigned long virt = uv_info.guest_virt_var_stor_len;
>  	unsigned long npages = 0, vlen = 0;
> -	struct kvm_memory_slot *memslot;
>  
>  	kvm->arch.pv.stor_var = NULL;
>  	kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL_ACCOUNT, get_order(base));
> @@ -131,8 +130,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
>  	 * Slots are sorted by GFN
>  	 */
>  	mutex_lock(&kvm->slots_lock);
> -	memslot = kvm_memslots(kvm)->memslots;
> -	npages = memslot->base_gfn + memslot->npages;
> +	npages = kvm_s390_get_gfn_end(kvm_memslots(kvm));
>  	mutex_unlock(&kvm->slots_lock);
>  
>  	kvm->arch.pv.guest_len = npages * PAGE_SIZE;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ