From patchwork Wed Feb 28 21:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10249825 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 32F4B60211 for ; Wed, 28 Feb 2018 21:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 200E2285B7 for ; Wed, 28 Feb 2018 21:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1300228649; Wed, 28 Feb 2018 21:17:35 +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 57F27285B7 for ; Wed, 28 Feb 2018 21:17:34 +0000 (UTC) Received: from localhost ([::1]:46982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er96T-0006ti-FF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 16:17:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er90Q-0001Qk-2V for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:11:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er90L-0005uo-Th for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:11:17 -0500 Received: from mail-sn1nam02on0081.outbound.protection.outlook.com ([104.47.36.81]:17351 helo=NAM02-SN1-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 1er90L-0005tr-LD for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:11:13 -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=cvghRRnMlb0sd+dJ+UpPWut0MKaPGlr7Y8yBJCwmyso=; b=IJeHC0xUiI3JcuI5Wfh8qXDy5UMhQ4CH+58zsuaj6S7vDrLHCfEHnEpQJoBH6Ge9RyriXtgdlZSnKTiNbPUzfb8/4S4gL78VOf5lBnMoyuLDA43bclwbmqdYX2S+E5uDgMePzpplyu3gwg6YpAPG2Ty0MTOPQyVes1c9oed1gXY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.15; Wed, 28 Feb 2018 21:11:10 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 15:10:19 -0600 Message-Id: <20180228211028.83970-20-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180228211028.83970-1-brijesh.singh@amd.com> References: <20180228211028.83970-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM5PR10CA0008.namprd10.prod.outlook.com (2603:10b6:4:2::18) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1cc9d1e3-86b1-4406-ecb2-08d57eefcb56 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:2NQu/+21p3Q8/9FYmAUYbmYAAY5Bi74VMA8p3WDqnle0ZXDng/Mwe1JgfHv3UULScfzPq2DnAD31fDapGGPYsVCOR/CWQTRS6qjZeJksou/gxtxwAzGiJMD6s9g+6FMI04dou0LqXxgyFBNzmEnUq4jFKMQ19b3GkuLio1Y/Bc+vs5o4wW48oLoe/jCf8AMuwP36aePa2lwOJukYMF5SoEDnR20ulXDphfXDVf5f6nwQRxt/yA8Jh73pMmZ9HMzH; 25:wlmtStpLXTVhZRfvYdwenwz4wcI9cL1uTz2xXDVcCOZkYMMM1Brcg9VXjBlBaPL59hpLkdbjBCNyTfAR7TuY85DpDtp2xrmWNY5e/feSBaEFMTBtYkt/H5joKsg+kxXO0w/kh1FFbX2p468UWyTCyRst7ey+djg0n5/Njr0SYFRNgO+T6SJfgr734Y3M0byWmU2TTs4B2Wv1R1LFMtvERg7OiYSfuMiko/3v41BktVQhhxvmnDzNSfO3OujGxJn3EMK1mYutwcoz6FZqrr/CL5xFajQ6ppTxLeKXQk7NxMnJ4/ITiifwMTlk8F8ywsRBI9W1/0O6Y5pVPdAoRui+UA==; 31:9QOhxXvxggs2dbQO88Myj5OirN1m0XUkkOiUQLxPsQDbyPe1LKjO9K0ekm19jv5rlD2SJ0o/AhYSn+ZPxj3qWH4DO20uzNda03PYuufHYcnuJrniSbpCtxkpNAHXpJg6k5OkyibrWHbl5wE6rxJ+7xs1+F49kJwnZ0WwIt5+yBe7f/AZiGdwZ7UY7Jxke+zFMeIUKuN2VFZuR0mqdiOIjuuklFdC/omlwcL8hC+gX34= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:/o3MKeO2UAa7NhFB/YCvd9syVSkhOZGDQETb7sevdvFbRZrGDj/fPtmlCoBt3x457aRpes8+78wuup3UCfncGH8FdfBMr2sweFsMomuDY1VSqhN7Z9n4flH/LkvKiQuu4tSUpdBv7q0EjoTE8mBvtEpH1lwdjphLXlCIIWW/SxV6NQfEPCfXXFkyyePDw9GiAQPzA+2G6D7+5Uwh5WIxzvfNzs1VWBrTPokar1gu//An1MbUnkrbZro15EjnLoUXwdRt4iC6G6zjA2Jj6rdyqt8utGegvZjHSyFvI/AR0WiZLsnWoEtTO6Doe1Vy2zjff0+XQwU4YM0MINQBlTQOifOFL7IwNCUcTHDUvyVumgm0UPQvdbYupLHFFbfJqmTNG0tEQTuGEm3x3RxDccA5DEGyPzMPtfD3xCSQVaoRcxswUeg5FhyHLLsr3HqlOVIMTDvjnGzNAQmvGZMkwvvuN/NXGPpfryiYb/nweNStGpHcAxPJqzjntQsLGu/Ofr2j; 4:K4dGlZMqe7BR+GmHKJ+7rk1o35QII1h5uX9SsI1LnezJ15/Nv0VHEs69HS05W8cHdGWrihEShqftqACUh/0mkgh5TNcawMvK2B4O3kxohd0I1Sc4tGcLwsYvik+CWH3h655CUDlPJwS3wx2+7JKLNDkldbrKroJpUHZSyRnwqZkLGLOn/X+MRtU9NX2nkGoBb2IP4gDy+00YZ/JYuMWNJQVELa+BCBp2YV8Ehy05Xha9skDIhrpesVZ81tr0vUWePllYlMhScfEB9mChXkomSMV57qNn/vh0vlREXg3mPeOqoa1RVWvyzHwnbzg2AcUq 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)(8121501046)(5005006)(3231220)(944501219)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0155; X-Forefront-PRVS: 0597911EE1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39860400002)(39380400002)(396003)(346002)(366004)(376002)(189003)(199004)(6486002)(6116002)(1076002)(2351001)(36756003)(16526019)(16586007)(54906003)(53416004)(26005)(53936002)(66066001)(186003)(47776003)(59450400001)(2361001)(478600001)(8666007)(316002)(81166006)(50226002)(8676002)(8936002)(386003)(106356001)(97736004)(5660300001)(2950100002)(305945005)(4326008)(76176011)(7736002)(39060400002)(8656006)(105586002)(68736007)(50466002)(7696005)(51416003)(25786009)(48376002)(52116002)(3846002)(2906002)(86362001)(81156014)(7416002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; 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; DM2PR12MB0155; 23:xILK/Sq2mCVvfpFAcf6seEcpkTEcu/E5iW5JzjB5s?= =?us-ascii?Q?RJStXQxV9uJd3Jald6v853e4wQY74Yzlb2W/cE1r0UkZLe+lpGwSO/Jh9mM7?= =?us-ascii?Q?7+9gaJRtRs9r+LJ3V+sH0TxgWhRQNbq1HYYJWHVinZdoDo0s42Sz4LsZmLYX?= =?us-ascii?Q?Rub3/8XXLvwMQF0bssKU3SoLmKIIELrX6wv1Wn4jTJ8JsVfU99VOMY3LRrKz?= =?us-ascii?Q?lO4g/Ac4u7o/RHk14epSNxFY/zGGG3Kj42GpYF3yLH7tC2CY3hH17W/bE5T4?= =?us-ascii?Q?5hJbcQKbBk7F45/YWcdCNBC95sk2qMF5hUfy3Tu+QIJSxZPQptO9znm14Pnz?=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rvW0foN2sNvBrlMtc+2cka/sFqpvig?= =?us-ascii?Q?AQNE4BnpF1xinFycwtGTTksh0Zv4qyvgs3YUOM2MOR4DPk1WKt20wxEWL38I?= =?us-ascii?B?QT09?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 6:fzB4Yy9ITgzbPsA2LIQk5vAV9GxR3KGKmNnDfRUdxIka1Y9U169KMDewegqza5UCBVzwUDdoKoz7tYk56knp53EUJmGYC2c9mQmg36pYertYVrsDg0TiI4INFadR+peliztI/PiUTO5sBX0fgTSLChAqDpkeQCLS8S/YnDt2JXdMSmdayZhajU+ntQV/FD9M1e3fYepYXLGRxJT5+suZJAMR6UDmks4hShl1dnQylZVK4X+RFvRSufum042/hnSCxuW2N+753zTkUlHVC112DicE4eg9o7g9k5rY7sTAR7KBTmMBMLrh8nfKBjhK/qYH27SpXn7m9OjYEL2nM/psqYxU4Unn2ayxkjBR+kxieRE=; 5:DVD553Ec7pQ9dL0wilhk5ANHqhQ+xPRiPjMXtGyIVB/b5I4bc9fLKe4tepqLOu+ykfdHNnjKgWdm/nSJ6AJoe+ozoWG5/46Dnap+X0x6i/RsSO3TsEyeE2jaccHWxzlSue5tma8olWX8NfDCulDFDaRk1wri1FEgUtgnmCYvVXA=; 24:n5FMZNNafWKe1+CI1VYjEwVeim0JYHGUqdGSUEBtUm2vHP+ctmCRWbwMC1+CA44E/0SsPO+5OnFPR+O9y8h5kS10PE7/2dVnwru/+7ij9h8=; 7:C/gidIr8Co32jVUlYgTEbyRsK1Uhm/u4mkVXZPzxNcFwgHiva95A9o1TRLoruOqh2lqUQd/oG9K1Y9NRqCL9REjThqBGAddCkfdra4mH2bLIXZsvRO2TF+1ZB4LYrs20jXowSaOdrgS4AsKlORmuAmmufqifVluqqcvgJ4lN/HmPKM+6mRO5oEnTErwKdb4Yg1ZgcCe+zlbnu4OSaEIrC/E057knSrUjlrv5Qwu/DTlwF6rRUSXbZwf/qvB08y9L SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:UeFxeI/Uuz/d0zhMJZi9CgcBAlQ51QiopEpR1BFMLmVFW7YbTAVTqEBDXPK85uWiHz7+4cs//UXQCBlgfQzQMNZoRzxUH3nPYVf57zA2uXuPwswuTKm7rr6gwWP18l/UlzeiIeqVMNPCdLuK9WSOobXg1Z7re/vFdo+8AjHnbMlTB+P9v/rjLPGLV+82TLz6Y2RzidyPb/03p0hY4kTnjVd8U6nPN7ftBhnrmAMD6HN9d7xBviGO6BCMEt/i+WRJ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2018 21:11:10.9673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cc9d1e3-86b1-4406-ecb2-08d57eefcb56 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.36.81 Subject: [Qemu-devel] [PATCH v10 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 a61c100ef47b..c341257fcc14 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -572,6 +572,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) { @@ -653,6 +681,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) ""