From patchwork Thu May 15 17:27:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 890213 Delivered-To: patch@linaro.org Received: by 2002:adf:fd8a:0:b0:3a1:f579:ae88 with SMTP id d10csp3268355wrr; Thu, 15 May 2025 10:28:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW7CZy7Z+M3Egpa0z1g+6ewyu9JmAKwfDTTbPr1j20Ne0xJ5HDRQrbJAe1c9+XT7S4m3o1Tuw==@linaro.org X-Google-Smtp-Source: AGHT+IFDovvaPSBs18ui1AZaTDD1Hwt8wa3TNw8F0DX42MXWZJ1Pubqe/h5kUf/FHEfCpPkT+Cve X-Received: by 2002:a05:6214:240a:b0:6e8:c713:321f with SMTP id 6a1803df08f44-6f8b08dc65amr9661106d6.35.1747330086800; Thu, 15 May 2025 10:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747330086; cv=none; d=google.com; s=arc-20240605; b=fWJE/qRCo+0nxHZXoFXBh+6/gvh2U/loRGeXM7qro+JjdOC6+sinvZv2aqwXHlhtG7 nwnScBvzg0M5WlTvhQZdmW3D3w6vWoCPZYiuA/yHBp+0+WbPe18YbQwKoaabaTeeuiaP t5qNeGhAkHRv1KDsD8+WRAEcmxsSSZzwWz6mLNTBSA8mWaE9Tu9o3kkbr6fa97/bxcRp e1Htz5wGZ99EB11doeCqCBq4bVrlLO8eK8vrM16jAo/zqK5Yk9qG350fVQbbzZC9YGTB VHsh8U62fmwU31XOa16q2KG5knmDHGtIVDOo17dh9F2D3ryEBEsMCAhpO9Su3+FyAlK2 dr0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IpZQezDLNs1bWZgYz4PCs4KujcbY96LROEFvSXsm75M=; fh=OJpaBvMmOsDyDUaboK7XVT1jzhwiftmC9hsBKL9dJIk=; b=Fa1w8OPAG7tdNjx+qzuw/M8oipaDosqwYX1G1yod13cPGn8zbczgBN61Q5njJMJLLc tbfXskkO+B9vfhSZddj1EFRQnRwLS6nS/S6Jl7d9A9TY1BVUu5KGCWSISAlbRI0g6Gbd xmG4bgN0Bch0LBqo47w1ZXonJwD4oXbE9Ipy3FqWDwYfeCQMx0azXSFbgBBG7PzHTmt8 /OLUfBP46kPGcX6HLAOlKP21A6f/n9EzeR0voCSjHurN4AIp4wuv/Qna9fn5gtJeJOYF SIgh6WT13NSrvZd+JrlNPaqDRq88TwGQKoGtMcs+WXumI+5W9wyesrTTGKZd11aFp+Te cy4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f4Ock17r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f8b08b78e5si2738406d6.122.2025.05.15.10.28.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 May 2025 10:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f4Ock17r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFcN4-0008ER-1p; Thu, 15 May 2025 13:27:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFcN1-000882-P8 for qemu-devel@nongnu.org; Thu, 15 May 2025 13:27:47 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uFcMz-00025M-BL for qemu-devel@nongnu.org; Thu, 15 May 2025 13:27:47 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-72d3b48d2ffso1352520b3a.2 for ; Thu, 15 May 2025 10:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1747330064; x=1747934864; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IpZQezDLNs1bWZgYz4PCs4KujcbY96LROEFvSXsm75M=; b=f4Ock17rceju6YugXqKCnuwNujFg/y2l/3TIdYiqo79DwIjJpPeRkOhwtHtVKWE4jJ oQjrV2xM2GxTDQ94rGjZeP1x9IhjVRldGnxBWFzClckF9dV9vzvbe3ti1THEntD551Ts 7ovzwNxpKKPkNQ6fs11fcnQIu6nT+Z9fpPruAy3cXhKenDfJOd3aaMMwi02fiukqhiU4 WaMSrHbCLmh3UmrakMFXYkE5SLbG7w9dTW4MAAgMGxrYq7X10moato9cGsjY+2sm43fN Siz82uaoSiT0DkcTEzEvlI39M+ZFU3Qem6/1gy7vn0xRSep/xixDcfq5kuZ+guOtum5/ tZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747330064; x=1747934864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IpZQezDLNs1bWZgYz4PCs4KujcbY96LROEFvSXsm75M=; b=F/X9Akzfft0rDsWTNENxOKaJ9CQ3TulWrlJ9SGR2j3oPXmoJ/h4TzU9zoR2qjDD+22 8WpQ3HYctVAjjYpgYuF6TeayQY9K1DOdasNw9pjVPtJdMT9DUvommC0aH0x7hF4/wWOn 9ag9dVMpKvTahwKk4O+RY/nZ4cqt4VkVLdZjEj2mPMzs51k3x864UtRtdJ+WVMbm85JQ ncRP4gwQnQj0t21TvvmUgEH/faxYCs7xWcVOLqz+oezkN6lKpo/iWLSzDQRjQPj/S8YZ 3uc6RE1uxwvZvwzaCLPNNBWSjuzNjqGE0pPV13tu6LSLyyRLIZ3a5CFXmKmHvWCw5A5O vb8w== X-Gm-Message-State: AOJu0Yyvca+ve/el9C6H7JwSaUv+aASe6SdLuClkh4ZRbEk0kSsoLAPo 4QAh5MM3EUUv2gdWAyR9pe31HxWcEUH6wkOcWETTEGDGW8OAPsHRqthT4NIoWqZisTqkeDQTrj2 2CIuN X-Gm-Gg: ASbGncvX7PxANkKkLLGYsDqyPOx+eWdupdCbPOEsn7lpZqVYXKw1pKcBUDPGn+FLZ1d 5hx3E0Ri/8OqESDZ5WlPqRNb6FgYeRyMIzzRYXIpPvOFPeorWUEbpjkuxCHRQMpp883Z8KZRqUU GnpzV7CfeHHf7j8ug/LupxhUUDZ/SrM6knkq9L2oymXU2Vc/EdV5p9rdvrx1MzH1fIhHN4szrF/ BkYq0oVtrqnyxD2gsM7gt0liMjAbg5/zdyKD2dMgYyAsv85i77kaqTnf/h4MY+MWKq7Hi6l7fQq 9Q3CCP/aCO6TKPfFYBqIiZmFS0z/zG+RtcWcdpxtGLtMAVYCEOo= X-Received: by 2002:a05:6a21:502:b0:1f5:7280:1cf2 with SMTP id adf61e73a8af0-2162189f48emr529454637.12.1747330063870; Thu, 15 May 2025 10:27:43 -0700 (PDT) Received: from pc.. ([38.41.223.211]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96dfa9dsm79730b3a.10.2025.05.15.10.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 May 2025 10:27:43 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Thomas Huth , Richard Henderson , Michael Roth , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , berrange@redhat.com, Markus Armbruster , Peter Maydell Subject: [PATCH v2 05/12] qapi: make SGX commands unconditionally available Date: Thu, 15 May 2025 10:27:25 -0700 Message-ID: <20250515172732.3992504-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250515172732.3992504-1-pierrick.bouvier@linaro.org> References: <20250515172732.3992504-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Daniel P. Berrangé This removes the TARGET_I386 condition from the SGX confidential virtualization commands, moving them to the recently introduced misc-i386.json QAPI file, given they are inherantly i386 specific commands. Observe a pre-existing bug that the "SGXEPCSection" struct lacked a TARGET_I386 condition, despite its only usage being behind a TARGET_I386 condition. Reviewed-by: Richard Henderson Signed-off-by: Daniel P. Berrangé Signed-off-by: Pierrick Bouvier --- qapi/misc-i386.json | 77 +++++++++++++++++++++++++++++++++++++++ qapi/misc-target.json | 78 ---------------------------------------- hw/i386/sgx-stub.c | 13 ------- hw/i386/sgx.c | 2 +- stubs/monitor-i386-sgx.c | 17 +++++++++ stubs/meson.build | 1 + 6 files changed, 96 insertions(+), 92 deletions(-) create mode 100644 stubs/monitor-i386-sgx.c diff --git a/qapi/misc-i386.json b/qapi/misc-i386.json index de0e4ab67ff..0ddc297ccbf 100644 --- a/qapi/misc-i386.json +++ b/qapi/misc-i386.json @@ -293,3 +293,80 @@ { 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' }, 'returns': 'SevAttestationReport' } + +## +# @SGXEPCSection: +# +# Information about intel SGX EPC section info +# +# @node: the numa node +# +# @size: the size of EPC section +# +# Since: 7.0 +## +{ 'struct': 'SGXEPCSection', + 'data': { 'node': 'int', + 'size': 'uint64'}} + +## +# @SGXInfo: +# +# Information about intel Safe Guard eXtension (SGX) support +# +# @sgx: true if SGX is supported +# +# @sgx1: true if SGX1 is supported +# +# @sgx2: true if SGX2 is supported +# +# @flc: true if FLC is supported +# +# @sections: The EPC sections info for guest (Since: 7.0) +# +# Since: 6.2 +## +{ 'struct': 'SGXInfo', + 'data': { 'sgx': 'bool', + 'sgx1': 'bool', + 'sgx2': 'bool', + 'flc': 'bool', + 'sections': ['SGXEPCSection']} } + +## +# @query-sgx: +# +# Returns information about SGX +# +# Returns: @SGXInfo +# +# Since: 6.2 +# +# .. qmp-example:: +# +# -> { "execute": "query-sgx" } +# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true, +# "flc": true, +# "sections": [{"node": 0, "size": 67108864}, +# {"node": 1, "size": 29360128}]} } +## +{ 'command': 'query-sgx', 'returns': 'SGXInfo' } + +## +# @query-sgx-capabilities: +# +# Returns information from host SGX capabilities +# +# Returns: @SGXInfo +# +# Since: 6.2 +# +# .. qmp-example:: +# +# -> { "execute": "query-sgx-capabilities" } +# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true, +# "flc": true, +# "section" : [{"node": 0, "size": 67108864}, +# {"node": 1, "size": 29360128}]} } +## +{ 'command': 'query-sgx-capabilities', 'returns': 'SGXInfo' } diff --git a/qapi/misc-target.json b/qapi/misc-target.json index d36292b3321..d9368a1f21f 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -2,84 +2,6 @@ # vim: filetype=python # -## -# @SGXEPCSection: -# -# Information about intel SGX EPC section info -# -# @node: the numa node -# -# @size: the size of EPC section -# -# Since: 7.0 -## -{ 'struct': 'SGXEPCSection', - 'data': { 'node': 'int', - 'size': 'uint64'}} - -## -# @SGXInfo: -# -# Information about intel Safe Guard eXtension (SGX) support -# -# @sgx: true if SGX is supported -# -# @sgx1: true if SGX1 is supported -# -# @sgx2: true if SGX2 is supported -# -# @flc: true if FLC is supported -# -# @sections: The EPC sections info for guest (Since: 7.0) -# -# Since: 6.2 -## -{ 'struct': 'SGXInfo', - 'data': { 'sgx': 'bool', - 'sgx1': 'bool', - 'sgx2': 'bool', - 'flc': 'bool', - 'sections': ['SGXEPCSection']}, - 'if': 'TARGET_I386' } - -## -# @query-sgx: -# -# Returns information about SGX -# -# Returns: @SGXInfo -# -# Since: 6.2 -# -# .. qmp-example:: -# -# -> { "execute": "query-sgx" } -# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true, -# "flc": true, -# "sections": [{"node": 0, "size": 67108864}, -# {"node": 1, "size": 29360128}]} } -## -{ 'command': 'query-sgx', 'returns': 'SGXInfo', 'if': 'TARGET_I386' } - -## -# @query-sgx-capabilities: -# -# Returns information from host SGX capabilities -# -# Returns: @SGXInfo -# -# Since: 6.2 -# -# .. qmp-example:: -# -# -> { "execute": "query-sgx-capabilities" } -# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true, -# "flc": true, -# "section" : [{"node": 0, "size": 67108864}, -# {"node": 1, "size": 29360128}]} } -## -{ 'command': 'query-sgx-capabilities', 'returns': 'SGXInfo', 'if': 'TARGET_I386' } - ## # @EvtchnPortType: diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c index 38ff75e9f37..10ffcdd154d 100644 --- a/hw/i386/sgx-stub.c +++ b/hw/i386/sgx-stub.c @@ -4,24 +4,11 @@ #include "hw/i386/pc.h" #include "hw/i386/sgx-epc.h" #include "qapi/error.h" -#include "qapi/qapi-commands-misc-target.h" void sgx_epc_build_srat(GArray *table_data) { } -SGXInfo *qmp_query_sgx(Error **errp) -{ - error_setg(errp, "SGX support is not compiled in"); - return NULL; -} - -SGXInfo *qmp_query_sgx_capabilities(Error **errp) -{ - error_setg(errp, "SGX support is not compiled in"); - return NULL; -} - void hmp_info_sgx(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "SGX is not available in this QEMU\n"); diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c index 5685c4fb802..2b10a8d144e 100644 --- a/hw/i386/sgx.c +++ b/hw/i386/sgx.c @@ -19,7 +19,7 @@ #include "monitor/hmp-target.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "qapi/qapi-commands-misc-target.h" +#include "qapi/qapi-commands-misc-i386.h" #include "system/address-spaces.h" #include "system/hw_accel.h" #include "system/reset.h" diff --git a/stubs/monitor-i386-sgx.c b/stubs/monitor-i386-sgx.c new file mode 100644 index 00000000000..55a4f194f3f --- /dev/null +++ b/stubs/monitor-i386-sgx.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-misc-i386.h" + +SGXInfo *qmp_query_sgx(Error **errp) +{ + error_setg(errp, "SGX support is not compiled in"); + return NULL; +} + +SGXInfo *qmp_query_sgx_capabilities(Error **errp) +{ + error_setg(errp, "SGX support is not compiled in"); + return NULL; +} diff --git a/stubs/meson.build b/stubs/meson.build index 07e9d3799a5..f2eb4880181 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -80,6 +80,7 @@ if have_system stub_ss.add(files('monitor-arm-gic.c')) stub_ss.add(files('monitor-i386-rtc.c')) stub_ss.add(files('monitor-i386-sev.c')) + stub_ss.add(files('monitor-i386-sgx.c')) endif if have_system or have_user