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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 57D17C73C53 for ; Tue, 9 Jul 2019 19:43:37 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2DE22087F for ; Tue, 9 Jul 2019 19:43:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2DE22087F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45jt6H0KH5zDqCp for ; Wed, 10 Jul 2019 05:43:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=janani@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45jt3t0BqmzDq7k for ; Wed, 10 Jul 2019 05:41:29 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x69JdIQf082322 for ; Tue, 9 Jul 2019 15:41:27 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tn05wtquy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Jul 2019 15:41:27 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Jul 2019 20:41:25 +0100 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 9 Jul 2019 20:41:21 +0100 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x69JfKmc43123054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Jul 2019 19:41:20 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18BBBC605B; Tue, 9 Jul 2019 19:41:20 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8560C6055; Tue, 9 Jul 2019 19:41:19 +0000 (GMT) Received: from ltc.linux.ibm.com (unknown [9.16.170.189]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 9 Jul 2019 19:41:19 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 09 Jul 2019 14:43:47 -0500 From: janani To: Bharata B Rao Subject: Re: [PATCH v5 4/7] kvmppc: Handle memory plug/unplug to secure VM Organization: IBM Mail-Reply-To: janani@linux.ibm.com In-Reply-To: <20190709102545.9187-5-bharata@linux.ibm.com> References: <20190709102545.9187-1-bharata@linux.ibm.com> <20190709102545.9187-5-bharata@linux.ibm.com> X-Sender: janani@linux.ibm.com User-Agent: Roundcube Webmail/1.0.1 X-TM-AS-GCONF: 00 x-cbid: 19070919-8235-0000-0000-00000EB44E59 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011401; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01229823; UDB=6.00647720; IPR=6.01011082; MB=3.00027657; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-09 19:41:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19070919-8236-0000-0000-000046546CF6 Message-Id: <730f4bbd1be9abae7640ddc7366b0beb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-09_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=983 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907090232 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: janani@linux.ibm.com Cc: linuxram@us.ibm.com, cclaudio@linux.ibm.com, kvm-ppc@vger.kernel.org, Linuxppc-dev , linux-mm@kvack.org, jglisse@redhat.com, aneesh.kumar@linux.vnet.ibm.com, paulus@au1.ibm.com, sukadev@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 2019-07-09 05:25, Bharata B Rao wrote: > Register the new memslot with UV during plug and unregister > the memslot during unplug. > > Signed-off-by: Bharata B Rao > Acked-by: Paul Mackerras Reviewed-by: Janani Janakiraman > --- > arch/powerpc/include/asm/ultravisor-api.h | 1 + > arch/powerpc/include/asm/ultravisor.h | 7 +++++++ > arch/powerpc/kvm/book3s_hv.c | 19 +++++++++++++++++++ > 3 files changed, 27 insertions(+) > > diff --git a/arch/powerpc/include/asm/ultravisor-api.h > b/arch/powerpc/include/asm/ultravisor-api.h > index 07b7d638e7af..d6d6eb2e6e6b 100644 > --- a/arch/powerpc/include/asm/ultravisor-api.h > +++ b/arch/powerpc/include/asm/ultravisor-api.h > @@ -21,6 +21,7 @@ > #define UV_WRITE_PATE 0xF104 > #define UV_RETURN 0xF11C > #define UV_REGISTER_MEM_SLOT 0xF120 > +#define UV_UNREGISTER_MEM_SLOT 0xF124 > #define UV_PAGE_IN 0xF128 > #define UV_PAGE_OUT 0xF12C > > diff --git a/arch/powerpc/include/asm/ultravisor.h > b/arch/powerpc/include/asm/ultravisor.h > index b46042f1aa8f..fe45be9ee63b 100644 > --- a/arch/powerpc/include/asm/ultravisor.h > +++ b/arch/powerpc/include/asm/ultravisor.h > @@ -70,6 +70,13 @@ static inline int uv_register_mem_slot(u64 lpid, > u64 start_gpa, u64 size, > return ucall(UV_REGISTER_MEM_SLOT, retbuf, lpid, start_gpa, > size, flags, slotid); > } > + > +static inline int uv_unregister_mem_slot(u64 lpid, u64 slotid) > +{ > + unsigned long retbuf[UCALL_BUFSIZE]; > + > + return ucall(UV_UNREGISTER_MEM_SLOT, retbuf, lpid, slotid); > +} > #endif /* !__ASSEMBLY__ */ > > #endif /* _ASM_POWERPC_ULTRAVISOR_H */ > diff --git a/arch/powerpc/kvm/book3s_hv.c > b/arch/powerpc/kvm/book3s_hv.c > index b8f801d00ad4..7cbb5edaed01 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -77,6 +77,7 @@ > #include > #include > #include > +#include > > #include "book3s.h" > > @@ -4504,6 +4505,24 @@ static void > kvmppc_core_commit_memory_region_hv(struct kvm *kvm, > if (change == KVM_MR_FLAGS_ONLY && kvm_is_radix(kvm) && > ((new->flags ^ old->flags) & KVM_MEM_LOG_DIRTY_PAGES)) > kvmppc_radix_flush_memslot(kvm, old); > + /* > + * If UV hasn't yet called H_SVM_INIT_START, don't register memslots. > + */ > + if (!kvm->arch.secure_guest) > + return; > + > + /* > + * TODO: Handle KVM_MR_MOVE > + */ > + if (change == KVM_MR_CREATE) { > + uv_register_mem_slot(kvm->arch.lpid, > + new->base_gfn << PAGE_SHIFT, > + new->npages * PAGE_SIZE, > + 0, > + new->id); > + } else if (change == KVM_MR_DELETE) { > + uv_unregister_mem_slot(kvm->arch.lpid, old->id); > + } > } > > /*