Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2179999pxj; Sun, 16 May 2021 17:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGZm3meIqwPuopkN6KCgRuSWswYuDlImGIpoLY8sit3dCSiHFISb/I76htlSidw11O01zG X-Received: by 2002:a5e:8305:: with SMTP id x5mr41962495iom.112.1621211626715; Sun, 16 May 2021 17:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621211626; cv=none; d=google.com; s=arc-20160816; b=P3JSqnhAIHYUVM/ECST1ai3guCBvGs9mJGYsHbbmrpJqyhp/TDK5aehdIhuTYxlXz+ UNi7Qda8DX3rv7ccPKswYh0UsmB1Cyxgfz1/FKfZwBFnFZQx1CAJFWOpY2A4wkQdfEwA qE7UBXku62bQk6pujzOsOh7g3h7MbvrOwbH70XH00npqExhhmOd210E344udPzwgqmZb W6NYIkcyWBbxjCOVuL3uGnjE2JGYPAxwfxIPCs18J5go1oGL0RLGmf+ET66WGP7x4PQ1 GPnN1E22iV1rvICMKYDTUJfLxIxjFQRwkzdiLBGItn09odheEQAgV2noeEtjPmcxFEI2 ZU5w== 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=Txu5TIAdpXNZz3syoDZid1j9eNYVciI+5vqCP7Lelro=; b=ytHCNv1V/bAfyJdZiUStJtSs43Q2VJC1hSAV9fdQ0EqQS2CnfitYwgcTprvkpOCMJ3 TqMlnCRZT0cjOs61ItIDyOPqATebMfKOClfQ7fbAtr51xCMvr4LAq2ya5o0MQDaLkLMf vZlGHvPRJOeva/InoZVTTKfWh/y33GrMFLACNvMdsMBbQHUbW+ZfZ8OsU6+XqP3fcSej VHRfPr1mq7VsfGM1E3pITbtjsEQ/rt3I4AFAQMPnTjpbJfmbQtVf39BB6OjDRVMKGIPS aMgJy0QbtdezNga9qrTegMXNT2Hx3oy8dnwUef+ZVc9YgvszYE3iz8IiTx3E+MbrnWQl DmaQ== 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 w8si15720101jaw.8.2021.05.16.17.33.34; Sun, 16 May 2021 17:33:46 -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 S234305AbhEPVqr (ORCPT + 99 others); Sun, 16 May 2021 17:46:47 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:54444 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234392AbhEPVqj (ORCPT ); Sun, 16 May 2021 17:46:39 -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 1liOZO-000809-V5; Sun, 16 May 2021 23:45:06 +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 v3 5/8] KVM: s390: Introduce kvm_s390_get_gfn_end() Date: Sun, 16 May 2021 23:44:31 +0200 Message-Id: <8554ddd03839f0938ea169a6b698b4125335355b.1621191551.git.maciej.szmigiero@oracle.com> 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 75e635ede6ff..c6dfb9c24c8c 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -1986,7 +1986,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 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;