From nobody Sat Apr 20 03:46:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1555027013; cv=none; d=zoho.com; s=zohoarc; b=DFebGtS1Kn9Xz9rdzsGWUFUaUTM9lIphr/MUnotYx90i87SgjJigV2+jcYnsnipqUFOQUVxEZU3ZCEkW0PhpbT0A+qyvRC/qdPvriip4HEloMf73kC3KWo1iVO6W4aInz/ti1JmN+8ReXNtVYxcx4//B2U34SPweNgCUQiZj7so= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555027013; h=Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=uLFzkXtQvhuNsfGT8YKqAYrpa4OelBWt3GM164npqjU=; b=Dl0C7gU339wKOhNA7G2wdT2lOaEiBBslpYYRXpsHN0pV2Uk6z5GW+U103DlNPHAckr28I6XXUOuTOjd6q8YrcP88JvhAakqtWJRCF4YyoqUl/d9/xk4//pPxs2+k7PJ/L1K3ZLRsE95sBCP/bN/cFQhB2wuwOcgtd2VfkFpri6I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=null header.from= (p=mdext6.amd.com. dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555027012911645.5741780838501; Thu, 11 Apr 2019 16:56:52 -0700 (PDT) Received: from localhost ([127.0.0.1]:56496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEjYg-0004b0-M2 for importer@patchew.org; Thu, 11 Apr 2019 19:56:42 -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 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 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= 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: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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-Type: text/plain; charset="utf-8" Content-ID: <8CE87D8491C0CC43A0A6F806EDDF16D7@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 Cc: Laszlo Ersek Cc: Erik Skultety Cc: Tom Lendacky Signed-off-by: Brijesh Singh Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Erik Skultety Reviewed-by: Laszlo Ersek --- 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 disa= bled +# (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)' } =20 ## @@ -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 =3D NULL; guchar *cert_chain_data =3D NULL; size_t pdh_len =3D 0, cert_chain_len =3D 0; - uint32_t ebx; + uint32_t ebx, ecx, edx; int fd; =20 fd =3D open(DEFAULT_SEV_DEVICE, O_RDWR); @@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =3D g_base64_encode(pdh_data, pdh_len); cap->cert_chain =3D g_base64_encode(cert_chain_data, cert_chain_len); =20 - host_cpuid(0x8000001F, 0, NULL, &ebx, NULL, NULL); + host_cpuid(0x8000001F, 0, NULL, &ebx, &ecx, &edx); cap->cbitpos =3D ebx & 0x3f; =20 /* @@ -516,6 +516,11 @@ sev_get_capabilities(void) */ cap->reduced_phys_bits =3D 1; =20 + /* + * The maximum number of SEV guests with SEV-ES disabled that can run + * simultaneously. + */ + cap->sev_max_guests =3D ecx - edx + 1; out: g_free(pdh_data); g_free(cert_chain_data); --=20 2.17.1