Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2376620pxb; Mon, 20 Sep 2021 20:40:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyo2KAShJ4z7g/nU+3uc2hqTYPmrT8ZCx7sfJWCFvcYP46uIbNnTxzQ+sgVLgduZyH1/okf X-Received: by 2002:a17:906:3854:: with SMTP id w20mr31010485ejc.537.1632195626753; Mon, 20 Sep 2021 20:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632195626; cv=none; d=google.com; s=arc-20160816; b=IqyP1t4vjMWgDi5Xe6pLP9OGpzCSYOPJupgXySy2GbvXirH0G43X2Y3o713faLUF2g ieGU9DRgMWsTX5J9mAimvgotQqNzlHn4Z+0rMnCJHmoEuZC/I57AmCjEwJxjYMmse9kB FZSZrcX+gfhA6dzKMLU3aHJZR9G9Y2+KuPE4Cq9ZfnfVX8qn2bVXRNynPl2jDyCyf/Z4 4wEtYhDE9Jd4tAJ6xlB1TJoc0CM3cP30eOWMB4WG7PjyvQEBQGRIC/nHs7vsZkJEJTup Pnlx73zyYILsuxyliOsg7H1Q/mxEWlDzzuyyyHgdqsIKUSY1ntd+RZjlDy2eUAVD/A+4 n5Xw== 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=s9wjXr5QWITmmxihK7HlaqJbLgF3/Dvtv9ljBOp0kDg=; b=bE6KnjRohTWvoHrLEslLVNudNanF+ScK4Qv0LvPL9N6folIKZO9zFgzmwk3GcML4Uu WjRIOTSyttxBM5iDMxygGI6mu2oSzL4u2Ys/LIYBnv6afsQ+bgQqEhNlIqbTkPtRcvgw TsP2opyBT49Ro58mcx2Ac20m8W8o/SN+s/z7Z/FG7FmiqbCNk6a41BlCZZ3tlJfBRc4b 8hLs95GjWn1HNo+AX0/qi+eG1PkFzhK8qWZinDBPv2C38ZdGD8KTFd0S679fbiHdA39C x3iMOdQmTJH/pxczNHQqd2rrz2UClQLmuYAZm9XpNG/jxX0VvS1vEqUnoNiGYIHAauym HIEQ== 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 kl9si17481555ejc.603.2021.09.20.20.40.03; Mon, 20 Sep 2021 20:40:26 -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 S240855AbhITVoE (ORCPT + 99 others); Mon, 20 Sep 2021 17:44:04 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:45666 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240405AbhITVly (ORCPT ); Mon, 20 Sep 2021 17:41:54 -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 1mSR16-0006TI-KP; Mon, 20 Sep 2021 23:40:00 +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 v5 10/13] KVM: s390: Introduce kvm_s390_get_gfn_end() Date: Mon, 20 Sep 2021 23:38:58 +0200 Message-Id: X-Mailer: git-send-email 2.33.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 Reviewed-by: Claudio Imbrenda --- 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 540fa948baa5..bbc32cd7a9a3 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 ecd741ee3276..73d4659ddd59 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;