From patchwork Mon Apr 5 14:25:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 12182977 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0F71EC433B4 for ; Mon, 5 Apr 2021 14:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3E93613B2 for ; Mon, 5 Apr 2021 14:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241332AbhDEOZo (ORCPT ); Mon, 5 Apr 2021 10:25:44 -0400 Received: from mail-co1nam11on2064.outbound.protection.outlook.com ([40.107.220.64]:22862 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235915AbhDEOZo (ORCPT ); Mon, 5 Apr 2021 10:25:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UExTH/3s/niz6XMjSjTMX4DryhPynwNnHFBFhEoHYBg6C1ekfwg6o8KH0EUDOSX+gVDaUDtJtSKOeoHIxRi06astl3GRyppKj1Zx++L4f2z84BOId7+ls4Z+VpXA2nyvFPGN79tzsuSs1FBqKgC5lrtVwyYUZNPCGrTd8w2QN/2pAI6nQoTwGmVSgsi8L0Vq9+1vbX78fyMYsQB4ncnWfEt1cdbqGhxNcvHQxcZRpbNDtSrKsEElLOCmSiVzKkPovq9Ol5m5euzIAejEWfnHaMj1CKpv/hDk2FaaptvGNTqHdkDKq5ZNX2kjTftU7Vq7xmnuvAn++GmQDbAumU0oZg== 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=ecWJetWk79BG8nSoPDpZq7XRRwLaEAjNQ7SI2nOsNIA=; b=bhEecpHXtyKeRxPY5Mh4zNfywFKMFDwrn+er2OaDHlZGbjDWH+D8UcYNRyW7GUB80x/ajp2m9PeyIAFv3SCiAU6EVqZQDx3jmmUHZb700tJEmY4fb08EwCsklc379b1X5dss3/UV2O3NvUjz3TwcTNt0TqbJTOwPhJH2tXAFovSguLxi1h3H0xpEYmHuTuhwfICIR68Q9F2yeDFFzsw5P7txfc3I5Z8mmvI1J8/956bSD8tprHUFQyiwEM3QM6Fn40tZlmnddCt3VUObhFLsdii9fTxJifMUzodCBduup69jCvSRrKX1Q4oCobIKJxRcFzDwvln8oM9hafduvrLsjw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ecWJetWk79BG8nSoPDpZq7XRRwLaEAjNQ7SI2nOsNIA=; b=vNL3nhk4ZWsedP2xAQYUwV3BC8CT3QQg+xjrNl/iloqqsPhvX/LpUR+qzmNeVv2uL4ZjNlF34p6dbj54EG1IVsMmDLA/ed6j5bjzWzqY4CZFoIGxJUaFytdc/+aIe+ySOCTShWXximbBJGFlI93vXQTo0cbZ2CCir7K2Q5Ub+38= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Mon, 5 Apr 2021 14:25:35 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::24bb:3e53:c95e:cb8e]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::24bb:3e53:c95e:cb8e%7]) with mapi id 15.20.3999.032; Mon, 5 Apr 2021 14:25:35 +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, srutherford@google.com, seanjc@google.com, venu.busireddy@oracle.com, brijesh.singh@amd.com Subject: [PATCH v11 06/13] KVM: SVM: Add KVM_SEV_RECEIVE_FINISH command Date: Mon, 5 Apr 2021 14:25:24 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN7PR04CA0102.namprd04.prod.outlook.com (2603:10b6:806:122::17) To SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ashkalra_ubuntu_server.amd.com (165.204.77.1) by SN7PR04CA0102.namprd04.prod.outlook.com (2603:10b6:806:122::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27 via Frontend Transport; Mon, 5 Apr 2021 14:25:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42f4af13-7ad8-4951-3667-08d8f83ead2f X-MS-TrafficTypeDiagnostic: SN6PR12MB2767: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PoBpvwgLo7zrEE3onrDzfEH5lgjdq9vu1yyp1PHqahatwYcHJHGlP+ET+eSeiRDdq5v1nQyXVult22QghzBeiH+Rlk+iYLCQBR4oHbgdiBk/fOI8hOeVD+2a2JtvRF2xoqPq3et0f65ujz4gKKo89BcPaVEWKlYkcf+8k+tFPGBZVHjpf815NWYxORSzraCk5UdOeYZ+nH7jrta/eNo6VPwR+WlVwwaN2pIAQAMG6U/j3f6BqiHeeURAE0x92JwbLHq/osEfJ3lG1MeDrVIK3kIy+mww1f/tvfcWeV+xN/u7AkatMZmF9wCINaAQKN4UIZnAQvOgHJv/H1yqEXZyKy7CHOyGbD14qCowtAHsL9BaIEyXA2OO+X5PmDi0kevoG7ZMcKVaqrcNijNi7kYP6EFIigxP7+yykIajXokcguGqchUD8SygkjD506SvtJWsiIk5BYlwkAPVYIC/Q5L/fB/7XZWxYULpGdK2gD0NXon7Cb/vvCSIml61QP60+n7SLpOFYjKMhtNp+5ynJRe72youfwwXpnhuwTD1Z36GuAk1XyEGuBRUcoXO1cpnfLjG4tneUptkwfwghG9PyARxu3W0meTUOk3UCycq1Op8G76wfuOB0F+t2cN6kckDKn5vaWcb6WercVfIHPeDX6x+PA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2767.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(366004)(39860400002)(376002)(396003)(136003)(66556008)(8936002)(66476007)(478600001)(36756003)(83380400001)(7696005)(66946007)(52116002)(5660300002)(186003)(2616005)(16526019)(26005)(86362001)(2906002)(38100700001)(6666004)(6916009)(7416002)(316002)(4326008)(956004)(8676002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?rAGBC28a2rfT4XmeDnkHHENttVwA5F?= =?utf-8?q?W+pNpVcNP8dkhUjqR33hsrThVCF0bq80TF3U+10OTpgu3TI3ndLWX8q7qIsgLQhe5?= =?utf-8?q?ZEB6hunwwQ9+RbUCwTk4BranUE0BQRPSt6WS+8oi+X0GCBl/mVQMYEDg5jr7DlnzC?= =?utf-8?q?0iX3uCqlN/RCiBkNQWIlUv2REn8VM5dGdWY16MICx5ViFvFSF2h7rX+/Bfco9p0Yy?= =?utf-8?q?/WQRcCJwWqpBJwsAa5ZakwmkmQA5oetyqqwhFekW3WQJDVCory8y/OdFl7r75GRSL?= =?utf-8?q?RIVKm88G/g2wq84aaDcSTUltcsjapj8GSsDXC7MXAfUn7DWajpy3Q7Me1z+4k1NU3?= =?utf-8?q?k1KaM6XIPYkd86IcKFzmVQcjgp59BLhuq/qWMbB8T/EPkJ8w7Hz7XS0qBh/PNd3ch?= =?utf-8?q?J1TBCKJMZPOUzwejDATLKwXNJIf4mHLuVRl7Ujj+ULekiZqYtwPcLdx8LFhuh5VVM?= =?utf-8?q?GiB61/9vkvYcHbfvmdwoEFoIzQCUUB6oDFrdFcmZx1fNVLqu56LeazYBLa/v2/IB7?= =?utf-8?q?FHsujCUPK1p97JnhCoyuTz5kdQWbawTE/wp1JSP8hIIK6F5qlQZlaEjhPNrJX6QG4?= =?utf-8?q?yLKikOLFYWzLoIQQl3iJMxWfZjsmdaXyJOlOJ+55OGzJJv1mGGQDAe8ClLJT3UR6s?= =?utf-8?q?rZ5JHe/WIq9U7KeAxp+iPw5Tp3QSpDcaObVMD4jsimksSGqEG8+Il2KsIjUNH/X6V?= =?utf-8?q?99+EWfZYAaMjjR3t647r2byoGhUtXqW7xtO+HM0YG0YDTwlMjZNDDCvuhNpZp9zFs?= =?utf-8?q?eRTvADQwSCn107Bga5/BC4aqYJDMd9NvHBPGDmtb2iwdZ81UlI7am6EkLc10MkFab?= =?utf-8?q?iX3PHDAMQvzVmj2zvmcyWuWGmlrPy8ESloeAEiPVtS3EDmaf9irb2pW8iGRBY89sc?= =?utf-8?q?CJA4d1gr6iv0QAvSpmzuOORmY+Qj3XJkRwUdxDxIpxP4+69UThAdXNkeW0naM/6qM?= =?utf-8?q?+4KqbZIxTNqzUN8lvsPJRNmgjGVRJyC3Wmf8kAfkSEcHo3aZ6e6GbMHX0tynOB+eC?= =?utf-8?q?PuaZixYCZNLciENNWV/kY6xuuAbktkdXive1tAxfvzfngkf83Fl0YWafRnV1jCamd?= =?utf-8?q?O0motSO6eIYWY13dHAHOjpcGjDDsgxR83C6vCAToFzq9fKRCo8JpldM2Mp3tiFIHI?= =?utf-8?q?HRPduBrJUDMPftfEE1zUqcluIpFXcGU/ktpecIsOsWgalZmDgVmHPUFg0pqiVgbFi?= =?utf-8?q?5SGOwNwE0WtFlZqyZynDOIRL/+m2Y3utBC9K0U7U7ak35x8baNfrJKOeNTyUcaPW3?= =?utf-8?q?inZ77Ruqikchgp?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42f4af13-7ad8-4951-3667-08d8f83ead2f X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2021 14:25:35.1557 (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: ohkNyEFDpa2cb9TukEnUKGAD/9N2311YO3htH8d9lnJlx/IqCybK/d9x1khXPwldmG/mMePN5R2VoNzETm6Zzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2767 Precedence: bulk List-ID: X-Mailing-List: kvm@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: Joerg Roedel Cc: Borislav Petkov Cc: Tom Lendacky Cc: x86@kernel.org Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Steve Rutherford Signed-off-by: Brijesh Singh Signed-off-by: Ashish Kalra --- .../virt/kvm/amd-memory-encryption.rst | 8 +++++++ arch/x86/kvm/svm/sev.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 c6ed5b26d841..0466c0febff9 100644 --- a/Documentation/virt/kvm/amd-memory-encryption.rst +++ b/Documentation/virt/kvm/amd-memory-encryption.rst @@ -396,6 +396,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/sev.c b/arch/x86/kvm/svm/sev.c index 2c95657cc9bf..c9795a22e502 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1524,6 +1524,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; +} + int svm_mem_enc_op(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; @@ -1592,6 +1612,9 @@ 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;