From nobody Mon May 6 13:20:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528221629189306.573415782727; Tue, 5 Jun 2018 11:00:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8191F316B76D; Tue, 5 Jun 2018 18:00:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E7A78E185; Tue, 5 Jun 2018 18:00:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D8C484CA85; Tue, 5 Jun 2018 18:00:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w55I0AcY029052 for ; Tue, 5 Jun 2018 14:00:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD6F7600C9; Tue, 5 Jun 2018 18:00:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B845B60170 for ; Tue, 5 Jun 2018 18:00:03 +0000 (UTC) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0085.outbound.protection.outlook.com [104.47.34.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5932878ED4 for ; Tue, 5 Jun 2018 18:00:01 +0000 (UTC) Received: from wsp141597wss.amd.com (165.204.78.1) by BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 5 Jun 2018 17:59:52 +0000 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:X-MS-Exchange-SenderADCheck; bh=y1bNsofhCY3EYD9zmoswS9LE2pe2aQilE3zTADBkXo4=; b=wdSCU8wU+Gnp4G0Q2piOGwCLENB2GpqHbf1IfI5BoQ7B7zJRV81Wx9vfYlnWM5vDEXQXKaDaFYOYsi5un/tEt5scHYb5dKbCr/zrSZ8oJ6hqaKZGoxjxYa5x/+7TZ9MN6x6RVL3TuMuFTNFOKvXw5zK6UQg6gee0Xf45V19FgNE= From: Brijesh Singh To: libvir-list@redhat.com Date: Tue, 5 Jun 2018 12:59:23 -0500 Message-Id: <20180605175932.62322-2-brijesh.singh@amd.com> In-Reply-To: <20180605175932.62322-1-brijesh.singh@amd.com> References: <20180605175932.62322-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0018.namprd05.prod.outlook.com (2603:10b6:803:40::31) To BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BL0PR12MB2452; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 3:O+28lejnPNdofQ9a8TkKozCpDsj/S9bjVY+5T68XF9Qfr9YT8VcINwXpZq5wzWxMs+q4CssYIEdY3ZSiWAaK2ej39RnMfRix11SREzTl3MgzDr0H6WwRmk/EqgRJ8APelfuIJJ891afhswohcG3c0m1V2p9Vd6DRD4GG6v9vkir5uF72sfpwSFOwSQcEdpfR6dfAcIGi/71rYERDy4jHHcBVAamRhNy/RjXGt2X+f7gpiqW7bgAxdX3y9DikqVHf; 25:aic2qHuy+N3ciFveOMnqo6vrpbJM6s8et9jMh7nkP1zATRWNPklHTf5v1c5sruj4qqPYNOBiKp/qU5/W6nUJGsaafXz7BMwBwZB6dJ89LWJN3OyWYix5CGfpFEhf1LWLWUHP/c6eCJ7feDeZ5meUZFmeawyDWTf1P8b9uRt8O1e3zmLE3NxOZX1pDmdzDGOVRvgwApl0gfwISHLu5++AJ6hicxnlYNc7K1gnF3W7R2EeSVMKpibDnFfW1e2X3ZMTuxujEjhsrAu3S8hT1s7FAmJqJlul37x+YpiSJf1IrLFlxZ8y7CvbE57ZqVDuq1p5LZFIo2Hn/S60W4Ausezf6w==; 31:Qdd7sa9mrmzB/IG3HnJ12HPAdGTaZ0n10tgrNLjOy9Qc+jwwNSVFuO48sLo8ruSKvOKh4ovix6PGkA56W16ZRqsFnV52iXf9OnZEw8oqenDDztyRCtKUZe+HDeW/sokf/PBRYSdgsNgTEK6CQQLV5cZqcvUpvhADG+zeFa1RL+gjx+leJdPjx+E90SRvdHwr8YqEom+Kn9tqAQpsouXN1MhycLM1r+kdDfMweuq7WUU= X-MS-TrafficTypeDiagnostic: BL0PR12MB2452: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 20:JJ5UteP2V7OnuMsAmnrorFdwEWZ/k+kT7++gdOJkgFyPLcGHPOBaiYK4RKlhGT5iWfYmJ0wLlqcdLf/3779JBRQn7I0BmhiQj0JyOrQ73Y5PRPqI3o/AaxKIrsviZ7ItS4D+tMhYZnBuQlUn8b+8VRrTPJWx3E3nyal8lbCH0yR05jKbmXCuaWlPY+xeTKMo2XNomEpMzLLuat+7XUIhhHvaYIk6C+SR5Ngplqkv89B5ww7K+A1Sga+Nk0NvYG+lCBPDSQJeOuuIP+XXg0vdmje8UO/oIwcQvfrMRm+5dWu7npWJ5qtHmoUtR7q0oNic6/Khmoc4rfWxXEcJ/IpUsgIGppW5jmB8I9GgcfYPAI1WWU/8M2TVOPMuXsI9v7slnAV7WjtGlIcEvqYeknSIOQyXePg2AZNo4bDBFgUSumqZgEQdT9Qyo4Om+/0knVUFyti+mrAUwKBxYOBOAQ4VlSAsKFk5QjCnqjx+sfYOOHnf/tODnkaCyQeVwJ5m55gU; 4:KREIW5LjgCzzfxnaJqqp0pyQICX6qUWCmTM0605Z4PsJ79cmKm3avL0NAF4Oib46B3YB4bLpnsfc0HUDv8CfgeLZE+DMQTzYn7ldAlX07Gl5nw/udpJcoBaTKqDRqUFFVi7/MViWlfBInsYLOqavGBLuwzJB109eGI6pvB0zKciVGpARBNpwLiaa363+d2dd6gzM7+WI9Ozwq6DgMce2f1Jyux6bemzMRt/mhILmUxQgK9qeCWinDv6MAhUhuf962WrEqULz7eS6sA649A5M8WmyomR5AMvyn1WBPwsQVNoBRGJSoChIZDfttZNvHU73 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:BL0PR12MB2452; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2452; X-Forefront-PRVS: 0694C54398 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(6916009)(1076002)(59450400001)(7696005)(2361001)(386003)(106356001)(2906002)(52116002)(53416004)(4326008)(68736007)(105586002)(8676002)(81156014)(76176011)(6486002)(2351001)(25786009)(81166006)(54906003)(36756003)(6116002)(3846002)(97736004)(47776003)(50466002)(6666003)(7736002)(44832011)(305945005)(26005)(51416003)(956004)(446003)(476003)(50226002)(86362001)(486006)(2616005)(575784001)(16586007)(478600001)(8936002)(66066001)(11346002)(53936002)(186003)(16526019)(5660300001)(316002)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2452; H:wsp141597wss.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2452; 23:Cr/hv8+hQBmfPoqZlNeDCR2XVBiAUmk650I6iKyj9?= =?us-ascii?Q?Uv6EwkPYPFPTjeVpBWaUVusatH7wKQPvjuf9W7j9OnlPYl03BoX/RmP4h0Wf?= =?us-ascii?Q?opiPuRgYIgPJnxDwqsLu9RJ80B9ZbO7EfJ4c6x3B3V6nT2tOVud8Sx2k0+Ul?= =?us-ascii?Q?fPL1zmgT7DjZ+2bYYUXXYPbDgYBJEmasXQzCkcQx37OB/tUJjFe1fk/n/31M?= =?us-ascii?Q?TnZ3w19jZq+HRNk0WGVRlINwXsVs2RgvHKsqZs7xM6J7HqaQ/AHLUgs5AO3r?= =?us-ascii?Q?xWEW2iMaRVd7id9WGtAWArWW5oy60JkFwfC1SfLm6oYrIEXmv0eIehap86Hp?= =?us-ascii?Q?/4bXJwV6f58i4aEG2nLKfVDfDJzYJug38tVZNfcdHLpvEM1f+p6B2zFTsMoJ?= =?us-ascii?Q?RCXMYZXNmJkZc8bmwLoHPcr3jewGXaNZUatGwk8ndcKsteSNd+TOYwBTAuX4?= =?us-ascii?Q?BLJi937kuKGAFgocMzxb4DJIVfWlJvzid/DvjkP21fQkJZG5NjkoB9BGMwmo?= =?us-ascii?Q?mPlC7rGpksD1gnkFIZ4wlpWgENrIHQz6tfFdqCDWhvKx9rh1CN9QHyJNPKNS?= =?us-ascii?Q?PFgXL5jnarqg0SgstJlePUPkYQ5BKvoMlwi9RNciAaONvlFDf+xcyLOpjq6h?= =?us-ascii?Q?fQa+hbAVatNkLlmqtwEyNH8K2DWLYwBS+xb8SDROm0E5Ba2zV8Nf4O+tDPw5?= =?us-ascii?Q?gbB5cUY8nwnO/IKlBz920IJgWavWGCYJW/0nOc7XgScXUaxCcHmLIxQvodkc?= =?us-ascii?Q?+yUDlPFN42uohaitDXts8H9fuzKwy+RPER+szmvIxEiSCBjvS2tBLvJAL6nw?= =?us-ascii?Q?hP7IS0mr4Xqm9kKyMK4433v/Z8vLVv3U9dPYqL1QS08H4Y3Vw/9XI4tRNwJT?= =?us-ascii?Q?Fh+9mBztL8zs6bDHJinhRHjtbKPkov0S45PIFK1Aj2l+EKjJokkZ+fa0Mkk4?= =?us-ascii?Q?M9pt1jJIi9vIBHqRjMibmOcmAgioJcBIUERkp9CLKoZmd9VAWNxbI580uL7W?= =?us-ascii?Q?kjfVcy924rlwX5YGrchkEz9PMePuMfndhKYCoJtcoVr01gigrzUx+X5nEtlD?= =?us-ascii?Q?U9huSEC2rPh0ATc50yQHinpYuQR4VwqnwOa+2uMNIEYrufJf3WbhcjsOcjX6?= =?us-ascii?Q?Jcozo/Ftv6y4/GgdSyY0UdVzX+682xGBEa+8zZmwnJB0WyhThpwxDWpel2jT?= =?us-ascii?Q?4rL37HebELRLcKRynT39dJWhGWQb7JgjyKA/AWasdyqh1xxvJ0g30QpyzsiL?= =?us-ascii?Q?42KKhhrdax3ZULonAa4CBesa7HyolteMCqAGSstM07NAYpomr48H+jmoliVl?= =?us-ascii?Q?cePoMlcCJsJ6j8DrnfwER3BjD6WPOeRn14f60Ov8gMM?= X-Microsoft-Antispam-Message-Info: lsD49oE2sVCAlpL9GPTF5pVCFCl3fkNpFXgDAQ8GaLu2omxG+QMaakS/MmZdXzh4CedL8S88odUo995TX5p7SfA+s9ree+c/n6Mxme72NeCHe8CrhDpyh/aN05fyxetgeKqIl05Bg0+rzmfcr1Tnlnhex64Mdc/DqKHQl8Zj0mpa7beYp+Cbv0/Fj+gnkuhc X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 6:8Dzoc+fc5JT7wFodll9GgcTc63XoUd+sR89REQGSYgZTpPyzjMdO4iuNe42SaQJL6CWi2TgmtzIYNFtP0XpoU8RLqr8ImurWD76GgI4MIasvCof95l+CcYLNbuHQjpSZi4zToSGxrul7se3sK0oKGevgRf/XoRkHFzH9Srvm2IJ9A/uyXpYb7rNhvqctTZCiifs4Sc2YfkDR1OOU88DNVFQblzIG7umRh+yVFMK256ZS+0HhWrvbH9T43+IXGasYQxbp94uwEDpq73wzwTSPcO1c16XRUVeXKV1JrVEpnx2P3OlW1O6v92355iA1fkJalp1WUjKBuKUTICSgGJCrtxayYLYzot3QoHWyRmTn88x8Bg3/RVer8BM8Dlz/JS3I4O+PZ3cVdkAEZMhErJ8ZFaFyxaV/1saBP/oWP8uNckyrQr1DBlZyCg4cOmUcymsPGyvr/ecLUGQUcrhWPdn9Mg==; 5:h8mnS7ZayHhJpGUjeaiD4FmlDNBy3RjlOthWDg/AhqZz1IUhOaTQENJEhDBU5koi6w809WmHDEMr0/3uzS5j352C61L54GjAaZ89QOazXENYU5ryFKL/hyLtBr4mLxdiZ6JH03ouGAKPuG8bUEM8pj0dlgJNr2vOoEhU/El3200=; 24:2KxwRsai/8+h1o31IjCIfOatpJVcf/enPGEX5o7VFnFPRJNIWptDa2iBSXabq3ZePV3R6/XY098JdkBJOIECIixrV6NIOCUkp6dyDHK4RWI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 7:6nEcHd+/GI3bV9MLeBT+8GGXHL+ekc5o75BhzJBCvsRjiNrBosP7oTjxe1c7OiuZ6yUnY4+gBWSv26Xc6lZddsa9461Cfb3Wjc83Y/nZoPRDYPVOOp/3Q/u6HkGJ6cgvwXfDZrDGpz9WUkxPM44TvhMyFXPipS25dKLTCAZ56MTsDXJ9Psqww4d9kFsyl+rU/KfzdIh67jAqvrqV+OEQy0E7vsKY7eEMVmj5s9Q6XAzVRS6L4q9yYJ/Jm51pw57U; 20:24UBPoKG3LMgoaO47Q7Yahge0oN/wzzpdEwjdySm/hpmE6xq8BGQlvYndKxBzT7jN2qjFKyeY2iq8Y3jyZp2Z3h5aoDJEYojEZUvkVBAaZxe4sGQffS4Mil/8ZGN4c6Ws1WSSslO/cmzjV6jDsiWT6hoLWfQH70xSntB+iUU13BXgQyahuQuuJFVawknK5mmtpFEqh0CtWUGjXvCoCT9vLcdKEJngq9TKPh7+v5bvzhake8JDS6iwkSKS9b4sTVX X-MS-Office365-Filtering-Correlation-Id: 36ce0182-bd4c-41e0-5c6a-08d5cb0e23a6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2018 17:59:52.6365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36ce0182-bd4c-41e0-5c6a-08d5cb0e23a6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2452 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jun 2018 18:00:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jun 2018 18:00:01 +0000 (UTC) for IP:'104.47.34.85' DOMAIN:'mail-by2nam01on0085.outbound.protection.outlook.com' HELO:'NAM01-BY2-obe.outbound.protection.outlook.com' FROM:'brijesh.singh@amd.com' RCPT:'' X-RedHat-Spam-Score: -0.021 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIMWL_WL_MED) 104.47.34.85 mail-by2nam01on0085.outbound.protection.outlook.com 104.47.34.85 mail-by2nam01on0085.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Tom Lendacky , Jon Grimm , Brijesh Singh , Borislav Petkov Subject: [libvirt] [PATCH v7 1/9] qemu: provide support to query the SEV capability X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 05 Jun 2018 18:00:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU version >=3D 2.12 provides support for launching an encrypted VMs on AMD x86 platform using Secure Encrypted Virtualization (SEV) feature. This patch adds support to query the SEV capability from the qemu. Signed-off-by: Brijesh Singh --- src/conf/domain_capabilities.c | 12 ++++ src/conf/domain_capabilities.h | 16 +++++ src/libvirt_private.syms | 2 +- src/qemu/qemu_capabilities.c | 35 ++++++++++ src/qemu/qemu_capabilities.h | 2 +- src/qemu/qemu_capspriv.h | 4 ++ src/qemu/qemu_monitor.c | 10 +++ src/qemu/qemu_monitor.h | 3 + src/qemu/qemu_monitor_json.c | 79 ++++++++++++++++++= ++++ src/qemu/qemu_monitor_json.h | 3 + .../caps_2.12.0.x86_64.replies | 10 +++ tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 3 +- 12 files changed, 176 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index c20358e..3589777 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -67,6 +67,18 @@ virDomainCapsStringValuesFree(virDomainCapsStringValuesP= tr values) } =20 =20 +void +virSEVCapabilitiesFree(virSEVCapability *cap) +{ + if (!cap) + return; + + VIR_FREE(cap->pdh); + VIR_FREE(cap->cert_chain); + VIR_FREE(cap); +} + + static void virDomainCapsDispose(void *obj) { diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index b0eb4aa..30b3272 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -137,6 +137,22 @@ struct _virDomainCapsCPU { virDomainCapsCPUModelsPtr custom; }; =20 +/* + * SEV capabilities + */ +typedef struct _virSEVCapability virSEVCapability; +typedef virSEVCapability *virSEVCapabilityPtr; +struct _virSEVCapability { + char *pdh; + char *cert_chain; + unsigned int cbitpos; + unsigned int reduced_phys_bits; +}; + +void +virSEVCapabilitiesFree(virSEVCapability *capabilities); + + struct _virDomainCaps { virObjectLockable parent; =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5540391..59a2efd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -185,7 +185,7 @@ virDomainCapsEnumClear; virDomainCapsEnumSet; virDomainCapsFormat; virDomainCapsNew; - +virSEVCapabilitiesFree; =20 # conf/domain_conf.h virBlkioDeviceArrayClear; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 26969ed..2c3665d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -493,6 +493,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, =20 /* 305 */ "vhost-vsock", + "sev-guest", ); =20 =20 @@ -559,6 +560,8 @@ struct _virQEMUCaps { size_t ngicCapabilities; virGICCapability *gicCapabilities; =20 + virSEVCapability *sevCapabilities; + virQEMUCapsHostCPUData kvmCPU; virQEMUCapsHostCPUData tcgCPU; }; @@ -1130,6 +1133,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "hda-output", QEMU_CAPS_HDA_OUTPUT }, { "vmgenid", QEMU_CAPS_DEVICE_VMGENID }, { "vhost-vsock-device", QEMU_CAPS_DEVICE_VHOST_VSOCK }, + { "sev-guest", QEMU_CAPS_SEV_GUEST }, }; =20 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[]= =3D { @@ -2066,6 +2070,16 @@ virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCap= s, } =20 =20 +void +virQEMUCapsSetSEVCapabilities(virQEMUCapsPtr qemuCaps, + virSEVCapability *capabilities) +{ + virSEVCapabilitiesFree(qemuCaps->sevCapabilities); + + qemuCaps->sevCapabilities =3D capabilities; +} + + static int virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -2648,6 +2662,21 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qe= muCaps, } =20 =20 +static int +virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps, + qemuMonitorPtr mon) +{ + virSEVCapability *caps =3D NULL; + + if (qemuMonitorGetSEVCapabilities(mon, &caps) < 0) + return -1; + + virQEMUCapsSetSEVCapabilities(qemuCaps, caps); + + return 0; +} + + bool virQEMUCapsCPUFilterFeatures(const char *name, void *opaque) @@ -4043,6 +4072,12 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW); } =20 + /* Probe for SEV capabilities */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) { + if (virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon) < 0) + virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST); + } + ret =3D 0; cleanup: return ret; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f2aecef..ad25e6c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -477,6 +477,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 305 */ QEMU_CAPS_DEVICE_VHOST_VSOCK, /* -device vhost-vsock-* */ + QEMU_CAPS_SEV_GUEST, /* -object sev-guest,... */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; @@ -614,5 +615,4 @@ bool virQEMUCapsGuestIsNative(virArch host, =20 bool virQEMUCapsCPUFilterFeatures(const char *name, void *opaque); - #endif /* __QEMU_CAPABILITIES_H__*/ diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index fea039e..32aeefa 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -89,6 +89,10 @@ virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps, virGICCapability *capabilities, size_t ncapabilities); =20 +void +virQEMUCapsSetSEVCapabilities(virQEMUCapsPtr qemuCaps, + virSEVCapability *capabilities); + int virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b0c63c6..d1e4d74 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3841,6 +3841,16 @@ qemuMonitorGetGICCapabilities(qemuMonitorPtr mon, =20 =20 int +qemuMonitorGetSEVCapabilities(qemuMonitorPtr mon, + virSEVCapability **capabilities) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetSEVCapabilities(mon, capabilities); +} + + +int qemuMonitorNBDServerStart(qemuMonitorPtr mon, const char *host, unsigned int port, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 9894eba..04abd92 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -710,6 +710,9 @@ int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr = mon, int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon, virGICCapability **capabilities); =20 +int qemuMonitorGetSEVCapabilities(qemuMonitorPtr mon, + virSEVCapability **capabilities); + typedef enum { QEMU_MONITOR_MIGRATE_BACKGROUND =3D 1 << 0, QEMU_MONITOR_MIGRATE_NON_SHARED_DISK =3D 1 << 1, /* migration with non-= shared storage with full disk copy */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 42d7b9c..b50f719 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6401,6 +6401,85 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon, return ret; } =20 + +int +qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon, + virSEVCapability **capabilities) +{ + int ret =3D -1; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr caps; + virSEVCapability *capability =3D NULL; + const char *pdh =3D NULL, *cert_chain =3D NULL; + unsigned int cbitpos, reduced_phys_bits; + + *capabilities =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-sev-capabilities", + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + goto cleanup; + + caps =3D virJSONValueObjectGetObject(reply, "return"); + + if (virJSONValueObjectGetNumberUint(caps, "cbitpos", &cbitpos) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-sev-capabilities reply was missing" + " 'cbitpos' field")); + goto cleanup; + } + + if (virJSONValueObjectGetNumberUint(caps, "reduced-phys-bits", + &reduced_phys_bits) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-sev-capabilities reply was missing" + " 'reduced-phys-bits' field")); + goto cleanup; + } + + if (!(pdh =3D virJSONValueObjectGetString(caps, "pdh"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-sev-capabilities reply was missing" + " 'pdh' field")); + goto cleanup; + } + + if (!(cert_chain =3D virJSONValueObjectGetString(caps, "cert-chain")))= { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-sev-capabilities reply was missing" + " 'cert-chain' field")); + goto cleanup; + } + + if (VIR_ALLOC(capability) < 0) + goto cleanup; + + if (VIR_STRDUP(capability->pdh, pdh) < 0) + goto cleanup; + + if (VIR_STRDUP(capability->cert_chain, cert_chain) < 0) + goto cleanup; + + capability->cbitpos =3D cbitpos; + capability->reduced_phys_bits =3D reduced_phys_bits; + VIR_STEAL_PTR(*capabilities, capability); + ret =3D 0; + + cleanup: + virSEVCapabilitiesFree(capability); + virJSONValueFree(cmd); + virJSONValueFree(reply); + + return ret; +} + static virJSONValuePtr qemuMonitorJSONBuildInetSocketAddress(const char *host, const char *port) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 2ae0faa..4c10574 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -152,6 +152,9 @@ int qemuMonitorJSONSetMigrationCapabilities(qemuMonitor= Ptr mon, int qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon, virGICCapability **capabilities); =20 +int qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon, + virSEVCapability **capabilities); + int qemuMonitorJSONMigrate(qemuMonitorPtr mon, unsigned int flags, const char *uri); diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies b/tests/= qemucapabilitiesdata/caps_2.12.0.x86_64.replies index c40046b..ace3537 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies @@ -18996,6 +18996,16 @@ } =20 { + "return" : { + "reduced-phys-bits": 1, + "cbitpos": 47, + "cert-chain": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA", + "pdh": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAO= AAA" + }, + "id": "libvirt-52" +} + +{ "return": { }, "id": "libvirt-1" diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.12.0.x86_64.xml index 964b9e8..716e299 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -206,9 +206,10 @@ + 2011090 0 - 390813 + 391059 v2.12.0-rc0 x86_64 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 13:20:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528221642274895.0560051888147; Tue, 5 Jun 2018 11:00:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52CDF7DA29; Tue, 5 Jun 2018 18:00:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07F5A10694C4; Tue, 5 Jun 2018 18:00:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A67AB180BA80; Tue, 5 Jun 2018 18:00:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w55I0FX9029104 for ; Tue, 5 Jun 2018 14:00:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9A5C5D9C8; Tue, 5 Jun 2018 18:00:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF7225D9CB for ; Tue, 5 Jun 2018 18:00:04 +0000 (UTC) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0041.outbound.protection.outlook.com [104.47.34.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 009D481DEF for ; Tue, 5 Jun 2018 18:00:03 +0000 (UTC) Received: from wsp141597wss.amd.com (165.204.78.1) by BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 5 Jun 2018 17:59:53 +0000 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:X-MS-Exchange-SenderADCheck; bh=1jP2Jy/JpF+k+YcYUkH88SqRrZxYZ2+chKVe1MSd5UA=; b=GBy/SPrs8mW7E9sOYC5PrL/2McHuXDsAzEc84Og8D4g0o47ViEgTe2574WREQxa3d9issf2Z2FZNWmgUfg+qFgyNolsZ2IbxcZdYDNb3aX8iPUsDcGp1USXQH45csv9Rm5Av4ImJ4ABQ8GPyXZrBcKeROc4oHWTATAFgCqFIKbI= From: Brijesh Singh To: libvir-list@redhat.com Date: Tue, 5 Jun 2018 12:59:24 -0500 Message-Id: <20180605175932.62322-3-brijesh.singh@amd.com> In-Reply-To: <20180605175932.62322-1-brijesh.singh@amd.com> References: <20180605175932.62322-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0018.namprd05.prod.outlook.com (2603:10b6:803:40::31) To BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BL0PR12MB2452; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 3:x0JY69ao/x8T2Cv1ES7JMrsSJuCVGSsFJQZUHjPn2RJ0Q+TcU8XeJsEGDcSuaAXWfNdTs/+9MdS3wu1hf2DxgGZKxLL+qH6S08v/OZlvueRuofKWplNoLxrLgVeErWWsTb5/SrVPF8zEJqz3f4o026amxWv452MNjRCOpZCDf2isBvdQxA0jZyWDNEHH62Z+inEcnW7H/+MYgZ6U0c5/YyGjRNVdw8EnunhlzZvX1vYXUbhejFqz/6SdXe9UxDEI; 25:BLTZJ4ywAbLui3/HBJ0FMU47rrD36vBBqRPvjNxon1YIhdl+FG4IcEQW+PQ6cVuH5GnNUWd6HZJX+f8tW69YQbxUR5M4jbpniPxl9fPguxdFxb4jA0PhEDyizM4SMod/bYtWIRthIpLcQxD/HXSK5fm1tInoqnwMJmCf48lghKBlH355as4xck09G15EK1AHoElrNWpyjf15X/VZ2ZUC5c4jL4N18fc+WCkdrUTcVCt2Qou3hz+7r6MXm94k3xtVXo3l5NEYHfiQaZQR4pSCMqB9qNYV2k3Jx+5gxeuvBfx+BKHCd2d5I2HUg0b6WkHbZfnDLPQD9yKu8Y3WcLGC6Q==; 31:cMLnQEWNpSg94usuC4IfGJ/bDbWks2MTFBEU4W4Js034xobZT6kXiSAFCQcZGNPc8BYaLy0vUqUjj9ZCO9BQmBuhhqlir4HS3xa/cCs1CFBC9UHMD1RB4l8YKCtzTnsdtKgnU3ZyQIZs2Kz8PM911TL3lSphGbF5qwah07eiqTRsftic6VdG5QQUlBfaS2zg2noZewHuqQFOqNF+qxtuO8meEivqgJ21elnSDXRFsew= X-MS-TrafficTypeDiagnostic: BL0PR12MB2452: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 20:7HpSRpHTS9nQ3fy/59SUGmMpG6KRFA8ame/qH4gu27Sj8IZIy8weVj+yYjwn3xAW+0fENZ9Dn2PhDDTg3T1X25fJYoeB4gAGogAvgKvXu5Tp8WBQh+yBMfg6fN6sNrb1ezVaHBX5EWtN2Jok6TMsEiVq5WYthv1ENh7S5K2YtPaWGpeEfOHqSJqxSm6RA7byJQJpPpb6mjWm/KRpzRH5+0bPXpBBoPGDJts6BDXKoLFzp5Pv/fE6ViMoeGXcw39QLDKxbzH7UPkAbEACoS4SlT/TVBu5DnbxO/Ah5b2ikE/amrnWPaHezv7ldDOltdcPDdJDjI1/75LyidTpA7hEBlGxAD0tc1hHdVNzi9H4810HQhJrdSZO6Xzu2rl1sDwMrQUrdZfbglBPB4sKtvZ73/dNl161MRDUTbbmGFva977V4lfqNdCgwUvS4XFKgZR/An+DOjnsDsESAV5pcJiSpU4TzRW6XrptGxvrb0Reizf4cGmcxcMJ4IlR8BUXx2r3; 4:6KJj00eq8yu5QC8+hzWCPZ29Ax5bRPUspXr2GjKSQYORzkQVrtmC1rKOnhWltiQTCKrOojb3s7VyBG5/DpOLM1p5gCj6GI2lYVNfC5PRvNOOZ+NAU9lasmFT8rDYNtJUoZT7RdXLaPvgE2yN3Na+luDsTSNlbS0seHqBZfcDDVWHlrOhV2wQWQpm/Pp6Haov8s0nNipc57yL7MKUJQjNCXEmLuFkhRMptsyX6zinRlBLgzhHT17wCIFCH/MaObjcPGejixKI3UnNzmcPv4DlJ/lu++lCMYcFAHG5FeVJ4/gK1Qy0rfJy3XLNuDvYuriMn1pbjZl1XcDQ0dEpjBMPspv9iBa4uiD4XDrCtCiQNWg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:BL0PR12MB2452; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2452; X-Forefront-PRVS: 0694C54398 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(6916009)(1076002)(59450400001)(7696005)(2361001)(386003)(106356001)(2906002)(52116002)(53416004)(4326008)(68736007)(105586002)(8676002)(81156014)(76176011)(298455003)(6486002)(2351001)(25786009)(81166006)(54906003)(36756003)(6116002)(3846002)(97736004)(47776003)(50466002)(6666003)(7736002)(236005)(44832011)(26005)(51416003)(956004)(606006)(446003)(476003)(50226002)(86362001)(486006)(2616005)(575784001)(16586007)(478600001)(8936002)(66066001)(11346002)(53936002)(186003)(16526019)(5660300001)(316002)(48376002)(6306002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2452; H:wsp141597wss.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2452; 23:DDiyhqRQiVmIW2Ikb72rbtP+SnRTv9M5PS5SAAMSz?= =?us-ascii?Q?D3ax8kV5SbZQX29LJACxuPeAvYMi52zOVbk4aVIkIUd5THYz4em4LehofwUp?= =?us-ascii?Q?oZCInfuPxBh72Om1fDIvbIVjTQAs01TXBfV2yR3pGMSAuo0I6oIXGiMCnphV?= =?us-ascii?Q?HVlW9JByBa5ESJhuI2/Epv2ih5OZHGUiLjuV+VXUMfmgr+xgFJNqtaLtpQZd?= =?us-ascii?Q?LKEZbByuY/4AkaCneJgb4S8J+KnwyRTJ0woyuz6/UKkwU+PS/ctjj2q4EueM?= =?us-ascii?Q?4fIm9iVTSmdk5nTtNmTEvnZjbaompxx+zBQG3fO1a5ILOxttdKcbBI+5JuXc?= =?us-ascii?Q?SOE1R48vvNDQsctzGz4adots+58lhLgIjcXaH1t38BMTlubHsC0ErjcNxZ2V?= =?us-ascii?Q?DrCJ4QIsm7drqPCcALXEdevEYyccGqvwbnMJa4EKmQ081R+06+9MubGAGCyi?= =?us-ascii?Q?uPmRnI5aviOXDRMQLmWTQ+UlUVI0ENmZOZ5mIwKPlwlb/DrBtZPkoSXfIo7G?= =?us-ascii?Q?tEE+CsMLdJBsvUM40hguo2bZC9kcpCf10ZNudzibzWW9zyPZm2GZFSunpfyx?= =?us-ascii?Q?7Q2clo0w8z/1839SSRwnozdO+1za6sHu74OyZx6KUSBQ96ivGhKaQjSjkpf1?= =?us-ascii?Q?rdvRIBnK2eA9KdDZqR5DBF5PK7LD9irREtThd4zFujhyTttLhRdG8bBq6Rjf?= =?us-ascii?Q?I3a0f9BNJt/ZMmuf18vBFtGTTegzMbFAgPq0c94kUtiZB8ngwk1+rUhasnJR?= =?us-ascii?Q?m938XcbJzuhQE+Dd9Jk1jtDjqO8o7f4RHYn1Gs87RWHH/FIt1AgQr2kc/Smq?= =?us-ascii?Q?F6ImROrCx/LNAJj8EKMQo/8T08GJGwwPEOozlS/sd5UfSymlGXqJsQYf/YHd?= =?us-ascii?Q?o/VkujWm1kTcFeoMXAxKJyGHnjfK4R+IAg/on00exegzKwreBa9qIIzyBo9i?= =?us-ascii?Q?b25Co8ZU3Q+aMhkl/Sfou4JT5TgT2ZZcRVBxbIIw7vh7tFX6+HZpDrm7twuR?= =?us-ascii?Q?uzz9zsGaR0koihTJxsnmYfiXIxJi6zws0aTwNrm2078DigES8YIdZn84HsUJ?= =?us-ascii?Q?1ZGLSzd3qtubkEtGjo20jhOpydguOGweX9lWpJIBb/yViffaXBUtuUQ7LP6u?= =?us-ascii?Q?N1bAavD2TCBmYxQRJW0SfVCQ7pt6z2DbjwIy8gPKuHS8edCioHeofdFzrWLR?= =?us-ascii?Q?kmyqYA8t+aCwqvRTuc04puiXcROPez3fpuev4NkBH+5Z/BgU5IjBwl27cXtM?= =?us-ascii?Q?w06XJ7CEKmrVZYaBI9Kiy00tspUVvwgo2+K0Ie1yB0o7BFT60yWDsvxLzfs8?= =?us-ascii?Q?o2tl0dMZlVXcEgylExSmO290QDefx2Yojy0Ve83FiPpP4J59g8234CTNvxYB?= =?us-ascii?Q?yuTY4j1GyKMsyWn4gMBnRbya60=3D?= X-Microsoft-Antispam-Message-Info: 9vXfVrSCu757lBW5CF6BwmfvT0AoGTbd0cE8YCmbI0dRdDay1GkFiAmHV9yJG4T42nyab9m/W9FJlRC9khhctGIPlsB/OMzFVbQ+BCcBpYrkAM7FDq31QNq0k8i85XcgKv9Tr/oldJRc5vR/dtemQyfVcirfwKkuP1tmDF526A0z/iYu7tRVjBNnSBoHU81w X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 6:8dlu5zy+haP5VyEP5Imn+er8PMMklysinU2h7vecqgLJ37fpGvA2Tf29VyI7Bt/XuzttuauRuLtGnHmojbjOGDQPTK1PwIrBHnzlgTdsvIIMVAD/rFvgANZEmNM8goEOAO2YzT8JUlcJuniOOCAkCziYkPAhznGycKoyrS4kyAObOzZfh6mfJCXDox3WPhMgnzYMmTfDD1IFk4tQDw6GNqmCYIkeHvhnpf9jK62Gmh2O91oso9+Q71HtgoP0u/vaUuufAwi4zv3ozQc/hneSBAyOUdZ1Z1VeUZYZhgs8cfHNKgHdoMuWUHAHUfklZ5NIARmY4IXln7vqlPjtHekbZQjKFoluBc9ZfkYWwcbbQ871USvC6zppslrnwGKCXEJ3Hepk9h20kHA6N7IYzhprmevSAGbGJ/njps9OSaplCKZXpiQgW8yqszrD7B8c2SD1OjtNkvnpGPEvKu7d6nP50Q==; 5:zG+XBCrpcffklYf18CZcfsqNGDWVJoJqErRlhw4mmxJuwKrKbcEytv8/lobMXm3O/noBXQQJQnXw/D+SQl1Npyu52UmLDJDSxkrmAg+wA446tlvcSyCPEA/QD3qkd1NR8uulSfCFCiVNIMZD25Nz3yYfulbD+hHn13RNvvYLm+A=; 24:D+0gP9VwGbgnoVNKlM7scswDLR8PB0/7Bl5q9LIA/LQvUenJr/l7HLJKWBUYtRvBjBk1hE+olAC2PcXmvbqAbSEDwUGx94/XLJmvb+TMqsk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 7:lwNeF4kYPoJ/OutzrieZJgToJDs/sNMbS1v1xU3m1uIDjQPhPJPTJUeKueVGMqOluFcLp6jg7N4Hwtjowde5hCMklNbpUJDhgkE9ojdtZrnPmVi2fckbA/jM/IP5N8fRWEO6xh3QxjQrV54o+6JwxxGq+Zw82xE3tzKUhDJPJ+ckDbL7SMsCJLO3YKKUevRLkQbZVfFYJl8K+YH4yTixehKDZSLdtLVJkAxxCgGBK3QdPEFHXxPjtKRidVIzCVdy; 20:97KqfPZa1Gj5XcDxMoidTbJAxOifz/4e4X4M+GEkwphrWGd29KyZ2NlUX9hn6p3/bmc9NIKCXoHvceg+LtcxuQOes28RLKoLxQtsVE1KfAHXsIANq/z3/+h7kYU7ClnHPC6kRRTGaZQBIXB9gyOJUpqjUr7WoWJhrHEmK/21K265kInZOnZNE1pbTTO73KG6d5Nvzx71ybP0uyYkMlj+LII2t26UCZ/uhC3STC3SamK6HqzOK9KN0VCS4D3tvSkS X-MS-Office365-Filtering-Correlation-Id: 8a7859b8-7b8f-4664-b552-08d5cb0e2425 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2018 17:59:53.4041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a7859b8-7b8f-4664-b552-08d5cb0e2425 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2452 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Jun 2018 18:00:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Jun 2018 18:00:03 +0000 (UTC) for IP:'104.47.34.41' DOMAIN:'mail-by2nam01on0041.outbound.protection.outlook.com' HELO:'NAM01-BY2-obe.outbound.protection.outlook.com' FROM:'brijesh.singh@amd.com' RCPT:'' X-RedHat-Spam-Score: -0.021 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIMWL_WL_MED) 104.47.34.41 mail-by2nam01on0041.outbound.protection.outlook.com 104.47.34.41 mail-by2nam01on0041.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Tom Lendacky , Jon Grimm , Brijesh Singh , Borislav Petkov Subject: [libvirt] [PATCH v7 2/9] conf: expose SEV feature in domain capabilities X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Jun 2018 18:00:41 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extend hypervisor capabilities to include sev feature. When available, hypervisor supports launching an encrypted VM on AMD platform. The sev feature tag provides additional details like Platform Diffie-Hellman (PDH) key and certificate chain which can be used by the guest owner to establish a cryptographic session with the SEV firmware to negotiate keys used for attestation or to provide secret during launch. Signed-off-by: Brijesh Singh --- docs/formatdomaincaps.html.in | 30 ++++++++++++++++++++++++++ docs/schemas/domaincaps.rng | 14 ++++++++++++ src/conf/domain_capabilities.c | 19 ++++++++++++++++- src/conf/domain_capabilities.h | 1 + src/qemu/qemu_capabilities.c | 48 ++++++++++++++++++++++++++++++++++++++= +++- 5 files changed, 110 insertions(+), 2 deletions(-) diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in index e0814cb..6be553a 100644 --- a/docs/formatdomaincaps.html.in +++ b/docs/formatdomaincaps.html.in @@ -435,6 +435,10 @@ </gic> <vmcoreinfo supported=3D'yes'/> <genid supported=3D'yes'/> + <sev> + <cbitpos>47</cbitpos> + <reduced-phys-bits>1</reduced-phys-bits> + </sev> </features> </domainCapabilities> @@ -467,5 +471,31 @@ =20

Reports whether the genid feature can be used by the domain.

=20 +

SEV capabilities

+ +

AMD Secure Encrypted Virtualization (SEV) capabilities are exposed = under + the sev element. + SEV is an extension to the AMD-V architecture which supports running + virtual machines (VMs) under the control of a hypervisor. When support= ed, + guest owner can create a VM whose memory contents will be transparently + encrypted with a key unique to that VM.

+ +

+ For more details on SEV feature see: + + SEV API spec and \n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%d\n", sev->cbitpos); + virBufferAsprintf(buf, "%d\n", + sev->reduced_phys_bits); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); +} + =20 char * virDomainCapsFormat(virDomainCapsPtr const caps) @@ -597,9 +614,9 @@ virDomainCapsFormat(virDomainCapsPtr const caps) virDomainCapsFeatureGICFormat(&buf, &caps->gic); virBufferAsprintf(&buf, "\n", caps->vmcoreinfo ? "yes" : "no"); - virBufferAsprintf(&buf, "\n", caps->genid ? "yes" : "no"); + virDomainCapsFeatureSEVFormat(&buf, caps->sev); =20 virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 30b3272..17c1f1c 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -176,6 +176,7 @@ struct _virDomainCaps { virDomainCapsFeatureGIC gic; bool vmcoreinfo; bool genid; + virSEVCapabilityPtr sev; /* add new domain features here */ }; =20 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2c3665d..5db444c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5145,6 +5145,50 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr q= emuCaps, } =20 =20 +/** + * virQEMUCapsFillDomainFeatureSEVCaps: + * @qemuCaps: QEMU capabilities + * @domCaps: domain capabilities + * + * Take the information about SEV capabilities that has been obtained + * using the 'query-sev-capabilities' QMP command and stored in @qemuCaps + * and convert it to a form suitable for @domCaps. + * + * Returns: 0 on success, <0 on failure + */ +static int +virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps, + virDomainCapsPtr domCaps) +{ + virSEVCapability *sev; + virSEVCapability *cap =3D qemuCaps->sevCapabilities; + + if (!cap) + return 0; + + if (VIR_ALLOC(sev) < 0) + return -1; + + if (VIR_STRDUP(sev->pdh, cap->pdh) < 0) + goto out; + + if (VIR_STRDUP(sev->cert_chain, cap->cert_chain) < 0) + goto out; + + sev->cbitpos =3D cap->cbitpos; + sev->reduced_phys_bits =3D cap->reduced_phys_bits; + domCaps->sev =3D sev; + + return 0; + + out: + VIR_FREE(sev->cert_chain); + VIR_FREE(sev->pdh); + VIR_FREE(sev); + return -1; +} + + int virQEMUCapsFillDomainCaps(virCapsPtr caps, virDomainCapsPtr domCaps, @@ -5182,8 +5226,10 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 || virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video) < 0 || virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0 || - virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps) < 0) + virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps) < 0 || + virQEMUCapsFillDomainFeatureSEVCaps(qemuCaps, domCaps) < 0) return -1; + return 0; } =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 13:20:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15282216291761009.1490303634814; Tue, 5 Jun 2018 11:00:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64A53309CC21; Tue, 5 Jun 2018 18:00:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 248E410694C7; Tue, 5 Jun 2018 18:00:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7C1D24CA83; Tue, 5 Jun 2018 18:00:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w55I0A9o029047 for ; Tue, 5 Jun 2018 14:00:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 358742010CEE; Tue, 5 Jun 2018 18:00:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 244392010CF3 for ; Tue, 5 Jun 2018 18:00:05 +0000 (UTC) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0085.outbound.protection.outlook.com [104.47.34.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A7EB80F79 for ; Tue, 5 Jun 2018 18:00:04 +0000 (UTC) Received: from wsp141597wss.amd.com (165.204.78.1) by BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 5 Jun 2018 17:59:55 +0000 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:X-MS-Exchange-SenderADCheck; bh=eRn5KrqHco2TxRnGRaM6ZuZmP9UAIrhS3hsfZiwrEoU=; b=13oCIchNy8iKROxrMF5ozxGeYrlRaXLajUyWHY+iCi31WZ3Dzobdjn/DBkUhWfq0IOAGd44QlQry0+P+jGhjy/0fiRiGBt9FtNor3QFgmMxVjKuIxsDoFxy5rLkNYSTseL8MGU2bGmtPR+oi+3tGH5ZNFOIs9y5ZQeNMeHso/U8= From: Brijesh Singh To: libvir-list@redhat.com Date: Tue, 5 Jun 2018 12:59:25 -0500 Message-Id: <20180605175932.62322-4-brijesh.singh@amd.com> In-Reply-To: <20180605175932.62322-1-brijesh.singh@amd.com> References: <20180605175932.62322-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0018.namprd05.prod.outlook.com (2603:10b6:803:40::31) To BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BL0PR12MB2452; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 3:cpZm0bphO0m6FcAhbbvXDPHe1DkYhs/cCt5j2L7LDCNsqe33xn1dLf7y1uNGzULx+huznYeEcPfLXfc8wSQWE8laGaG4tFY1DKaPBknoDMCf24rEl9Os++KgNySWb3FakQHnayf1Og59cCqU8coqVeGgJVSGr7hNMSItLMffK5O24JJ2gPkH8SFciuzhjvD0uZxszl75jea/cQbnmfN9AVF26nYRkDspNlyKRh62Z3WKK5KHHl3T9PK6WSXAmIGl; 25:J3WhmUMQpONlrYrqgfJt+pHPW/cL5AhpbHirzhLy0mAyjQ5VV4KpOpO9ZZ3Pk03Olr6BVU0Wjxi0JWzp09L0GOnC2DppvnDW2AjGvnOSBybIGCV/+8eMH41heighRvkEib2L3cIyxt3upIEa5o+F2YriEX+xgsxCA7qHAYLh3tfD8c9IzgI2KUHHLHclNFcUbOmHJVnvxAPq89Ue254Hug7t1baK8thEudBszSaYitcXR7wzxnHuzwrgNVhkhe7Cu+E6o0C4Mnvf76omldgT49h+RyxyIp3TOMZmYMmDWpD361anMbsLSVj+DVl2zlOpdAtT0LiIVurai89V4Jx6uQ==; 31:khOEAVB/PMB5nrYi4m0FnsGKMNYH0oclsdBRiKjgNkWp9nRbYZR+Gr2/jabBqzl8t0u/7zLoMns4foDp4yAQ0U1tSFsBr63GZOKWevNBJ5DSWxAuD9paoi3UGr4foL3w3qACWB2vsF5pXI/HEczTrsGEivTi86Y4pbo2Uv3tkD7fxzSBBXJ0wDHRYv6Cxt++gEXLf7D3I2Y04g8elR6j9/RGGRnzU+T4r/I40rS+GJ4= X-MS-TrafficTypeDiagnostic: BL0PR12MB2452: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 20:ew2n8W8bs/cSGmY3rc8r65YFYUAWY0zKyLgof8fuSlQxKPYzXi2PbiCUWCDVezlkfqPaPS65N1225SP7PAEVPJzQmeSJWcWpIsjhNUc8NF4tsiRg6XW34f6LADYUf+G7frtAvU+bcl8GRnmDN0Q8ZDShTyGPKBXWx5xDc/R1fTWSDWY0WNPtMRQAji1lDcuFFVGPJgBFcEEVaH6pC7WrM88BY2WFRBX8GQsGt4wRSCnDCdODprE7YAOnHAEZITBMTPK2VgI8xXG0yN+bSw6ouObqMXp5l9+w6c/N9MBP+0hJYOB+mGp/pCKiThYXsVNCQvrcSHWzuDnsPsMRja54Dlqz6Op3P1KRVF7Y/iB0VnobSRm8MTVea5hzftTX9xVkiAGRPUihqsImN0Zfh71y+4AlPPXfwHd+lwi6ZKOExDb8YTDTO9CL46dt7yrSwLgYh8BhTJPvyA1nbrGegweM0dVZjkWqhEA5xclFN8+/mi8FaJSfBmpSqbxDeT/EqcXy; 4:GBZQEDZwi7GiEhrZj7wldrpAuplYepiWW2YItiyGWo1hwKodamHP2RIavSUCQIlX2MUQZJ749gnAFHmPorK+Aaeds9TW2KGO3nRJ7avjai23x1c9fjPmQpYB5Fs4iGSAQh4gTrAWqn6wNwjO6OhwlRLyL1ZZp5t6aD7qCjG3ygd+enVDjwPUFvwZADEeZU/7GzfvdR0XyH2wbBzTHZDXBexR3Hf9gxIOKGa3A2idjlgrdTohVfiyAG+2zJiGZRrfkeJiqyb7QbuPlSBh+pCb+DP2k4j9X4Eo4YpHQm6TGRIbLSwLHmLr5EYTxZ9NhaKc1nHvJ0UwFhFdOay/nzE0cMSI4AyvQfnzHI/txuG/sQ+WHklRW7JKDPNW1+gLKFY5 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863)(767451399110)(21532816269658); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:BL0PR12MB2452; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2452; X-Forefront-PRVS: 0694C54398 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(6916009)(1076002)(59450400001)(7696005)(2361001)(386003)(106356001)(2906002)(52116002)(53416004)(4326008)(68736007)(105586002)(8676002)(81156014)(76176011)(6486002)(2351001)(25786009)(81166006)(54906003)(36756003)(6116002)(3846002)(97736004)(47776003)(50466002)(6666003)(7736002)(44832011)(305945005)(26005)(51416003)(956004)(446003)(476003)(50226002)(86362001)(486006)(2616005)(575784001)(16586007)(478600001)(8936002)(66066001)(11346002)(53936002)(186003)(16526019)(5660300001)(316002)(48376002)(145543001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2452; H:wsp141597wss.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2452; 23:e+zeh8dnEL8vZUF+ZDgZDTaf8DsvJ4iR6ChDQ4rbe?= =?us-ascii?Q?EYUTz3Bc3omOecyyU0uB5OEA0vbJyUyaz2Dv86tqcnzobuSS96J52d5g3nNp?= =?us-ascii?Q?QjO4Y7AnHvhDTk21SYOfjgvV7ZRdv/QfywKepngoUo9ONwxXlhhucsYcx1UB?= =?us-ascii?Q?o3eX3g0DiUjIa+zUX0OgqVHRVc2y2Rcos+7JkTCXOnADSaEiDlW2rHnAWt/Q?= =?us-ascii?Q?KqOOPEH2I6W+1IBxuNBCO9GBBKrcwBGZB1Unv0kZMJh6ZWQ1yMY/YLkUrZqU?= =?us-ascii?Q?zvK4UX+0Z0Ly8XvosF7TOSCLr3hIsbLpFkK3YaC0iIgI8mgslqehfKVZD3Ch?= =?us-ascii?Q?JbFJ1kio5qhBu5Zl6iPlhCcekJ2y445V+dlXDqAei22QZTKGijFxELU8zV1e?= =?us-ascii?Q?9IzoW7NPdh2SFSTtYQDxZQ+oAyT6Nz5uIWXYcWWZ7YazmeL2a41CdLEh2a1N?= =?us-ascii?Q?vv3QDkhsevWtv1gmh+TVoRFjUCx+akzf/7odMWe5xL6oRNw65P6pv1z9FDoM?= =?us-ascii?Q?64Do6JJ1Aea7ZIB/SXV1MCKK+bTGpa2PppCSoMCIt8UphGNS6aVe/kkJrUOy?= =?us-ascii?Q?IeQnhVlk9u17xsub/C+0VqdBxNhgqPxP1lPNtpxIrNqPk1cQYBA4X/WND7d5?= =?us-ascii?Q?e7P3pDTJvce8R28rIDO1uLKnmw+xSWheQ/dNfWXnnDOVfUOFbsgUtYfqTLC9?= =?us-ascii?Q?JFDwbfTdXJWTizktlWCb+2qvOWm0guKm9NWh94SCbjmX203Gf5azyr6Qa+Cl?= =?us-ascii?Q?iqeWElmo16Fn2UJZIGB0OI/JsjbFEN8Lrif08N/LT3Mlj5oZZuqyeiZWBmA4?= =?us-ascii?Q?sr7M8Ag+cyZUAIzxktqXrhyw60OfVLyBlJWjLFAhqB7FUxnGuKmo61uYDU5y?= =?us-ascii?Q?H/N2OeHeria1MtpwWo9Z2b7WEq9Ld7HnmpF1sAOpcdFW0grhoHEe8xwo/Dn7?= =?us-ascii?Q?Wi6HvPMgWX3oiZR87IykV06C3hRV04IBrb0NzuJ3QVcQQVn1dOLlVd1E0RvH?= =?us-ascii?Q?ANuKdxQVqtf5NWKV4xVbGx4kOrsj6ti9b88bL7/IefnLI05edTXmHRW2Hgc8?= =?us-ascii?Q?0NkSHxJ8hD4oNB9YGNAGoBJh0qLs7lYI0TZy7Cgss81sln0Z7oLvZY9x2/sp?= =?us-ascii?Q?1qfEbA2oWkMl8H0mD+TBnAK0jfYTnmoCXwflaC6QOzA7l3YrMl7YOx3pugAB?= =?us-ascii?Q?uZPXDGjyMDHMimmLQ+f1xch7bl8OKvRPCLECWvv/gF/MqK6SQWEmkGaZwDMT?= =?us-ascii?Q?dEgfjoIEc1nRNBjWn2JEjkYmM0tdW5w57UUAnPCFdXEESFgk0K9/UHGs2bhY?= =?us-ascii?Q?8dk8dlGoiIGoKvU1VmXyqtKhFMnyx0kCW4/IzX0ROKHYA8PrOC3ynVzJKTOQ?= =?us-ascii?Q?E9J8A=3D=3D?= X-Microsoft-Antispam-Message-Info: jPxf8BoUPPILhkmaaVstTXFXYoNIfVsnge01UJ9WJ8eMh7wQ6zhgiQI9p9zjnNNvSnpudr4jHOghFWlNmo5krcOOj/8QkxVJ/ffi+OMC/JJcLr159Y9U/aP4y6/cenRMvyDRDbnND/DRomUTFtqGnnNmNxGEzlrwsqsBQJXbQsOquHu4u/mIL3/pkap8SDMv X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 6:b5dxwn1UbrxVZ+KhUxKg9tdexNotD8fvp+EgutILFo/l3Li/B7FfGMukK4uFo5CEGt3OprvDw2SfHzRL78INuzb1RR4q3jaz33x/gPTN7u942EmVXso3tRW5La3QcpWYSAv3vqPVmzUQ2SD6w3B1eStDUcLAUeaD2Ow8ra8rHKWSQpvQap90Q+i8S64cKykdMM/GYMxBH6p6NsbtZl4xdaDyN1mIbQURf7MrcU3iSPIuI3k69F1zNn28lXR2G1yQ6yy/X5ebnfAfIofmOKHrQjnnIndPcjHz/moAAnn+Z3V0LiHUscJhbO/U8Zd733zHrQralISTsGRJ59KGET2Zc/dHyJ+wccWAhREcrNxAjxnc1jzjOM4l3UmMr3SFvGcs/OnHfAnbrDVMb7WzBqJ6igMS54amCjYiZtcA3XxCbk8v70iIDzes9m2sA8ASIPref8J2+BuUoU/Ln02ixfJysA==; 5:caasmOERNVD4HJ+WfFdHnLILWLBGL1aiYoN8Ujqsz87D9doZuHmS7vJpuHl+2z5XFAWFm2EWBwtVHpa62rNVHzaqByYcVStDy/hsz7f/VSRYFXAfOtKsZ2xq0aWL2vN7CiLBeflaEyRnLRst64uQ7Sj/zhRGsZ4mOykb7L3JxJY=; 24:STDvxrbcpIh8QMMUxFFgQTO9A3at0ONafZlshKzdCPrGMswe8Wai54w+LErTatZPci3iydWzpGP+RrWJJQ4wRgTWxRw4ts6AkedKPYklgiE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 7:8uAGBKfNgcdZ9/owJhhi6O3a5SqFzG4ChVT54ef5rZCWM47RGEb7NPsvAZawsHH9Pq6ZvB8RZjLF7qCSV3SL427t9fdDFKfmXsTl3CqJqR6qcQ3iYThrhMiWgdh63u6rfAuHhS3mkENWC/VsQCCVIOXXNjT2H7SCGejFvfqoUJ13U+3pKODzevSf72dCPbq6eojRB8lTjkI2JgvV3DYVD261+dQ8bq2KcA2PE3Jyzr4Drxc9WszfZobggDp8aaeC; 20:k5exWYM7ToESSY71FCEl4hux3xZFKNMG7r5/jhbCWmCLuFza7HVz6Bj5Nu8ZaRNJi8P2QROYFnng3mzpojn3SKvVLBHd07/aHAmVweyytVsrlN1jThNcqv8IIozRUJotuShJ8a0JOU5JxL7J5t2EBeuC4WV5IwZHniJM0mNrCDKq8Fz1DdzekMzW8ec0IaeGOcQ5dzt10vSCktaGYiRcpuhI41bNBGzKs64YY0KAosou5+DhBBQ9fG50N0BEUqrX X-MS-Office365-Filtering-Correlation-Id: 873421f2-f190-47a0-7380-08d5cb0e2565 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2018 17:59:55.5676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 873421f2-f190-47a0-7380-08d5cb0e2565 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2452 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jun 2018 18:00:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jun 2018 18:00:04 +0000 (UTC) for IP:'104.47.34.85' DOMAIN:'mail-by2nam01on0085.outbound.protection.outlook.com' HELO:'NAM01-BY2-obe.outbound.protection.outlook.com' FROM:'brijesh.singh@amd.com' RCPT:'' X-RedHat-Spam-Score: -0.021 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIMWL_WL_MED) 104.47.34.85 mail-by2nam01on0085.outbound.protection.outlook.com 104.47.34.85 mail-by2nam01on0085.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Cc: Tom Lendacky , Jon Grimm , Brijesh Singh , Borislav Petkov Subject: [libvirt] [PATCH v7 3/9] expose virNodeGetSEVCapability API X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 05 Jun 2018 18:00:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The API can be used by application to query the SEV capability. Signed-off-by: Brijesh Singh <> --- include/libvirt/libvirt-host.h | 42 +++++++++++++++++ src/driver-hypervisor.h | 6 +++ src/libvirt-host.c | 48 +++++++++++++++++++ src/libvirt_public.syms | 5 ++ src/qemu/qemu_capabilities.c | 7 +++ src/qemu/qemu_capabilities.h | 4 ++ src/qemu/qemu_driver.c | 93 +++++++++++++++++++++++++++++++++= ++++ src/remote/remote_daemon_dispatch.c | 44 ++++++++++++++++++ src/remote/remote_driver.c | 41 ++++++++++++++++ src/remote/remote_protocol.x | 22 ++++++++- src/remote_protocol-structs | 13 ++++++ 11 files changed, 324 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 84f4858..d020597 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -432,6 +432,48 @@ typedef virNodeCPUStats *virNodeCPUStatsPtr; =20 typedef virNodeMemoryStats *virNodeMemoryStatsPtr; =20 + +/** + * + * SEV Parameters + */ + +/** + * VIR_NODE_SEV_PDH: + * + * Marco represents the Platform Diffie-Hellman key, as VIR_TYPED_PARAMS_S= TRING. + */ +# define VIR_NODE_SEV_PDH "pdh" + +/** + * VIR_NODE_SEV_CERT_CHAIN: + * + * Marco represents the Platform certificate chain that includes the + * endorsement key (PEK), owner certificate authority (OCD) and chip + * endorsement key (CEK), as VIR_TYPED_PARAMS_STRING. + */ +# define VIR_NODE_SEV_CERT_CHAIN "cert-chain" + +/** + * VIR_NODE_SEV_CBITPOS: + * + * Marco represents the CBit Position used by hypervisor when SEV is enabl= ed. + */ +# define VIR_NODE_SEV_CBITPOS "cbitpos" + +/** + * VIR_NODE_SEV_REDUCED_PHYS_BITS: + * + * Marco represents the number of bits we lose in physical address space + * when SEV is enabled in the guest. + */ +# define VIR_NODE_SEV_REDUCED_PHYS_BITS "reduced-phys-bits" + +int virNodeGetSEVCapability (virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags); + /** * virConnectFlags * diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index aa99cbb..cb2ab9c 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1309,6 +1309,11 @@ typedef int unsigned int action, unsigned int flags); =20 +typedef int +(*virDrvNodeGetSEVCapability)(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags); =20 typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1558,6 +1563,7 @@ struct _virHypervisorDriver { virDrvDomainSetLifecycleAction domainSetLifecycleAction; virDrvConnectCompareHypervisorCPU connectCompareHypervisorCPU; virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; + virDrvNodeGetSEVCapability nodeGetSEVCapability; }; =20 =20 diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 3aaf558..0f78166 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1639,3 +1639,51 @@ virNodeAllocPages(virConnectPtr conn, virDispatchError(conn); return -1; } + +/* + * virNodeGetSEVCapability: + * @conn: pointer to the hypervisor connection + * @params: where to store SEV capability + * @nparams: pointer to number of SEV parameters; output + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Get the SEV host capabilities, If hypervisor supports SEV then it @para= ms + * will contains PDH and certificate chain. + * + * Returns 0 in case of success, and -1 in case of failure. + */ +int +virNodeGetSEVCapability(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + VIR_DEBUG("conn=3D%p, params=3D%p, nparams=3D%p (%d), flags=3D0x%x", + conn, params, nparams, *nparams, flags); + + virResetLastError(); + + virCheckConnectReturn(conn, -1); + virCheckNonNullArgGoto(nparams, error); + virCheckNonNegativeArgGoto(*nparams, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + flags |=3D VIR_TYPED_PARAM_STRING_OKAY; + + if (conn->driver->nodeGetSEVCapability) { + int ret; + ret =3D conn->driver->nodeGetSEVCapability(conn, params, + nparams, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 958601b..438205f 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -792,4 +792,9 @@ LIBVIRT_4.4.0 { virConnectBaselineHypervisorCPU; } LIBVIRT_4.1.0; =20 +LIBVIRT_4.5.0 { + global: + virNodeGetSEVCapability; +} LIBVIRT_4.4.0; + # .... define new API here using predicted next version number .... diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5db444c..82aec96 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2080,6 +2080,13 @@ virQEMUCapsSetSEVCapabilities(virQEMUCapsPtr qemuCap= s, } =20 =20 +virSEVCapabilityPtr +virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps) +{ + return qemuCaps->sevCapabilities; +} + + static int virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index ad25e6c..630ce77 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -615,4 +615,8 @@ bool virQEMUCapsGuestIsNative(virArch host, =20 bool virQEMUCapsCPUFilterFeatures(const char *name, void *opaque); + +virSEVCapabilityPtr +virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps); + #endif /* __QEMU_CAPABILITIES_H__*/ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c200c5a..7c619dd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -137,6 +137,8 @@ VIR_LOG_INIT("qemu.qemu_driver"); =20 #define QEMU_NB_BANDWIDTH_PARAM 7 =20 +#define QEMU_SEV_PARAMS 4 + static void qemuProcessEventHandler(void *data, void *opaque); =20 static int qemuStateCleanup(void); @@ -21438,6 +21440,96 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, } =20 =20 +static int +qemuGetSEVCapabilities(virQEMUCapsPtr qemuCaps, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + int maxpar =3D 0; + virSEVCapabilityPtr sev =3D virQEMUCapsGetSEVCapabilities(qemuCaps); + + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); + + if (virTypedParamsAddString(params, nparams, &maxpar, + VIR_NODE_SEV_PDH, sev->pdh) < 0) + return -1; + + if (virTypedParamsAddString(params, nparams, &maxpar, + VIR_NODE_SEV_CERT_CHAIN, sev->pdh) < 0) + goto cleanup; + + if (virTypedParamsAddUInt(params, nparams, &maxpar, + VIR_NODE_SEV_CBITPOS, sev->cbitpos) < 0) + goto cleanup; + + if (virTypedParamsAddUInt(params, nparams, &maxpar, + VIR_NODE_SEV_REDUCED_PHYS_BITS, + sev->reduced_phys_bits) < 0) + goto cleanup; + + return 0; + + cleanup: + return -1; +} + + +static int +qemuNodeGetSEVCapability(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D conn->privateData; + virCapsPtr caps =3D NULL; + virQEMUCapsPtr qemucaps =3D NULL; + virArch hostarch; + virCapsDomainDataPtr capsdata; + int ret =3D -1; + + if (virNodeGetSevCapabilityEnsureACL(conn) < 0) + return ret; + + if (!(caps =3D virQEMUDriverGetCapabilities(driver, true))) + return ret; + + hostarch =3D virArchFromHost(); + if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, + VIR_DOMAIN_OSTYPE_HVM, hostarch, VIR_DOMAIN_VIRT_QEMU, + NULL, NULL))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot find suitable emulator for %s"), + virArchToString(hostarch)); + goto UnrefCaps; + } + + qemucaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + capsdata->emulator); + VIR_FREE(capsdata); + if (!qemucaps) + goto UnrefCaps; + + if (!virQEMUCapsGet(qemucaps, QEMU_CAPS_SEV_GUEST)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support SEV guest")); + goto UnrefQemuCaps; + } + + if (qemuGetSEVCapabilities(qemucaps, params, nparams, flags) < 0) + goto UnrefQemuCaps; + + ret =3D 0; + + UnrefQemuCaps: + virObjectUnref(qemucaps); + UnrefCaps: + virObjectUnref(caps); + + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -21661,6 +21753,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainSetLifecycleAction =3D qemuDomainSetLifecycleAction, /* 3.9.0 */ .connectCompareHypervisorCPU =3D qemuConnectCompareHypervisorCPU, /* 4= .4.0 */ .connectBaselineHypervisorCPU =3D qemuConnectBaselineHypervisorCPU, /*= 4.4.0 */ + .nodeGetSEVCapability =3D qemuNodeGetSEVCapability, /* 4.5.0 */ }; =20 =20 diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 81d0445..f974b71 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -5001,6 +5001,50 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr se= rver ATTRIBUTE_UNUSED, =20 =20 static int +remoteDispatchNodeGetSevCapability(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client ATTRIBUTE_= UNUSED, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_node_get_sev_capability_args *ar= gs, + remote_node_get_sev_capability_ret *ret) +{ + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + int rv =3D -1; + struct daemonClientPrivate *priv =3D + virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + goto cleanup; + } + + if (virNodeGetSEVCapability(priv->conn, ¶ms, &nparams, args->flags= ) < 0) + goto cleanup; + + if (nparams > REMOTE_NODE_SEV_CAPABILITY_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); + goto cleanup; + } + + + if (virTypedParamsSerialize(params, nparams, + (virTypedParameterRemotePtr *) &ret->param= s.params_val, + &ret->params.params_len, + args->flags) < 0) + goto cleanup; + + rv =3D 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + virTypedParamsFree(params, nparams); + return rv; +} + + +static int remoteDispatchNodeGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNU= SED, virNetServerClientPtr client ATTRIBU= TE_UNUSED, virNetMessagePtr msg ATTRIBUTE_UNUSE= D, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3be30bd..cdc9a70 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -6776,6 +6776,46 @@ remoteNodeGetMemoryParameters(virConnectPtr conn, return rv; } =20 + +static int +remoteNodeGetSEVCapability(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + int rv =3D -1; + remote_node_get_sev_capability_args args; + remote_node_get_sev_capability_ret ret; + struct private_data *priv =3D conn->privateData; + + remoteDriverLock(priv); + + args.flags =3D flags; + + memset(&ret, 0, sizeof(ret)); + if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_SEV_CAPABILITY, + (xdrproc_t) xdr_remote_node_get_sev_capability_args, (char *)= &args, + (xdrproc_t) xdr_remote_node_get_sev_capability_ret, (char *) = &ret) =3D=3D -1) + goto done; + + if (virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.params.= params_val, + ret.params.params_len, + REMOTE_NODE_SEV_CAPABILITY_MAX, + params, + nparams) < 0) + goto cleanup; + + rv =3D 0; + + cleanup: + xdr_free((xdrproc_t) xdr_remote_node_get_sev_capability_ret, + (char *) &ret); + done: + remoteDriverUnlock(priv); + return rv; +} + + static int remoteNodeGetCPUMap(virConnectPtr conn, unsigned char **cpumap, @@ -8452,6 +8492,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainSetLifecycleAction =3D remoteDomainSetLifecycleAction, /* 3.9.0= */ .connectCompareHypervisorCPU =3D remoteConnectCompareHypervisorCPU, /*= 4.4.0 */ .connectBaselineHypervisorCPU =3D remoteConnectBaselineHypervisorCPU, = /* 4.4.0 */ + .nodeGetSEVCapability =3D remoteNodeGetSEVCapability, /* 4.5.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index a0ab7e9..a4e1166 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -253,6 +253,9 @@ const REMOTE_DOMAIN_IP_ADDR_MAX =3D 2048; /* Upper limit on number of guest vcpu information entries */ const REMOTE_DOMAIN_GUEST_VCPU_PARAMS_MAX =3D 64; =20 +/* Upper limit on number of SEV parameters */ +const REMOTE_NODE_SEV_CAPABILITY_MAX =3D 64; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; =20 @@ -3480,6 +3483,17 @@ struct remote_connect_baseline_hypervisor_cpu_ret { remote_nonnull_string cpu; }; =20 +struct remote_node_get_sev_capability_args { + int nparams; + unsigned int flags; +}; + +struct remote_node_get_sev_capability_ret { + remote_typed_param params; + int nparams; +}; + + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6187,5 +6201,11 @@ enum remote_procedure { * @generate: both * @acl: connect:write */ - REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU =3D 394 + REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU =3D 394, + + /** + * @generate: none + * @acl: connect:read + */ + REMOTE_PROC_NODE_GET_SEV_CAPABILITY =3D 395 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 0c4cfc6..7705821 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2907,6 +2907,18 @@ struct remote_connect_baseline_hypervisor_cpu_args { struct remote_connect_baseline_hypervisor_cpu_ret { remote_nonnull_string cpu; }; +struct remote_node_get_sev_capability_args { + int nparams; + u_int flags; +}; +struct remote_node_get_sev_capability_ret { + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + int nparams; +}; + enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3302,4 +3314,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_DETACH_DEVICE_ALIAS =3D 392, REMOTE_PROC_CONNECT_COMPARE_HYPERVISOR_CPU =3D 393, REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU =3D 394, + REMOTE_PROC_NODE_SEV_CAPABILITY =3D 395, }; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 13:20:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528221615651132.66688080546385; Tue, 5 Jun 2018 11:00:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1E6F3082051; Tue, 5 Jun 2018 18:00:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF68D308BDA1; Tue, 5 Jun 2018 18:00:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 879511800C9D; Tue, 5 Jun 2018 18:00:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w55I094I029033 for ; Tue, 5 Jun 2018 14:00:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE011308BDA2; Tue, 5 Jun 2018 18:00:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D65BF308BDA1 for ; Tue, 5 Jun 2018 18:00:06 +0000 (UTC) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0041.outbound.protection.outlook.com [104.47.34.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9371581DF4 for ; Tue, 5 Jun 2018 18:00:04 +0000 (UTC) Received: from wsp141597wss.amd.com (165.204.78.1) by BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 5 Jun 2018 17:59:56 +0000 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:X-MS-Exchange-SenderADCheck; bh=4BwJSs+iSTySh+r3963UnlOzPsn/bu5gpogwczPd1ag=; b=KBg0/EpbYfjVRAH6g+FoFL8jnWKCAiC3TwAPCeurWg590NNnHMDOF1rFm+4JzwEB7uSXeJBCeFkB6dIVB+pHLwzKvm7n/nVqPO4inXgP8rbT8KmEuZTXzWL4/+P5AS/J77emvCqeo4wLbFKKauLvc2Y4hWdYgIjPgAnVzYixqDg= From: Brijesh Singh To: libvir-list@redhat.com Date: Tue, 5 Jun 2018 12:59:26 -0500 Message-Id: <20180605175932.62322-5-brijesh.singh@amd.com> In-Reply-To: <20180605175932.62322-1-brijesh.singh@amd.com> References: <20180605175932.62322-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0018.namprd05.prod.outlook.com (2603:10b6:803:40::31) To BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BL0PR12MB2452; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 3:51Nht6qrM5qhuFQ6ZI+sFa+x1OQzpJs+5Jv8xBfwgcVEgE1nFV4F4nj+SH1PCd0+AI5DnUe/qvokz1mcjzz8nSXIn72800Gfet/BxpI3mwn0kQF84C7qNJJ5GMVitEkfmt/VjHUxKm48xhvgo+rtZuFSzMWLeU0sYV/5N0Z72fcex/B1EfUb5b2PufyeRyM7RECKCO93Y8VxnxH3yTf2QkWl8H3/M7hqwUo3ZgHt3ZSThy1X9yLDZ2DVctwSqwuj; 25:xVImh2pli/qVqNMB2CY/Jc3LOPF+subYbNuJJSWzlWoGkHjw8vER8c8WBjj4QwtbnnOKpO54ML5GitizDhThoN8AAcm+Ljjh+B8d8WG2G+LQFdF54r+c6rmnaMR4F4NkbVbWpz2dcNe4LW/H76UxG7Dtn2HbaC9vauA7re+dUnWKTr3Pg4hQcgK4cFAtVyPzUTstRCTzHXegxK55xet/u0TYKYIxcwm8QmdRA5KsejMix65guP6m2wkSlEpoYx01dsmcqlYcfbXOgtxPkkNSOFX8Zdfmrva/PgAu1tm6qpYKY4SqrJNhK2MKFzVzzKbd3ih96KJmCWpj1hATVc8tZw==; 31:24pREyin0khlnYt5lRpQZQ9gVouJENuA7U4udckgZU7prvp5Xa6ZlwmNr1KWA+u05ly14yNXbrlAevOSfudNxzdQx1cXm8kTE2QdxWeIsmbxJDb6/Q/6637+ZYpLbArVpRPdblRJK9GLxeS5/PJWO40td5xAhACRfUKYhdEzwokAdJobfw37yM1IQzKt9jE/wCeHuO4gR1bzokCLnfGuJccyAxAKjfNOQZ6q2hTLvBg= X-MS-TrafficTypeDiagnostic: BL0PR12MB2452: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 20:lMkQhBHs1WtPW0+k4HZvSXrDvQ4m9aqZPz2sp4cOWtw3mfe233UoS62huS4eTskBNLI4mWosq7fiZ917URqHy7uKjnw2cjlg05IRDetaAZR9DPwMmhw2kFTmdLd+Vai1YBASG+6t1zHc2jA0Tpp1jb9RqqbBewIODWnN2yZSOATrnecL2QmF8bkFQoZ7K/CMBOzlKs6FwvEsQTI2o7kX3mLBr3HSPeCPJLbWNOI0S7n0/eTat3WAvtDyx4/549ZPTawyDYG9uPn0DLiN0PHNb1Rvsy+eibqKzC5Q92Mlzwhup2emvQg9ukyismEx0sxV4CAzJwLpRf7o/3jmIh5G4PhVnBaYxmWaqwvAIYYO91CD15TkysFQ+EJZ1OXlv+VZA3AV2LhkdHuskD4Ws74jEeoehl+dMd0BrAK7ydfABWkm9mfeAR9bFnJcOWuwv1/X+lqWMKOed5sjIoig/Ne9kWZCnbJiovb0SlQvKCjkHogHXuVSgyJt7hYo31zRXHQW; 4:gpSrRAf3UK1K2rfBVP/O8Ne6iwGLihnE7sRQACeyvVibFquxz+Q3dA90i2PK6V72zljVYjW6Zs7EysTwu8m7kOI1WwaAcaBT/kqNecsN2pWjd1wQ5X3SqHN2OZBdDtRzMQ/VLgZZUIJbfAmm5ttNae4+T9L5zl5VttEmO4tWZueppg36NowjV4L89dz31cn4zqtualHz3YF/JLXaEGWvr/obByIW0nZdZG+5KWqcTF5l+tzlZZ2C95u513bcxEeVh1npZHcXXTRMCeytYKH/7WyHgPeQGpUIhhlTyKkh6LgCZ7y9QkDD+1GWt8PxN5hPYCeCvdyjFO7DVXrehBb6UWt3nM76W5cSrViEiKv6n0mFIqPLoYSMPFwzE83pt+ps X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863)(767451399110)(21532816269658); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:BL0PR12MB2452; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2452; X-Forefront-PRVS: 0694C54398 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(6916009)(1076002)(59450400001)(7696005)(2361001)(386003)(106356001)(2906002)(52116002)(53416004)(4326008)(68736007)(105586002)(8676002)(81156014)(76176011)(6486002)(2351001)(25786009)(81166006)(54906003)(36756003)(6116002)(3846002)(97736004)(47776003)(50466002)(6666003)(7736002)(44832011)(305945005)(26005)(51416003)(956004)(446003)(476003)(50226002)(86362001)(486006)(2616005)(575784001)(16586007)(478600001)(8936002)(66066001)(11346002)(53936002)(186003)(16526019)(5660300001)(316002)(48376002)(145543001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2452; H:wsp141597wss.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2452; 23:D8XJh4XDk0e/ELzC1BXymilhAE+clIqjDNdSoYD3A?= =?us-ascii?Q?9Od+N2wGCMjyfuYz+Ku7RhDKdV1EsNcbmoHiJ9G+LYiHKGzG8EOkXTOVYoSy?= =?us-ascii?Q?6mAGWbuMI2NjHUuHMJcaxGU3HJei6HSp8IhrSx2wEL/4m7Dpw2NzM0cARxJm?= =?us-ascii?Q?mlElHdSszrb3dwv/6H8ur3LZDeH2eq8eb5ipCyOZQVAO/S7nImKgWvb+wBbc?= =?us-ascii?Q?ZnX4rThzQMPtW8UvdviOStEfX4mduIYGXC6p3YlHRfSBHphH+QMrRgXaGJP2?= =?us-ascii?Q?WyAD2qaICBDgEZAIF/CI3TcmQx2wLRw9/2zBeaqSuu2O50MnCI9LB7bJJODu?= =?us-ascii?Q?gcUbLPJFKpVKjIrBk2rA6nCAZNiYCSWcDPN/7pzsegBa15iXFaexmyR+M9hf?= =?us-ascii?Q?2sDtSxeLAvk3SQ4yuV0qRingoFJZFZHvkxoY5A/6j2BlIglbRka0GCeJ8j1/?= =?us-ascii?Q?8Lqmxh8ddC1SzNhWgbCCYxfqyAcNTAhW1oe6VrJCF1Kt6ZoyZEu4GeD/Jh6w?= =?us-ascii?Q?8LUt9prZGUut923jBN2n/xvWGFIvjzViiT+Vzz2GLA8KzfKnQ5tiyNE3qK8w?= =?us-ascii?Q?Lzsa2jBIw2sEC3ye3Tba4eskR/OuYe/fA0ElZMl76gNAhOLzQgq1uWbFJLfq?= =?us-ascii?Q?z0qq4ltY0R7sfxPc8YYVlpk9jv5+CbIPoo5/x3ottVwQDjWcxZYX7EusfzMG?= =?us-ascii?Q?uG2AOiAwRG6rql4fCjB6lBBxUo3WaDcolqWCsADZ6x2f+TeBfT0hAx9IDdJx?= =?us-ascii?Q?jY9EAbViggXWNA4ZF7AeC4k9mFNXK6wvVpFMPV9TboD2oKrEWfGQkVAJ9e80?= =?us-ascii?Q?AmjkzGlCoA3gIgwz9S7JzaQJDzxNRPsaZUQpImhbXat872Vk47IMqqj3zoEf?= =?us-ascii?Q?KnFr3yYQhtAJDfM5qHJvReQgi411qvPCHas0IXhEW3fNEssaUHJ4lHwvWxbM?= =?us-ascii?Q?JWbnqz5q6xu9iMxUNfsPvVvVM6N1go9qnIDRcvxZI8a4ZehuaJpRO7bKfEeK?= =?us-ascii?Q?KHZTBkWl7prut+bpzN3J76IXdObwgblYVdfrSY0nJrvoiFJ37krrXuhyPls2?= =?us-ascii?Q?M+k5/TC4wpNfsT5A/m8I2K6MGWlBbSzFhuJCe8NGN0G0zK+r9h6HEq5Sdmh2?= =?us-ascii?Q?Lh0LnlVvpKzsnS+scmNIYWTQDXklLtfZ5ViTjwFeWDRyH1lUenSWk4UIMAiq?= =?us-ascii?Q?d7Gl8NXM6TJ+nDq83Xp2PQVnUmXeWOhnq37XzHmwRDWCTC20SUr+GNlgZE44?= =?us-ascii?Q?Qf7Kjm4KpU8xL7tJxxFR6USl90eaPgAZwuOE4A49cYSh+t9JVaFSGwvwQpsE?= =?us-ascii?Q?+CZ3y2B0YXWGt7vNnW2sQABMlBW0Ph905spN8g4pfmrG/6Xg0m/S5VYjmL7Z?= =?us-ascii?Q?QvnoQ=3D=3D?= X-Microsoft-Antispam-Message-Info: 7f0NohgqHP3lC3RLrhkcsZEM/et3WeNdYlpEuUZPUCSW9GpFOZxxJZYe9djo4MmaC71SFSWCK3soDpFbxrQOe3C6DuUHpmqOP5uxHMC8kLxDFfkyNcr8LQLhMn17WV10rBlkdLZRmCG76hbvp7WJUnXe8mLtXyCR+2i3WhYukxR8c/Jxlkfcr2DceraeqNwv X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 6:lRgT8gtPmqei9+ONJ/leD5ecLBa94KjvOmiZpnmbQZnDPZbXVGmn5U31YnwV69jGJXYsODeIOA9TtZ8Gkc0/dV3hnBAtxalIrQSD+aHFmmEVOLYGTHOXpjKSVemSYhnRCbkFQfyAFKDWYxQolURSMFwxYgX+B3ynLj6bijB7JPz0tYhTTQfG/q4coo83j47BnFyU638b/JPny3kK4azem3w0HXuZdwkUeK4xJf76yzEBBOVOWbmF5qK3soCry/5V09pGNhkw6Hpq8uwrxY6J9XUSOSXVHF5N929H2t7Zfs4CKaFPxdmXboLUdw7WY7yvCIsbp4eXlENPn7C3BpNIH/4SmwGgtebnW8KY6J40tfmnIh5jSgh9LttCjI/HYI3jtw7coJAFfN1gx8yHox95AU+U+h0ZnhT+kWULmWyUQY+e6Wq+3O2XCv96daCZkH9M8pJ24W2rj0IuAplAF8bYFw==; 5:VzgRASmefhFIeKQt/LfgYnWDfliDa6YJHvhYhqj2dRfAnjaUv/xxhjLVvWGxSenx86PX+Um62nNKrOn5CyHCVFIJFDA6gSTL/KgoUABZKvoNe4ldAMWiOd0lwPucB7uqdB7Wn/Qq0zsNnm/sVgBNnmq1oEjGyZAZKtomwB4SeGE=; 24:s6FCk//yo7T+0OlLnxyErqrfVtSHOKZVF28w+e2Lr4FjyaE8E8sil7rfcH8K92ZWsj97YR8CjmpKKAv2hzrkRo+dWKI0W4Bvg0r8x+0JZcw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 7:5O0Z2G9vYHMOekD0kn1p9HRcTNU6iGXCOjKjOT6fpB+Amz5m+oE01KidXV2bcj/rsZoNT5gCImMSopGsOOs3U49ClTFZzbDdHKiv83LwLMT8vJCtMbZ6amgvZWtqaiawAebYr2QXyxMwZdZ7mN6Qj3TaOcr9zVW4/nKkzXSW0lbOVn7w6Zvzkm3tvKCPhqPIT0hMvHdY5D/eibGbAQdwxTUJjfWKFZYAJTAPQQrz8puefas8OgeNKuSdhFRFBQCB; 20:S8rtBfc2NqMpwQX25mt/XG5iBsVP81X58ilf5Cs/b3iupGMDL1X0jmoqJvTFaCmxbn76cdmqnjxeEVA+yz0wgrWZEOUYRBBUuUnV8OTHFfejtw8/zH8H8hNvCOrUko8PeaYFZwy1f79njjbkg9p3HiWYF1SHBr3GICTEJAWISJoRUnElWBCFMGsjq8u5GVWklx9ysZ4I7Psps8PWgRKp/kUloNObpjhikR5dXfQJ66IHj6nNFay2zCiN83cbIFjT X-MS-Office365-Filtering-Correlation-Id: ad949ae2-9d02-4804-472e-08d5cb0e25d8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2018 17:59:56.3201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad949ae2-9d02-4804-472e-08d5cb0e25d8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2452 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Jun 2018 18:00:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Jun 2018 18:00:05 +0000 (UTC) for IP:'104.47.34.41' DOMAIN:'mail-by2nam01on0041.outbound.protection.outlook.com' HELO:'NAM01-BY2-obe.outbound.protection.outlook.com' FROM:'brijesh.singh@amd.com' RCPT:'' X-RedHat-Spam-Score: -0.021 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIMWL_WL_MED) 104.47.34.41 mail-by2nam01on0041.outbound.protection.outlook.com 104.47.34.41 mail-by2nam01on0041.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: Tom Lendacky , Jon Grimm , Brijesh Singh , Borislav Petkov Subject: [libvirt] [PATCH v7 3/9] libvirt-host: expose virNodeGetSEVCapability API X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 05 Jun 2018 18:00:14 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The API can be used by application to get the SEV capability (which includes platform certificate chain and other releated information) Signed-off-by: Brijesh Singh <> --- include/libvirt/libvirt-host.h | 42 +++++++++++++++++ src/driver-hypervisor.h | 6 +++ src/libvirt-host.c | 48 +++++++++++++++++++ src/libvirt_public.syms | 5 ++ src/qemu/qemu_capabilities.c | 7 +++ src/qemu/qemu_capabilities.h | 4 ++ src/qemu/qemu_driver.c | 91 +++++++++++++++++++++++++++++++++= ++++ src/remote/remote_daemon_dispatch.c | 44 ++++++++++++++++++ src/remote/remote_driver.c | 41 +++++++++++++++++ src/remote/remote_protocol.x | 22 ++++++++- src/remote_protocol-structs | 13 ++++++ 11 files changed, 322 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 84f4858..d020597 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -432,6 +432,48 @@ typedef virNodeCPUStats *virNodeCPUStatsPtr; =20 typedef virNodeMemoryStats *virNodeMemoryStatsPtr; =20 + +/** + * + * SEV Parameters + */ + +/** + * VIR_NODE_SEV_PDH: + * + * Marco represents the Platform Diffie-Hellman key, as VIR_TYPED_PARAMS_S= TRING. + */ +# define VIR_NODE_SEV_PDH "pdh" + +/** + * VIR_NODE_SEV_CERT_CHAIN: + * + * Marco represents the Platform certificate chain that includes the + * endorsement key (PEK), owner certificate authority (OCD) and chip + * endorsement key (CEK), as VIR_TYPED_PARAMS_STRING. + */ +# define VIR_NODE_SEV_CERT_CHAIN "cert-chain" + +/** + * VIR_NODE_SEV_CBITPOS: + * + * Marco represents the CBit Position used by hypervisor when SEV is enabl= ed. + */ +# define VIR_NODE_SEV_CBITPOS "cbitpos" + +/** + * VIR_NODE_SEV_REDUCED_PHYS_BITS: + * + * Marco represents the number of bits we lose in physical address space + * when SEV is enabled in the guest. + */ +# define VIR_NODE_SEV_REDUCED_PHYS_BITS "reduced-phys-bits" + +int virNodeGetSEVCapability (virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags); + /** * virConnectFlags * diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index aa99cbb..cb2ab9c 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1309,6 +1309,11 @@ typedef int unsigned int action, unsigned int flags); =20 +typedef int +(*virDrvNodeGetSEVCapability)(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags); =20 typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1558,6 +1563,7 @@ struct _virHypervisorDriver { virDrvDomainSetLifecycleAction domainSetLifecycleAction; virDrvConnectCompareHypervisorCPU connectCompareHypervisorCPU; virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; + virDrvNodeGetSEVCapability nodeGetSEVCapability; }; =20 =20 diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 3aaf558..6c47b69 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1639,3 +1639,51 @@ virNodeAllocPages(virConnectPtr conn, virDispatchError(conn); return -1; } + +/* + * virNodeGetSEVCapability: + * @conn: pointer to the hypervisor connection + * @params: where to store SEV capabilities; output + * @nparams: pointer to number of SEV parameters; output + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Get the SEV host capabilities, If hypervisor supports SEV then @params + * will contains PDH and certificate chain. + * + * Returns 0 in case of success, and -1 in case of failure. + */ +int +virNodeGetSEVCapability(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + VIR_DEBUG("conn=3D%p, params=3D%p, nparams=3D%p (%d), flags=3D0x%x", + conn, params, nparams, *nparams, flags); + + virResetLastError(); + + virCheckConnectReturn(conn, -1); + virCheckNonNullArgGoto(nparams, error); + virCheckNonNegativeArgGoto(*nparams, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + flags |=3D VIR_TYPED_PARAM_STRING_OKAY; + + if (conn->driver->nodeGetSEVCapability) { + int ret; + ret =3D conn->driver->nodeGetSEVCapability(conn, params, + nparams, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 958601b..438205f 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -792,4 +792,9 @@ LIBVIRT_4.4.0 { virConnectBaselineHypervisorCPU; } LIBVIRT_4.1.0; =20 +LIBVIRT_4.5.0 { + global: + virNodeGetSEVCapability; +} LIBVIRT_4.4.0; + # .... define new API here using predicted next version number .... diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5db444c..82aec96 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2080,6 +2080,13 @@ virQEMUCapsSetSEVCapabilities(virQEMUCapsPtr qemuCap= s, } =20 =20 +virSEVCapabilityPtr +virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps) +{ + return qemuCaps->sevCapabilities; +} + + static int virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index ad25e6c..630ce77 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -615,4 +615,8 @@ bool virQEMUCapsGuestIsNative(virArch host, =20 bool virQEMUCapsCPUFilterFeatures(const char *name, void *opaque); + +virSEVCapabilityPtr +virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps); + #endif /* __QEMU_CAPABILITIES_H__*/ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c200c5a..0fb1aba 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21438,6 +21438,96 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, } =20 =20 +static int +qemuGetSEVCapabilities(virQEMUCapsPtr qemuCaps, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + int maxpar =3D 0; + virSEVCapabilityPtr sev =3D virQEMUCapsGetSEVCapabilities(qemuCaps); + + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); + + if (virTypedParamsAddString(params, nparams, &maxpar, + VIR_NODE_SEV_PDH, sev->pdh) < 0) + return -1; + + if (virTypedParamsAddString(params, nparams, &maxpar, + VIR_NODE_SEV_CERT_CHAIN, sev->pdh) < 0) + goto cleanup; + + if (virTypedParamsAddUInt(params, nparams, &maxpar, + VIR_NODE_SEV_CBITPOS, sev->cbitpos) < 0) + goto cleanup; + + if (virTypedParamsAddUInt(params, nparams, &maxpar, + VIR_NODE_SEV_REDUCED_PHYS_BITS, + sev->reduced_phys_bits) < 0) + goto cleanup; + + return 0; + + cleanup: + return -1; +} + + +static int +qemuNodeGetSEVCapability(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D conn->privateData; + virCapsPtr caps =3D NULL; + virQEMUCapsPtr qemucaps =3D NULL; + virArch hostarch; + virCapsDomainDataPtr capsdata; + int ret =3D -1; + + if (virNodeGetSevCapabilityEnsureACL(conn) < 0) + return ret; + + if (!(caps =3D virQEMUDriverGetCapabilities(driver, true))) + return ret; + + hostarch =3D virArchFromHost(); + if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, + VIR_DOMAIN_OSTYPE_HVM, hostarch, VIR_DOMAIN_VIRT_QEMU, + NULL, NULL))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot find suitable emulator for %s"), + virArchToString(hostarch)); + goto UnrefCaps; + } + + qemucaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + capsdata->emulator); + VIR_FREE(capsdata); + if (!qemucaps) + goto UnrefCaps; + + if (!virQEMUCapsGet(qemucaps, QEMU_CAPS_SEV_GUEST)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support SEV guest")); + goto UnrefQemuCaps; + } + + if (qemuGetSEVCapabilities(qemucaps, params, nparams, flags) < 0) + goto UnrefQemuCaps; + + ret =3D 0; + + UnrefQemuCaps: + virObjectUnref(qemucaps); + UnrefCaps: + virObjectUnref(caps); + + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -21661,6 +21751,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainSetLifecycleAction =3D qemuDomainSetLifecycleAction, /* 3.9.0 */ .connectCompareHypervisorCPU =3D qemuConnectCompareHypervisorCPU, /* 4= .4.0 */ .connectBaselineHypervisorCPU =3D qemuConnectBaselineHypervisorCPU, /*= 4.4.0 */ + .nodeGetSEVCapability =3D qemuNodeGetSEVCapability, /* 4.5.0 */ }; =20 =20 diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 81d0445..f974b71 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -5001,6 +5001,50 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr se= rver ATTRIBUTE_UNUSED, =20 =20 static int +remoteDispatchNodeGetSevCapability(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client ATTRIBUTE_= UNUSED, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_node_get_sev_capability_args *ar= gs, + remote_node_get_sev_capability_ret *ret) +{ + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + int rv =3D -1; + struct daemonClientPrivate *priv =3D + virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + goto cleanup; + } + + if (virNodeGetSEVCapability(priv->conn, ¶ms, &nparams, args->flags= ) < 0) + goto cleanup; + + if (nparams > REMOTE_NODE_SEV_CAPABILITY_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); + goto cleanup; + } + + + if (virTypedParamsSerialize(params, nparams, + (virTypedParameterRemotePtr *) &ret->param= s.params_val, + &ret->params.params_len, + args->flags) < 0) + goto cleanup; + + rv =3D 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + virTypedParamsFree(params, nparams); + return rv; +} + + +static int remoteDispatchNodeGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNU= SED, virNetServerClientPtr client ATTRIBU= TE_UNUSED, virNetMessagePtr msg ATTRIBUTE_UNUSE= D, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3be30bd..cdc9a70 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -6776,6 +6776,46 @@ remoteNodeGetMemoryParameters(virConnectPtr conn, return rv; } =20 + +static int +remoteNodeGetSEVCapability(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + int rv =3D -1; + remote_node_get_sev_capability_args args; + remote_node_get_sev_capability_ret ret; + struct private_data *priv =3D conn->privateData; + + remoteDriverLock(priv); + + args.flags =3D flags; + + memset(&ret, 0, sizeof(ret)); + if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_SEV_CAPABILITY, + (xdrproc_t) xdr_remote_node_get_sev_capability_args, (char *)= &args, + (xdrproc_t) xdr_remote_node_get_sev_capability_ret, (char *) = &ret) =3D=3D -1) + goto done; + + if (virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.params.= params_val, + ret.params.params_len, + REMOTE_NODE_SEV_CAPABILITY_MAX, + params, + nparams) < 0) + goto cleanup; + + rv =3D 0; + + cleanup: + xdr_free((xdrproc_t) xdr_remote_node_get_sev_capability_ret, + (char *) &ret); + done: + remoteDriverUnlock(priv); + return rv; +} + + static int remoteNodeGetCPUMap(virConnectPtr conn, unsigned char **cpumap, @@ -8452,6 +8492,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainSetLifecycleAction =3D remoteDomainSetLifecycleAction, /* 3.9.0= */ .connectCompareHypervisorCPU =3D remoteConnectCompareHypervisorCPU, /*= 4.4.0 */ .connectBaselineHypervisorCPU =3D remoteConnectBaselineHypervisorCPU, = /* 4.4.0 */ + .nodeGetSEVCapability =3D remoteNodeGetSEVCapability, /* 4.5.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index a0ab7e9..a4e1166 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -253,6 +253,9 @@ const REMOTE_DOMAIN_IP_ADDR_MAX =3D 2048; /* Upper limit on number of guest vcpu information entries */ const REMOTE_DOMAIN_GUEST_VCPU_PARAMS_MAX =3D 64; =20 +/* Upper limit on number of SEV parameters */ +const REMOTE_NODE_SEV_CAPABILITY_MAX =3D 64; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; =20 @@ -3480,6 +3483,17 @@ struct remote_connect_baseline_hypervisor_cpu_ret { remote_nonnull_string cpu; }; =20 +struct remote_node_get_sev_capability_args { + int nparams; + unsigned int flags; +}; + +struct remote_node_get_sev_capability_ret { + remote_typed_param params; + int nparams; +}; + + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6187,5 +6201,11 @@ enum remote_procedure { * @generate: both * @acl: connect:write */ - REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU =3D 394 + REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU =3D 394, + + /** + * @generate: none + * @acl: connect:read + */ + REMOTE_PROC_NODE_GET_SEV_CAPABILITY =3D 395 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 0c4cfc6..7705821 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2907,6 +2907,18 @@ struct remote_connect_baseline_hypervisor_cpu_args { struct remote_connect_baseline_hypervisor_cpu_ret { remote_nonnull_string cpu; }; +struct remote_node_get_sev_capability_args { + int nparams; + u_int flags; +}; +struct remote_node_get_sev_capability_ret { + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + int nparams; +}; + enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3302,4 +3314,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_DETACH_DEVICE_ALIAS =3D 392, REMOTE_PROC_CONNECT_COMPARE_HYPERVISOR_CPU =3D 393, REMOTE_PROC_CONNECT_BASELINE_HYPERVISOR_CPU =3D 394, + REMOTE_PROC_NODE_SEV_CAPABILITY =3D 395, }; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 13:20:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528221622421575.2782695412328; Tue, 5 Jun 2018 11:00:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90047C057F93; Tue, 5 Jun 2018 18:00:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC03F608F6; Tue, 5 Jun 2018 18:00:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 73F2C4CA82; Tue, 5 Jun 2018 18:00:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w55I09LD029032 for ; Tue, 5 Jun 2018 14:00:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA54A30012D0; Tue, 5 Jun 2018 18:00:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0DB03001A5F for ; Tue, 5 Jun 2018 18:00:07 +0000 (UTC) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0085.outbound.protection.outlook.com [104.47.34.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF317AC96 for ; Tue, 5 Jun 2018 18:00:05 +0000 (UTC) Received: from wsp141597wss.amd.com (165.204.78.1) by BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 5 Jun 2018 17:59:57 +0000 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:X-MS-Exchange-SenderADCheck; bh=b3Yd4oKaATkstQueETViD8/ddNL9QY8dKxyKqE4CbCI=; b=rgePjDQZerrYvq4Koj0EHJPNA5MAX2eGNY9oWhPXqY5+P4Isz8ncgTMOWQi5SXf7vqZxHxknrVNRt5X5eNZhe2EyrIJOVW67wsbXkvF71+GoHs3Vh+2InY5f7EbnYjWl8GftdzyyZDcSzPhBcrEOV3+lQGlTmvOu4NOv8J/qqeg= From: Brijesh Singh To: libvir-list@redhat.com Date: Tue, 5 Jun 2018 12:59:27 -0500 Message-Id: <20180605175932.62322-6-brijesh.singh@amd.com> In-Reply-To: <20180605175932.62322-1-brijesh.singh@amd.com> References: <20180605175932.62322-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0018.namprd05.prod.outlook.com (2603:10b6:803:40::31) To BL0PR12MB2452.namprd12.prod.outlook.com (2603:10b6:207:4e::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BL0PR12MB2452; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 3:8Fib1+HZ0sPZAwWSrnMkagfYnUB1omJvV11By+euQw+xcCfngYC0HObuc+H2uVQ8jNQOPTMenrGsl+KJQTKMYFFI2ydBggpa2UP+vZh4RZq/ZFPy9mphgVAQqlb389Hkdr9JXtJ1nJBoCn0tImar6Ko9FUIDhVfkpY3yspoyiB2bkd2bVxhh56EZ5cRrksZtg7hKErgnKgkwH2YkdFcN+EgFAK6rPfYEMAP2Jy3CKWRKx1dnoE03CpsqE8davail; 25:mg/IwoN3rWqUMg2ELMWWX0IRZdzg0jQgBLycD4f7rQZEUXpKWXul2EKeRLn65u7mcsnoWCoVsHb6Q3bxW6njJa/ytYWEPMT3bK0bv2RpsGrE7j84XZ1iOBc6yK11K1hjatvZEWLYkBik8VjY3cFdj8Cbk5bXj11xQVVCc30vyQNMRO3zCKRx/Iwu48YjKw0h4RHz48rYRX+z/LrSI+Tx5uDNk9solLfwPX3Hu1Fx15GjKWt1nXxNn8PuUqJCvaP36DFCRh2pDClM2dO6VJQDyrTSCExi4yJ2rLqx0oAGEwd+zxE/25GqvhLMQwJYAQ4hItsmXlmZjb9r6yYNs8y6DA==; 31:Z03523gY/E1Hc9pdhuLlanjFc2FBG9HKu4FHqntblIdih7u7ctu3dmTb6G1eRLy9+Vnuin9wrBLjgenkUydhJi+abokTR52OEVrKxmITzz19yEQworl2na8folpRoRL4zOobV9x0JlccqFqoeK5xhprnHRmVrfFJwWQfig6l+1UBYbarxHnWLHrpAQ6oKulVC/M7lI//nnpgmE9u4rhzj2Mh7f7J56nCO5BD8V+JI5Q= X-MS-TrafficTypeDiagnostic: BL0PR12MB2452: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 20:f5NgakgeG4dWXGrBOzhZa451TNudkNIkteHnf5+9CfaElzk+vc6DkEcJ2/I/zSzovXWs6rNwryzjff/S0tEAoaDc8IUn57hGm2LtQAjyY1CG/iSLFj/Uf7/vEPblo0NCtJPh+TNLuRYH1eheeal1V+R3xGejMzAdl31skjdUgXFfLRAzXn/CFuaK91kvGUyGWrHa8vZFSaqZF3+4AGwLBzxa12kpZStZD32Q9CkQhjE9BqmFhBwSiD/ENeMqnmS7bcznkv96ku7/XugMYRJ3v8R6mU4fnnrBbYkprwhZ0srbYKXFRQwh+LqlLWj6tSMLlKJpyR//vnI2NkiXgff3elMZBOM17UX1OSbrHeQWkJV8VQqIVY9ITTgJxXeHok8TnHRDh70OsWRcxMu6fKmzcrUSypooJ2Tt7RS0YkrDZQwLhRM83YbDrf57q8N6NLz1/RhNcJ9r8FWnifnbjtpvTkQQWKkKIrhnJ/TE/mqicB4DJS3FxAcnsd0tUituD39v; 4:pkk8IpsoUVccbGVkjeq6hEt+7lRu4wZCl5lzbA/ZAfb2jd0upkMckWS3eVC5zJuV0q4ecgKNt/Qk8HrtwFi/B6JnBkk/G16+PQTglXg9DXfazyrIDaJSxGekHloaSSv0uRDUCOb8neFWCcnPFDEsEecbPhwKu5DIZShMcwrHr8Atw4ykEejMosTBTPXQ7RjONecQU7I3bgYGZHxTRgzB+jZDG3PADg5ZzcIt0YJWQxLWXzawgw+tYB31Wrddt1TSNGC4i8feEQV1h3GjH+sYKzLr4edggp/G3efY5dCGqNDrbu3b/mHTjCo4b6KLda4IuCm3iL+Lpp1azk1kYmz70EesCZBRbTLhzC6Uky8mKT4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:BL0PR12MB2452; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2452; X-Forefront-PRVS: 0694C54398 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(15404003)(6916009)(1076002)(59450400001)(7696005)(2361001)(386003)(106356001)(2906002)(52116002)(53416004)(4326008)(68736007)(105586002)(8676002)(81156014)(76176011)(6486002)(2351001)(25786009)(81166006)(54906003)(36756003)(6116002)(3846002)(97736004)(47776003)(15650500001)(50466002)(6666003)(7736002)(236005)(44832011)(305945005)(26005)(51416003)(956004)(606006)(446003)(476003)(50226002)(86362001)(486006)(2616005)(16586007)(478600001)(8936002)(66066001)(966005)(11346002)(53936002)(186003)(16526019)(5660300001)(316002)(48376002)(6306002)(44824005)(19607625011); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2452; H:wsp141597wss.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2452; 23:WaGV4KF+nCi85659Fpv2cD/RkHFhduTCmg/KLSmNf?= =?us-ascii?Q?6dpCT0QNbQsAADX3e6G7QgeJcILgdddZEwymiBGHFmfhZvteVV55k+FdCuHX?= =?us-ascii?Q?8WBWpYfZK8GxgH3hrS7DnPnJZHbB9uYcpIWM3dZxhQHfjYZYyKaVwMH9NmQ7?= =?us-ascii?Q?/YXg9KyY+bVnbBekrjXGd7cEgY+ddFAgu9Qoko4Ev8epBQ23Unob0NCNAM0K?= =?us-ascii?Q?ki+7SzL0s+naw+XwSEGiS5PXUtLavpNQRE+FDY+BesE3lSRcR66ev1RY5GIi?= =?us-ascii?Q?Ukv8R9bZ36gX3AbwPGg5OkT1yKWD6IycoMGhBqPx8BW6ymVAP7+Rt2LYUzTP?= =?us-ascii?Q?WOGw1tNgGLiGNPBYpBaGD/f9k21/n7Ex5fXUjiv6/JxA6HwzhDIO/mkyC8Ub?= =?us-ascii?Q?NVFInDu+rSBPOVMzIrlW4HhAkBodpWVekfNUrlFDRZbJ3sPTPIfAhEwyhfO1?= =?us-ascii?Q?3hUst3dGYB006bm7SHmoIOk7/eZjfjlxI4vKTFjuxn9YjZXp3CYiNX/CNy5h?= =?us-ascii?Q?pUq7+KrfRnj/PEzaGSPPtnA9M3OFeSoj3H67f3KuleUon3NDBhk1WAcj4OL+?= =?us-ascii?Q?fM7OCD3z4AZDaVYGNA4bvBWfDNMzf5602v9rznugTYRSHJZ/8+miEH2pvLs8?= =?us-ascii?Q?y4viwrqNVDY/bsOEoSfrQmRRYwlqEc55LRlTTAR+8CqeMPaK9TLiYVxnb6lx?= =?us-ascii?Q?51uP/dW4HaugB4J46j9zIU+ZNi0pSU7Rf+4MYsYLD2lkhMA6XwLoU81bGZWq?= =?us-ascii?Q?ljygTufDejA6ykxsL0RMJV7a9zzHB0BfM+dlJzAxmRtaFbD1TVuJphvI01nQ?= =?us-ascii?Q?s1OfVZDrD9z7t+72o54ipv/koDkZraKmCqgkP7QjZ/RyQzsKP45hVh7F/25m?= =?us-ascii?Q?GPVOW9H7xC7DqYrPQGLyWTYxS5IuIU5HhUApvX5kS4tMyX1XQU+p3R7y/kkR?= =?us-ascii?Q?f1cRchQib0unobZIG14QZoGxif5kliGU+nFaYvbZBvCX1EgVI+1mUUSYGwxM?= =?us-ascii?Q?SxnXF7U+1Gb5tXXOTqTNihmKjuTV1wWBeUypUH5hYBj62GNiOOSddLLdfdwQ?= =?us-ascii?Q?KiV8eQpnaT0jCzZNH6B5jqkWos0rFVjh4xlZoUhSsIdnbwREVFojkCh1KyIU?= =?us-ascii?Q?SfxJehG5RxQVsKjs76+k81wd7pRVQTMOFPhwWu0DKdQXKDWoSnxBlUXZxF8D?= =?us-ascii?Q?x798mmUvuwQ7zldxHFKR5zVpsOxwGgtzSN+S1SEWXUyibNb3zn4zFpS5NmdP?= =?us-ascii?Q?D/mJAd5OhOu5k77QxOv1L5C8gebR201S4Nz25UIgB0XpaA4PK5SahSe2sfO4?= =?us-ascii?Q?77KjahPmE52nVOp3xA39/EHRH+RPFSQOxfI5mkh58o71Dn/R1joJ7mzGvvWS?= =?us-ascii?Q?AcTEdWG+oa3I+uqKguPnhWPTDxqAPnYkJxTtVhMfLzwFbpxWEBSthkZkXxka?= =?us-ascii?Q?Ew8kxr2aqprhrpKkqIRnqllgpBIJIX4wu2jI0BQkwbYnr9bNF9A?= X-Microsoft-Antispam-Message-Info: 6xBJsq6qZ1o8NWaQBKJlekTfF7KmR3+DevwJ73QhQBYooCFsi2I6BgVEMLzQ6v7eH5siCRHGLCtVRQ0iiP/WqNIMdItP9HL5lrsA0mwZMniQQvCVQNNtGm4KjwVPzFJsRTLTBS60HYNAzX7M2Gn9gi6mfg82ctgwJsbE7Qds2af6yAW5inBRe4QzqeP7UzX2 X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 6:Yph+rdIQP97qCDD0y1kXEVtCNavhr0bL0RZfHRNOdOtVM1J4WRlRqIBZMiIjwmO8jbUaPJs8LbTjTlULyVYLvBxWP3b3HuLTY4iO0DUF1//Uh7Venh87su47Ex7/738F68pmg/AY8Wz6E64h5KClHz10PGfFIOA4eBwKZ5IQch5EdzoCjLXyhUCwBwyVuRCahU3x/Qp8JXkzocV+Mm8kevgue/6MNzyRKZovT49xcWXhwM8yUdengvs4NYzNw4czXSkBWNu1D/eaFENkUdjMClB5BXF8gpGSeawF1ZzP/YCRoa7GJbP5Nr+CO6Ylr9jDkXZIHi8IRVLiy00McOiKOoFPK+IKSsLXJQjnL4IBbzbnS66tyAA3AqYa/C9EFhwO71XmEfxBLensN0jUJIGY5Yqt+Lydncj4wJPGZDP7tf2d9Ao0PvY3DppvEvXUXFume4CvWvpngbEBNXD7k0uLPw==; 5:1uQai3db7KoiFjrJVZf4KUqHwq1f15H9A8L9VxNIOrYTF94YThOOJw4GrjvYi9kLGlp9X5fyyQ+JXi4OLA+fAstv07aQtUWlFUvuiEPEKumx1RnfqknFS9/d0oNHpHUfbKYLnw47N+HOv5pVhnlNk6WRbn75yvVDrEKIa/4m8fY=; 24:P0gN2k2YC9MhnPStu9QTTFguYWVcqWNyJd0jE3mqYgO7joMxzOzuctLgyKWwDUDPLW6lV6UMPNO1f4I45BZoGckFaHZVsLPBlzyfaiFyuuY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2452; 7:5eJNJJPeRzdtGwdpytIiUBJoFFjtEM24PmSEH8J2FrzxDRw8/RkQ+nFPz01NujIGNxFlNdraTI+YJ+UE6VW4uuo5Qox1KM45YFLqUD5R1o094I9ZYFvpDEveOSod1UKpRjAHcs9cx0lHW7Se55Ec8O0SVXU67g38jvpNm2oXp8UuAHJjZ+ndZV8gGOPu/cqu1TmQ3YH8UuFbdrBNiyFQPMzvDhzLj73HXR3FRGsqd1IsRQ+oTuOtRE63FmHJi5U7; 20:UTtkhAe7LQXeSKTbVVaIkMz+RimVlMLd0wWevRj+7KXONnGONgl7riojpYCFl241vHXSDftEnMlmLtpStBIs9p4kfZ1veR8+KztMaEv6zxZDHp8HAGvdfeRTIoOe3BiVD20fftQ1nEGnbyrDLax1k/mj7DNF09v7OHbHk8INZh0X1kh9Ps40Lx7UtRQYDttX0EszdakoiUvAZLnugLdTMcpwJthJQft+kFf4igtmMA0MLaz/eRVjulh3ysKjh8JM X-MS-Office365-Filtering-Correlation-Id: 87897822-d97e-44ac-5b1f-08d5cb0e2648 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2018 17:59:57.0506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87897822-d97e-44ac-5b1f-08d5cb0e2648 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2452 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jun 2018 18:00:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Jun 2018 18:00:06 +0000 (UTC) for IP:'104.47.34.85' DOMAIN:'mail-by2nam01on0085.outbound.protection.outlook.com' HELO:'NAM01-BY2-obe.outbound.protection.outlook.com' FROM:'brijesh.singh@amd.com' RCPT:'' X-RedHat-Spam-Score: -0.021 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIMWL_WL_MED) 104.47.34.85 mail-by2nam01on0085.outbound.protection.outlook.com 104.47.34.85 mail-by2nam01on0085.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Tom Lendacky , Jon Grimm , Brijesh Singh , Borislav Petkov Subject: [libvirt] [PATCH v7 4/9] conf: introduce launch-security element in domain X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Jun 2018 18:00:21 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The launch-security element can be used to define the security model to use when launching a domain. Currently we support 'sev'. When 'sev' is used, the VM will be launched with AMD SEV feature enabled. SEV feature supports running encrypted VM under the control of KVM. Encrypted VMs have their pages (code and data) secured such that only the guest itself has access to the unencrypted version. Each encrypted VM is associated with a unique encryption key; if its data is accessed to a different entity using a different key the encrypted guests data will be incorrectly decrypted, leading to unintelligible data. Signed-off-by: Brijesh Singh --- docs/formatdomain.html.in | 115 ++++++++++++++++++ docs/schemas/domaincommon.rng | 37 ++++++ src/conf/domain_conf.c | 133 +++++++++++++++++= ++++ src/conf/domain_conf.h | 27 +++++ tests/genericxml2xmlindata/launch-security-sev.xml | 24 ++++ tests/genericxml2xmltest.c | 2 + 6 files changed, 338 insertions(+) create mode 100644 tests/genericxml2xmlindata/launch-security-sev.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 7f4de65..decd854 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8367,6 +8367,121 @@ qemu-kvm -net nic,model=3D? /dev/null =20

Note: DEA/TDEA is synonymous with DES/TDES.

=20 +

Secure Encrypted Virtualization (SEV)

+ +

+ The contents of the <launch-security type=3D'sev'> element + is used to provide the guest owners input used for creating an encr= ypted + VM using the AMD SEV feature. + + SEV is an extension to the AMD-V architecture which supports running + encrypted virtual machine (VMs) under the control of KVM. Encrypted + VMs have their pages (code and data) secured such that only the gue= st + itself has access to the unencrypted version. Each encrypted VM is + associated with a unique encryption key; if its data is accessed to= a + different entity using a different key the encrypted guests data wi= ll + be incorrectly decrypted, leading to unintelligible data. + + For more information see various input parameters and its format se= e the SEV API spec + https://support.amd.com/TechDocs/55766_SEV-KM%20API_Specifi= cation.pdf + Since 4.4.0 +

+
+<domain>
+  ...
+  <launch-security type=3D'sev'>
+    <policy> 0x0001 </policy>
+    <cbitpos> 47 </cbitpos>
+    <reduced-phys-bits> 1 </reduced-phys-bits>
+    <session> AAACCCDD=3DFFFCCCDSDS </session>
+    <dh-cert> RBBBSDDD=3DFDDCCCDDDG </dh>
+  </sev>
+  ...
+</domain>
+
+ +
+
cbitpos
+
The required cbitpos element provides the C-bit (ak= a encryption bit) + location in guest page table entry. The value of cbitpos is + hypervisor dependent and can be obtained through the sev element + from the domain capabilities. +
+
reduced-phys-bits
+
The required reduced-phys-bits element provides the= physical + address bit reducation. Similar to cbitpos the value of= + reduced-phys-bit is hypervisor dependent and can be obtained + through the sev element from the domain capabilities. +
+
policy
+
The required policy element provides the guest poli= cy + which must be maintained by the SEV firmware. This policy is enforce= d by + the firmware and restricts what configuration and operational comman= ds + can be performed on this guest by the hypervisor. The guest policy + provided during guest launch is bound to the guest and cannot be cha= nged + throughout the lifetime of the guest. The policy is also transmitted + during snapshot and migration flows and enforced on the destination = platform. + + The guest policy is a 4 unsigned byte with the fields shown in Table: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bit(s) Description
0 Debugging of the guest is disallowed when set
1 Sharing keys with other guests is disallowed when set
2 SEV-ES is required when set
3 Sending the guest to another platform is disallowed when se= t
4 The guest must not be transmitted to another platform that = is + not in the domain when set.
5 The guest must not be transmitted to another platform that = is + not SEV capable when set.
6:15 reserved
16:32 The guest must not be transmitted to another platform with a + lower firmware version.
+ +
+
dh-cert
+
The optional dh-cert element provides the guest own= ers + base64 encoded Diffie-Hellman (DH) key. The key is used to negotiate= a + master secret key between the SEV firmware and guest owner. This mas= ter + secret key is then used to establish a trusted channel between SEV + firmware and guest owner. +
+
session
+
The optional session element provides the guest own= ers + base64 encoded session blob defined in the SEV API spec. + + See SEV spec LAUNCH_START section for the session blob format. +
+
+

Example configs

=20

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6379ab1..c6f3c7d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -77,6 +77,9 @@ + + + @@ -436,6 +439,40 @@ =20 + + + + sev + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +