From patchwork Thu Apr 11 17:59:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10896557 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 12B791515 for ; Thu, 11 Apr 2019 18:00:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F152128D7D for ; Thu, 11 Apr 2019 18:00:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E535E28D7F; Thu, 11 Apr 2019 18:00:50 +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 2E9BD28D7D for ; Thu, 11 Apr 2019 18:00:49 +0000 (UTC) Received: from localhost ([127.0.0.1]:52994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEe0H-0005De-23 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Apr 2019 14:00:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEdzO-0004V7-UK for qemu-devel@nongnu.org; Thu, 11 Apr 2019 13:59:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEdzN-0002gC-SP for qemu-devel@nongnu.org; Thu, 11 Apr 2019 13:59:54 -0400 Received: from mail-eopbgr680045.outbound.protection.outlook.com ([40.107.68.45]:44014 helo=NAM04-BN3-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 1hEdzN-0002ff-HG for qemu-devel@nongnu.org; Thu, 11 Apr 2019 13:59:53 -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=JetKE8+EhNKomFaTzxAxRSOXZce6sB2Yh8/1lE8CPfU=; b=HgOazl88X1HR3/DV1fd6K6OFRzsFv0o+jLE80+ewqa3o9Hyq6HUK8Kj7TWA16LdblEUTDVZGtOixL4afPeViWfdf0QDzFgBmdmNKxkxJZEpAlPYBXrdByE/gcS1PidLyR9FyMHIr0JV9hqTy3b7TjWo8y0cCPScmkwxAsDf12Wc= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2748.namprd12.prod.outlook.com (20.176.118.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.16; Thu, 11 Apr 2019 17:59:50 +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 17:59:50 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH] target/i386: sev: add 'sev-max-guests' field to 'query-sev-capabilities' Thread-Index: AQHU8JBbMl53pn0tMEuZJLOOksDkdQ== Date: Thu, 11 Apr 2019 17:59:50 +0000 Message-ID: <20190411175931.29235-1-brijesh.singh@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0084.namprd12.prod.outlook.com (2603:10b6:802:21::19) 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: 8e14c959-7925-4d80-d12c-08d6bea77e2d 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:DM6PR12MB2748; x-ms-traffictypediagnostic: DM6PR12MB2748: x-microsoft-antispam-prvs: x-forefront-prvs: 00046D390F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(396003)(136003)(376002)(39860400002)(189003)(199004)(478600001)(14454004)(71200400001)(6506007)(71190400001)(54906003)(99286004)(8676002)(186003)(97736004)(36756003)(52116002)(5660300002)(386003)(68736007)(256004)(14444005)(3846002)(6116002)(81166006)(81156014)(26005)(316002)(8936002)(50226002)(102836004)(2906002)(1076003)(86362001)(6512007)(106356001)(5640700003)(2351001)(476003)(2501003)(105586002)(305945005)(7736002)(2616005)(6916009)(4326008)(66066001)(53936002)(6486002)(6436002)(25786009)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2748; 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: a12UTdO5jcAyHOJ3kQKIrANDdrWu6tknEwDcj/JxJL3b2MP0XV6Ab34dJr3LJ9Md/PPLVdA/z+3kBrP7juLQIQQJOAZzUiZQBUC7nginVT32YrBC1q9vVWEfzgsj/xtczvwRt/SlyFTolWqUoe2qpOgCpXPPAPr18gBGruuwe9r58/BRN+w8qr29qAeoYUmd5HxTAbCNHw7twcBZoKnyU5IewSY1m/R8H84A7JplR8SqBfBeHkcECjg7JTZCEqcXy03t3Z+3mHmILFrQqQLCURTI1PuE4x/p47dQ6lt0c94EEXRysfKX3c7EbgQszKE7TBBprV+L19trUp+QkfleABNz3Zi8hvAAY+0Zl0dyInkWqcZApJCr8CNriJSE1i1f8ytceRjTBjmNQjknmkzQ3kp0PCYpkxDXrpDjXPzWpu0= Content-ID: <92061E548BE82E4A8C5B684CFD4CD405@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e14c959-7925-4d80-d12c-08d6bea77e2d X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2019 17:59:50.8483 (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: DM6PR12MB2748 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.68.45 Subject: [Qemu-devel] [PATCH] 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: 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 Signed-off-by: Brijesh Singh --- qapi/target.json | 6 ++++-- target/i386/sev.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qapi/target.json b/qapi/target.json index 1d4d54b600..b45121d30b 100644 --- a/qapi/target.json +++ b/qapi/target.json @@ -183,7 +183,8 @@ '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 +201,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..bb0cd79acd 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,8 @@ sev_get_capabilities(void) */ cap->reduced_phys_bits = 1; + /* the maximum number of SEV guests that can run simultaneously */ + cap->sev_max_guests = ecx - edx + 1; out: g_free(pdh_data); g_free(cert_chain_data);