Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2127445ybb; Sun, 29 Mar 2020 23:22:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtI/KOaiuB6YaQW3TBiuoOeAg97eKvS6+xJgCw5hUSf2rwgXj+WdOnQqWqKqcuNXVzXrfo9 X-Received: by 2002:aca:4d13:: with SMTP id a19mr6405317oib.105.1585549366725; Sun, 29 Mar 2020 23:22:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1585549366; cv=pass; d=google.com; s=arc-20160816; b=ZoLASulYLNctLJ+mk4I4ptm4zHS/A0z9ReUbYhpjU+RCSp4X7MhNkgqP3Vf+zdav+3 8MSPpcLL5RUfya+eiH8/wj0WqrcAWPALs9rt03yG24LxtxSF3TmIs5s78pUxNslUuPrK gxbNZpyTNP5uykpefcAvTYKFbYgx74/CTb+sYJSC7RkkJd8kWrhmGlpPxyfiJ192ZY4z UcAY0yI5vXVIoIWCA16DbkC+eOfkR9zKR57AHF6UAZBXUOzk+rHTnv8zHHn8+5kNXQsX gpaF8xHEw+F2PgjN5K/aqrx49GtMzoEdVJ3YPho5UpwXbN+J5YrT6Dl4xxsyjH3aNg7o u0zg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W+0q6Nyh9f1u3yEndkck8hsJTicRQCuicnRxNyF547g=; b=PyUjbkJna6qRMsqa8nTpO9oE9Nqrc4qm9GPvDsAdIVBFIvdwo54qKZi6+DStq3D29B bA+Jg2/FjFa6B7a/WmrRmn7ihVEq5IWbizppVNWbVJ3iTB3X2Sbzjg95n5xz+w3GnHWR av99802eMviej3utFWedjH/n2gplvyzjPLokKlGIl5FYVFewBE0pskelYCkEI3ycRvy7 rhF0ijqS4Pl3N49mW6qDBE0nvgrb8prU+RQpkBJJueuPVCUvKNc61dEEeVRCs+WvWshn gbLGjB2XmDtv+c3zKOLwEt8FK0CpFn7E+QIg3T6A235uSOJNZmQCWFCZpqnZAEBvz/pF /Z3g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=zgW9QPGh; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h192si5476149oib.166.2020.03.29.23.22.34; Sun, 29 Mar 2020 23:22:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=zgW9QPGh; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729071AbgC3GWI (ORCPT + 99 others); Mon, 30 Mar 2020 02:22:08 -0400 Received: from mail-dm6nam12on2077.outbound.protection.outlook.com ([40.107.243.77]:20854 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728955AbgC3GWG (ORCPT ); Mon, 30 Mar 2020 02:22:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=inqAwu50z7Lkp5XzXT7NOZZbSKExPdE4MVWP751FbLFrhNIlA0k73CguA1le+j2P/KoWOcmndgiwAoRAgp5DsUR2cGy9YZs8qLBzd0D9xEmxHg53PFMlj6N+lC+KYTp+5BqvV6pcyqOwqCMyE0BRXEHTCmEE08lubM2btl40QOH05pRt0eDKfODmUTgBJQvvCKuR8Foa3qFSSuraJ51AQfNqXwRTfclh6/zKOC3neGXQGtQUXHUEMT7j8vyrbQUSWMjdPrYYAa3zKS47fT9GNHMriEHsu+f5QUD9aK95Bj7U0TMZaQ6Zp53nur7sH5ZOKQeCjtNs6jWAqvK4xZM2cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W+0q6Nyh9f1u3yEndkck8hsJTicRQCuicnRxNyF547g=; b=ckUyjKZJkpdFDGrjzkzv8PZfJx21BX3M1sPNkQ2cOO7ZtVA+cSIPtemPyOXfUXoa0ly3c38b9q78AOnB5MyGqDF7Z2knjCg0HE7eIsGZjKGDSf469dJpyMYUsPjwq2Yus1g78llk7a9Fw4J3HNANB0bv+mdH4Ac20yoQbl+4kggGHyCXsObmroUQPsa9lslAg4GKmWj2N7fJ80eENMVub1cSqqJoTpxByXxGi/KRh2EdaA2i13QAeLsMKXlp/kq8afYHulGymY4r3cnPOI1eGsZWTF0Xr76vTot9HzjtHuUB3lZTW/rI6apgB7rTKqDB159tlYu4RNiRsZRu5fQSow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W+0q6Nyh9f1u3yEndkck8hsJTicRQCuicnRxNyF547g=; b=zgW9QPGh1TBNLOnkIuszTG9FPJCPtofObPeQFNhq7RSCN3Z9nyXq6C6huh5JqgpMdIFu3L/0CGsOUTSpJUb1xEsR7w8Plf/kn6q4j9jlxNB8Zwu5zKkmmPDYSkjKg0+CvChDJbnAdYHU2KhZa57cHLMpE0laYznc1x1oYuo20kk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ashish.Kalra@amd.com; Received: from DM5PR12MB1386.namprd12.prod.outlook.com (2603:10b6:3:77::9) by DM5PR12MB1692.namprd12.prod.outlook.com (2603:10b6:4:5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18; Mon, 30 Mar 2020 06:21:45 +0000 Received: from DM5PR12MB1386.namprd12.prod.outlook.com ([fe80::969:3d4e:6f37:c33c]) by DM5PR12MB1386.namprd12.prod.outlook.com ([fe80::969:3d4e:6f37:c33c%12]) with mapi id 15.20.2856.019; Mon, 30 Mar 2020 06:21:45 +0000 From: Ashish Kalra To: pbonzini@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, joro@8bytes.org, bp@suse.de, thomas.lendacky@amd.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, rientjes@google.com, srutherford@google.com, luto@kernel.org, brijesh.singh@amd.com Subject: [PATCH v6 06/14] KVM: SVM: Add KVM_SEV_RECEIVE_FINISH command Date: Mon, 30 Mar 2020 06:21:36 +0000 Message-Id: <0f8a2125c7acb7b38fc51a044a8088e8baa45e3d.1585548051.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DM5PR19CA0036.namprd19.prod.outlook.com (2603:10b6:3:9a::22) To DM5PR12MB1386.namprd12.prod.outlook.com (2603:10b6:3:77::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ashkalra_ubuntu_server.amd.com (165.204.77.1) by DM5PR19CA0036.namprd19.prod.outlook.com (2603:10b6:3:9a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20 via Frontend Transport; Mon, 30 Mar 2020 06:21:45 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0c2c79b0-e23c-4c1d-cbd7-08d7d4729f0c X-MS-TrafficTypeDiagnostic: DM5PR12MB1692:|DM5PR12MB1692: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 0358535363 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1386.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(346002)(136003)(366004)(39860400002)(396003)(376002)(66556008)(86362001)(66476007)(478600001)(2616005)(956004)(81166006)(52116002)(8676002)(66574012)(81156014)(6916009)(7696005)(8936002)(5660300002)(6666004)(6486002)(16526019)(186003)(26005)(66946007)(316002)(7416002)(2906002)(4326008)(36756003)(136400200001);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wtrF3Gd1bslAqfomZJueuZawM4x84uN1HHWPiHqq0mdtUXG3aLrvmP/YrHkfNpCPdHsh3BZEkzAt26V9MTujKm+GGmFALizrieJhJKqEYcbX1iGeVvZ9HRIXuFL7jJCPZiV6j8ME9elgEdEqp4mCaM+5BzN7zQUI6LENh0ySExVl16oBZc49ss7ILHaKGc7s69gEzCyMND9BPxApoJUx+iGf24bXe81bk1sw3n2wJqjQRX0f4eMV0ztju3qLRHt/4fiQg5RTgE1SgwJSY4XKnuhXeCtdGgjOeBfCohsYaD3E069vbXDk7w7weS8vJpqe4GJSatjmABq4fvR9DVE1/4S4u35hL5FLlEfucES27FQ5UdZSQHiWc3rDl/HNV/EQf3VbphYWy4vI8DOaBpd1asXINQkdvqsoysKvDnLRlKQ8uLADxhVlDtYj+47j6KVFcSYnV1/dtXbjSNUez3QZ+j9a54/Vl9kMGHxOvn7cQzs/rJD4vrvROgQ5/It18dr+ X-MS-Exchange-AntiSpam-MessageData: l3yIuSFmbRj+ArExEuqR4bV15lEhuyL+FwYNq1wx4MiSyCtgvM0Uzx8HZ9Z2bp0E6dnPuAcK1lvQ7bzQwNqXM3Nb0arKHyMNCz0LMtKgsC2f42IKSeqF7c8+VUHxofJLj1YBIeDRkZabpNIzr19T6A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c2c79b0-e23c-4c1d-cbd7-08d7d4729f0c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2020 06:21:45.7270 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 95aQZGKxoH2XArSgoKyA85vOOtpDwUYREWYAXzttInQhvvBErcHaa3Tcx1IzxUuRTpFeWLDIyXAv9rgQv0abig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1692 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brijesh Singh The command finalize the guest receiving process and make the SEV guest ready for the execution. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Joerg Roedel Cc: Borislav Petkov Cc: Tom Lendacky Cc: x86@kernel.org Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Brijesh Singh Signed-off-by: Ashish Kalra --- .../virt/kvm/amd-memory-encryption.rst | 8 +++++++ arch/x86/kvm/svm.c | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Documentation/virt/kvm/amd-memory-encryption.rst b/Documentation/virt/kvm/amd-memory-encryption.rst index 554aa33a99cc..93cd95d9a6c0 100644 --- a/Documentation/virt/kvm/amd-memory-encryption.rst +++ b/Documentation/virt/kvm/amd-memory-encryption.rst @@ -375,6 +375,14 @@ Returns: 0 on success, -negative on error __u32 trans_len; }; +15. KVM_SEV_RECEIVE_FINISH +------------------------ + +After completion of the migration flow, the KVM_SEV_RECEIVE_FINISH command can be +issued by the hypervisor to make the guest ready for execution. + +Returns: 0 on success, -negative on error + References ========== diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 5fc5355536d7..7c2721e18b06 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -7573,6 +7573,26 @@ static int sev_receive_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) return ret; } +static int sev_receive_finish(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; + struct sev_data_receive_finish *data; + int ret; + + if (!sev_guest(kvm)) + return -ENOTTY; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->handle = sev->handle; + ret = sev_issue_cmd(kvm, SEV_CMD_RECEIVE_FINISH, data, &argp->error); + + kfree(data); + return ret; +} + static int svm_mem_enc_op(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; @@ -7632,6 +7652,9 @@ static int svm_mem_enc_op(struct kvm *kvm, void __user *argp) case KVM_SEV_RECEIVE_UPDATE_DATA: r = sev_receive_update_data(kvm, &sev_cmd); break; + case KVM_SEV_RECEIVE_FINISH: + r = sev_receive_finish(kvm, &sev_cmd); + break; default: r = -EINVAL; goto out; -- 2.17.1