From nobody Sat May 18 08:35:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1684150355; cv=none; d=zohomail.com; s=zohoarc; b=CpCZFaXap4yGXV3QCW64gCBfg5QU+cgIZD5sjaOp1G3/sFGDjhw4urYpZE5RWfoAz1m81NigoU1pWAsFiGwS4qv+/LlGyChJqfxS3cbuBh3TCiu3g8i4pwWPsQ6Dk3Mf8DrNbo44PYlDeDZ8IANRo4YE+1nY8TKiOt8xOlcdMm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684150355; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TGFm+3lAlf7VMEM6bIEf2GWuO0LeQWDDCKOo0efIzZY=; b=jo1mwSboUPWWO3Tb39bJDh85lx4f/TBOzSuZm/sRrk+5zqn8j7gSNO4mUrLXMIONWw0Iw/BsX0cUf0/MMdvkm5VWOuyXqTdaSX6muquJDXEE9Uo19UwDxBLxkp04iQKitOuoChNCyOCSeCA32xa5nWFKvBQxNG6Fg7Jv+1iE784= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1684150355319788.9369821564701; Mon, 15 May 2023 04:32:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.534712.832015 (Exim 4.92) (envelope-from ) id 1pyWQd-0000c8-QU; Mon, 15 May 2023 11:31:47 +0000 Received: by outflank-mailman (output) from mailman id 534712.832015; Mon, 15 May 2023 11:31:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyWQd-0000c1-Mc; Mon, 15 May 2023 11:31:47 +0000 Received: by outflank-mailman (input) for mailman id 534712; Mon, 15 May 2023 11:31:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyWQc-0000Ms-7e for xen-devel@lists.xenproject.org; Mon, 15 May 2023 11:31:46 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 11f9e53a-f314-11ed-8611-37d641c3527e; Mon, 15 May 2023 13:31:44 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-307a8386946so4859001f8f.2 for ; Mon, 15 May 2023 04:31:44 -0700 (PDT) Received: from localhost.localdomain (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c22c200b003f42328b5d9sm24857485wmg.39.2023.05.15.04.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 04:31:42 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 11f9e53a-f314-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1684150303; x=1686742303; 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=TGFm+3lAlf7VMEM6bIEf2GWuO0LeQWDDCKOo0efIzZY=; b=AHy1rhj9SasQX0lJ1QL/RiJIXJGBHFGVG/UiFpfgd2tjoZkUHfxFX6SFoXS335ZQk4 h1e1T7aYEDW4t3XxVbmtToVEEnUeG6iornHXOgphCQJYIYhUoIOvbmnC4pMLK7DVRVkM 2BjAmrcDTkWVCLAVuKoVSSedzSF1EHgDYqjsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684150303; x=1686742303; 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=TGFm+3lAlf7VMEM6bIEf2GWuO0LeQWDDCKOo0efIzZY=; b=OwUddQVQyqgwR399qnf9TyfzOYsu2A+0/BU1foTaIicgklY8+Glzn6DVnAcn/j4LBJ 47hIiMVdlkUdFjKLtTtJzXsnO+bGrHpQIg3gRB907mhK74pC4sYXvObk0Vnol/6C1mkp IwuWI+F9XjZ+4q7n29aZw9Mvj+dV/9P3/Dkj9Wk0VwO/zKKYtYZn4g8hdEVVSaD/Z/dX Osjadew8GkHC5/QQ0K4q2kn0g7v0wPehHDPrIo160v056kIbnZ96MiDmp/i66In86+LN f0Kot0c/wTKrTUBV6tQcnkvskIgX69oQ2kJ28/YD4myGIoy3MEaMojxkVlWWUXRek31Y fdpg== X-Gm-Message-State: AC+VfDyonaheOEf0xQZfGjOYySmXhzo9TzL9RZW+3u6rM/cYGpTwqoCF mgzqZGvtEpQgjfHYTPaSJTlV9adAIHGJe4ZeXpo= X-Google-Smtp-Source: ACHHUZ6rVekaauOji+qzfUyxp3ydiH/CIVyARgmQhoLqpMouNJpruA4b7lIfCJHSHroYfgYGX3ENww== X-Received: by 2002:adf:f990:0:b0:307:c0c4:109a with SMTP id f16-20020adff990000000b00307c0c4109amr11096133wrr.6.1684150303524; Mon, 15 May 2023 04:31:43 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v3 1/2] x86: Refactor conditional guard in probe_cpuid_faulting() Date: Mon, 15 May 2023 12:31:35 +0100 Message-Id: <20230515113136.2465-2-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230515113136.2465-1-alejandro.vallejo@cloud.com> References: <20230515113136.2465-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1684150355690100005 Content-Type: text/plain; charset="utf-8" Move vendor-specific checks to the vendor-specific callers. While at it move the synth cap setters to the callers too, as it's needed for a later patch and it's not a functional change either. No functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Jan Beulich --- v3: * Moved the setting of LCAP_* bits to intel.c and amd.c --- xen/arch/x86/cpu/amd.c | 13 ++++++++++++- xen/arch/x86/cpu/common.c | 13 ------------- xen/arch/x86/cpu/intel.c | 12 +++++++++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c index caafe44740..440af59670 100644 --- a/xen/arch/x86/cpu/amd.c +++ b/xen/arch/x86/cpu/amd.c @@ -271,8 +271,19 @@ static void __init noinline amd_init_levelling(void) { const struct cpuidmask *m =3D NULL; =20 - if (probe_cpuid_faulting()) + /* + * If there's support for CpuidUserDis or CPUID faulting then + * we can skip levelling because CPUID accesses are trapped anyway. + * + * CPUID faulting is an Intel feature analogous to CpuidUserDis, so + * that can only be present when Xen is itself virtualized (because + * it can be emulated) + */ + if (cpu_has_hypervisor && probe_cpuid_faulting()) { + expected_levelling_cap |=3D LCAP_faulting; + levelling_caps |=3D LCAP_faulting; return; + } =20 probe_masking_msrs(); =20 diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index edc4db1335..52646f7dfb 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -131,17 +131,6 @@ bool __init probe_cpuid_faulting(void) uint64_t val; int rc; =20 - /* - * Don't bother looking for CPUID faulting if we aren't virtualised on - * AMD or Hygon hardware - it won't be present. Likewise for Fam0F - * Intel hardware. - */ - if (((boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) || - ((boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_INTEL) && - boot_cpu_data.x86 =3D=3D 0xf)) && - !cpu_has_hypervisor) - return false; - if ((rc =3D rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) =3D=3D 0) raw_cpu_policy.platform_info.cpuid_faulting =3D val & MSR_PLATFORM_INFO_CPUID_FAULTING; @@ -155,8 +144,6 @@ bool __init probe_cpuid_faulting(void) return false; } =20 - expected_levelling_cap |=3D LCAP_faulting; - levelling_caps |=3D LCAP_faulting; setup_force_cpu_cap(X86_FEATURE_CPUID_FAULTING); =20 return true; diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c index 71fc1a1e18..168cd58f36 100644 --- a/xen/arch/x86/cpu/intel.c +++ b/xen/arch/x86/cpu/intel.c @@ -226,8 +226,18 @@ static void cf_check intel_ctxt_switch_masking(const s= truct vcpu *next) */ static void __init noinline intel_init_levelling(void) { - if (probe_cpuid_faulting()) + /* + * Intel Fam0f is old enough that probing for CPUID faulting support + * introduces spurious #GP(0) when the appropriate MSRs are read, + * so skip it altogether. In the case where Xen is virtualized these + * MSRs may be emulated though, so we allow it in that case. + */ + if ((boot_cpu_data.x86 !=3D 0xf || cpu_has_hypervisor) && + probe_cpuid_faulting()) { + expected_levelling_cap |=3D LCAP_faulting; + levelling_caps |=3D LCAP_faulting; return; + } =20 probe_masking_msrs(); =20 --=20 2.34.1 From nobody Sat May 18 08:35:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1684150351; cv=none; d=zohomail.com; s=zohoarc; b=VeYfdQc50ZWjiZOvHZ3oYA9MpeDsOzlY3DPtmnltoWFPaG6U8Th2Wfytkus/wQkWHv8P3o3kCWi3PZceaZNw21BLurfgZKZms+pdWzaUHc5tw6s85XFRFk0fhhnKOV4tTdMGKKRMtMRT0xGg8NWTiI2xvOEwWUcmKShkpO4mFPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684150351; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FePqsA7ELp0EtWX0sxXIM57wZyVx9jZJGScpb51/u1s=; b=c0QzV+/Hb2vKMilXM+wql+bxi+A+tPlFWHhAIymwJRn9PgVzFt4AT/8zWYfeI3mIOqUJoMA7VBMkAVYC53GgUNMirrWW4oiqfz8F520DZnm66gDmSS6shsLNfzQ7XqRrqdbXSqeF8OXGxxNV0QhgPi6amf/jFdtEO/5nWAirs1s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1684150351316869.2341438931378; Mon, 15 May 2023 04:32:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.534713.832024 (Exim 4.92) (envelope-from ) id 1pyWQf-0000r1-1l; Mon, 15 May 2023 11:31:49 +0000 Received: by outflank-mailman (output) from mailman id 534713.832024; Mon, 15 May 2023 11:31:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyWQe-0000qu-V3; Mon, 15 May 2023 11:31:48 +0000 Received: by outflank-mailman (input) for mailman id 534713; Mon, 15 May 2023 11:31:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyWQd-0000c0-P6 for xen-devel@lists.xenproject.org; Mon, 15 May 2023 11:31:47 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 12ef7049-f314-11ed-b229-6b7b168915f2; Mon, 15 May 2023 13:31:46 +0200 (CEST) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f41dceb9c9so66752665e9.3 for ; Mon, 15 May 2023 04:31:46 -0700 (PDT) Received: from localhost.localdomain (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c22c200b003f42328b5d9sm24857485wmg.39.2023.05.15.04.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 04:31:43 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 12ef7049-f314-11ed-b229-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1684150305; x=1686742305; 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=FePqsA7ELp0EtWX0sxXIM57wZyVx9jZJGScpb51/u1s=; b=K/MDGwykdntuhMMRF4Av/PjrIJnlSnmPzh4d19jq99GNIWbqO3TqH2Am2hRpY6UN0l PM6O6/zQbTIXMIuCXyFhxp3tCqXpF0p2b8EYwH6JUdrmRWN5fd/lQAJboYmhkBtOD4+H j7QsmoLpGPuul0gK7pD4UTLqdi4dNvg1rhTHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684150305; x=1686742305; 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=FePqsA7ELp0EtWX0sxXIM57wZyVx9jZJGScpb51/u1s=; b=Ykcpv0XmPTds/Zp9iZ11fXTWqevQMmgphLzVU9Jade/6OKuvW/ZGDnZQmyntZotcWz LwP/UaWBdYQYyHbQF+Wuo7GkHC2612/Y5MDJlBcDxyEKOexfbOvvCIbARjakCK72oFVK YPlgcd4bc4vHaAvw3A++D1qkw1G4FGYKp7NM3MwInKONkQ7QpUP8+7T0ntW8JtMn+DIe TcibUb9mwHcH/rA07BX3nf71xIBwk5oMDN0Zj333IgT1xgg85dfIRUSraASjiF+/fnLy w5yzx62rwOlI+QIl9vKO0CgEN4gTgsMSG3neF6gha/oTHvdYdO0km3NLQWW0f09tPdGO ibWA== X-Gm-Message-State: AC+VfDz7ivnNOLS7CX8KVvjRoHTfSbUkDOLRBEtP0i3iZ0NL+HCQgYFj KEbMskbPMkgD4dsP0EyuR+tWWzQH3Hecs8RNHUY= X-Google-Smtp-Source: ACHHUZ7q9WubgGbTtqbnUqhWCbotkJGKcKJUhhjjHf1p3pVtVMZKNAsd6Sd7lipunzQqN8XGfbKFQA== X-Received: by 2002:a7b:cd89:0:b0:3f4:247c:b00a with SMTP id y9-20020a7bcd89000000b003f4247cb00amr19425242wmj.15.1684150305097; Mon, 15 May 2023 04:31:45 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v3 2/2] x86: Add support for CpuidUserDis Date: Mon, 15 May 2023 12:31:36 +0100 Message-Id: <20230515113136.2465-3-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230515113136.2465-1-alejandro.vallejo@cloud.com> References: <20230515113136.2465-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1684150352214100001 Content-Type: text/plain; charset="utf-8" Because CpuIdUserDis is reported in CPUID itself, the extended leaf containing that bit must be retrieved before calling c_early_init() Signed-off-by: Alejandro Vallejo Reviewed-by: Jan Beulich --- v3: * Moved LCAP_* setters to the callers in patch1/v3 * Added rationale for checking CPUID faulting before CpuidUserDis in AMD --- xen/arch/x86/cpu/amd.c | 23 ++++++++++++++++++-- xen/arch/x86/cpu/common.c | 38 ++++++++++++++++++++++++---------- xen/arch/x86/include/asm/amd.h | 1 + 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c index 440af59670..3072b68628 100644 --- a/xen/arch/x86/cpu/amd.c +++ b/xen/arch/x86/cpu/amd.c @@ -277,9 +277,14 @@ static void __init noinline amd_init_levelling(void) * * CPUID faulting is an Intel feature analogous to CpuidUserDis, so * that can only be present when Xen is itself virtualized (because - * it can be emulated) + * it can be emulated). + * + * Note that probing for the Intel feature _first_ isn't a mistake, + * but a means to ensure MSR_INTEL_PLATFORM_INFO is read and added + * to the raw CPU policy if present. */ - if (cpu_has_hypervisor && probe_cpuid_faulting()) { + if ((cpu_has_hypervisor && probe_cpuid_faulting()) || + boot_cpu_has(X86_FEATURE_CPUID_USER_DIS)) { expected_levelling_cap |=3D LCAP_faulting; levelling_caps |=3D LCAP_faulting; return; @@ -374,6 +379,20 @@ static void __init noinline amd_init_levelling(void) ctxt_switch_masking =3D amd_ctxt_switch_masking; } =20 +void amd_set_cpuid_user_dis(bool enable) +{ + const uint64_t bit =3D K8_HWCR_CPUID_USER_DIS; + uint64_t val; + + rdmsrl(MSR_K8_HWCR, val); + + if (!!(val & bit) =3D=3D enable) + return; + + val ^=3D bit; + wrmsrl(MSR_K8_HWCR, val); +} + /* * Check for the presence of an AMD erratum. Arguments are defined in amd.= h=20 * for each known erratum. Return 1 if erratum is found. diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 52646f7dfb..9bbb385db4 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -4,6 +4,7 @@ #include #include =20 +#include #include #include #include @@ -166,8 +167,10 @@ static void set_cpuid_faulting(bool enable) void ctxt_switch_levelling(const struct vcpu *next) { const struct domain *nextd =3D next ? next->domain : NULL; + bool enable_cpuid_faulting; =20 - if (cpu_has_cpuid_faulting) { + if (cpu_has_cpuid_faulting || + boot_cpu_has(X86_FEATURE_CPUID_USER_DIS)) { /* * No need to alter the faulting setting if we are switching * to idle; it won't affect any code running in idle context. @@ -188,12 +191,18 @@ void ctxt_switch_levelling(const struct vcpu *next) * an interim escape hatch in the form of * `dom0=3Dno-cpuid-faulting` to restore the older behaviour. */ - set_cpuid_faulting(nextd && (opt_dom0_cpuid_faulting || - !is_control_domain(nextd) || - !is_pv_domain(nextd)) && - (is_pv_domain(nextd) || - next->arch.msrs-> - misc_features_enables.cpuid_faulting)); + enable_cpuid_faulting =3D nextd && (opt_dom0_cpuid_faulting || + !is_control_domain(nextd) || + !is_pv_domain(nextd)) && + (is_pv_domain(nextd) || + next->arch.msrs-> + misc_features_enables.cpuid_faulting); + + if (cpu_has_cpuid_faulting) + set_cpuid_faulting(enable_cpuid_faulting); + else + amd_set_cpuid_user_dis(enable_cpuid_faulting); + return; } =20 @@ -402,6 +411,17 @@ static void generic_identify(struct cpuinfo_x86 *c) c->apicid =3D phys_pkg_id((ebx >> 24) & 0xFF, 0); c->phys_proc_id =3D c->apicid; =20 + eax =3D cpuid_eax(0x80000000); + if ((eax >> 16) =3D=3D 0x8000) + c->extended_cpuid_level =3D eax; + + /* + * These AMD-defined flags are out of place, but we need + * them early for the CPUID faulting probe code + */ + if (c->extended_cpuid_level >=3D 0x80000021) + c->x86_capability[FEATURESET_e21a] =3D cpuid_eax(0x80000021); + if (this_cpu->c_early_init) this_cpu->c_early_init(c); =20 @@ -418,10 +438,6 @@ static void generic_identify(struct cpuinfo_x86 *c) (cpuid_ecx(CPUID_PM_LEAF) & CPUID6_ECX_APERFMPERF_CAPABILITY) ) __set_bit(X86_FEATURE_APERFMPERF, c->x86_capability); =20 - eax =3D cpuid_eax(0x80000000); - if ((eax >> 16) =3D=3D 0x8000) - c->extended_cpuid_level =3D eax; - /* AMD-defined flags: level 0x80000001 */ if (c->extended_cpuid_level >=3D 0x80000001) cpuid(0x80000001, &tmp, &tmp, diff --git a/xen/arch/x86/include/asm/amd.h b/xen/arch/x86/include/asm/amd.h index a975d3de26..09ee52dc1c 100644 --- a/xen/arch/x86/include/asm/amd.h +++ b/xen/arch/x86/include/asm/amd.h @@ -155,5 +155,6 @@ extern bool amd_legacy_ssbd; extern bool amd_virt_spec_ctrl; bool amd_setup_legacy_ssbd(void); void amd_set_legacy_ssbd(bool enable); +void amd_set_cpuid_user_dis(bool enable); =20 #endif /* __AMD_H__ */ --=20 2.34.1