From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B74A7C352A4 for ; Mon, 10 Feb 2020 14:58:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B93320714 for ; Mon, 10 Feb 2020 14:58:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XiBf0dMx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B93320714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 272A26B0119; Mon, 10 Feb 2020 09:58:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24AA76B011B; Mon, 10 Feb 2020 09:58:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 111E06B011C; Mon, 10 Feb 2020 09:58:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id EC6076B0119 for ; Mon, 10 Feb 2020 09:58:26 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id AE4958248068 for ; Mon, 10 Feb 2020 14:58:26 +0000 (UTC) X-FDA: 76474523412.09.play90_66c399fad9a41 X-HE-Tag: play90_66c399fad9a41 X-Filterd-Recvd-Size: 5140 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Mon, 10 Feb 2020 14:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581346705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:openpgp:openpgp; bh=Ai1/Z236VGvcSi9aos29tUsyKZUbyNytyfpikXX8Exg=; b=XiBf0dMx8AB+GSYvq4egmNykaWFCtgdpo4mCRb4oyLtlfl8bw7Q4A051AIRsX6gR/YXfEs //1MPcWyaHH7Orni0juiEf06Unql8VWV5QAkPXiNz7/w3XE/zXVK8zyAoDGnmxWYyx0C5k ax8k/VGFFNqliELXQ4DnZHW3208FAew= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-hvbszyYqOYihSyIlykokpQ-1; Mon, 10 Feb 2020 09:58:21 -0500 X-MC-Unique: hvbszyYqOYihSyIlykokpQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD4D21005510; Mon, 10 Feb 2020 14:58:19 +0000 (UTC) Received: from thuth.remote.csb (ovpn-116-219.ams2.redhat.com [10.36.116.219]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBB1E87B2F; Mon, 10 Feb 2020 14:58:12 +0000 (UTC) Subject: Re: [PATCH 21/35] KVM: s390/mm: handle guest unpin events To: Christian Borntraeger , Janosch Frank Cc: KVM , Cornelia Huck , David Hildenbrand , Ulrich Weigand , Claudio Imbrenda , Andrea Arcangeli , linux-s390 , Michael Mueller , Vasily Gorbik , linux-mm@kvack.org, Andrew Morton References: <20200207113958.7320-1-borntraeger@de.ibm.com> <20200207113958.7320-22-borntraeger@de.ibm.com> From: Thomas Huth Openpgp: preference=signencrypt Message-ID: <2fd5c392-a2b7-c6b8-f079-8b87ee60f65e@redhat.com> Date: Mon, 10 Feb 2020 15:58:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200207113958.7320-22-borntraeger@de.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 07/02/2020 12.39, Christian Borntraeger wrote: > From: Claudio Imbrenda > > The current code tries to first pin shared pages, if that fails (e.g. > because the page is not shared) it will export them. For shared pages > this means that we get a new intercept telling us that the guest is > unsharing that page. We will make the page secure at that point in time > and revoke the host access. This is synchronized with other host events, > e.g. the code will wait until host I/O has finished. > > Signed-off-by: Claudio Imbrenda > [borntraeger@de.ibm.com: patch merging, splitting, fixing] > Signed-off-by: Christian Borntraeger > --- > arch/s390/kvm/intercept.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c > index 2a966dc52611..e155389a4a66 100644 > --- a/arch/s390/kvm/intercept.c > +++ b/arch/s390/kvm/intercept.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > > #include "kvm-s390.h" > #include "gaccess.h" > @@ -484,12 +485,35 @@ static int handle_pv_sclp(struct kvm_vcpu *vcpu) > return 0; > } > > +static int handle_pv_uvc(struct kvm_vcpu *vcpu) > +{ > + struct uv_cb_share *guest_uvcb = (void *)vcpu->arch.sie_block->sidad; > + struct uv_cb_cts uvcb = { > + .header.cmd = UVC_CMD_UNPIN_PAGE_SHARED, > + .header.len = sizeof(uvcb), > + .guest_handle = kvm_s390_pv_handle(vcpu->kvm), > + .gaddr = guest_uvcb->paddr, > + }; > + int rc; > + > + if (guest_uvcb->header.cmd != UVC_CMD_REMOVE_SHARED_ACCESS) { > + WARN_ONCE(1, "Unexpected UVC 0x%x!\n", guest_uvcb->header.cmd); Is there a way to signal the failed command to the guest, too? Thomas > + return 0; > + } > + rc = uv_make_secure(vcpu->arch.gmap, uvcb.gaddr, &uvcb); > + if (rc == -EINVAL && uvcb.header.rc == 0x104) > + return 0; > + return rc; > +} > + > static int handle_pv_notification(struct kvm_vcpu *vcpu) > { > if (vcpu->arch.sie_block->ipa == 0xb210) > return handle_pv_spx(vcpu); > if (vcpu->arch.sie_block->ipa == 0xb220) > return handle_pv_sclp(vcpu); > + if (vcpu->arch.sie_block->ipa == 0xb9a4) > + return handle_pv_uvc(vcpu); > > return handle_instruction(vcpu); > } >