From nobody Sun Nov 24 16:21:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722424801; cv=none; d=zohomail.com; s=zohoarc; b=fOeQ1cqSAWXehCwiYi/6S8p2IUT7vMtSCIwXl1pz00Eem5dw8BvAvanOzeRKn49TyXhUcE6yfNYUKjFnbp7T3UkZVQ09Ufk+z3IxPQ+3tS8SRmWAS1rq1vxy7xMIlD6pop707TR/0MOrSKg5pTzcQxD4XBPAIWH6NbeIoFsWg14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722424801; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=D3GWXk89dFoCnN0qZrsb3fQ2QxGZwcvcR/+7hFQmEt0=; b=NBteGnFl4D8Ph2xHTIUFzsm86pNJzavgH0kN0aKEcCg8+7YhlMgkhgjcBwBlSmvS1aWn4292KpgrxhaTGEjohRzv13JSv1GgOuAMuyecAvdr8kiDzqPLTLILLE0sk8PZTXsTMSlyjRUjLSckYIcLTWZod69Rmkd3wUFFfaUWt14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722424801013596.7033578602424; Wed, 31 Jul 2024 04:20:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Ls-00063K-Nr; Wed, 31 Jul 2024 07:18:40 -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 1sZ7Lp-0005qn-7z for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZ7Ln-0006n6-FN for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:36 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-7KxeTYmOMqqjzgSRFg7Ccg-1; Wed, 31 Jul 2024 07:18:28 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5a7b5bd019cso5549982a12.0 for ; Wed, 31 Jul 2024 04:18:28 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac65481320sm8494703a12.81.2024.07.31.04.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D3GWXk89dFoCnN0qZrsb3fQ2QxGZwcvcR/+7hFQmEt0=; b=R8MN1KnpJu51lprFVhmlyyR3c3qgPHiwwdUmhGhKZuqxerfTWKrmmuXrLT4Av8O/v8DjGS 26jIXASiU0pjVXlanHMEkHdm0dJLBWw6/nd/kWJztxdPVALIYgcgb1a3h4IuUfGQoj/b/X +Dmqd2I/MGQhxyyF2Vj22DFKWGGFKtA= X-MC-Unique: 7KxeTYmOMqqjzgSRFg7Ccg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424705; x=1723029505; 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=D3GWXk89dFoCnN0qZrsb3fQ2QxGZwcvcR/+7hFQmEt0=; b=BVZwBScqx5iEo9N1p/9T76fHVZ3rIXsni8kFcMAQBhbE1wBiFEotlODOm3oHaFudF/ DZoFNfpnoVCVz+hQp9LH8AHxFpMnJkPNTu8Dywh7MH/yu2qsUrZ14jfJips3Oz1omo0f Sais+JcEkdHtGtsyq2Bs0+reMqGzmW4sUD+4KnnuUcIaxhdYrZ75HKARb/gMx5mHsD0T t0NHRiTf3mDHe2GaYL7VFbqjxrsxi8H4CuIDfSEbwcAKJiZkH2xU5LM75A6KOTgLY3Ww 9MC2QY1tNocK3UwZz7H3x+gWgc1MMxclK54Q0AZ7ogHBIwVogI3XOJu51AjRX6jVlz7w S3PA== X-Gm-Message-State: AOJu0YxixkrhalqkIPZK1dM87TE6LLz0DNQl8jjFvWajGrHq6xPbgOXr ODm9Hx8/2I6nysWSENM9//ZE0q9FZtTvoXCTgy05b9RsbjRBmdM92rOXk1AJrQi0nNkkIBzeyva XTjGC4U8w3Ndsxls3IaMGRareZ3VPbjyklAU7vGdw2rP1I2/Be43HYSFUq+hLKnLthaCdvlteH4 d2JRKGkxC8iye19nWsZFofb0N8lNUEmp0g0gIX X-Received: by 2002:a50:9504:0:b0:57d:4f47:d9ee with SMTP id 4fb4d7f45d1cf-5b0221f0afcmr9571326a12.31.1722424705606; Wed, 31 Jul 2024 04:18:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcF+AFAG7W2hYI8niZxggMhrLUEleNnv0O4IkDAX34xFe9ShitPIMxEIT5xLTQJuNUC3AWGg== X-Received: by 2002:a50:9504:0:b0:57d:4f47:d9ee with SMTP id 4fb4d7f45d1cf-5b0221f0afcmr9571305a12.31.1722424704991; Wed, 31 Jul 2024 04:18:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 06/10] target/i386/cpu: Mask off SGX/SGX_LC feature words for non-PC machine Date: Wed, 31 Jul 2024 13:18:02 +0200 Message-ID: <20240731111806.167225-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722424802855116600 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Only PC machine supports SGX, so mask off SGX related feature words for non-PC machine (microvm). Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20240730045544.2516284-5-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- include/hw/i386/sgx-epc.h | 1 + hw/i386/sgx-stub.c | 5 +++++ hw/i386/sgx.c | 8 ++++++++ target/i386/cpu.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h index 3e00efd870c..41d55da4799 100644 --- a/include/hw/i386/sgx-epc.h +++ b/include/hw/i386/sgx-epc.h @@ -58,6 +58,7 @@ typedef struct SGXEPCState { int nr_sections; } SGXEPCState; =20 +bool check_sgx_support(void); bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size); void sgx_epc_build_srat(GArray *table_data); =20 diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c index 16b1dfd90bb..38ff75e9f37 100644 --- a/hw/i386/sgx-stub.c +++ b/hw/i386/sgx-stub.c @@ -32,6 +32,11 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms) memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState)); } =20 +bool check_sgx_support(void) +{ + return false; +} + bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { return true; diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c index 849472a1286..4900dd414a1 100644 --- a/hw/i386/sgx.c +++ b/hw/i386/sgx.c @@ -266,6 +266,14 @@ void hmp_info_sgx(Monitor *mon, const QDict *qdict) size); } =20 +bool check_sgx_support(void) +{ + if (!object_dynamic_cast(qdev_get_machine(), TYPE_PC_MACHINE)) { + return false; + } + return true; +} + bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { PCMachineState *pcms =3D diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 28b46ef536f..85ef7452c04 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6103,6 +6103,21 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *= cpu, FeatureWord w) } break; =20 + case FEAT_7_0_EBX: +#ifndef CONFIG_USER_ONLY + if (!check_sgx_support()) { + unavail =3D CPUID_7_0_EBX_SGX; + } +#endif + break; + case FEAT_7_0_ECX: +#ifndef CONFIG_USER_ONLY + if (!check_sgx_support()) { + unavail =3D CPUID_7_0_ECX_SGX_LC; + } +#endif + break; + default: break; } --=20 2.45.2