Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp1082753pxb; Fri, 13 Aug 2021 13:07:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyMWOl7jzTVccE9HxUzNYu6h0Q9Lt98D4k6xaUlHjxW7J+AGmeibtMHGGX3iW/7TutErUm X-Received: by 2002:aa7:d5d3:: with SMTP id d19mr5112062eds.201.1628885223746; Fri, 13 Aug 2021 13:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628885223; cv=none; d=google.com; s=arc-20160816; b=vaJ21anhN7lwZH7MxoKEdavJ09lNrj49x2iWTGcA/dujph/PCnTc0gWL3ZuOi1qHaH +cfEpMnRHQ8roXyj9K4b4+1GnqPlEXiG0tUl3V+Adt7gh8az19DWMtqk7KoQx/Kq0b/y 5QHX7BmiLmgdeGWqwUkvS/njlzja1v8f5pQktunKnRURqwqQ2RWWYzvvrSCvmdu4w0YL Egg6CtH7xvy2qPdfY5Z3qiQ8sn0meOmx4NgnGLm6dM9GNG7DiVHNvcFm26/aOjkX0IYP cvgq2mVydJtm8e/0F77WtbdFqPULEP0GKPo1+pXQAm4Cnmds51vf/LmwDEPBQK1brROq kn5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wB28e0vEronrFPrRLoI8qbk4ixH3CiHXOjfyCa8T6zI=; b=eNQOpETfewIo3jgAyYzzgxbrsHwuZlNB5cdKOTJLImG50TKicfEkigovsZ/AhbX+Nv Q1f+jbOMUGl0DnCppcgMQNAzG78qo7YEcjDIzqy5JzUHdSwF76d8C9bW0KjxZHSiSpDs mRVBDEVICklhHpXCZCvwaujIg7zJdfqQ50yg4YjCNmr8S6N/sirQ9ZWWw2lEaYOXjV6Z lT7HqTG09mO/x4Hq3LYFutbbXpVHfCMndkwSBa56Wo2DUF0fBq+YdrcyzqtxiTYN18p+ 7wPuWpKs+YQBXqJ8PD05ypK2JYeAY7uocTwGdukBmzB/m9zoF1pDklIhiY4WfZdz9fPI pkBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si2601444eju.572.2021.08.13.13.06.40; Fri, 13 Aug 2021 13:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234527AbhHMUCR (ORCPT + 99 others); Fri, 13 Aug 2021 16:02:17 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:50372 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234342AbhHMUCP (ORCPT ); Fri, 13 Aug 2021 16:02:15 -0400 Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mEcwj-00045W-3W; Fri, 13 Aug 2021 21:34:25 +0200 From: "Maciej S. Szmigiero" To: Paolo Bonzini , Vitaly Kuznetsov Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Igor Mammedov , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 10/13] KVM: s390: Introduce kvm_s390_get_gfn_end() Date: Fri, 13 Aug 2021 21:33:23 +0200 Message-Id: <5de2569b7a6c7df38c5fdd3baf88e6d987f42776.1628871413.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Maciej S. Szmigiero" 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 --- 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;