From patchwork Thu Feb 15 15:39:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10222163 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 0CA16602CB for ; Thu, 15 Feb 2018 16:01:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F17B92890E for ; Thu, 15 Feb 2018 16:01:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E58F0290B4; Thu, 15 Feb 2018 16:01:45 +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=ham 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 33BFB2890E for ; Thu, 15 Feb 2018 16:01:45 +0000 (UTC) Received: from localhost ([::1]:33169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emLyi-00012g-7c for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Feb 2018 11:01:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emLej-0004Zl-GS for qemu-devel@nongnu.org; Thu, 15 Feb 2018 10:41:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emLef-0003bY-E5 for qemu-devel@nongnu.org; Thu, 15 Feb 2018 10:41:05 -0500 Received: from mail-cys01nam02on0055.outbound.protection.outlook.com ([104.47.37.55]:8497 helo=NAM02-CY1-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 1emLef-0003bK-5F for qemu-devel@nongnu.org; Thu, 15 Feb 2018 10:41:01 -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=N3PHmn7P8kUDDPE5txdxo5aPjc7mGVqYRpNi/fi02BU=; b=yWMcLo9eL7AUvLl8tjnEXNVBmRQ450OV+3EBL/k0/f/3UIIBCTGqKkZZYtBqX7f/8WTbm52j6ZlvL4tQSDfHJi6d0efCYCo7b1imlXdo1OZoH+kQNQrXWSaHCPz7MyGFXsrg1gSW84QQ/VLtldPhSihFKkp0Dp5qbAk3cO+1gJ4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Thu, 15 Feb 2018 15:40:56 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 09:39:45 -0600 Message-Id: <20180215153955.3253-20-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180215153955.3253-1-brijesh.singh@amd.com> References: <20180215153955.3253-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR04CA0044.namprd04.prod.outlook.com (10.172.133.30) To SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6e7e479e-1f3c-4b82-175c-08d5748a8219 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:SN1PR12MB0157; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 3:sUWXi70umdE/usU+tp4i+RsgAD/n35Yz/ftY7S69p8O1dQ67YcT/MIKPYx7KTvXZIv0yMUfSv0mBce0f5wjx6pOISxbiC2R8xneaiQk0WPw1rVStWeqXIKr/2+7s66Vry9mIOKm+wnXPSJxAyES2MQzd+QBF8SX5IRUZ3mRsZWHjhZtfLs73TKVXT8pWvvjz6Ekjt3sZjMtRVzKVPU3uMtgpMM4SILnUySbq82UZbvdiqL439L8oVqgLkd1CNjFO; 25:MCCR3o8jpBsR1IBQ/UaxY3KOI9XGSGh5lDKsN8FYFlsuTrSM6faxyREHLgrfqsPoIe25xzFS6GquVrrkCVKghvARrVg48PBiSu9rg//rhOdKD9+bzleH7YYeTawzjvRWcHjeCsO3Bp11i7UzVEfvO1VQED9knOYtBc1ewepm+a7D9/mtc8n8Q2vJsjN1uOXiX9PxGf3BVgjVAvsIrlnmfZ5isMnEsBIxNT8Idyh94OmCdVP2wfjzvQwp1Oiwk1qM6WlQfZ+vEx1V9BVi3ShQFy8iLJ+tYxeCJwQz+6zw/FCJcvEhFLYBuE/Iov96tnobrKBAbTaAPWJvhsDwG7oqWw==; 31:DRNOs1gorI64jZa5API5fgMaJwsnnd6fLna77oYWIreCDe6+5FrhDEt4Ep0LdT83XrOUaXuJtmgskbhJBoCUxwvlf6RPpM+oRR2D0YThN4/Y5DKhIyDwBRy1ZcRMR5WKNJWZ6YqWt9RnZ/3jUJUmBTj9XI8FD6nkT2AmbIgeSz6jixGGxqLgy4b1HVZRdUM7C11iZnfzl5bsjW0Ud39516HBoIAS6XlVJsE1hKnVTxQ= X-MS-TrafficTypeDiagnostic: SN1PR12MB0157: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:YmJmWUWQz/kQXT1P7AmES9D+hlaq7kNaRd2mqpUKp7QJbVYw4J7nKkxqL4bnI9hBsZwDMeCiO04gIVxyxkLyxSp16sZ46+kw65W3AeYPr2+MF1ac7uw6nEFR2QkaqEtYTZ+U6lJk9x1wUPL4C23uXPnUR7A1lsw7vec/LB6OyW321lUR1MkI7PXLtMCC+HZ4YwwR52u4HKqCzDi6eFIWXaS/hzMmYxF3oD7/7t5QHGFARyYU9GYT3mJCHusXwdQVhLGeRoXcRm54CNQvEz0Nw8oVPuHX/StSIPjmasrsfFhYreYnAyl+AU6ln7vxMRMaUeSDAnDTIqPFWKgQyEz20f0w/loU8mcgptYUOxzmT5FxTbRkz/foLoRvJI2c1XxxIiAf4Eay4rfVyHrfdYwsahFNSespf50Kc1tXbRnXtxzwiK5jlpE+ibLRlY8+/1dnzuKfmBw/g8qhyiZB/4flBE8BHHAtZ00TDydoYaxnocrzZx2xXBU/THpqhB7mQbVt; 4:/ji3+tUpGa3hF1WSWQogbRNnXocRG8+UEwFNd2nTnN1LZOaR6jFASBMYdpyPqMD0NgXw+d5FhPxbGP1c/sQoJnhKOcfc35bbZPtXpN97AVGNuxMX9sHLSGlhdYHC/NcaDrT7hZn7SWwfXWxsZwWRY389+zGfpqOX3+ymDvjnlWttnkpR5b6SSZ2LowHiEdTUZwyBKJ0ntb+Q/Bc0a31UbTRTZRq98Yn94WtKlyvzwdMZVhmjqjzQZtfU/KvAg2TKskdhdqhaazYMUi/17PxTCoKVdZXBoAY+27N0KJbneXBjVbwv3KBLORoYRwbIktnT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231101)(944501161)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:SN1PR12MB0157; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0157; X-Forefront-PRVS: 058441C12A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(376002)(39380400002)(346002)(396003)(39860400002)(366004)(189003)(199004)(26005)(3846002)(386003)(8936002)(5660300001)(186003)(16526019)(316002)(6666003)(8666007)(1076002)(54906003)(6116002)(48376002)(50466002)(7416002)(478600001)(59450400001)(8676002)(68736007)(86362001)(16586007)(2906002)(50226002)(39060400002)(2351001)(6916009)(7736002)(106356001)(51416003)(8656006)(52116002)(25786009)(4326008)(97736004)(2950100002)(6486002)(2361001)(36756003)(76176011)(81166006)(53416004)(66066001)(53936002)(81156014)(47776003)(305945005)(105586002)(7696005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0157; 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; SN1PR12MB0157; 23:bfvX1iLcUDSNQGXpWuUa73XzPWtxcIaD9j1jCbZUK?= =?us-ascii?Q?NWV2w6NArJmQlD2bic3XqEsSaM5Q36J2zHZvtyG8CXrGqOphQ+75L5AkJ/9o?= =?us-ascii?Q?saJ1vs9J4fZoyKxt8zpcptjsin5t9pE2U5KCSjBw8iiTDOocvtE4Q8hAHCUn?= =?us-ascii?Q?e397eb+ODPtXIwcPPkTObOaF+FDn+yojTATg+kJx+dI+rABuYIzNTkbIwu94?= =?us-ascii?Q?2Df+zXjkJqsjMtZnFPLnfT8Bkxs75y0aJ5viaUnmdnXzwbspr7bN0ngaVkjh?= =?us-ascii?Q?qB3ZMM3E7V5m3mD/uP1o6fNY+Uo2NdGalBZZkDbGzjdJmFRCSBMsknNk248k?= =?us-ascii?Q?bCsh5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kKhe9h2PK5D9p+24iSapk13si1UCy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:23kEcTKJQN4RfIwt1hNmrTxZWS9OORLaIcTEcuECadfUYA4xIBLgWoSOH6ScZgtoq9WejZP5T5liwzqzZ88YzmsiBTC4nH7zaMF1wjFw8/mi5iRT0hme/bnZdosptDSgWKeji8rypMsqCJAytINXEpIJvZzWIGv522lE+vlfcSL+wwCX+cpNn/dD8ACydehCRRsiskHMugMtxm5rlzXK45ZdtcFs/pJQo8qEW52tTAieFH0xoLOatBEHNHA0L5er X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2018 15:40:56.2909 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e7e479e-1f3c-4b82-175c-08d5748a8219 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0157 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.55 Subject: [Qemu-devel] [PATCH v9 19/29] 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 401b2a33d7cc..305ef65191c9 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -567,6 +567,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(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) { @@ -635,6 +663,7 @@ sev_guest_init(const char *id) sev_active = true; 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); sev_state = s; 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) ""