From patchwork Wed May 14 23:41:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 889891 Delivered-To: patch@linaro.org Received: by 2002:adf:fd8a:0:b0:3a1:f579:ae88 with SMTP id d10csp2875842wrr; Wed, 14 May 2025 16:42:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGJJIhkmE7wyM959cmJW+460bdE3+ZOO80g1WPAHEOmsCfMRMMr4cMMf7EcU7iUQ1Sdo/Z6w==@linaro.org X-Google-Smtp-Source: AGHT+IEL6edRNBf1swLoiabbcg0SuTmrpUeVs4EPbqTMXc6MIT0jt3OrWIYFkCVmwVc19oJs1wVm X-Received: by 2002:a05:6214:3009:b0:6f5:40a5:e07b with SMTP id 6a1803df08f44-6f896e35101mr64245596d6.26.1747266173948; Wed, 14 May 2025 16:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747266173; cv=none; d=google.com; s=arc-20240605; b=cvcbCZBreJIzmAP7FjPJwvU7KUIcSKrTeueL0+L0gmrJvzaQmmWf1hoZBk8sjhKUVY 9NNiE4b5RLy4AUCKsnyEmnKJ+MJDex+t1z2nMgpQKqJzr68jfGDxJvdzupi+BapoOe4Q d8KQ0/J/Scf0BrF28JPZNajyrv2WaxCAO2snfmD+G/ux0uZdZaxIFpbs+aFSsVnygFOT 9YkZTtWOCwxI/qrxJKZtkoOWHPERWeU/xHCkYLmWRwoG2qbKU1APJMjT50zXL0MtFlmp kZZBW1oh4ayHIrxpXA5iGEDi31zuqX947lTtA0UvdnI6coeVhVdtF/2X4Ddz8FpfFi+K tvZQ== 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=lBS2AIpxXgiP9xnU+n7gYkZBp0TynhJ2U8QSIxuWAKE=; fh=VLmoI/6EX8QpenFjusv8qhWaEfIPciazAbyYTbMJFJo=; b=LpPbTObtYYTN+DT8kHM/LhMHMJi6gHm3/j6d4MPWOzOMWqXf8SBrNXfX0fy5AakRB7 phGyG0ZTokv06q8kk7k3iYH1wwoRnWg0K/QDvtZ+5psq3wAiymqnAnvsppxD2cNOc/kq OaDh3kQI/QfLBQBH4EOW2yyEIxibTJG9codbWHBEjTgwgdcnnUWZnb1UcdZyW+JgVwfE 8VJIQucksKZrc9dlGZ2nXj3Goj9kvl4PPGmyAJGe34470rzSGJyWuuyzQ5m48+j8Menv x0ADzsQeZ1WtCq1faRaRRHN6NX+uYvsy1GTTKKSAVjwTP1oKHGJhhNY2lFaWd3hmPfCt ufXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K4ZmI/s9"; 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-6f6e39e7272si143182266d6.98.2025.05.14.16.42.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 May 2025 16:42:53 -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="K4ZmI/s9"; 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 1uFLj7-0001gB-So; Wed, 14 May 2025 19:41:29 -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 1uFLj2-0001TR-NT for qemu-devel@nongnu.org; Wed, 14 May 2025 19:41:24 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uFLj0-00032w-6i for qemu-devel@nongnu.org; Wed, 14 May 2025 19:41:24 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-22d95f0dda4so4136495ad.2 for ; Wed, 14 May 2025 16:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1747266080; x=1747870880; 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=lBS2AIpxXgiP9xnU+n7gYkZBp0TynhJ2U8QSIxuWAKE=; b=K4ZmI/s9RnQ4Bqfu4SnDzvfLuEI2ADM2cc2U+u2K1Hi8AjEPB8iLEVS1zcLse5Sh0U 9jtAEf7HL49qSQW8gqWtIBJV2/mHAjugkwpdRzcN9ZFqtJZKM2iLerr3h1hAxCMynAP7 ULGVyXuiy/GdP/yQhgfKeogJSBV4JCN2Hfh015PBc9INbhXlhvvNp9daG6XaVeHZSr+L E6GMNVtNeo5EwnPwV2ko19LNatksk0SfNKjWn2uZ/KzEZO8BM8XEYDo/KGEQx70HOye3 twNDuBP6T2eN4FjzyXu57+TbyIKn7YNaQ4zwnzw1yDdg2RrNKyRGOF7VcsxhdArD6D0o YiTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747266080; x=1747870880; 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=lBS2AIpxXgiP9xnU+n7gYkZBp0TynhJ2U8QSIxuWAKE=; b=SN1K9TD1MvmaBygVeIlc2dkrWv3JMOIAvXDyBfYtm8Cd94i0z8WIOoXC5O4M/oNZf7 9i3kitO+7nck1GvT6DW9dc6zX6TEAY4+mTefa1h42vttnn+NRe5bhV3o76XqRpVUhI+S 9STnJXV8vsFT2r7XrvQeDkbvz8bcQT6ZwM1AsbziSY9I1x9fx9vw9Sid16C6aUB0byKZ f0irUsbxyKA87DZDXzt6+ZGySDYVh8bkm8u5YjrthQEZ0HUtacrPzo4iHpyGQS5xDgRO 7gOJf3VSke9XXMnBiCJlzbNs7qg53TuB0l5qJFYSYY/b7ZP0hg7q90dZ5njDol3f8JaT LJ9A== X-Gm-Message-State: AOJu0Yw/bnJeFdqA44i0lAexi3OrlbthVUorekyBP4subYdJhxB8Zz1n KyqCURmJW3fLCaYPmcc1zmm1g88T57O/sa0h3W1++GdeZoYS6Hcwf/y+zJJedU8ZyWBW4v/wR9Z msCs= X-Gm-Gg: ASbGnctrlsTh7F88GppRBCgDNs9U42R4Jcdd/U+usaFBqHE9NlKS7Mli5+kPWvZMiMQ 0butNPnmAONmr0yP6UugRfb79H2YBqBLo3B2sXtfcGeyoX6OLbtfUP8Fje1H5XOMdLamFGJkBdB 5b1xfujtu4DLkB4zSGM3aFW/G/7UuxJcZHvPRL5pPyfldsbSXpR9XGEo6hQnPgIPTLvRv87JC6v c7nQDbcO1CU4si4xIvBAWVieFqvjzCcB72+Ko0bHokUqxplcK5nlM0MssWtRXloQdI0rh7k2MwA OSUC/7+NAqibL32RcmdsBy+cctKG1Iy3o2T94ZDJQsSSboZYSIU= X-Received: by 2002:a17:903:2f85:b0:223:5ca8:5ecb with SMTP id d9443c01a7336-23198143b9bmr69090595ad.42.1747266080411; Wed, 14 May 2025 16:41:20 -0700 (PDT) Received: from pc.. ([38.41.223.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc828b4e4sm104583615ad.182.2025.05.14.16.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 May 2025 16:41:20 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Michael Roth , alex.bennee@linaro.org, Paolo Bonzini , Thomas Huth , berrange@redhat.com, Richard Henderson , peter.maydell@linaro.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 05/12] qapi: make SGX commands unconditionally available Date: Wed, 14 May 2025 16:41:01 -0700 Message-ID: <20250514234108.3746675-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250514234108.3746675-1-pierrick.bouvier@linaro.org> References: <20250514234108.3746675-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x630.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. 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