From patchwork Thu Apr 11 23:55:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10897087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F70E13B5 for ; Thu, 11 Apr 2019 23:56:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0816828E13 for ; Thu, 11 Apr 2019 23:56:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F05F728E1C; Thu, 11 Apr 2019 23:56:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D36CA28E13 for ; Thu, 11 Apr 2019 23:56:27 +0000 (UTC) Received: from localhost ([127.0.0.1]:56496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEjYQ-0004b0-Mt for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Apr 2019 19:56:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEjXc-0003dL-La for qemu-devel@nongnu.org; Thu, 11 Apr 2019 19:55:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEjXV-0001pw-3l for qemu-devel@nongnu.org; Thu, 11 Apr 2019 19:55:32 -0400 Received: from mail-eopbgr750079.outbound.protection.outlook.com ([40.107.75.79]:25504 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hEjXL-0001hc-SY for qemu-devel@nongnu.org; Thu, 11 Apr 2019 19:55:22 -0400 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=uLFzkXtQvhuNsfGT8YKqAYrpa4OelBWt3GM164npqjU=; b=Uq2uBbgYARw62ZIYiOn4kJNo7FczX7xmaviOP4jDXXDumMaPzDbht80R9wyhZEzYGx1hTR//wrvK6inQ9wQDKhN6YAI9DAzIAEOLxANZOVKPqWEOlS98gQEqJLudahbjuA0YQr2XSCfGlEh2uTVf429EpsiO79m6RwDFz4Ikytg= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2826.namprd12.prod.outlook.com (20.177.221.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.15; Thu, 11 Apr 2019 23:55:15 +0000 Received: from DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::9d54:69c5:d057:80de]) by DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::9d54:69c5:d057:80de%3]) with mapi id 15.20.1771.021; Thu, 11 Apr 2019 23:55:15 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v2] target/i386: sev: add 'sev-max-guests' field to 'query-sev-capabilities' Thread-Index: AQHU8MICSdEfZ1Yulk67b7vJ+MjSjg== Date: Thu, 11 Apr 2019 23:55:15 +0000 Message-ID: <20190411235456.12918-1-brijesh.singh@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN6PR2101CA0029.namprd21.prod.outlook.com (2603:10b6:805:106::39) To DM6PR12MB2682.namprd12.prod.outlook.com (2603:10b6:5:4a::31) authentication-results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2bd5e49b-323d-42fe-344e-08d6bed92492 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:DM6PR12MB2826; x-ms-traffictypediagnostic: DM6PR12MB2826: x-microsoft-antispam-prvs: x-forefront-prvs: 00046D390F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(376002)(346002)(39860400002)(366004)(189003)(199004)(97736004)(102836004)(52116002)(25786009)(2616005)(186003)(14444005)(2501003)(1076003)(256004)(386003)(99286004)(7736002)(68736007)(6486002)(8936002)(50226002)(71200400001)(54906003)(26005)(6916009)(71190400001)(6506007)(6436002)(305945005)(316002)(6116002)(8676002)(81166006)(3846002)(2906002)(106356001)(36756003)(476003)(81156014)(86362001)(105586002)(14454004)(66066001)(5660300002)(486006)(6512007)(5640700003)(53936002)(478600001)(2351001)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2826; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Nodjwer2n06y7HweUoJO0bhbVX9A3TvOnT1yOTev2OtRqFpn/FlhvRgSw2tWLvGxAFo6y8a4jvJHvgQ9D7gPQXb9iZnC4uUUSNgYC5bFzZj8NkFe7lZ76cIXQHPG/RBnaySc9goOQjglTDN7y5PxahEESxcvW8V0w8km+M0MVJlBKaIaGuU4wZu/+e+X9X1oL1mOU/V+JDw94oz63+sZsumYILHcsHF1lF6vlvIHxezlpELGA9ar+3SS93gufJwa4aaTZF+a7wkAawWVtKR/mW9/qxgaCk4IN0q1jJ1ADlMG3xAMffQc95C5uFYoMVVqCu+ohRD454sJmVTQ9bysljgywiYPUApcmh1J61qn/15VggbvOx29lXmwxY36ifg/OdJLa9NxlxnhJFwzJEH6b1TIL9jfprfpLTDdUS4I+2E= Content-ID: <8CE87D8491C0CC43A0A6F806EDDF16D7@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bd5e49b-323d-42fe-344e-08d6bed92492 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2019 23:55:15.6920 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2826 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.79 Subject: [Qemu-devel] [PATCH v2] target/i386: sev: add 'sev-max-guests' field to 'query-sev-capabilities' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Lendacky, Thomas" , Erik Skultety , Laszlo Ersek , Markus Armbruster , "Singh, Brijesh" , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available. Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information. Cc: Paolo Bonzini Cc: Markus Armbruster Cc: Eric Blake Cc: Daniel P. Berrangé Cc: Laszlo Ersek Cc: Erik Skultety Cc: Tom Lendacky Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek Reviewed-by: Daniel P. Berrangé Reviewed-by: Erik Skultety --- changes since v1: - document the new field and add (since 4.1) annotation. qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/qapi/target.json b/qapi/target.json index 1d4d54b600..8cd4fc7919 100644 --- a/qapi/target.json +++ b/qapi/target.json @@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ## @@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}} # ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability', diff --git a/target/i386/sev.c b/target/i386/sev.c index cd77f6b5d4..6829586fbe 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -488,7 +488,7 @@ sev_get_capabilities(void) guchar *pdh_data = NULL; guchar *cert_chain_data = NULL; size_t pdh_len = 0, cert_chain_len = 0; - uint32_t ebx; + uint32_t ebx, ecx, edx; int fd; fd = open(DEFAULT_SEV_DEVICE, O_RDWR); @@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh = g_base64_encode(pdh_data, pdh_len); cap->cert_chain = g_base64_encode(cert_chain_data, cert_chain_len); - host_cpuid(0x8000001F, 0, NULL, &ebx, NULL, NULL); + host_cpuid(0x8000001F, 0, NULL, &ebx, &ecx, &edx); cap->cbitpos = ebx & 0x3f; /* @@ -516,6 +516,11 @@ sev_get_capabilities(void) */ cap->reduced_phys_bits = 1; + /* + * The maximum number of SEV guests with SEV-ES disabled that can run + * simultaneously. + */ + cap->sev_max_guests = ecx - edx + 1; out: g_free(pdh_data); g_free(cert_chain_data);