From patchwork Wed Nov 21 05:28:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 10691977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3320D5A4 for ; Wed, 21 Nov 2018 05:28:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1090B2B329 for ; Wed, 21 Nov 2018 05:28:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2C062B3F4; Wed, 21 Nov 2018 05:28:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72D522B329 for ; Wed, 21 Nov 2018 05:28:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 229F96B243E; Wed, 21 Nov 2018 00:28:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1D94C6B243F; Wed, 21 Nov 2018 00:28:25 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07B076B2440; Wed, 21 Nov 2018 00:28:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 9C0836B243E for ; Wed, 21 Nov 2018 00:28:24 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id z10so2455172edz.15 for ; Tue, 20 Nov 2018 21:28:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=fx0NA7cYdJVMd3lh2U9mySu7PjQRRngiKGZ4T+VH/mY=; b=JOXtUcX88bOyVJpYXqwF/xvvH2hzv9BiP02SCtqtfZ+2xdOAQ3Jud5t2HBZtrIXslo zom6tHnDGsc9+gEUxg2plTioPQe3G0jozQ5aUUddxVc97q5n+cCurR0ATpx8Jyt1zUwR qt1nNQ0p4thz9wd14JUEIW9tpQIkFrYM2m18qKLzo2VAo46IcWYkfqSSOQb4TR6ko32I mXlmzZFi66Jgst5Hm16ZJ6JAZ1IUyjKet9W1CrupWOfOtcTyPgRai9pOgqHrcYy6+VYu 7tns7VWshOk1xvROb7UUU3rseY2D7UkH3cuO6LBf1CHdQPj0dPse4iOWSTSwQD46fMjI bp1A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of bharata@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=bharata@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AA+aEWY+H+SLL1ylUKyeMwJhQjHBzo+5+iXKWWk1H1riYqu5/235bMz/ G3SW5OIUI1in1NEM9XciQ0Of94RgezmSXhePkwrOV3rmWesOH652+8KOs/qUlhDYkACFq3gBr2T nBcaC2NaJQCKHacUxU0CAPOrlq4aGWWeJRLwHDH1Jd7Xwplhgo3NBEm90LYTE5WPYaw== X-Received: by 2002:a50:903c:: with SMTP id b57mr4543550eda.161.1542778104103; Tue, 20 Nov 2018 21:28:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/U3ZDaEDSoz1CTOhoFMBkhmUy8UMSpVQMWUR5tDZTou56V/dSFZj9Ea6hVFUbEbke5bOyaK X-Received: by 2002:a50:903c:: with SMTP id b57mr4543505eda.161.1542778103015; Tue, 20 Nov 2018 21:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542778102; cv=none; d=google.com; s=arc-20160816; b=Ekro9IRt49VG7iz0yiotkMu8q+hDftzARxPueJvIelBeV0m322NCeO4+PrB9GS3S78 HAzyUDnVAQU/pKcLBVYKmEy7D9SFHQUARGZap+pxYBHHkcitfQXH9dUyNaP9tz7Y6jNM 6SxHFHw7faFtgZ3n3vNu9reFd91Y4VeGfRh8FV7Z3+Dp9KDebnGHK5bsGbPKeljb5PNz sxe1yPFNOE4zZJSrd+XYbqJNyU/lDna0J6aP9Ig45CrJPSY4bz9xzTElIots51OGStxa OTYYLQjXUCuxLHIX6oiDNK8qS+K89NfePqBG8JSun9Scrjr3ghPth6T3ur173VBAOxBI p4tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=fx0NA7cYdJVMd3lh2U9mySu7PjQRRngiKGZ4T+VH/mY=; b=W+vHgbwNs88Myr7u8IjNTLk9L80XyEew3BvO6i/Au1NyBWW7GKu58Q5CH7xkUQQuHK zdBksrqXgOWFhJmxRTVU5jxrDTKgT9OhxQnoNf0R481eQp/Nw1MfNUxkRGSqMEXQpiTN kaBpxb7KBDCrrnY3030SCKt5Ki3JWTC3Z3SllT0bfuSIJ4lsFgVze2B9ZncaJq2ap/55 RvWtbl6PtQFL8w64x+A6yFMNQWVzxLDs1aFkCOdn8q7cuo2ssat0nhDYolG3rxRKm9wt h4hMYZ/Ar3nYCXtd6iBU0s/wBP6SGwgEfkU14M9kB2Z1E/So3Bz9MArtEetPP6fnTHcf MYkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bharata@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=bharata@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id l1si4551487edc.252.2018.11.20.21.28.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 21:28:22 -0800 (PST) Received-SPF: pass (google.com: domain of bharata@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of bharata@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=bharata@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAL5SKjB052746 for ; Wed, 21 Nov 2018 00:28:21 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nvxhyd975-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 21 Nov 2018 00:28:21 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Nov 2018 05:28:19 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 21 Nov 2018 05:28:17 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAL5SFCq62783602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Nov 2018 05:28:15 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E6E34C058; Wed, 21 Nov 2018 05:28:15 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 254DE4C044; Wed, 21 Nov 2018 05:28:14 +0000 (GMT) Received: from bharata.in.ibm.com (unknown [9.124.35.234]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 21 Nov 2018 05:28:13 +0000 (GMT) From: Bharata B Rao To: linuxppc-dev@lists.ozlabs.org Cc: kvm-ppc@vger.kernel.org, linux-mm@kvack.org, paulus@au1.ibm.com, benh@linux.ibm.com, aneesh.kumar@linux.vnet.ibm.com, jglisse@redhat.com, linuxram@us.ibm.com, Bharata B Rao Subject: [RFC PATCH v2 0/4] kvmppc: HMM backend driver to manage pages of secure guest Date: Wed, 21 Nov 2018 10:58:07 +0530 X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 x-cbid: 18112105-0012-0000-0000-000002CDBF88 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112105-0013-0000-0000-00002102EAC9 Message-Id: <20181121052811.4819-1-bharata@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-21_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=752 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811210050 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: X-Virus-Scanned: ClamAV using ClamSMTP Hi, A pseries guest can be run as a secure guest on Ultravisor-enabled POWER platforms. On such platforms, this driver will be used to manage the movement of guest pages between the normal memory managed by hypervisor (HV) and secure memory managed by Ultravisor (UV). This is an early post of HMM driver patches that manage page migration between normal and secure memory. Private ZONE_DEVICE memory equal to the amount of secure memory available in the platform for running secure guests is created via a HMM device. The movement of pages between normal and secure memory is done by ->alloc_and_copy() callback routine of migrate_vma(). The page-in or page-out requests from UV will come to HV as hcalls and HV will call back into UV via uvcalls to satisfy these page requests. The implementation of uvcall themselves are not present in this post and will be posted separately. Changes in v2 ============= - Removed the HMM PFN hash table as the same information is now being stored in kvm_memory_slot->arch.rmap[] array as suggested by Paul Mackerras. - Addressed the review comments from v1. Bharata B Rao (4): kvmppc: HMM backend driver to manage pages of secure guest kvmppc: Add support for shared pages in HMM driver kvmppc: H_SVM_INIT_START and H_SVM_INIT_DONE hcalls kvmppc: Handle memory plug/unplug to secure VM arch/powerpc/include/asm/hvcall.h | 9 + arch/powerpc/include/asm/kvm_host.h | 15 + arch/powerpc/include/asm/kvm_ppc.h | 46 ++- arch/powerpc/include/asm/ucall-api.h | 33 ++ arch/powerpc/kvm/Makefile | 3 + arch/powerpc/kvm/book3s.c | 5 +- arch/powerpc/kvm/book3s_hv.c | 49 ++- arch/powerpc/kvm/book3s_hv_hmm.c | 542 +++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_pr.c | 3 +- arch/powerpc/kvm/powerpc.c | 2 +- 10 files changed, 700 insertions(+), 7 deletions(-) create mode 100644 arch/powerpc/include/asm/ucall-api.h create mode 100644 arch/powerpc/kvm/book3s_hv_hmm.c