Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4584898pxj; Wed, 12 May 2021 08:42:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt3sA83dA/iaGcrptvryNUAabuKBPOxY5svOgQnk0Boo8TiPUnbYx/62k8nPDEw0SHxVmW X-Received: by 2002:a17:906:a39a:: with SMTP id k26mr10449701ejz.350.1620834121108; Wed, 12 May 2021 08:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834121; cv=none; d=google.com; s=arc-20160816; b=IrYbf958geKq/ZTLYnRYTv5Cyo4mzOqruJRg8psuWub34n03TkWmEjjKREBwuzKsRw PHQORHC8QJSGIbi0tWtBt6GVsEcpu/sw1Ab+mvflwjU1MS/jl8WlBNPxokpQ0hhvjfav ROKjg9bzIQVrxBQbu8T3CxNcfgkpr5NZQc458xAHB0IifFzDXu0khAFlrgt3uicSTZsc nnr4H1aVcDQR5KJa5oEW6El+ppIydkSrq73HTqu6zub8yhqsSP7hoS8zNnCbdyFnb8Yf NHtmgQxy4lvNeNDfGtYnDUePNp01vsTjbrh647cUBxT+S5v4J0Z/PQqmeZLC5lHvLASg kFDg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0xXA/M60jlqC2dzGVRWrQL6i/cuRSfXWtcbs4oZ/GZ0=; b=UgUFtJDVG/WoPtn7WNPeUpxLgC11e6XONjLKdKuGl7SAgIdXWcKQpA+4e8Lgb9RK2p VJzuWVW/9KQepIEzy5HIiNsqM0OVaa1x7CsPVEObZFuHW6fJ3+JyOnh5zEXGyyTnh7gO Dabs3T2HHlzgylGZlgI6kihxWaybcDMB8vuZVSeP/rHC1uGXNbhzwXA+ixtiNbbWIE2f OS5mpG2GXW3lomPHVr+aIwB2UDLnwhxvfK78iY1inIasQ6tapqqfYQWlqeTSwGGy+qA7 o4riqc9ubxp+0c9NtJEFVieWfK1pXUKTNQARBvs259KKIQr+2lebzeiuLxDrL6kJg5CK S35w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ZZsGjS/q"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si251231eju.563.2021.05.12.08.41.35; Wed, 12 May 2021 08:42:01 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ZZsGjS/q"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235876AbhELPgE (ORCPT + 99 others); Wed, 12 May 2021 11:36:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:50766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234250AbhELPQS (ORCPT ); Wed, 12 May 2021 11:16:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D6D56194A; Wed, 12 May 2021 15:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831960; bh=gF3ENYH1MX9au7Q9ZOzAFmnKgrgF/OFpsE8Ho3z2q14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZsGjS/qliWOnWrpK0xWfF39dP+IfTnu+Z+MPFTlyHoyd1to/LP1Pt6GODBy41cFW cVa3q7r4H81PsI4cFaac6QLn5D8kVHwKIavHZSPEaGTiO/9TxOOoWLi/Y65K/fb89Z vh5hWo2cTUCc264hpJ4ki9n/KHXbF4q6gUJ4rgug= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudio Imbrenda , Christian Borntraeger Subject: [PATCH 5.10 085/530] KVM: s390: split kvm_s390_logical_to_effective Date: Wed, 12 May 2021 16:43:15 +0200 Message-Id: <20210512144822.571131181@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Claudio Imbrenda commit f85f1baaa18932a041fd2b1c2ca6cfd9898c7d2b upstream. Split kvm_s390_logical_to_effective to a generic function called _kvm_s390_logical_to_effective. The new function takes a PSW and an address and returns the address with the appropriate bits masked off. The old function now calls the new function with the appropriate PSW from the vCPU. This is needed to avoid code duplication for vSIE. Signed-off-by: Claudio Imbrenda Reviewed-by: Christian Borntraeger Cc: stable@vger.kernel.org # for VSIE: correctly handle MVPG when in VSIE Link: https://lore.kernel.org/r/20210302174443.514363-2-imbrenda@linux.ibm.com Signed-off-by: Christian Borntraeger Signed-off-by: Greg Kroah-Hartman --- arch/s390/kvm/gaccess.h | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) --- a/arch/s390/kvm/gaccess.h +++ b/arch/s390/kvm/gaccess.h @@ -37,6 +37,29 @@ static inline unsigned long kvm_s390_rea } /** + * _kvm_s390_logical_to_effective - convert guest logical to effective address + * @psw: psw of the guest + * @ga: guest logical address + * + * Convert a guest logical address to an effective address by applying the + * rules of the addressing mode defined by bits 31 and 32 of the given PSW + * (extendended/basic addressing mode). + * + * Depending on the addressing mode, the upper 40 bits (24 bit addressing + * mode), 33 bits (31 bit addressing mode) or no bits (64 bit addressing + * mode) of @ga will be zeroed and the remaining bits will be returned. + */ +static inline unsigned long _kvm_s390_logical_to_effective(psw_t *psw, + unsigned long ga) +{ + if (psw_bits(*psw).eaba == PSW_BITS_AMODE_64BIT) + return ga; + if (psw_bits(*psw).eaba == PSW_BITS_AMODE_31BIT) + return ga & ((1UL << 31) - 1); + return ga & ((1UL << 24) - 1); +} + +/** * kvm_s390_logical_to_effective - convert guest logical to effective address * @vcpu: guest virtual cpu * @ga: guest logical address @@ -52,13 +75,7 @@ static inline unsigned long kvm_s390_rea static inline unsigned long kvm_s390_logical_to_effective(struct kvm_vcpu *vcpu, unsigned long ga) { - psw_t *psw = &vcpu->arch.sie_block->gpsw; - - if (psw_bits(*psw).eaba == PSW_BITS_AMODE_64BIT) - return ga; - if (psw_bits(*psw).eaba == PSW_BITS_AMODE_31BIT) - return ga & ((1UL << 31) - 1); - return ga & ((1UL << 24) - 1); + return _kvm_s390_logical_to_effective(&vcpu->arch.sie_block->gpsw, ga); } /*