Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2890897pxb; Tue, 13 Apr 2021 12:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxkimDa4LDrfMztx7bArFWa/FnuIHrfccGXleZVxYp/DFgr6a24boAt+7sA11ad4hGSjz2 X-Received: by 2002:a17:90a:c788:: with SMTP id gn8mr1647445pjb.60.1618343481449; Tue, 13 Apr 2021 12:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618343481; cv=none; d=google.com; s=arc-20160816; b=cwy7ouDLZAUpU0Ifik46FHpy2utTUGEWRSGSZVC3G8DuIsU4P94wBjt7yT5Xxo+YPN RIlh1iWV9GLPim3B3VS7oL+SnrUCVQ9W/Uj1nwppBAhyhcVcRvxnfxeyMz8MQ/Pnd1Ko AwGtcG0pZlz4uR8XaOw/eXc+KtQvvPcff2ji+57j0WTf7dnGA/M6QdPsDnp0wsW+6WbK wSUE1geC00alT8NuUvOjN79INC79qJm4vOUi/MZ4Jz6gNz9ezLvDRs41jEkxEkVMUpa1 QA01MicL9IXmunNijNScqTJTuNdarv6Bc+dmbHVCA0g+3eH8U7xgG5uCYww3HXr2tCLs dVtQ== 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=IFKcqvgo8ikrsFn8bz2IETF2sBAWOQPe76PCFinhhF0=; b=ur7ER823GHf0XqwlSdBrRfF2SuwNoIalqfb1U9iCfQi61aKbyUHIZGqVls2YSSo0wH n2zqEGmPQJ3gMXmRu4j/eBY3RNgJrcRaEsnMw4lrJgOxIAxC9mwZDVojiucrLmX2DQPl REnfniw6LKreJ+AJ7a9LKh62ppCua8yUG8O79ooJL7QUla7AK5t2LyCtmZ27hxr3XxOj QO3YfJo0avR0vvAzFOVWmM06Y68+iGRBTwcuzq42+0FVptvm83Y5xLTg069Qeh7Eh3zB 8e2klAa8/3d/9fPHPyvWSghIFN4GpKlVd8If3kd7TfUXjW/rD7SVAAg3YE3nRITWskOQ MV8A== 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 b15si12167702pfd.331.2021.04.13.12.50.54; Tue, 13 Apr 2021 12:51:21 -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 S1346377AbhDMOLo (ORCPT + 99 others); Tue, 13 Apr 2021 10:11:44 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:48218 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346333AbhDMOLc (ORCPT ); Tue, 13 Apr 2021 10:11:32 -0400 Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.93.0.4) (envelope-from ) id 1lWJkc-0003zn-HB; Tue, 13 Apr 2021 16:10:46 +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 v2 5/8] KVM: s390: Introduce kvm_s390_get_gfn_end() Date: Tue, 13 Apr 2021 16:10:11 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 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 62491ec003d8..4445c99eb00e 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -1977,7 +1977,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 79dcd647b378..96537370ce8c 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 813b6e93dc83..6bf42cdf4013 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;