From patchwork Mon Oct 22 05:18:36 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: 10651693 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 D3066921 for ; Mon, 22 Oct 2018 05:19:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C449528382 for ; Mon, 22 Oct 2018 05:19:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8643287A4; Mon, 22 Oct 2018 05:19:07 +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 2C31228382 for ; Mon, 22 Oct 2018 05:19:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DF0E6B000D; Mon, 22 Oct 2018 01:19:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 06B056B000E; Mon, 22 Oct 2018 01:19:04 -0400 (EDT) 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 DFE316B0010; Mon, 22 Oct 2018 01:19:04 -0400 (EDT) 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 8AC836B000D for ; Mon, 22 Oct 2018 01:19:04 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id i16-v6so23709957ede.11 for ; Sun, 21 Oct 2018 22:19:04 -0700 (PDT) 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:in-reply-to:references:message-id; bh=mwFcU9rpnGtrKmOZO/PFxUi5Cv1lx7IkLLIoNTUu7ak=; b=MKLcVJgoszBa0T+bMqQrW3tK23l9sI6pyBtGa5BPCnkAkJBwetUqu1FlrUv2IswGbF wrlyOre8wbtvo0ORGO+H/OX8OuFEPQyx6DqpofAFvK6kr3l1DZf/d7nTYcYUJW2Q0UYH VNAsjjxUXdjRZNE8Hc4Qz/UdD/seIPWqAIIIjwk0zFqe4GXkJUoMMuNAbFJAoJSWxMcG OnDigOCSws8VCbgMN2qWqBUWWyMleDhs4pBWrzm3SBgZApM/NPoUCmv0K75uzgaPcl2V 7ydbndPyUhi5GOrIZ5rnFkKcFQaYDwZ5xsg/fK7IN8Da+yqC6rjPmqfWcOOHPy0qSCTV 2SmQ== 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: ABuFfoiWmD6vWB63whMarmruu/L3U6kUwg6slZ/2QTlEZatGGSCXiyGK btMNGeb3pwHDPIqGZwUPzv5o05vwvDc4NaVXqQDbgw1XhEZ/pO8JPz7Dq493G0vwWOqQZpaQsj6 jodBltpHFSUXjotvkDAlsILT73T/QEA6pYTTydOMgoOJKitvsOTrd92GZegUhaLFaxw== X-Received: by 2002:a50:b905:: with SMTP id m5-v6mr11804844ede.108.1540185543974; Sun, 21 Oct 2018 22:19:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV63eE1zUpckM8Z1wItn89zKFOY5qgNsQCl1XoNTniGF/PQAX2euzz0TqUn4/o5/qh01Trg4s X-Received: by 2002:a50:b905:: with SMTP id m5-v6mr11804815ede.108.1540185543038; Sun, 21 Oct 2018 22:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540185543; cv=none; d=google.com; s=arc-20160816; b=VDz/bHSHk/zOouuJoJK8dJE4X0Cu79T5aDSTfoXhELFr8fH0tbbFgQ5qFUoJdwRT5r KwefQm5O6+9aW4abtIr4oZNbg1+SS3cQ0A1Pc5iwphznY+RqljUngWc7Ki8TnDLxzODy jvAb+Hrx5VTh8gL6DoBsjP1gdoOZGnlQXQCKfXC+7GAlSnZBNC1Mqb3mwvuNKRC8VUIX YAWhq3o5Zb4gQ7whK5rEyvwa78JjMoct2sARbRRs08RMgXa6TH9r9wnbOazO3GogJh96 jDsJvDtVrfuLB1lA5ojmS7yRxYWFMhkXm62RHvy01hjmQPyVmK9Vsa+tNSrGGOSVhcFI Hc7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from; bh=mwFcU9rpnGtrKmOZO/PFxUi5Cv1lx7IkLLIoNTUu7ak=; b=O7M9bCI2t5hnNhACmaWLk4BqKQ1c+0iSGNGNhOqPtuuX87M+t8dMDsl2XCSqaqYekE is0aHoKb03OQ+UUFElOrTkt/H67xnSCPICsFxqRc/WWWXBgkODXwCXO5cV/+ML0Cnh+v KecINEHlOSx/Fbl57v17LqHmUkRzEiWVOht99Nas9MN6iIjTAFKXEMv3UuBVDvdrr48d Ft9zDK2a+hvJ4lfLed9tdBNqUx0Em8o4hfHw8OJHTiA18Y+fKWzMphn8BKp6PP7u3YPa 14hAivEJEMxQAZmO2SBpuP23TiNCCBiE7hjfLZA8TCPJfvgljXuxPAakrea3fs5Xr4q7 SmcA== 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 x43-v6si17050926edd.165.2018.10.21.22.19.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 22:19:03 -0700 (PDT) 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 (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9M59a1k145373 for ; Mon, 22 Oct 2018 01:19:01 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n921ftafx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 22 Oct 2018 01:19:01 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Oct 2018 06:18:59 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 22 Oct 2018 06:18:57 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9M5Iuw620119786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 22 Oct 2018 05:18:56 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2066AE058; Mon, 22 Oct 2018 05:18:55 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CB03AE045; Mon, 22 Oct 2018 05:18:54 +0000 (GMT) Received: from bharata.in.ibm.com (unknown [9.124.35.126]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 22 Oct 2018 05:18:54 +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 v1 3/4] kvmppc: H_SVM_INIT_START and H_SVM_INIT_DONE hcalls Date: Mon, 22 Oct 2018 10:48:36 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181022051837.1165-1-bharata@linux.ibm.com> References: <20181022051837.1165-1-bharata@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18102205-0020-0000-0000-000002D8147D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18102205-0021-0000-0000-000021272E0F Message-Id: <20181022051837.1165-4-bharata@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-21_14:,, 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810220049 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 H_SVM_INIT_START: Initiate securing a VM H_SVM_INIT_DONE: Conclude securing a VM During early guest init, these hcalls will be issued by UV. As part of these hcalls, [un]register memslots with UV. Signed-off-by: Bharata B Rao --- arch/powerpc/include/asm/hvcall.h | 4 ++- arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/include/asm/ucall-api.h | 6 ++++ arch/powerpc/kvm/book3s_hv.c | 54 ++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h index 89e6b70c1857..6091276fef07 100644 --- a/arch/powerpc/include/asm/hvcall.h +++ b/arch/powerpc/include/asm/hvcall.h @@ -300,7 +300,9 @@ #define H_INT_RESET 0x3D0 #define H_SVM_PAGE_IN 0x3D4 #define H_SVM_PAGE_OUT 0x3D8 -#define MAX_HCALL_OPCODE H_SVM_PAGE_OUT +#define H_SVM_INIT_START 0x3DC +#define H_SVM_INIT_DONE 0x3E0 +#define MAX_HCALL_OPCODE H_SVM_INIT_DONE /* H_VIOCTL functions */ #define H_GET_VIOA_DUMP_SIZE 0x01 diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 194e6e0ff239..267f8c568bc3 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -292,6 +292,7 @@ struct kvm_arch { struct dentry *debugfs_dir; struct dentry *htab_dentry; struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */ + bool svm_init_start; /* Indicates H_SVM_INIT_START has been called */ #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE struct mutex hpt_mutex; diff --git a/arch/powerpc/include/asm/ucall-api.h b/arch/powerpc/include/asm/ucall-api.h index 2c12f514f8ab..9ddfcf541211 100644 --- a/arch/powerpc/include/asm/ucall-api.h +++ b/arch/powerpc/include/asm/ucall-api.h @@ -17,4 +17,10 @@ static inline int uv_page_out(u64 lpid, u64 dw0, u64 dw1, u64 dw2, u64 dw3) return U_SUCCESS; } +static inline int uv_register_mem_slot(u64 lpid, u64 dw0, u64 dw1, u64 dw2, + u64 dw3) +{ + return 0; +} + #endif /* _ASM_POWERPC_UCALL_API_H */ diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 05084eb8aadd..47f366f634fd 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -819,6 +819,50 @@ static int kvmppc_get_yield_count(struct kvm_vcpu *vcpu) return yield_count; } +#ifdef CONFIG_PPC_SVM +#include +/* + * TODO: Check if memslots related calls here need to be called + * under any lock. + */ +static unsigned long kvmppc_h_svm_init_start(struct kvm *kvm) +{ + struct kvm_memslots *slots; + struct kvm_memory_slot *memslot; + int ret; + + slots = kvm_memslots(kvm); + kvm_for_each_memslot(memslot, slots) { + ret = uv_register_mem_slot(kvm->arch.lpid, + memslot->base_gfn << PAGE_SHIFT, + memslot->npages * PAGE_SIZE, + 0, memslot->id); + if (ret < 0) + return H_PARAMETER; + } + kvm->arch.svm_init_start = true; + return H_SUCCESS; +} + +static unsigned long kvmppc_h_svm_init_done(struct kvm *kvm) +{ + if (kvm->arch.svm_init_start) + return H_SUCCESS; + else + return H_UNSUPPORTED; +} +#else +static unsigned long kvmppc_h_svm_init_start(struct kvm *kvm) +{ + return H_UNSUPPORTED; +} + +static unsigned long kvmppc_h_svm_init_done(struct kvm *kvm) +{ + return H_UNSUPPORTED; +} +#endif + int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) { unsigned long req = kvmppc_get_gpr(vcpu, 3); @@ -950,6 +994,12 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) kvmppc_get_gpr(vcpu, 6), kvmppc_get_gpr(vcpu, 7)); break; + case H_SVM_INIT_START: + ret = kvmppc_h_svm_init_start(vcpu->kvm); + break; + case H_SVM_INIT_DONE: + ret = kvmppc_h_svm_init_done(vcpu->kvm); + break; default: return RESUME_HOST; } @@ -978,6 +1028,8 @@ static int kvmppc_hcall_impl_hv(unsigned long cmd) #endif case H_SVM_PAGE_IN: case H_SVM_PAGE_OUT: + case H_SVM_INIT_START: + case H_SVM_INIT_DONE: return 1; } @@ -4413,6 +4465,8 @@ static unsigned int default_hcall_list[] = { #endif H_SVM_PAGE_IN, H_SVM_PAGE_OUT, + H_SVM_INIT_START, + H_SVM_INIT_DONE, 0 };