From patchwork Wed Mar 7 16:50:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10264519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4180F602BD for ; Wed, 7 Mar 2018 17:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E52F2947F for ; Wed, 7 Mar 2018 17:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2162B29498; Wed, 7 Mar 2018 17:04:16 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B6F672947F for ; Wed, 7 Mar 2018 17:04:15 +0000 (UTC) Received: from localhost ([::1]:34413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etcUB-0000al-2q for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Mar 2018 12:04:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etcHl-0004pK-K6 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 11:51:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etcHk-0008Oi-N3 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 11:51:25 -0500 Received: from mail-bl2nam02on0087.outbound.protection.outlook.com ([104.47.38.87]:41344 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etcHk-0008OW-EB for qemu-devel@nongnu.org; Wed, 07 Mar 2018 11:51:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Y+JXKzIzA9qx3GWqZkfCB+o0hdnoBurpD4ZmVtVJZQw=; b=CEryjK4U7M4YExfdCv3jvEBlVJJyGNg1Muf3ic7lDqa/Fe9bzFmpDi5jRYshYRifvL6YDfpm/+WqZCIkOp5bZP2MYpYSdEdkyZFspSwUufzmAl6R4VZEJf8B+dy2DfL/YaKG1qI7YFr1Yj0Rw5v/XepX68qdxTtPCpzc0VNe/AA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by SN1PR12MB0158.namprd12.prod.outlook.com (2a01:111:e400:5144::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Wed, 7 Mar 2018 16:51:20 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 10:50:29 -0600 Message-Id: <20180307165038.88640-20-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180307165038.88640-1-brijesh.singh@amd.com> References: <20180307165038.88640-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To SN1PR12MB0158.namprd12.prod.outlook.com (2a01:111:e400:5144::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 57f4c8d2-196c-46da-0757-08d5844ba75f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:D55KP8wJiaKDs9Jid4QaBuo3PYoq4NnJDPQvJbHmatuDh7dINUx9Wtth8RILERfX/aKL/iASG7+g/hhyLptOHeTPEhlnW70cB0oFCt4dhesDJpSUI8RoDvDxJAb+XCzq1WfL0kIqu7eT71kQxyYdxjD+lmah7JD7RVT02oV86fL/hkZn07AKE1M55KGtcNb/MukNyNOh/9AAi+HhmuWxZV3Qh+kTUj+UouUEBlFtTBZKgi/F7JJ4IEhUKJpyVqlH; 25:cKvRYenesAz00DO30eRMSyTYVDynX1wgKHzl6Y32lkgPX7q4DE5bw7/eXRKMXahh3iSfhG5Dn7E+klDpXWKMuLAcOdvprLbjS3G0aq2QfqYv6A6EvL7ObSKjTwWEiZvEGnGmL4s6oV2E+I3KbAmoj8+cJF+OOL2LCWPdtasJzPzKo0jecVXGWK5abS16+Y5PYOQOGS4hjRGKAQWm4huOsGurVwnyxghAzDoiuXXcumbj7KO4nXJiyLOW7jwJvxYyh5WLExRmj1erw6nj6XYUpvU7of73IL5rvo8FIzPIVYfkrbY1ZEaH70OYWn43wvsBf3wlkzuU7vjYxlJTatIreA==; 31:GU5k8o6EpPmrDhvVxqUk2oSpuEeHQZ2BdyCQJFsp96j6REq0nsPA/Ht+L5ja2LOFTT7SXJGmbWeXWtO47rJpn5vKvAj3J9jbuMf4sI3aO1VrEvTJ3smbaDzb0WcCFn0Rr1KECvVfpz1/PmirRqtIn5FogS+G7By1DwHEBjQR0nuRSgHRfS/vhgMOB1IVennB4IRKpQTsom9a1hy7uEk0iKTNRu+ww9HC/O9kCv8ZEkM= X-MS-TrafficTypeDiagnostic: SN1PR12MB0158: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:NzyaAy4/kGfH4xrmc1AcSkgRel1p/eeGM6ojYCqovfWxLXlG1diGXiXBdaCz+wMpolC4z7HKZO0K0CK6kIW0i1squ90YzW1Za2bJso1jRAVVCuXPIESn/VV9GVdKi7fB+GhLR/EV0oI9yZcFpB1edTMWoSZxgC1Ld8L+dQrSJ5G2i3j2OLBqfQUHz/9aN0opnSZ6HdWsSAuaO6oeVyADfxGBNI+M+PA6JjEU2Dg8QHamZWQD8bTp+/GsCYCv7WLWfHfpE1F8I6B308bk2zNaMtX3B+bHYhufMY0eORZGhVXPPWtDgUdsXmyPh8tMhSi+DRzLp1WthHqVwO2XE69PdBWK76EN4IbnlN1lZEJ8CO07R8LxYtWxzxQcgqETgnce1zS1yMAMgTU2ZdFG/NSto+A/N9BP/OJhwwfWtNxB+p7SeH3OGQkWJoRl3tuAiXRVk1rV/A+7oWxoYlICayS4QfRucRBMVuo6PT3k0rkIUWnpmWFHEmLhpumv0pxmkWlB; 4:e3Se4eOMyxEcNU5nFQoHNFPeC57rWZ0dvnya9Jk05Ubjw/LowboPMiVpu+2enZB3Me22+oEnvWY+Svg2gOKKODZS78nDLrEYqLbQCbtIONXKz7RYo9t2q5ef2laplU3tVnfu0tPy6siKZUQtHwqPH0Ou3NpmtxN17Fmt+GKJBZwiTLm6tAqFNMQu1pGjXZ+Qf29CwgvVfJhRO6Z0lOl8wWdUh5py5JlQJhZZPZWgGtVpcF5XqvNybGSelXF+LnMXQmYCq/46GS7ilSgF05o5/QlP30PvsVUNVmhcKLZQFW1BNHNm8fwceVwKSS3yE89c X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0158; X-Forefront-PRVS: 0604AFA86B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39380400002)(39860400002)(376002)(346002)(396003)(366004)(189003)(199004)(53936002)(8666007)(2950100002)(6486002)(6916009)(53416004)(3846002)(1076002)(6116002)(4326008)(54906003)(8656006)(2906002)(25786009)(59450400001)(386003)(68736007)(478600001)(48376002)(50466002)(105586002)(2361001)(2351001)(86362001)(66066001)(106356001)(47776003)(186003)(16526019)(51416003)(76176011)(52116002)(7696005)(26005)(16586007)(316002)(50226002)(8936002)(8676002)(81156014)(81166006)(36756003)(7416002)(97736004)(305945005)(7736002)(39060400002)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; H:wsp141597wss.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0158; 23:uZklsj9CcnXZpFBaKpQUl+RwJSuI4UHwDZEJo1Rd4?= =?us-ascii?Q?8UP1tzX6IgoRef5Rpq4/gieQeoioMITq0mtAuL1Sx/Jmvpt1eP4hZQlCcExx?= =?us-ascii?Q?eQTKyDjQpT9mfBhXoM2A1Fsi9YZS2vgA6hmfcTc5NOAM9Z9gEyXBwtbYshSt?= =?us-ascii?Q?Rh9sUYXo4wE3f35km4dFQkdjwPRxZrKyLKWt8mSwDX+/N6affJZkdDQgA6Jf?= =?us-ascii?Q?IMryFmfT5WjHBKAhktyG9gMyXfcPBfWdCbnfzB5v/DdINfgEFI9BgVwrpzTi?= =?us-ascii?Q?RMjQBk5em7XlWUp6T3SE9g5sUH52XfpQ5wzBKzhzR6VOECMN6Ms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EUnGP7RgvB+p5567prDrv9+Kj+QTKe6DoExarbD//CNjpwuKpLrdIX/nINY8eOC1x4OtS+K5HxQOHMqrSxQ8oYT1nQIjVTIZo7PE8bMSXykuMIEx2h1hmd3KrpQSi1LIcqmyg7p7x4k2jyd+4QJKunObVKfR2j/8c2S73/x8fR6Gin3gFokzQl6wQr0YaN+ppjefvuQ2QC0mS325u SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:gXPIY5U7b1wBPq3ocstADpDdakZ+9Y69v04ptcELBN/FiI9HqfRm018Fw0MukN5czhiVNW87zADwtHsA5hp++4+9E/Xw8RkcgfxjJhSBOft0bM9WDDB/NL5S+5oitIOQr1E4q7ECV5rGCOUyZq0yEgoQYKBji/fGrRuP3SN3C5Pc+gR0Rh4H3QHKv22p1V020v4z5qH+UT4bVEt4Kf64UWPH2ulG+HH55g75g87kO3EigC/xAF4GLPEju40Va893 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2018 16:51:20.1823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57f4c8d2-196c-46da-0757-08d5844ba75f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.87 Subject: [Qemu-devel] [PATCH v11 19/28] sev/i386: finalize the SEV guest launch flow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Brijesh Singh , kvm@vger.kernel.org, "Michael S. Tsirkin" , Stefan Hajnoczi , Alexander Graf , "Edgar E. Iglesias" , Markus Armbruster , Bruce Rogers , Christian Borntraeger , Marcel Apfelbaum , Borislav Petkov , Thomas Lendacky , Eduardo Habkost , Richard Henderson , "Dr. David Alan Gilbert" , Alistair Francis , Cornelia Huck , Richard Henderson , Peter Crosthwaite , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP SEV launch flow requires us to issue LAUNCH_FINISH command before guest is ready to run. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Signed-off-by: Brijesh Singh --- target/i386/sev.c | 29 +++++++++++++++++++++++++++++ target/i386/trace-events | 1 + 2 files changed, 30 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index e01c753be3ec..5fbb3105ccd4 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -573,6 +573,34 @@ static Notifier sev_machine_done_notify = { .notify = sev_launch_get_measure, }; +static void +sev_launch_finish(SEVState *s) +{ + int ret, error; + + trace_kvm_sev_launch_finish(); + ret = sev_ioctl(sev_state->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error); + if (ret) { + error_report("%s: LAUNCH_FINISH ret=%d fw_error=%d '%s'", + __func__, ret, error, fw_error_to_str(error)); + exit(1); + } + + sev_set_guest_state(SEV_STATE_RUNNING); +} + +static void +sev_vm_state_change(void *opaque, int running, RunState state) +{ + SEVState *s = opaque; + + if (running) { + if (!sev_check_state(SEV_STATE_RUNNING)) { + sev_launch_finish(s); + } + } +} + void * sev_guest_init(const char *id) { @@ -651,6 +679,7 @@ sev_guest_init(const char *id) ram_block_notifier_add(&sev_ram_notifier); qemu_add_machine_init_done_notifier(&sev_machine_done_notify); + qemu_add_vm_change_state_handler(sev_vm_state_change, s); return s; err: diff --git a/target/i386/trace-events b/target/i386/trace-events index f7a1a1e6b85c..b1fbde6e40fe 100644 --- a/target/i386/trace-events +++ b/target/i386/trace-events @@ -14,3 +14,4 @@ kvm_sev_change_state(const char *old, const char *new) "%s -> %s" kvm_sev_launch_start(int policy, void *session, void *pdh) "policy 0x%x session %p pdh %p" kvm_sev_launch_update_data(void *addr, uint64_t len) "addr %p len 0x%" PRIu64 kvm_sev_launch_measurement(const char *value) "data %s" +kvm_sev_launch_finish(void) ""