Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1054999ybh; Tue, 21 Jul 2020 14:38:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6iwjySLqanhoruzyrEc9uXsXun//KaqGUIe+lXA1Q/eBxBkhDn2R/7Pks1WOLJE2rUatF X-Received: by 2002:a17:907:2654:: with SMTP id ar20mr25757205ejc.62.1595367528332; Tue, 21 Jul 2020 14:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595367528; cv=none; d=google.com; s=arc-20160816; b=hnqDeDlujUinWohWGvJyt3z1TR6xHLFCxrPrkXZofBiIrL7ysGokf80e4cyG82cfAg FTJjBq0n8MBEPb5vcEC6jMyrYG2SLDR09wPh/LVcviVGdOqdblbhP3QGFW72gcRUZ2gR FqKQYfUZc9EmauUSfF31ZlsjILxO3Zd6HFoWsLNlapbNdj7Ki3V8VRJryxfp6jXqrhsA 3yoBMKRJ+cNRShvhuS25vcsy1d+8A64bdFLUhRqDjWSeyhnLn3ffRVyL05hJujM+XivL SQpRrNPs3eoyP2ot8f5kRVtatMgSilBlcFJeLvYHn6H9ZKVi8CrQblaXDA7qo1AXtmSD jaXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=MaFSReGnjWFULcMkUTAFC5+er9kwU5NikodXJtg72A4=; b=oZ7epvJn2YIJAu2c/lathZ6BiWrqh2/PO5mS1Ye/AvHQo1+J7uiShgQj/hDvGrOcVT mc1pS4BGU7yps3HYhNMgoHyQXSi2dQ7X4lbRVwofr2LMd93QuizJqTOJeRVF79W0tbrI /KLp0Iho04VScNPR88u0K/Ol2ZoOrp99Mtl/WTCN1kpvrrsjhjQqq+DF4qNQvRdRFuRB paLbDsYcJLgugB2zP187QKn+f2enYL6V/b51ohzGz1kglZnWK9Htv2H8yYHj7eqYj+BT 3sll089ze2LWv7Lzf+d7OoLmXl1wmZUgWS2jCxL38SQ2bXr3fue+5lI6EeofZyZzBfO9 ACgg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si12851503ejb.89.2020.07.21.14.38.24; Tue, 21 Jul 2020 14:38:48 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731137AbgGUViG (ORCPT + 99 others); Tue, 21 Jul 2020 17:38:06 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55580 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbgGUViG (ORCPT ); Tue, 21 Jul 2020 17:38:06 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06LLXDjQ176851; Tue, 21 Jul 2020 17:37:47 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 32e1yabx0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jul 2020 17:37:47 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06LLb3AG026274; Tue, 21 Jul 2020 21:37:45 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 32brq826r5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jul 2020 21:37:45 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06LLbg3G64094472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Jul 2020 21:37:42 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B93A4C044; Tue, 21 Jul 2020 21:37:42 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E2D84C040; Tue, 21 Jul 2020 21:37:39 +0000 (GMT) Received: from oc0525413822.ibm.com (unknown [9.163.39.1]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 21 Jul 2020 21:37:39 +0000 (GMT) Date: Tue, 21 Jul 2020 14:37:36 -0700 From: Ram Pai To: Laurent Dufour Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, mpe@ellerman.id.au, paulus@samba.org, sukadev@linux.ibm.com, bauerman@linux.ibm.com, bharata@linux.ibm.com, Paul Mackerras Subject: Re: [PATCH v2 2/2] KVM: PPC: Book3S HV: rework secure mem slot dropping Message-ID: <20200721213736.GG7339@oc0525413822.ibm.com> Reply-To: Ram Pai References: <20200721104202.15727-1-ldufour@linux.ibm.com> <20200721104202.15727-3-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200721104202.15727-3-ldufour@linux.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-21_15:2020-07-21,2020-07-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 mlxlogscore=328 phishscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007210138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 21, 2020 at 12:42:02PM +0200, Laurent Dufour wrote: > When a secure memslot is dropped, all the pages backed in the secure device > (aka really backed by secure memory by the Ultravisor) should be paged out > to a normal page. Previously, this was achieved by triggering the page > fault mechanism which is calling kvmppc_svm_page_out() on each pages. > > This can't work when hot unplugging a memory slot because the memory slot > is flagged as invalid and gfn_to_pfn() is then not trying to access the > page, so the page fault mechanism is not triggered. > > Since the final goal is to make a call to kvmppc_svm_page_out() it seems > simpler to directly calling it instead of triggering such a mechanism. This ^^ call directly instead of triggering.. > way kvmppc_uvmem_drop_pages() can be called even when hot unplugging a > memslot. > > Since kvmppc_uvmem_drop_pages() is already holding kvm->arch.uvmem_lock, > the call to __kvmppc_svm_page_out() is made. > As __kvmppc_svm_page_out needs the vma pointer to migrate the pages, the > VMA is fetched in a lazy way, to not trigger find_vma() all the time. In > addition, the mmap_sem is help in read mode during that time, not in write ^^ held > mode since the virual memory layout is not impacted, and > kvm->arch.uvmem_lock prevents concurrent operation on the secure device. > > Cc: Ram Pai Reviewed-by: Ram Pai RP