Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4546748pxj; Wed, 12 May 2021 07:57:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLotnLJLlyscKXpsqx/SfRvUNKsUy2/f7POT/BiTLt0ORuFfNj1AY1xRoNKEcjXSz0vRSq X-Received: by 2002:a9d:7f83:: with SMTP id t3mr28079711otp.32.1620831465464; Wed, 12 May 2021 07:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620831465; cv=none; d=google.com; s=arc-20160816; b=m2rcac3zkXcVrFRZRy4xiP2Anmab0S2SgDKpqafF/EiAK2e93xb7ZyX54T5mUSwFWY UZZIv3WpbpARJ/SIXKvhCbu0UwQeZ2qV6ltnmKULU6YfDb0h4+/8A/1wzVwMyGNLfiEB qYd0vCrwBWcZEzRUwcn5LjDuGW5+mybbnXu3ML9e+7F8IWTwRUuwa8FQom02QvxqgLqn ViXxboz2OmbeMlx13r9wGc5EdMJzXywJEx6yHQT0dVQFnAdAtTEdOg4BN3aEuRpDXQdr SNWnxsc+GfYiExomsJBTfTiy3A1aGR4H7HOdXRRAQV4rrH7KtcHtuCEycjtFLoBAg15O 3Mkg== 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=FsreWu5IxP5TK9H9vNFkicDNfp08Ro0YUOptxJ6w1KOZzRXxfBKhEN+82YLk8mxZMQ VuqIpVLSzIbIwKwWXkQitS/KxwwA8lVj/vRMDsEclMYnL5t8PzGCqXIP8toV17dAWJfR n2agH9KtWbSckAMwfLjIP2Yil44Ro7MV0PXtCjhSWtpb9VDuiHAyL31jxgIubrGntyJY zhDRBG9EUfIsqGG3r/rjufuPqOFXXH9XWD9HTjmcgY8pvjjNv+wkAMQgThDBCaBfViLi jJq9wrJktue7GooTnhOBSOlwlSyA4c/HS7BCXyjFQiUsGYg1SxBedor+5xEXdhH2GuS+ vUrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s4HZhHDS; 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 q1si134259otm.143.2021.05.12.07.57.32; Wed, 12 May 2021 07:57:45 -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=s4HZhHDS; 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 S231894AbhELO5W (ORCPT + 99 others); Wed, 12 May 2021 10:57:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:46734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232201AbhELOzq (ORCPT ); Wed, 12 May 2021 10:55:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E2EB36143C; Wed, 12 May 2021 14:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831278; bh=gF3ENYH1MX9au7Q9ZOzAFmnKgrgF/OFpsE8Ho3z2q14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s4HZhHDSsZBLjlt9dCUBdCI9M4E8T5oWkpv4lkPzdn65igGfXIeyXC15ChciKDKIE f6ePFOQ40u6RqrgudR61Lyf4pdDaeYOUs5AvUE8J7NGlmTZW8f/csdiqmyxg0aIQ4z hHJx4R1FeNxrh35GqPRP6f8MtEjX6+5vH+B23RXw= 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.4 056/244] KVM: s390: split kvm_s390_logical_to_effective Date: Wed, 12 May 2021 16:47:07 +0200 Message-Id: <20210512144744.838544452@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144743.039977287@linuxfoundation.org> References: <20210512144743.039977287@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); } /*