From patchwork Wed Mar 8 20:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9612003 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 A444F6016C for ; Wed, 8 Mar 2017 21:31:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9694E2863F for ; Wed, 8 Mar 2017 21:31:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B3FF28642; Wed, 8 Mar 2017 21:31:25 +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=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 E63192863F for ; Wed, 8 Mar 2017 21:31:24 +0000 (UTC) Received: from localhost ([::1]:58542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cljB5-0001oU-R9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Mar 2017 16:31:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clj6S-0006Py-Or for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:26:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clj6P-0005dx-C6 for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:26:36 -0500 Received: from mail-by2nam03on0060.outbound.protection.outlook.com ([104.47.42.60]:18307 helo=NAM03-BY2-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 1clj6P-0005dV-0E for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:26:33 -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=J8w+6b6DMcF71v3ES6S9YUVkTnv3Lo3XwTSnNOSYqmY=; b=nfv72dz2quCJeJ+bQ/cY6cC6JQNWpq3faYEc+DkCd5bFF1uB6z6mpr3S7Wd6QKVaVhOhRt/ckncC52EbFa1mNlUbjk5rA52Odeesl3uuCq6oOcbbGtNP2hh32ynVv36wsrWrRTcTDSJPJUCkAX/QgEFvB5BZU3Vf7RPLyA6CSSk= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from [127.0.1.1] (165.204.77.1) by DM5PR12MB1611.namprd12.prod.outlook.com (10.172.40.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Wed, 8 Mar 2017 20:53:18 +0000 From: Brijesh Singh To: , , , , , , , , Date: Wed, 8 Mar 2017 15:53:16 -0500 Message-ID: <148900639629.27090.3342242561788466949.stgit@brijesh-build-machine> In-Reply-To: <148900626714.27090.1616990932333159904.stgit@brijesh-build-machine> References: <148900626714.27090.1616990932333159904.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR21CA0008.namprd21.prod.outlook.com (10.172.122.146) To DM5PR12MB1611.namprd12.prod.outlook.com (10.172.40.17) X-MS-Office365-Filtering-Correlation-Id: 933829fc-9f67-49de-3d84-08d4666526af X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:DM5PR12MB1611; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1611; 3:83hcW3QwQDPI8I9bcOqjDH7ch68qGQmtPwBBN8wP90/E5lMD3Eorlv9a/IvJUgYy3ymhOdUMEVhSihZ3/00lFt1DnLrFj5ZCeIHgZAWGI9L5IHnFU3D8GC00rnCLTQmyNWD6uqmsQp54p03WB8udBHgUdAW9iuSVc6GLJC697HE1BfPfz89+TbY/dhLYA8hslKZa/FmcL0e8o26OuXPxP4AhZAKgqxjgiMn23Ne6R+tw64P9dSzWnJfX2NnP5KclRXx4VK/rcTYz7IV0zoHGCuF3BkXS03IqERbWOjI0cUc=; 25:DfGf6QtaQWYnTx3TwJlq1w+HU6+CQTvXbKmhpFehEWgg4Lc+b39kaQydK+QLyO7d2Fgg3ewBCkOFEgq6eTWWptQKvxp0Q8FvY8lst8obHjCCjg8Z8p8/d8RZTS9Iz69RWNJptrt8+rHn86bcivKBTDdZ7bKkmFHk5lXifBXjtemp+bgdH8m+l8avagIEthzUrVzVfCpYxCIQViTsI56qgjY0qo/cw0HyVWG07ikfSPyrisQAz8SoglPMT8Rre09nLL52GSLGlVVlyjvaxMY3ye87jANKfBWRnBGmBOkRDtKz9hTPuOihqYmtcsvUQuv55cJ3lwNujx3OTPvwpM6hN+7Y1XhVukn5WMzw92lPeRPdlcLpc/kivxVoo9HnqLgOHJBKs4yJTs7NmcEjQPU4vvtKmKnWQhEmTcSh5Pl3AMIcrtr+zbokq9ISszAf5pdAcfkRmUPGvO7vVzpyOwjYxw== X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1611; 31:v+n3ywePCZfeNJPL1kfeUYksXrfDkmPy9FfThlI6pa/oKIyuG6VF8sRgsT5DhNw6RK+FoVe0PXtQydB6q068SU9HDLMw50VcppKsKqs8zd7g+Hm1Wbhvjr4LiddDgB//1RC8boc40gpB2k4x1pr73AuBcoOG2+xbhLB2o4NJGmHMFMJvH21cSAWrPGEnaYuXj7sfx6eW+AdLprUEcrDfSjahWQmpPhd0DbGvf17nX2k=; 20:RqjGE12nt6MAdQ3FX1Ji1fQLYa3pcDTpibrfePyJA2zW0vJ0w133e2RdIzojjr0mgZRca5Ej2jIh34aRbukEJPaslnsyEmPvZbLZhBeuBfQ8FndADPyePSOUXDU+3RlBdoJEj/urbHZBKpR7CBelGDBbg7iYLbVw7Ttq5COPGbyilmxxBwBqb5u2c3ot7q9/FoH9mMj7yVL9yKCRg60AAxC0uFl5XvjcMpviWwPeo6nHerwkPBIELKcXADgCzccQChbm5o/FLoG8R//bkCQ4SFMW4E68rYFpBV54TSjvyJUx5xS4nGbCHGb5OMF1tRoMeHV9SrPZs997bnkZACYt02VTXbKv50fQMcLq/ekqUWAh0W5KU50xGMepFBgO1wY5t9zKTXESkH1vG+k4n+XZvmIukPgAZCZVyXvyuT+m64t0zQ2Ds/nTVRerH9bOB8wAQUu4iAUNmeU7lI2oIF5vk0YLMYp3kZYDTLRFfVuJ/f6oRQ5YVwMtz1vgJcPze83P X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123562025)(20161123560025)(20161123558025)(20161123564025)(6072148); SRVR:DM5PR12MB1611; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1611; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1611; 4:PqI0YHiTnIKz/ZHb9ninewSj8P1rQXtKFTwXlHbt2NQvNOWWkgc9kBn5pOCZsjBBeKEpiyv8H7C8/BUDNFIz3f6yn2ztg5XGpWHBWD+ZaxzpLXr5OOwAEN0PwQuh0Jc0mggSXfbUG4Huvj1Hrpom7+8drqikomdec/xJ7olBSp0oA6X95OhZgmcREwPLRsjyWrhtjPpCmxB+27VcuJerjWpHvBgTUwBMIGHbovdepCqgqNrNjWAj7ELgcJDI7L4m9n62GhH7ORIfwtHQ3n/MmyMeR9XQSw4WdQh+S1Lf8T5v03+xlaAAzEHSN0c5jamURg+3Ealz8Fo08FaFXTDOHCMCSVG8X1AOy3zGrd4YW6xR+RQZW47lHAnyQVgstNLADP36ien8n5Uavkvbg7RI3L9v/DVhsORcgNgpUYdaV7EHyliy+GZ7BGtzk1v3OcO74CHeBzlrobqqfaP41P9f49OGluuJ5CvyOeQWtPZ32xS6CPsjFuwyZ4Qy3ctkBPsFGNQzfnkbVrgNxFnvrB+4Q0gSxJRf7Gr/D66Kn/T4RHAYFKP4YIaHjxrHzwACPG7pqSsld2pz5SV689+QaW+NJ5lGSp2AXj3WLOgzrq81rstG4ihinV3WeE5dar3WeWYofrdzikD3h3lbi5bjbWO43Ps4lOggnZBecktk3FwbiDc= X-Forefront-PRVS: 02408926C4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(39840400002)(39850400002)(39410400002)(39450400003)(39860400002)(2950100002)(5660300001)(81166006)(8676002)(4326008)(2201001)(53936002)(23676002)(86362001)(230700001)(6116002)(2906002)(38730400002)(47776003)(3846002)(90366009)(6486002)(77096006)(25786008)(54906002)(66066001)(9686003)(83506001)(54356999)(305945005)(50986999)(33716001)(7736002)(189998001)(42186005)(33646002)(103116003)(50466002)(76176999)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1611; H:[127.0.1.1]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyTUIxNjExOzIzOkNEVXlMRDl4bFNkcnlsNFJvbFJIbi8wYmRm?= =?utf-8?B?dEZEUU1MUzR1ZS9LOXJKZmQwWkZOVExxNTRweURnZ3JMNU1CeTBLeXZDU3c2?= =?utf-8?B?UDZRZm53YXI2YW1JOGZXRUJsS09IbD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Lnj05V31yJGMVrmvfXSisKQSRRuoOUBA4VgHyaWcaPm2pc6lFcnzWVJPg+zWSjoufMUxhZU3rXf+jzABKPWieuVVpag=; 24:Ydv5y7gAujt4cnap2gVMmp6wsHaZ/fM0asGWSv+mMhQBpocgFRV3rgSEYZA/Q2X0zni7oZZBFh63xXrXmNlfa2gbme/yqBFiibnIH1ufNPU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1611; 7:AuXutilDZztlgL0qEjJzgjz7BUl/SCJ4V7KujEADxprNimB5kPHpNY5jVhW0PbprYLVYwWP5Dw5Mhtvu+wHpkXSCFWh1SK/SyQ6j3uRrJ3Oftxzx/McAQfe1iXdZTxMFdJAi1aqbPtIyhIEVMw0C8x/I7fxSK3V7U3xXFQI1Um2vknchIuIL/lfpWDRolJZ4bFdiMWGPD72kEVUCDTLfWYMICYjA/me/l+dY+3jkUXOS6jkZuZJ++SiHjl2YaApnMSzmk/ZfDJXrnKVB+P/W8bjPnAjnjufo49y3gpeptYt3NgH5+u0OJo/8p4kdb4EHVqVO+Q6SkFOtKNhA3DwVRg==; 20:aOe7t87Vxwzq3QeabEJhv5WczPLijdzfav0rSXiUO99KmalsS7USOLhv8fcvDqg2OGrvWwTvZ7nfdzfR6d8QqbkZ15e1KRR+agpvNCBTq1v0viGGUjxEMhJBthzqUcx7ryQ2p/LcYFu2ZeA/fZ6ZbNP/dii8KITz+3KBDvmHYNGMQ2vTXQBsn1W3daI1hFdxElz8bodbb1ukhcndj57uKf/y3NQgdI8Qe2UP+nNWD/KpP+kdN2zz+uqPEqik3fMW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 20:53:18.5643 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1611 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.42.60 Subject: [Qemu-devel] [RFC PATCH v4 12/20] SEV: add GUEST_STATUS command 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: Thomas.Lendacky@amd.com, brijesh.singh@amd.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The command is used to retrieve status information about an SEV-enabled guest. Signed-off-by: Brijesh Singh --- include/sysemu/sev.h | 9 +++++++++ sev.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index 747fe87..88cbea5 100644 --- a/include/sysemu/sev.h +++ b/include/sysemu/sev.h @@ -82,6 +82,15 @@ struct SEVState { typedef struct SEVState SEVState; +enum { + SEV_STATE_INVALID = 0, + SEV_STATE_LAUNCHING, + SEV_STATE_SECRET, + SEV_STATE_RUNNING, + SEV_STATE_RECEIVING, + SEV_STATE_SENDING, + SEV_STATE_MAX +}; bool sev_enabled(void); void *sev_guest_init(const char *keyid); diff --git a/sev.c b/sev.c index 4b3f39a..c13bbfd 100644 --- a/sev.c +++ b/sev.c @@ -197,6 +197,34 @@ err: } static int +sev_get_current_state(SEVState *s) +{ + int error; + int ret = SEV_STATE_INVALID; + struct kvm_sev_guest_status *status; + + if (!s) { + return ret; + } + + status = g_malloc(sizeof(*status)); + if (!status) { + return ret; + } + + ret = sev_ioctl(KVM_SEV_GUEST_STATUS, status, &error); + if (ret) { + fprintf(stderr, "failed GUEST_STATUS %d (%#x)\n", ret, error); + goto err; + } + + ret = status->state; +err: + g_free(status); + return ret; +} + +static int sev_mem_write(uint8_t *dst, const uint8_t *src, uint32_t len, MemTxAttrs attrs) { return 0;