From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0126.outbound.protection.outlook.com ([104.47.34.126]:59343 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753773AbeDIASq (ORCPT ); Sun, 8 Apr 2018 20:18:46 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: David Hildenbrand , Christian Borntraeger , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 083/189] KVM: s390: vsie: store guest addresses of satellite blocks in vsie_page Date: Mon, 9 Apr 2018 00:17:50 +0000 Message-ID: <20180409001637.162453-83-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: David Hildenbrand [ Upstream commit 15e5020e575d0c1a4eddd99bf7ffdc1f34a3b17d ] This way, the values cannot change, even if another VCPU might try to mess with the nested SCB currently getting executed by another VCPU. We now always use the same gpa for pinning and unpinning a page (for unpinning, it is only relevant to mark the guest page dirty for migration). Signed-off-by: David Hildenbrand Message-Id: <20180116171526.12343-3-david@redhat.com> Reviewed-by: Christian Borntraeger Acked-by: Cornelia Huck Signed-off-by: Christian Borntraeger Signed-off-by: Sasha Levin --- arch/s390/kvm/vsie.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 11fc525e6e7f..861832c2e842 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -38,7 +38,13 @@ struct vsie_page { struct gmap *gmap; /* 0x0220 */ /* address of the last reported fault to guest2 */ unsigned long fault_addr; /* 0x0228 */ - __u8 reserved[0x0700 - 0x0230]; /* 0x0230 */ + /* calculated guest addresses of satellite control blocks */ + gpa_t sca_gpa; /* 0x0230 */ + gpa_t itdba_gpa; /* 0x0238 */ + gpa_t gvrd_gpa; /* 0x0240 */ + gpa_t riccbd_gpa; /* 0x0248 */ + gpa_t sdnx_gpa; /* 0x0250 */ + __u8 reserved[0x0700 - 0x0258]; /* 0x0258 */ struct kvm_s390_crypto_cb crycb; /* 0x0700 */ __u8 fac[S390_ARCH_FAC_LIST_SIZE_BYTE]; /* 0x0800 */ }; @@ -485,46 +491,42 @@ static void unpin_guest_page(struct kvm *kvm, gpa_t g= pa, hpa_t hpa) /* unpin all blocks previously pinned by pin_blocks(), marking them dirty = */ static void unpin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_pag= e) { - struct kvm_s390_sie_block *scb_o =3D vsie_page->scb_o; struct kvm_s390_sie_block *scb_s =3D &vsie_page->scb_s; hpa_t hpa; - gpa_t gpa; =20 hpa =3D (u64) scb_s->scaoh << 32 | scb_s->scaol; if (hpa) { - gpa =3D scb_o->scaol & ~0xfUL; - if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_64BSCAO)) - gpa |=3D (u64) scb_o->scaoh << 32; - unpin_guest_page(vcpu->kvm, gpa, hpa); + unpin_guest_page(vcpu->kvm, vsie_page->sca_gpa, hpa); + vsie_page->sca_gpa =3D 0; scb_s->scaol =3D 0; scb_s->scaoh =3D 0; } =20 hpa =3D scb_s->itdba; if (hpa) { - gpa =3D scb_o->itdba & ~0xffUL; - unpin_guest_page(vcpu->kvm, gpa, hpa); + unpin_guest_page(vcpu->kvm, vsie_page->itdba_gpa, hpa); + vsie_page->itdba_gpa =3D 0; scb_s->itdba =3D 0; } =20 hpa =3D scb_s->gvrd; if (hpa) { - gpa =3D scb_o->gvrd & ~0x1ffUL; - unpin_guest_page(vcpu->kvm, gpa, hpa); + unpin_guest_page(vcpu->kvm, vsie_page->gvrd_gpa, hpa); + vsie_page->gvrd_gpa =3D 0; scb_s->gvrd =3D 0; } =20 hpa =3D scb_s->riccbd; if (hpa) { - gpa =3D scb_o->riccbd & ~0x3fUL; - unpin_guest_page(vcpu->kvm, gpa, hpa); + unpin_guest_page(vcpu->kvm, vsie_page->riccbd_gpa, hpa); + vsie_page->riccbd_gpa =3D 0; scb_s->riccbd =3D 0; } =20 hpa =3D scb_s->sdnxo; if (hpa) { - gpa =3D scb_o->sdnxo; - unpin_guest_page(vcpu->kvm, gpa, hpa); + unpin_guest_page(vcpu->kvm, vsie_page->sdnx_gpa, hpa); + vsie_page->sdnx_gpa =3D 0; scb_s->sdnxo =3D 0; } } @@ -569,6 +571,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsi= e_page *vsie_page) } if (rc) goto unpin; + vsie_page->sca_gpa =3D gpa; scb_s->scaoh =3D (u32)((u64)hpa >> 32); scb_s->scaol =3D (u32)(u64)hpa; } @@ -585,6 +588,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsi= e_page *vsie_page) rc =3D set_validity_icpt(scb_s, 0x0080U); goto unpin; } + vsie_page->itdba_gpa =3D gpa; scb_s->itdba =3D hpa; } =20 @@ -603,6 +607,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsi= e_page *vsie_page) rc =3D set_validity_icpt(scb_s, 0x1310U); goto unpin; } + vsie_page->gvrd_gpa =3D gpa; scb_s->gvrd =3D hpa; } =20 @@ -619,6 +624,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsi= e_page *vsie_page) goto unpin; } /* Validity 0x0044 will be checked by SIE */ + vsie_page->riccbd_gpa =3D gpa; scb_s->riccbd =3D hpa; } if ((scb_s->ecb & ECB_GS) && !(scb_s->ecd & ECD_HOSTREGMGMT)) { @@ -646,6 +652,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsi= e_page *vsie_page) rc =3D set_validity_icpt(scb_s, 0x10b0U); goto unpin; } + vsie_page->sdnx_gpa =3D gpa; scb_s->sdnxo =3D hpa | sdnxc; } return 0; --=20 2.15.1