From patchwork Mon Jan 29 17:41:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10190287 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 05C3460388 for ; Mon, 29 Jan 2018 17:53:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE48721F61 for ; Mon, 29 Jan 2018 17:53:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E200225D99; Mon, 29 Jan 2018 17:53:24 +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 5B8D721F61 for ; Mon, 29 Jan 2018 17:53:24 +0000 (UTC) Received: from localhost ([::1]:53715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egDcP-0006jc-9Y for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Jan 2018 12:53:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egDRo-0005sk-I0 for qemu-devel@nongnu.org; Mon, 29 Jan 2018 12:42:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egDRk-0003hS-Di for qemu-devel@nongnu.org; Mon, 29 Jan 2018 12:42:24 -0500 Received: from mail-dm3nam03on0042.outbound.protection.outlook.com ([104.47.41.42]:46789 helo=NAM03-DM3-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 1egDRk-0003gQ-6O for qemu-devel@nongnu.org; Mon, 29 Jan 2018 12:42:20 -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=vvShIU8nu8EWxWkDjL21WZcdjdRFB3mhGZ2oT58Sj1U=; b=YvDGFS1DcFFueSyxZm8JJVTyti0XFXlbb5XqT01y0FeUgrFYZOc2zzLeRbZHwd1UphefrQsyHheDmSlK61SxL8CYVram66mjm7czpp31anItADLu3z4XeeJkx5R4kbNsolYq1z7jFEb0PfDcu4a1q2CvmrdNfwLn7lbUEOa4xZs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by DM2PR12MB0154.namprd12.prod.outlook.com (2a01:111:e400:50ce::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Mon, 29 Jan 2018 17:42:16 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:41:28 -0600 Message-Id: <20180129174132.108925-20-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180129174132.108925-1-brijesh.singh@amd.com> References: <20180129174132.108925-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR17CA0018.namprd17.prod.outlook.com (2603:10b6:404:65::28) To DM2PR12MB0154.namprd12.prod.outlook.com (2a01:111:e400:50ce::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e1a6eb94-9d8b-4028-d341-08d5673fa3f7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM2PR12MB0154; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0154; 3:vgLL8f4hmzzdZvwU0skRTDF+D9exSumTAg567XaqLOWikxkXS1xXDol2MKVV6pW+dDjHrJN81ZjbsLAL0ZiFVS94sXo6i2I1XQS9fUTAZ+Yo72gdIXYnRxHh36PMoi45AmtV55sX7C6zGp8EHgd8ztb7EhbPfRJAxOnwq5Fl7rnrKoyhwuQ5SOc7N97VELjmudPALY6TOh7nSsg5mptu0n4EXsBwJQhxgtW1fmK964cRsWfTdvV565rYMJNSdMK1; 25:9uJlxqdy0y4GodoOwd79hLhKEydPnKpZuVRRn+DXs6etxsqpx58dq2+k4ncJGTJ++vYHLTOwjpE2NGFqsvPnHLzYnsB44NTh8br4kDN89eCihCDuFLVnj1fOpk/nepMCUCkDgrNCY8z7tXB9peaUM87G0ZCnSpQacLOlKMOO4yhDDu3AUeA/TFK0uDg91tkMFvUd23w3YolRUH3ntqnHQ6ogsp0ypA9YCfKWb5l8SmDfQQAVdQr8+TfndbS8vVkqqv829lWjyfzv10HsBTHwCFXSlZ8faYD8k0CBN2Zbl5HSzvwqiO3ZZXsJHxRz1Z3RhkFMtLkd5UtAkRU5WsfSAw==; 31:+MGuCZrFlYWUEUsvLbnXmVWpX4VMOM2ZUEiDK/MY4CFh1COwqU5rq+DgkFMKK0Ayjfd02ncC9IO0P8XtVXuze5z2/kdSw2JAg+dw0tJNbZoRngUbeEa5aoRfy7Z6qmoYw474Fp6pDLt284U2WhY/JcFARR/eVyX+B7ruFLO6TgM8/mFSgsYUwWeDyBro2zZKyIDkGEpqy7o7cJavcZrSUFtSekHtwWsUuyP2ot5X1gQ= X-MS-TrafficTypeDiagnostic: DM2PR12MB0154: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0154; 20:QKNEq3p2gCD9gWNcXPX61q0vR6Mf13/xFiXdvjodyorzpJ9rlnQ7DWpz8Oty+6cOJ3npJq4EPe2Br7x33pgm22kdYb05fGvi7mq8QbtapSzu2e6Sfdm0ZBYwG+7zg6w7nm3j+osUDfrHVn+a8/L7IWfdhHip/VNeY2mJKAq1iu8xwhyHPCn3MiGItb64R7WEzLIrDZOo8Q6vSSP9f8BVt/U78SDa9fUJ6q9Zbcs7TgFF8OYse9kxmQvyeLjUdGrrobU3KTw18q0KflqDpvfXsvmr1UNGwlgw5mabgJwDYsbPPnCg2DDDp5P1svMLCRsn7k14o6tHdcxwlVThflSGgq3lrCCpAhwbFYS3iBCmfAe4CISYsLpt/hyyX+EArVs48I+qjzFEN8GhnpRvCpSayP1cWlgNnYnMtaRlXB2U7kd1YqsXmkrHd5PWnP/2whAtKzzBr15vhU4T9yXa7Z8f+t1G4l2xfw5ZvnBCeDyyOSc0ZEx8bQw+VnfbNGmcYgcu; 4:xrc5IP5o0/gWYjzYpUSU0sjRvSM2ZFrL/cOzQmJr+5klc3V/pFa6VwOXrszIAmuUQWOAudcw2v9Uh15AGy8NLOUNL/B8ZxXMgm4ZIM1vch3ySTkmLGXViRsNCBhsf1Rc0wFPk08faKzF6/3nDWRZ73uzj3gWrT4VyqHX/niQ5aRegPzKKbJAqGDYMBFD8RD2Z7JKwUHYR4KFcdsYn/3YZ+9uulKwc/H3LD/qUjFfc1lmDBWkNilpmI2F7j4CeTNVp1E73ybpug2fO9Fg2hbzzLlOdIt86X8POmyW74XDLYUHMPm4G3g/dtmyQcamzvMPzYgtj68ADndB+eMPoJVB+Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3231101)(944501161)(93006095)(93001095)(3002001)(6055026)(6041288)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:DM2PR12MB0154; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0154; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39860400002)(376002)(39380400002)(396003)(366004)(346002)(199004)(189003)(48376002)(8656006)(39060400002)(4326008)(6486002)(68736007)(36756003)(478600001)(26005)(97736004)(16526019)(53936002)(386003)(50466002)(86362001)(25786009)(8666007)(16586007)(54906003)(186003)(47776003)(59450400001)(316002)(7416002)(305945005)(7696005)(105586002)(106356001)(76176011)(51416003)(2906002)(81156014)(66066001)(81166006)(8676002)(2361001)(53416004)(3846002)(50226002)(52116002)(6116002)(2351001)(1076002)(8936002)(7736002)(6666003)(6916009)(5660300001)(2950100002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0154; H:wsp141597wss.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; DM2PR12MB0154; 23:cHY8pRrA8PF8mguKMcMSsnuDSxYDp/H/T8n1M/tfy?= =?us-ascii?Q?U6mDfI2YsTyfFz6gncjOdiTRHnV338IhR5lbR/OzNM/8V0omV0ypTmTP5Aju?= =?us-ascii?Q?YDNIZiW6ZyRONBiS+cxp5GCpH2q/eoiJqcTSXAdD3QBxtvjd9PfA+f4SNGP8?= =?us-ascii?Q?pHPJG3Bk/BRtDXi9Z1jgH81C4+YLkwdonp/P+5748i1hKUk33B/ArhPPtG2I?= =?us-ascii?Q?T4cWYWt2oU2biwUE9azR180V5y2+LwSFTdt4b6TK8itxGqIixSm6sbT1WOdR?= =?us-ascii?Q?5C68fHsRiZdT2HpdJIA6TMG77Yjv4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uAAG6dyfJ14XTrfaMkHko5XNNGVNZnHgSAVBuidolGlpViVof7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0154; 20:m3kap0ZLFmglf1xwEv6fc5rt09++UiP6x7NFWxxQAuMoQZ0CbbMTvVK0cXq373k/J5waWLCy5Jw4Nn1Z49UEdShmLxE+hHJ1wK2q5Dx1GeMbsqaQ8YkfnaHMIyai67fUjLAenAFiU2Sqhgh1zPFCD2BA6V09LdWqfzUGbeJS/NRMQNAfyTEiS8MPXhVAgsZy52wz2nJimPNREgWQ+Od7pDNr7mqANickzjFQQJ+4cV8M2VHooCD0wp9sQOtJAgF7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 17:42:16.1352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1a6eb94-9d8b-4028-d341-08d5673fa3f7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0154 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.41.42 Subject: [Qemu-devel] [PATCH v6 19/23] sev: 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: "Edgar E. Iglesias" , Peter Maydell , Eduardo Habkost , kvm@vger.kernel.org, Tom Lendacky , Stefan Hajnoczi , "Michael S. Tsirkin" , Richard Henderson , "Dr. David Alan Gilbert" , Brijesh Singh , 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: kvm@vger.kernel.org Signed-off-by: Brijesh Singh --- accel/kvm/sev.c | 29 +++++++++++++++++++++++++++++ accel/kvm/trace-events | 1 + 2 files changed, 30 insertions(+) diff --git a/accel/kvm/sev.c b/accel/kvm/sev.c index b78cf3144b1d..c227d7591c38 100644 --- a/accel/kvm/sev.c +++ b/accel/kvm/sev.c @@ -473,6 +473,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) { @@ -517,6 +545,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); sev_state = s; diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events index 51df5113ad07..05038709acfc 100644 --- a/accel/kvm/trace-events +++ b/accel/kvm/trace-events @@ -21,3 +21,4 @@ kvm_sev_change_state(char *old, 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) ""