* [PATCH v4 0/4] x86: Disentangle <asm/processor.h> dependency on CPUID headers
@ 2025-07-23 17:36 Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 1/4] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Ahmed S. Darwish @ 2025-07-23 17:36 UTC (permalink / raw)
To: Borislav Petkov, Ingo Molnar, Dave Hansen
Cc: Thomas Gleixner, Andrew Cooper, Paolo Bonzini, Vitaly Kuznetsov,
Sean Christopherson, Juergen Gross, Boris Ostrovsky,
Greg Kroah-Hartman, John Ogness, x86, kvm, x86-cpuid, LKML,
Ahmed S. Darwish
Hi,
This series stops <asm/processor.h> from including <asm/cpuid/api.h>
since there is no code at the former which needs the latter.
For this to work, modify all CPUID call sites that implicitly include the
CPUID <asm/cpuid/api.h> header to explicitly include it instead
This allows the CPUID API header to include <asm/processor.h> without
inducing a circular dependency — which is needed for the upcoming CPUID
model and parser.
Changelog v4
~~~~~~~~~~~~
Per feedback at:
https://lore.kernel.org/lkml/aH-dqcMWj3cFDos2@google.com
Remove the two patches doing the include lines alphabetical and section
reorderings.
I leave it to the maintainers to merge this series or version 3 of it:
highest priority is to keep the CPUID parser work ongoing (by
disentangling the headers…)
Changelog v3
~~~~~~~~~~~~
( [PATCH v3 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers
https://lore.kernel.org/lkml/20250722065448.413503-1-darwi@linutronix.de )
* For the KVM CPUID call sites:
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/pmu_intel.c
arch/x86/kvm/vmx/sgx.c
arch/x86/kvm/vmx/vmx.c
Let them explicitly include <asm/cpuid/api.h> instead of letting their
internal arch/x86/kvm/cpuid.h header does it. The latter header does
not need the former, so making it include a itnot just for the sake of
its call sites was not correct.
* While at it, modify /all/ call sites that use the CPUID API to
explicitly include <asm/cpuid/api.h>.
Previous iterations only modified the CPUID call sites which implicitly
included the CPUID headers through <asm/processor.h>. Since we're at
it anyway, there's no reason not to complete the task across the whole
kernel tree.
Thus, also convert below arch/x86/ sites:
arch/x86/kernel/apic/apic.c
arch/x86/kernel/cpu/sgx/driver.c
arch/x86/kernel/cpu/vmware.c
arch/x86/kernel/jailhouse.c
arch/x86/kernel/kvm.c
arch/x86/mm/pti.c
arch/x86/pci/xen.c
arch/x86/xen/enlighten_hvm.c
arch/x86/xen/pmu.c
arch/x86/xen/time.c
and below drivers/ sites:
drivers/gpu/drm/gma500/mmu.c
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
drivers/ras/amd/fmpm.c
drivers/virt/acrn/hsm.c
drivers/xen/events/events_base.c
drivers/xen/grant-table.c
drivers/xen/xenbus/xenbus_xs.c
to explicitly include the CPUID API header.
* Fix the v2 i386 compilation error:
https://lore.kernel.org/x86-cpuid/202507150403.hKKg9xjJ-lkp@intel.com
by making drivers/char/agp/efficeon-agp.c explicitly include the CPUID
API.
* Make sure that an "i386 allyesconfig" build is successful this time.
* Based on v6.16-rc7.
Changelog v2
~~~~~~~~~~~~
( [PATCH v2 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers
https://lore.kernel.org/lkml/20250709203033.90125-1-darwi@linutronix.de )
Remove the <asm/cpuid/types.h> include from <asm/processor.h> since only
the upcoming CPUID model needed that — not current mainline code. That
include was kept in v1, by mistake, because this series was originally
part of the CPUID model patch queue.
Due to the CPUID types include remove above, let
arch/x86/kvm/reverse_cpuid.h include <asm/cpuid/types.h> since it
references the CPUID_EAX..EDX macros. At this series v1, the KVM header
implicitly included such CPUID types header through <asm/cpufeature.h>,
through <asm/processor.h>.
Drop the "x86/cpuid: Rename cpuid_leaf()/cpuid_subleaf() APIs" patch from
this series. After a second look, it should be part of the CPUID model
PQ instead.
Changelog v1
~~~~~~~~~~~~
( [PATCH v1 0/7] x86: Disentangle <asm/processor.h> dependency on CPUID APIs
https://lore.kernel.org/lkml/20250612234010.572636-1-darwi@linutronix.de )
This series avoids including the full CPUID API from <asm/processor.h>.
That header only needs the CPUID data types and not the full API.
Let <asm/processor.h> include <asm/cpuid/types.h> instead of
<asm/cpuid/api.h>.
Modify all CPUID call sites which implicitly included the CPUID API
though <asm/processor.h> to explicitly include <asm/cpuid/api.h> instead.
This work prepares for an upcoming v4 of the CPUID model:
[PATCH v3 00/44] x86: Introduce a centralized CPUID data model
https://lore.kernel.org/lkml/20250612234010.572636-1-darwi@linutronix.de
where <asm/cpuid/api.h> needs to include <asm/processor.h>, thus creating
a circular dependency if not resolved beforehand… Patches 1->19 of the
v3 above had parts of this series circular dependency disentanglement.
Per Boris' remarks above, merge the header includes reorderings into two
patches only: one patch for x86 and one for drivers.
The 0-day bot x86-32 compilation error:
Re: [PATCH v3 41/44] x86/cpu: <asm/processor.h>: Do not include CPUID…
https://lore.kernel.org/lkml/202506132039.imS2Pflx-lkp@intel.com
is also fixed in this series.
Beside the call sites converted at CPUID model v3 above, this series also
switches below files:
arch/x86/kernel/cpu/microcode/core.c
arch/x86/kernel/cpu/microcode/intel.c
arch/x86/kernel/cpu/mshyperv.c
drivers/cpufreq/longrun.c
drivers/cpufreq/powernow-k7.c
drivers/cpufreq/powernow-k8.c
to explicitly include <asm/cpuid/api.h>.
Based on v6.16-rc5.
Thanks!
8<----
Ahmed S. Darwish (4):
x86/cpuid: Remove transitional <asm/cpuid.h> header
ASoC: Intel: avs: Include CPUID header at file scope
treewide: Explicitly include the x86 CPUID headers
x86/cpu: <asm/processor.h>: Do not include the CPUID API header
arch/x86/boot/compressed/pgtable_64.c | 1 +
arch/x86/boot/startup/sme.c | 1 +
arch/x86/coco/tdx/tdx.c | 1 +
arch/x86/events/amd/core.c | 2 ++
arch/x86/events/amd/ibs.c | 1 +
arch/x86/events/amd/lbr.c | 2 ++
arch/x86/events/amd/power.c | 3 +++
arch/x86/events/amd/uncore.c | 1 +
arch/x86/events/intel/core.c | 1 +
arch/x86/events/intel/lbr.c | 1 +
arch/x86/events/zhaoxin/core.c | 1 +
arch/x86/include/asm/acrn.h | 2 ++
arch/x86/include/asm/cpuid.h | 8 ------
arch/x86/include/asm/microcode.h | 1 +
arch/x86/include/asm/processor.h | 1 -
arch/x86/include/asm/xen/hypervisor.h | 1 +
arch/x86/kernel/apic/apic.c | 1 +
arch/x86/kernel/cpu/amd.c | 1 +
arch/x86/kernel/cpu/centaur.c | 1 +
arch/x86/kernel/cpu/hygon.c | 1 +
arch/x86/kernel/cpu/mce/core.c | 1 +
arch/x86/kernel/cpu/mce/inject.c | 1 +
arch/x86/kernel/cpu/microcode/amd.c | 1 +
arch/x86/kernel/cpu/microcode/core.c | 1 +
arch/x86/kernel/cpu/microcode/intel.c | 1 +
arch/x86/kernel/cpu/mshyperv.c | 1 +
arch/x86/kernel/cpu/resctrl/core.c | 1 +
arch/x86/kernel/cpu/resctrl/monitor.c | 1 +
arch/x86/kernel/cpu/scattered.c | 1 +
arch/x86/kernel/cpu/sgx/driver.c | 3 +++
arch/x86/kernel/cpu/sgx/main.c | 3 +++
arch/x86/kernel/cpu/topology_amd.c | 1 +
arch/x86/kernel/cpu/topology_common.c | 1 +
arch/x86/kernel/cpu/topology_ext.c | 1 +
arch/x86/kernel/cpu/transmeta.c | 3 +++
arch/x86/kernel/cpu/vmware.c | 1 +
arch/x86/kernel/cpu/zhaoxin.c | 1 +
arch/x86/kernel/cpuid.c | 1 +
arch/x86/kernel/jailhouse.c | 1 +
arch/x86/kernel/kvm.c | 1 +
arch/x86/kernel/paravirt.c | 1 +
arch/x86/kvm/mmu/mmu.c | 1 +
arch/x86/kvm/mmu/spte.c | 1 +
arch/x86/kvm/reverse_cpuid.h | 2 ++
arch/x86/kvm/svm/svm.c | 1 +
arch/x86/kvm/vmx/pmu_intel.c | 1 +
arch/x86/kvm/vmx/sgx.c | 1 +
arch/x86/kvm/vmx/vmx.c | 1 +
arch/x86/mm/pti.c | 1 +
arch/x86/pci/xen.c | 2 +-
arch/x86/xen/enlighten_hvm.c | 1 +
arch/x86/xen/pmu.c | 1 +
arch/x86/xen/time.c | 1 +
drivers/char/agp/efficeon-agp.c | 1 +
drivers/cpufreq/longrun.c | 1 +
drivers/cpufreq/powernow-k7.c | 2 +-
drivers/cpufreq/powernow-k8.c | 1 +
drivers/cpufreq/speedstep-lib.c | 1 +
drivers/firmware/efi/libstub/x86-5lvl.c | 1 +
drivers/gpu/drm/gma500/mmu.c | 2 ++
drivers/hwmon/fam15h_power.c | 1 +
drivers/hwmon/k10temp.c | 2 ++
drivers/hwmon/k8temp.c | 1 +
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 1 +
drivers/ras/amd/fmpm.c | 1 +
drivers/thermal/intel/intel_hfi.c | 1 +
drivers/thermal/intel/x86_pkg_temp_thermal.c | 1 +
drivers/virt/acrn/hsm.c | 1 +
drivers/xen/events/events_base.c | 1 +
drivers/xen/grant-table.c | 1 +
drivers/xen/xenbus/xenbus_xs.c | 3 +++
sound/soc/intel/avs/tgl.c | 25 ++++++++++++-------
72 files changed, 101 insertions(+), 20 deletions(-)
delete mode 100644 arch/x86/include/asm/cpuid.h
base-commit: 89be9a83ccf1f88522317ce02f854f30d6115c41
--
2.50.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/4] x86/cpuid: Remove transitional <asm/cpuid.h> header
2025-07-23 17:36 [PATCH v4 0/4] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
@ 2025-07-23 17:36 ` Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 2/4] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Ahmed S. Darwish @ 2025-07-23 17:36 UTC (permalink / raw)
To: Borislav Petkov, Ingo Molnar, Dave Hansen
Cc: Thomas Gleixner, Andrew Cooper, Paolo Bonzini, Vitaly Kuznetsov,
Sean Christopherson, Juergen Gross, Boris Ostrovsky,
Greg Kroah-Hartman, John Ogness, x86, kvm, x86-cpuid, LKML,
Ahmed S. Darwish
All CPUID call sites were updated at commit:
968e30006807 ("x86/cpuid: Set <asm/cpuid/api.h> as the main CPUID header")
to include <asm/cpuid/api.h> instead of <asm/cpuid.h>.
The <asm/cpuid.h> header was still retained as a wrapper, just in case
some new code in -next started using it. Now that everything is merged
to Linus' tree, remove the header.
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
arch/x86/include/asm/cpuid.h | 8 --------
1 file changed, 8 deletions(-)
delete mode 100644 arch/x86/include/asm/cpuid.h
diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h
deleted file mode 100644
index d5749b25fa10..000000000000
--- a/arch/x86/include/asm/cpuid.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _ASM_X86_CPUID_H
-#define _ASM_X86_CPUID_H
-
-#include <asm/cpuid/api.h>
-
-#endif /* _ASM_X86_CPUID_H */
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/4] ASoC: Intel: avs: Include CPUID header at file scope
2025-07-23 17:36 [PATCH v4 0/4] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 1/4] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
@ 2025-07-23 17:36 ` Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 3/4] treewide: Explicitly include the x86 CPUID headers Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header Ahmed S. Darwish
3 siblings, 0 replies; 6+ messages in thread
From: Ahmed S. Darwish @ 2025-07-23 17:36 UTC (permalink / raw)
To: Borislav Petkov, Ingo Molnar, Dave Hansen
Cc: Thomas Gleixner, Andrew Cooper, Paolo Bonzini, Vitaly Kuznetsov,
Sean Christopherson, Juergen Gross, Boris Ostrovsky,
Greg Kroah-Hartman, John Ogness, x86, kvm, x86-cpuid, LKML,
Ahmed S. Darwish
Commit
cbe37a4d2b3c ("ASoC: Intel: avs: Configure basefw on TGL-based platforms")
includes the main CPUID header from within a C function. This works by
luck and forbids valid refactorings inside the CPUID header.
Include the CPUID header at file scope instead.
Note, for the CPUID(0x15) leaf number, use CPUID_LEAF_TSC instead of
defining a custom local macro for it.
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Acked-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/tgl.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/sound/soc/intel/avs/tgl.c b/sound/soc/intel/avs/tgl.c
index 9dbb3ad0954a..cf19d3a7ced2 100644
--- a/sound/soc/intel/avs/tgl.c
+++ b/sound/soc/intel/avs/tgl.c
@@ -10,8 +10,6 @@
#include "avs.h"
#include "messages.h"
-#define CPUID_TSC_LEAF 0x15
-
static int avs_tgl_dsp_core_power(struct avs_dev *adev, u32 core_mask, bool power)
{
core_mask &= AVS_MAIN_CORE_MASK;
@@ -39,22 +37,31 @@ static int avs_tgl_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stal
return avs_dsp_core_stall(adev, core_mask, stall);
}
+#ifdef CONFIG_X86
+#include <asm/cpuid/api.h>
+static unsigned int intel_crystal_freq_hz(void)
+{
+ return cpuid_ecx(CPUID_LEAF_TSC);
+}
+#else
+static unsigned int intel_crystal_freq_hz(void)
+{
+ return 0;
+}
+#endif /* !CONFIG_X86 */
+
static int avs_tgl_config_basefw(struct avs_dev *adev)
{
+ unsigned int freq = intel_crystal_freq_hz();
struct pci_dev *pci = adev->base.pci;
struct avs_bus_hwid hwid;
int ret;
-#ifdef CONFIG_X86
- unsigned int ecx;
-#include <asm/cpuid/api.h>
- ecx = cpuid_ecx(CPUID_TSC_LEAF);
- if (ecx) {
- ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(ecx), &ecx);
+ if (freq) {
+ ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(freq), &freq);
if (ret)
return AVS_IPC_RET(ret);
}
-#endif
hwid.device = pci->device;
hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16);
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/4] treewide: Explicitly include the x86 CPUID headers
2025-07-23 17:36 [PATCH v4 0/4] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 1/4] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 2/4] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish
@ 2025-07-23 17:36 ` Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header Ahmed S. Darwish
3 siblings, 0 replies; 6+ messages in thread
From: Ahmed S. Darwish @ 2025-07-23 17:36 UTC (permalink / raw)
To: Borislav Petkov, Ingo Molnar, Dave Hansen
Cc: Thomas Gleixner, Andrew Cooper, Paolo Bonzini, Vitaly Kuznetsov,
Sean Christopherson, Juergen Gross, Boris Ostrovsky,
Greg Kroah-Hartman, John Ogness, x86, kvm, x86-cpuid, LKML,
Ahmed S. Darwish
Modify all CPUID call sites which implicitly include any of the CPUID
headers to explicitly include them instead.
For arch/x86/kvm/reverse_cpuid.h, just include <asm/cpuid/types.h> since
it references the CPUID_EAX..EDX symbols without using any of the CPUID
APIs.
Note, adding explicit CPUID includes for all call sites allows removing
the <asm/cpuid/api.h> include from <asm/processor.h> next. This way, the
CPUID API header can include <asm/procesor.h> at a later step without
introducing a circular dependency.
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
arch/x86/boot/compressed/pgtable_64.c | 1 +
arch/x86/boot/startup/sme.c | 1 +
arch/x86/coco/tdx/tdx.c | 1 +
arch/x86/events/amd/core.c | 2 ++
arch/x86/events/amd/ibs.c | 1 +
arch/x86/events/amd/lbr.c | 2 ++
arch/x86/events/amd/power.c | 3 +++
arch/x86/events/amd/uncore.c | 1 +
arch/x86/events/intel/core.c | 1 +
arch/x86/events/intel/lbr.c | 1 +
arch/x86/events/zhaoxin/core.c | 1 +
arch/x86/include/asm/acrn.h | 2 ++
arch/x86/include/asm/microcode.h | 1 +
arch/x86/include/asm/xen/hypervisor.h | 1 +
arch/x86/kernel/apic/apic.c | 1 +
arch/x86/kernel/cpu/amd.c | 1 +
arch/x86/kernel/cpu/centaur.c | 1 +
arch/x86/kernel/cpu/hygon.c | 1 +
arch/x86/kernel/cpu/mce/core.c | 1 +
arch/x86/kernel/cpu/mce/inject.c | 1 +
arch/x86/kernel/cpu/microcode/amd.c | 1 +
arch/x86/kernel/cpu/microcode/core.c | 1 +
arch/x86/kernel/cpu/microcode/intel.c | 1 +
arch/x86/kernel/cpu/mshyperv.c | 1 +
arch/x86/kernel/cpu/resctrl/core.c | 1 +
arch/x86/kernel/cpu/resctrl/monitor.c | 1 +
arch/x86/kernel/cpu/scattered.c | 1 +
arch/x86/kernel/cpu/sgx/driver.c | 3 +++
arch/x86/kernel/cpu/sgx/main.c | 3 +++
arch/x86/kernel/cpu/topology_amd.c | 1 +
arch/x86/kernel/cpu/topology_common.c | 1 +
arch/x86/kernel/cpu/topology_ext.c | 1 +
arch/x86/kernel/cpu/transmeta.c | 3 +++
arch/x86/kernel/cpu/vmware.c | 1 +
arch/x86/kernel/cpu/zhaoxin.c | 1 +
arch/x86/kernel/cpuid.c | 1 +
arch/x86/kernel/jailhouse.c | 1 +
arch/x86/kernel/kvm.c | 1 +
arch/x86/kernel/paravirt.c | 1 +
arch/x86/kvm/mmu/mmu.c | 1 +
arch/x86/kvm/mmu/spte.c | 1 +
arch/x86/kvm/reverse_cpuid.h | 2 ++
arch/x86/kvm/svm/svm.c | 1 +
arch/x86/kvm/vmx/pmu_intel.c | 1 +
arch/x86/kvm/vmx/sgx.c | 1 +
arch/x86/kvm/vmx/vmx.c | 1 +
arch/x86/mm/pti.c | 1 +
arch/x86/pci/xen.c | 2 +-
arch/x86/xen/enlighten_hvm.c | 1 +
arch/x86/xen/pmu.c | 1 +
arch/x86/xen/time.c | 1 +
drivers/char/agp/efficeon-agp.c | 1 +
drivers/cpufreq/longrun.c | 1 +
drivers/cpufreq/powernow-k7.c | 2 +-
drivers/cpufreq/powernow-k8.c | 1 +
drivers/cpufreq/speedstep-lib.c | 1 +
drivers/firmware/efi/libstub/x86-5lvl.c | 1 +
drivers/gpu/drm/gma500/mmu.c | 2 ++
drivers/hwmon/fam15h_power.c | 1 +
drivers/hwmon/k10temp.c | 2 ++
drivers/hwmon/k8temp.c | 1 +
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 1 +
drivers/ras/amd/fmpm.c | 1 +
drivers/thermal/intel/intel_hfi.c | 1 +
drivers/thermal/intel/x86_pkg_temp_thermal.c | 1 +
drivers/virt/acrn/hsm.c | 1 +
drivers/xen/events/events_base.c | 1 +
drivers/xen/grant-table.c | 1 +
drivers/xen/xenbus/xenbus_xs.c | 3 +++
69 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
index bdd26050dff7..d94d98595780 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -2,6 +2,7 @@
#include "misc.h"
#include <asm/bootparam.h>
#include <asm/bootparam_utils.h>
+#include <asm/cpuid/api.h>
#include <asm/e820/types.h>
#include <asm/processor.h>
#include "../string.h"
diff --git a/arch/x86/boot/startup/sme.c b/arch/x86/boot/startup/sme.c
index 70ea1748c0a7..1b1bcb41bf23 100644
--- a/arch/x86/boot/startup/sme.c
+++ b/arch/x86/boot/startup/sme.c
@@ -42,6 +42,7 @@
#include <asm/init.h>
#include <asm/setup.h>
#include <asm/sections.h>
+#include <asm/cpuid/api.h>
#include <asm/coco.h>
#include <asm/sev.h>
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 7b2833705d47..168388be3a3e 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -14,6 +14,7 @@
#include <asm/ia32.h>
#include <asm/insn.h>
#include <asm/insn-eval.h>
+#include <asm/cpuid/api.h>
#include <asm/paravirt_types.h>
#include <asm/pgtable.h>
#include <asm/set_memory.h>
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index b20661b8621d..d28d45ceb707 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -7,8 +7,10 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
+
#include <asm/apicdef.h>
#include <asm/apic.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/nmi.h>
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 112f43b23ebf..0c7848e6149e 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -15,6 +15,7 @@
#include <linux/sched/clock.h>
#include <asm/apic.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include "../perf_event.h"
diff --git a/arch/x86/events/amd/lbr.c b/arch/x86/events/amd/lbr.c
index d24da377df77..5b437dc8e4ce 100644
--- a/arch/x86/events/amd/lbr.c
+++ b/arch/x86/events/amd/lbr.c
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/perf_event.h>
+
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/perf_event.h>
diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c
index dad42790cf7d..744dffa42dee 100644
--- a/arch/x86/events/amd/power.c
+++ b/arch/x86/events/amd/power.c
@@ -10,8 +10,11 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/perf_event.h>
+
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
+
#include "../perf_event.h"
/* Event code: LSB 8 bits, passed in attr->config any other bit is reserved. */
diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
index e8b6af199c73..c602542f3a36 100644
--- a/arch/x86/events/amd/uncore.c
+++ b/arch/x86/events/amd/uncore.c
@@ -16,6 +16,7 @@
#include <linux/smp.h>
#include <asm/perf_event.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#define NUM_COUNTERS_NB 4
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index c2fb729c270e..ebbcdf82b494 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -17,6 +17,7 @@
#include <linux/kvm_host.h>
#include <asm/cpufeature.h>
+#include <asm/cpuid/api.h>
#include <asm/debugreg.h>
#include <asm/hardirq.h>
#include <asm/intel-family.h>
diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
index 7aa59966e7c3..0d1ec3651735 100644
--- a/arch/x86/events/intel/lbr.c
+++ b/arch/x86/events/intel/lbr.c
@@ -3,6 +3,7 @@
#include <linux/types.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/perf_event.h>
#include <asm/msr.h>
diff --git a/arch/x86/events/zhaoxin/core.c b/arch/x86/events/zhaoxin/core.c
index 4bdfcf091200..6ed644fe89aa 100644
--- a/arch/x86/events/zhaoxin/core.c
+++ b/arch/x86/events/zhaoxin/core.c
@@ -13,6 +13,7 @@
#include <linux/nmi.h>
#include <asm/cpufeature.h>
+#include <asm/cpuid/api.h>
#include <asm/hardirq.h>
#include <asm/apic.h>
#include <asm/msr.h>
diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index fab11192c60a..db42b477c41d 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -2,6 +2,8 @@
#ifndef _ASM_X86_ACRN_H
#define _ASM_X86_ACRN_H
+#include <asm/cpuid/api.h>
+
/*
* This CPUID returns feature bitmaps in EAX.
* Guest VM uses this to detect the appropriate feature bit.
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index 8b41f26f003b..645e65ac1586 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -3,6 +3,7 @@
#define _ASM_X86_MICROCODE_H
#include <asm/msr.h>
+#include <asm/cpuid/api.h>
struct cpu_signature {
unsigned int sig;
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index c2fc7869b996..7c596cebfb78 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -37,6 +37,7 @@ extern struct shared_info *HYPERVISOR_shared_info;
extern struct start_info *xen_start_info;
#include <asm/bug.h>
+#include <asm/cpuid/api.h>
#include <asm/processor.h>
#define XEN_SIGNATURE "XenVMMXenVMM"
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index d73ba5a7b623..42045b7200ac 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -63,6 +63,7 @@
#include <asm/tsc.h>
#include <asm/hypervisor.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/intel-family.h>
#include <asm/irq_regs.h>
#include <asm/cpu.h>
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 329ee185d8cc..9f706a832ffb 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -15,6 +15,7 @@
#include <asm/cacheinfo.h>
#include <asm/cpu.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/spec-ctrl.h>
#include <asm/smp.h>
#include <asm/numa.h>
diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index a3b55db35c96..cc5a390dcd07 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -5,6 +5,7 @@
#include <asm/cpu.h>
#include <asm/cpufeature.h>
+#include <asm/cpuid/api.h>
#include <asm/e820/api.h>
#include <asm/mtrr.h>
#include <asm/msr.h>
diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
index 2154f12766fb..75ad7eb1301a 100644
--- a/arch/x86/kernel/cpu/hygon.c
+++ b/arch/x86/kernel/cpu/hygon.c
@@ -10,6 +10,7 @@
#include <asm/apic.h>
#include <asm/cpu.h>
+#include <asm/cpuid/api.h>
#include <asm/smp.h>
#include <asm/numa.h>
#include <asm/cacheinfo.h>
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 4da4eab56c81..2b0da00b9d4b 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -48,6 +48,7 @@
#include <asm/fred.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/processor.h>
#include <asm/traps.h>
#include <asm/tlbflush.h>
diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index d02c4f556cd0..42c82c14c48a 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -26,6 +26,7 @@
#include <asm/amd/nb.h>
#include <asm/apic.h>
+#include <asm/cpuid/api.h>
#include <asm/irq_vectors.h>
#include <asm/mce.h>
#include <asm/msr.h>
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 097e39327942..eddb665b2db2 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -34,6 +34,7 @@
#include <asm/microcode.h>
#include <asm/processor.h>
+#include <asm/cpuid/api.h>
#include <asm/cmdline.h>
#include <asm/setup.h>
#include <asm/cpu.h>
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index fe50eb5b7c4a..ee0cf65c0f47 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -34,6 +34,7 @@
#include <asm/apic.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/perf_event.h>
#include <asm/processor.h>
#include <asm/cmdline.h>
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 371ca6eac00e..dacfbffe4cd2 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -22,6 +22,7 @@
#include <linux/mm.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/processor.h>
#include <asm/tlbflush.h>
#include <asm/setup.h>
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index c78f860419d6..b397c1385ebd 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -19,6 +19,7 @@
#include <linux/random.h>
#include <asm/processor.h>
#include <asm/hypervisor.h>
+#include <asm/cpuid/api.h>
#include <hyperv/hvhdk.h>
#include <asm/mshyperv.h>
#include <asm/desc.h>
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 187d527ef73b..c1dd1a3d4b38 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -22,6 +22,7 @@
#include <linux/cpuhotplug.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/resctrl.h>
#include "internal.h"
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index c261558276cd..5dffb9453d77 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -21,6 +21,7 @@
#include <linux/resctrl.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include "internal.h"
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index b4a1f6732a3a..54b98b326f33 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -6,6 +6,7 @@
#include <asm/memtype.h>
#include <asm/apic.h>
+#include <asm/cpuid/api.h>
#include <asm/processor.h>
#include "cpu.h"
diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c
index 7f8d1e11dbee..f0c0a001bce6 100644
--- a/arch/x86/kernel/cpu/sgx/driver.c
+++ b/arch/x86/kernel/cpu/sgx/driver.c
@@ -6,7 +6,10 @@
#include <linux/mman.h>
#include <linux/security.h>
#include <linux/suspend.h>
+
+#include <asm/cpuid/api.h>
#include <asm/traps.h>
+
#include "driver.h"
#include "encl.h"
diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index 2de01b379aa3..00bf42f4c536 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -14,8 +14,11 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/vmalloc.h>
+
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/sgx.h>
+
#include "driver.h"
#include "encl.h"
#include "encls.h"
diff --git a/arch/x86/kernel/cpu/topology_amd.c b/arch/x86/kernel/cpu/topology_amd.c
index 843b1655ab45..abc6f5a7a486 100644
--- a/arch/x86/kernel/cpu/topology_amd.c
+++ b/arch/x86/kernel/cpu/topology_amd.c
@@ -2,6 +2,7 @@
#include <linux/cpu.h>
#include <asm/apic.h>
+#include <asm/cpuid/api.h>
#include <asm/memtype.h>
#include <asm/msr.h>
#include <asm/processor.h>
diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c
index b5a5e1411469..b8c55f025b7e 100644
--- a/arch/x86/kernel/cpu/topology_common.c
+++ b/arch/x86/kernel/cpu/topology_common.c
@@ -6,6 +6,7 @@
#include <asm/intel-family.h>
#include <asm/apic.h>
#include <asm/processor.h>
+#include <asm/cpuid/api.h>
#include <asm/smp.h>
#include "cpu.h"
diff --git a/arch/x86/kernel/cpu/topology_ext.c b/arch/x86/kernel/cpu/topology_ext.c
index 467b0326bf1a..eb915c73895f 100644
--- a/arch/x86/kernel/cpu/topology_ext.c
+++ b/arch/x86/kernel/cpu/topology_ext.c
@@ -2,6 +2,7 @@
#include <linux/cpu.h>
#include <asm/apic.h>
+#include <asm/cpuid/api.h>
#include <asm/memtype.h>
#include <asm/processor.h>
diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmeta.c
index 42c939827621..1fdcd69c625c 100644
--- a/arch/x86/kernel/cpu/transmeta.c
+++ b/arch/x86/kernel/cpu/transmeta.c
@@ -3,8 +3,11 @@
#include <linux/sched.h>
#include <linux/sched/clock.h>
#include <linux/mm.h>
+
#include <asm/cpufeature.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
+
#include "cpu.h"
static void early_init_transmeta(struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index cb3f900c46fc..fe181620f8f6 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -32,6 +32,7 @@
#include <asm/div64.h>
#include <asm/x86_init.h>
#include <asm/hypervisor.h>
+#include <asm/cpuid/api.h>
#include <asm/timer.h>
#include <asm/apic.h>
#include <asm/vmware.h>
diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c
index 89b1c8a70fe8..cfcfb6221e3f 100644
--- a/arch/x86/kernel/cpu/zhaoxin.c
+++ b/arch/x86/kernel/cpu/zhaoxin.c
@@ -4,6 +4,7 @@
#include <asm/cpu.h>
#include <asm/cpufeature.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include "cpu.h"
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index dae436253de4..cbd04b677fd1 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -37,6 +37,7 @@
#include <linux/gfp.h>
#include <linux/completion.h>
+#include <asm/cpuid/api.h>
#include <asm/processor.h>
#include <asm/msr.h>
diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 9e9a591a5fec..f58ce9220e0f 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -17,6 +17,7 @@
#include <asm/io_apic.h>
#include <asm/acpi.h>
#include <asm/cpu.h>
+#include <asm/cpuid/api.h>
#include <asm/hypervisor.h>
#include <asm/i8259.h>
#include <asm/irqdomain.h>
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 921c1c783bc1..8a8e6a9c2de8 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -39,6 +39,7 @@
#include <asm/hypervisor.h>
#include <asm/mtrr.h>
#include <asm/tlb.h>
+#include <asm/cpuid/api.h>
#include <asm/cpuidle_haltpoll.h>
#include <asm/msr.h>
#include <asm/ptrace.h>
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index ab3e172dcc69..15f608f057ac 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -24,6 +24,7 @@
#include <asm/time.h>
#include <asm/pgalloc.h>
#include <asm/irq.h>
+#include <asm/cpuid/api.h>
#include <asm/delay.h>
#include <asm/fixmap.h>
#include <asm/apic.h>
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 4e06e2e89a8f..25e36300e6ab 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -52,6 +52,7 @@
#include <asm/page.h>
#include <asm/memtype.h>
#include <asm/cmpxchg.h>
+#include <asm/cpuid/api.h>
#include <asm/io.h>
#include <asm/set_memory.h>
#include <asm/spec-ctrl.h>
diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c
index cfce03d8f123..e7b69275ae50 100644
--- a/arch/x86/kvm/mmu/spte.c
+++ b/arch/x86/kvm/mmu/spte.c
@@ -15,6 +15,7 @@
#include "x86.h"
#include "spte.h"
+#include <asm/cpuid/api.h>
#include <asm/e820/api.h>
#include <asm/memtype.h>
#include <asm/vmx.h>
diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h
index c53b92379e6e..77bdc3fe3fc5 100644
--- a/arch/x86/kvm/reverse_cpuid.h
+++ b/arch/x86/kvm/reverse_cpuid.h
@@ -3,8 +3,10 @@
#define ARCH_X86_KVM_REVERSE_CPUID_H
#include <uapi/asm/kvm.h>
+
#include <asm/cpufeature.h>
#include <asm/cpufeatures.h>
+#include <asm/cpuid/types.h>
/*
* Define a KVM-only feature flag.
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index ab9b947dbf4f..d7478ffad168 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -41,6 +41,7 @@
#include <asm/irq_remapping.h>
#include <asm/spec-ctrl.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/traps.h>
#include <asm/reboot.h>
#include <asm/fpu/api.h>
diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
index bbf4509f32d0..2711040d73af 100644
--- a/arch/x86/kvm/vmx/pmu_intel.c
+++ b/arch/x86/kvm/vmx/pmu_intel.c
@@ -15,6 +15,7 @@
#include <linux/perf_event.h>
#include <asm/msr.h>
#include <asm/perf_event.h>
+#include <asm/cpuid/api.h>
#include "x86.h"
#include "cpuid.h"
#include "lapic.h"
diff --git a/arch/x86/kvm/vmx/sgx.c b/arch/x86/kvm/vmx/sgx.c
index df1d0cf76947..29a1f8e3be60 100644
--- a/arch/x86/kvm/vmx/sgx.c
+++ b/arch/x86/kvm/vmx/sgx.c
@@ -2,6 +2,7 @@
/* Copyright(c) 2021 Intel Corporation. */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/sgx.h>
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 191a9ed0da22..80ba1e2e7d06 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -34,6 +34,7 @@
#include <asm/asm.h>
#include <asm/cpu.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/debugreg.h>
#include <asm/desc.h>
#include <asm/fpu/api.h>
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index c0c40b67524e..fbf0ec1bb0dc 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -31,6 +31,7 @@
#include <asm/cpufeature.h>
#include <asm/hypervisor.h>
+#include <asm/cpuid/api.h>
#include <asm/vsyscall.h>
#include <asm/cmdline.h>
#include <asm/pti.h>
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index b8755cde2419..6acfbdbaf4d5 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -18,6 +18,7 @@
#include <linux/io.h>
#include <asm/io_apic.h>
#include <asm/pci_x86.h>
+#include <asm/cpuid/api.h>
#include <asm/xen/hypervisor.h>
@@ -583,4 +584,3 @@ int __init pci_xen_initial_domain(void)
return 0;
}
#endif
-
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index fe57ff85d004..bd57259a02e6 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -20,6 +20,7 @@
#include <asm/setup.h>
#include <asm/idtentry.h>
#include <asm/hypervisor.h>
+#include <asm/cpuid/api.h>
#include <asm/e820/api.h>
#include <asm/early_ioremap.h>
diff --git a/arch/x86/xen/pmu.c b/arch/x86/xen/pmu.c
index 8f89ce0b67e3..5f50a3ee08f5 100644
--- a/arch/x86/xen/pmu.c
+++ b/arch/x86/xen/pmu.c
@@ -2,6 +2,7 @@
#include <linux/types.h>
#include <linux/interrupt.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/xen/hypercall.h>
#include <xen/xen.h>
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 96521b1874ac..d935cc1f2896 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -17,6 +17,7 @@
#include <linux/pvclock_gtod.h>
#include <linux/timekeeper_internal.h>
+#include <asm/cpuid/api.h>
#include <asm/pvclock.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 0d25bbdc7e6a..4d0b7d7c0aad 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -27,6 +27,7 @@
#include <linux/gfp.h>
#include <linux/page-flags.h>
#include <linux/mm.h>
+#include <asm/cpuid/api.h>
#include "agp.h"
#include "intel-agp.h"
diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c
index 1caaec7c280b..f3aaca0496a4 100644
--- a/drivers/cpufreq/longrun.c
+++ b/drivers/cpufreq/longrun.c
@@ -14,6 +14,7 @@
#include <asm/msr.h>
#include <asm/processor.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
static struct cpufreq_driver longrun_driver;
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index 31039330a3ba..ee122aafa56a 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -29,6 +29,7 @@
#include <asm/timer.h> /* Needed for recalibrate_cpu_khz() */
#include <asm/msr.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#ifdef CONFIG_X86_POWERNOW_K7_ACPI
#include <linux/acpi.h>
@@ -691,4 +692,3 @@ MODULE_LICENSE("GPL");
late_initcall(powernow_init);
module_exit(powernow_exit);
-
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index f7512b4e923e..84d7a737203b 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -39,6 +39,7 @@
#include <asm/msr.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <linux/acpi.h>
#include <linux/mutex.h>
diff --git a/drivers/cpufreq/speedstep-lib.c b/drivers/cpufreq/speedstep-lib.c
index 0b66df4ed513..b3fe873103a8 100644
--- a/drivers/cpufreq/speedstep-lib.c
+++ b/drivers/cpufreq/speedstep-lib.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/cpufreq.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include <asm/tsc.h>
#include "speedstep-lib.h"
diff --git a/drivers/firmware/efi/libstub/x86-5lvl.c b/drivers/firmware/efi/libstub/x86-5lvl.c
index f1c5fb45d5f7..029ad80cf0b4 100644
--- a/drivers/firmware/efi/libstub/x86-5lvl.c
+++ b/drivers/firmware/efi/libstub/x86-5lvl.c
@@ -2,6 +2,7 @@
#include <linux/efi.h>
#include <asm/boot.h>
+#include <asm/cpuid/api.h>
#include <asm/desc.h>
#include <asm/efi.h>
diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c
index e6753282e70e..4d2aba31a78c 100644
--- a/drivers/gpu/drm/gma500/mmu.c
+++ b/drivers/gpu/drm/gma500/mmu.c
@@ -7,6 +7,8 @@
#include <linux/highmem.h>
#include <linux/vmalloc.h>
+#include <asm/cpuid/api.h>
+
#include "mmu.h"
#include "psb_drv.h"
#include "psb_reg.h"
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 8ecebea53651..e200c7b7a698 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -19,6 +19,7 @@
#include <linux/sched.h>
#include <linux/topology.h>
#include <asm/processor.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor");
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
index babf2413d666..12115654689a 100644
--- a/drivers/hwmon/k10temp.c
+++ b/drivers/hwmon/k10temp.c
@@ -20,7 +20,9 @@
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pci_ids.h>
+
#include <asm/amd/node.h>
+#include <asm/cpuid/api.h>
#include <asm/processor.h>
MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 2b80ac410cd1..53241164570e 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/mutex.h>
#include <asm/processor.h>
+#include <asm/cpuid/api.h>
#define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000)
#define REG_TEMP 0xe4
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index ea33ae39be6b..7612759c7267 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -6,6 +6,7 @@
#include <linux/pci.h>
#include <linux/dmi.h>
#include <linux/platform_data/x86/intel_pmc_ipc.h>
+#include <asm/cpuid/api.h>
#include "dwmac-intel.h"
#include "dwmac4.h"
#include "stmmac.h"
diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c
index 8877c6ff64c4..416a14bbd714 100644
--- a/drivers/ras/amd/fmpm.c
+++ b/drivers/ras/amd/fmpm.c
@@ -52,6 +52,7 @@
#include <acpi/apei.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/mce.h>
#include "../debugfs.h"
diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
index bd2fca7dc017..c910cc563d9d 100644
--- a/drivers/thermal/intel/intel_hfi.c
+++ b/drivers/thermal/intel/intel_hfi.c
@@ -41,6 +41,7 @@
#include <linux/topology.h>
#include <linux/workqueue.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include "intel_hfi.h"
diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c
index 3fc679b6f11b..80f98e4ae61f 100644
--- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
@@ -20,6 +20,7 @@
#include <linux/debugfs.h>
#include <asm/cpu_device_id.h>
+#include <asm/cpuid/api.h>
#include <asm/msr.h>
#include "thermal_interrupt.h"
diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
index e4e196abdaac..67119f9da449 100644
--- a/drivers/virt/acrn/hsm.c
+++ b/drivers/virt/acrn/hsm.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <asm/acrn.h>
+#include <asm/cpuid/api.h>
#include <asm/hypervisor.h>
#include "acrn_drv.h"
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 41309d38f78c..4d847dcd6d76 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -40,6 +40,7 @@
#include <linux/ktime.h>
#ifdef CONFIG_X86
+#include <asm/cpuid/api.h>
#include <asm/desc.h>
#include <asm/ptrace.h>
#include <asm/idtentry.h>
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 04a6b470b15d..ae3e384c2d1b 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -59,6 +59,7 @@
#include <xen/swiotlb-xen.h>
#include <xen/balloon.h>
#ifdef CONFIG_X86
+#include <asm/cpuid/api.h>
#include <asm/xen/cpuid.h>
#endif
#include <xen/mem-reservation.h>
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index dcf9182c8451..dff3752314e7 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -47,6 +47,9 @@
#include <linux/rwsem.h>
#include <linux/mutex.h>
#include <asm/xen/hypervisor.h>
+#ifdef CONFIG_X86
+#include <asm/cpuid/api.h>
+#endif
#include <xen/xenbus.h>
#include <xen/xen.h>
#include "xenbus.h"
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header
2025-07-23 17:36 [PATCH v4 0/4] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
` (2 preceding siblings ...)
2025-07-23 17:36 ` [PATCH v4 3/4] treewide: Explicitly include the x86 CPUID headers Ahmed S. Darwish
@ 2025-07-23 17:36 ` Ahmed S. Darwish
2025-07-24 9:11 ` kernel test robot
3 siblings, 1 reply; 6+ messages in thread
From: Ahmed S. Darwish @ 2025-07-23 17:36 UTC (permalink / raw)
To: Borislav Petkov, Ingo Molnar, Dave Hansen
Cc: Thomas Gleixner, Andrew Cooper, Paolo Bonzini, Vitaly Kuznetsov,
Sean Christopherson, Juergen Gross, Boris Ostrovsky,
Greg Kroah-Hartman, John Ogness, x86, kvm, x86-cpuid, LKML,
Ahmed S. Darwish
<asm/processor.h> includes the main CPUID API header <asm/cpuid/api.h>
but it does not need it.
Remove the include.
Note, this allows the CPUID API header to include <asm/processor.h> at a
later step, which is needed for the upcoming CPUID model and parser,
without introducing a circular dependency.
Note, all call sites which implicitly included the CPUID API header
through <asm/processor.h> have been already modified to explicitly
include the CPUID API instead.
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
arch/x86/include/asm/processor.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index bde58f6510ac..910e36b0c00d 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -16,7 +16,6 @@ struct vm86;
#include <uapi/asm/sigcontext.h>
#include <asm/current.h>
#include <asm/cpufeatures.h>
-#include <asm/cpuid/api.h>
#include <asm/page.h>
#include <asm/pgtable_types.h>
#include <asm/percpu.h>
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header
2025-07-23 17:36 ` [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header Ahmed S. Darwish
@ 2025-07-24 9:11 ` kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-07-24 9:11 UTC (permalink / raw)
To: Ahmed S. Darwish, Borislav Petkov, Ingo Molnar, Dave Hansen
Cc: llvm, oe-kbuild-all, Thomas Gleixner, Andrew Cooper,
Paolo Bonzini, Vitaly Kuznetsov, Sean Christopherson,
Juergen Gross, Boris Ostrovsky, Greg Kroah-Hartman, John Ogness,
x86, kvm, x86-cpuid, LKML, Ahmed S. Darwish
Hi Ahmed,
kernel test robot noticed the following build errors:
[auto build test ERROR on 89be9a83ccf1f88522317ce02f854f30d6115c41]
url: https://github.com/intel-lab-lkp/linux/commits/Ahmed-S-Darwish/x86-cpuid-Remove-transitional-asm-cpuid-h-header/20250724-014828
base: 89be9a83ccf1f88522317ce02f854f30d6115c41
patch link: https://lore.kernel.org/r/20250723173644.33568-5-darwi%40linutronix.de
patch subject: [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250724/202507241752.gju4meHj-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250724/202507241752.gju4meHj-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507241752.gju4meHj-lkp@intel.com/
All errors (new ones prefixed by >>):
>> arch/x86/kvm/svm/sev.c:2939:2: error: call to undeclared function 'cpuid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
2939 | cpuid(0x8000001f, &eax, &ebx, &ecx, &edx);
| ^
1 error generated.
vim +/cpuid +2939 arch/x86/kvm/svm/sev.c
179a8427fcbffe Ashish Kalra 2025-05-12 2904
916391a2d1dc22 Tom Lendacky 2020-12-10 2905 void __init sev_hardware_setup(void)
eaf78265a4ab33 Joerg Roedel 2020-03-24 2906 {
7aef27f0b2a8a5 Vipin Sharma 2021-03-29 2907 unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count;
6f1d5a3513c237 Ashish Kalra 2025-03-24 2908 struct sev_platform_init_args init_args = {0};
1dfe571c12cf99 Brijesh Singh 2024-05-01 2909 bool sev_snp_supported = false;
916391a2d1dc22 Tom Lendacky 2020-12-10 2910 bool sev_es_supported = false;
916391a2d1dc22 Tom Lendacky 2020-12-10 2911 bool sev_supported = false;
916391a2d1dc22 Tom Lendacky 2020-12-10 2912
80d0f521d59e08 Sean Christopherson 2023-08-24 2913 if (!sev_enabled || !npt_enabled || !nrips)
e8126bdaf19400 Sean Christopherson 2021-04-21 2914 goto out;
e8126bdaf19400 Sean Christopherson 2021-04-21 2915
c532f2903b69b7 Sean Christopherson 2022-01-20 2916 /*
c532f2903b69b7 Sean Christopherson 2022-01-20 2917 * SEV must obviously be supported in hardware. Sanity check that the
c532f2903b69b7 Sean Christopherson 2022-01-20 2918 * CPU supports decode assists, which is mandatory for SEV guests to
770d6aa2e416fd Sean Christopherson 2023-10-18 2919 * support instruction emulation. Ditto for flushing by ASID, as SEV
770d6aa2e416fd Sean Christopherson 2023-10-18 2920 * guests are bound to a single ASID, i.e. KVM can't rotate to a new
770d6aa2e416fd Sean Christopherson 2023-10-18 2921 * ASID to effect a TLB flush.
c532f2903b69b7 Sean Christopherson 2022-01-20 2922 */
c532f2903b69b7 Sean Christopherson 2022-01-20 2923 if (!boot_cpu_has(X86_FEATURE_SEV) ||
770d6aa2e416fd Sean Christopherson 2023-10-18 2924 WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)) ||
770d6aa2e416fd Sean Christopherson 2023-10-18 2925 WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_FLUSHBYASID)))
916391a2d1dc22 Tom Lendacky 2020-12-10 2926 goto out;
916391a2d1dc22 Tom Lendacky 2020-12-10 2927
44e70718df4fc2 Sean Christopherson 2025-02-10 2928 /*
44e70718df4fc2 Sean Christopherson 2025-02-10 2929 * The kernel's initcall infrastructure lacks the ability to express
44e70718df4fc2 Sean Christopherson 2025-02-10 2930 * dependencies between initcalls, whereas the modules infrastructure
44e70718df4fc2 Sean Christopherson 2025-02-10 2931 * automatically handles dependencies via symbol loading. Ensure the
44e70718df4fc2 Sean Christopherson 2025-02-10 2932 * PSP SEV driver is initialized before proceeding if KVM is built-in,
44e70718df4fc2 Sean Christopherson 2025-02-10 2933 * as the dependency isn't handled by the initcall infrastructure.
44e70718df4fc2 Sean Christopherson 2025-02-10 2934 */
44e70718df4fc2 Sean Christopherson 2025-02-10 2935 if (IS_BUILTIN(CONFIG_KVM_AMD) && sev_module_init())
44e70718df4fc2 Sean Christopherson 2025-02-10 2936 goto out;
44e70718df4fc2 Sean Christopherson 2025-02-10 2937
916391a2d1dc22 Tom Lendacky 2020-12-10 2938 /* Retrieve SEV CPUID information */
916391a2d1dc22 Tom Lendacky 2020-12-10 @2939 cpuid(0x8000001f, &eax, &ebx, &ecx, &edx);
916391a2d1dc22 Tom Lendacky 2020-12-10 2940
1edc14599e06fd Tom Lendacky 2020-12-10 2941 /* Set encryption bit location for SEV-ES guests */
1edc14599e06fd Tom Lendacky 2020-12-10 2942 sev_enc_bit = ebx & 0x3f;
1edc14599e06fd Tom Lendacky 2020-12-10 2943
eaf78265a4ab33 Joerg Roedel 2020-03-24 2944 /* Maximum number of encrypted guests supported simultaneously */
916391a2d1dc22 Tom Lendacky 2020-12-10 2945 max_sev_asid = ecx;
8cb756b7bdcc6e Sean Christopherson 2021-04-21 2946 if (!max_sev_asid)
916391a2d1dc22 Tom Lendacky 2020-12-10 2947 goto out;
eaf78265a4ab33 Joerg Roedel 2020-03-24 2948
eaf78265a4ab33 Joerg Roedel 2020-03-24 2949 /* Minimum ASID value that should be used for SEV guest */
916391a2d1dc22 Tom Lendacky 2020-12-10 2950 min_sev_asid = edx;
d3d1af85e2c75b Brijesh Singh 2021-04-15 2951 sev_me_mask = 1UL << (ebx & 0x3f);
eaf78265a4ab33 Joerg Roedel 2020-03-24 2952
bb2baeb214a71c Mingwei Zhang 2021-08-02 2953 /*
bb2baeb214a71c Mingwei Zhang 2021-08-02 2954 * Initialize SEV ASID bitmaps. Allocate space for ASID 0 in the bitmap,
bb2baeb214a71c Mingwei Zhang 2021-08-02 2955 * even though it's never used, so that the bitmap is indexed by the
bb2baeb214a71c Mingwei Zhang 2021-08-02 2956 * actual ASID.
bb2baeb214a71c Mingwei Zhang 2021-08-02 2957 */
bb2baeb214a71c Mingwei Zhang 2021-08-02 2958 nr_asids = max_sev_asid + 1;
bb2baeb214a71c Mingwei Zhang 2021-08-02 2959 sev_asid_bitmap = bitmap_zalloc(nr_asids, GFP_KERNEL);
eaf78265a4ab33 Joerg Roedel 2020-03-24 2960 if (!sev_asid_bitmap)
916391a2d1dc22 Tom Lendacky 2020-12-10 2961 goto out;
eaf78265a4ab33 Joerg Roedel 2020-03-24 2962
bb2baeb214a71c Mingwei Zhang 2021-08-02 2963 sev_reclaim_asid_bitmap = bitmap_zalloc(nr_asids, GFP_KERNEL);
f31b88b35f90f6 Sean Christopherson 2021-04-21 2964 if (!sev_reclaim_asid_bitmap) {
f31b88b35f90f6 Sean Christopherson 2021-04-21 2965 bitmap_free(sev_asid_bitmap);
f31b88b35f90f6 Sean Christopherson 2021-04-21 2966 sev_asid_bitmap = NULL;
916391a2d1dc22 Tom Lendacky 2020-12-10 2967 goto out;
f31b88b35f90f6 Sean Christopherson 2021-04-21 2968 }
eaf78265a4ab33 Joerg Roedel 2020-03-24 2969
0aa6b90ef9d75b Ashish Kalra 2024-01-31 2970 if (min_sev_asid <= max_sev_asid) {
7aef27f0b2a8a5 Vipin Sharma 2021-03-29 2971 sev_asid_count = max_sev_asid - min_sev_asid + 1;
106ed2cad9f7bd Sean Christopherson 2023-06-06 2972 WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count));
0aa6b90ef9d75b Ashish Kalra 2024-01-31 2973 }
916391a2d1dc22 Tom Lendacky 2020-12-10 2974 sev_supported = true;
eaf78265a4ab33 Joerg Roedel 2020-03-24 2975
916391a2d1dc22 Tom Lendacky 2020-12-10 2976 /* SEV-ES support requested? */
8d364a0792dd95 Sean Christopherson 2021-04-21 2977 if (!sev_es_enabled)
916391a2d1dc22 Tom Lendacky 2020-12-10 2978 goto out;
916391a2d1dc22 Tom Lendacky 2020-12-10 2979
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2980 /*
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2981 * SEV-ES requires MMIO caching as KVM doesn't have access to the guest
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2982 * instruction stream, i.e. can't emulate in response to a #NPF and
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2983 * instead relies on #NPF(RSVD) being reflected into the guest as #VC
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2984 * (the guest can then do a #VMGEXIT to request MMIO emulation).
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2985 */
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2986 if (!enable_mmio_caching)
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2987 goto out;
0c29397ac1fdd6 Sean Christopherson 2022-08-03 2988
916391a2d1dc22 Tom Lendacky 2020-12-10 2989 /* Does the CPU support SEV-ES? */
916391a2d1dc22 Tom Lendacky 2020-12-10 2990 if (!boot_cpu_has(X86_FEATURE_SEV_ES))
916391a2d1dc22 Tom Lendacky 2020-12-10 2991 goto out;
916391a2d1dc22 Tom Lendacky 2020-12-10 2992
d922056215617e Ravi Bangoria 2024-05-31 2993 if (!lbrv) {
d922056215617e Ravi Bangoria 2024-05-31 2994 WARN_ONCE(!boot_cpu_has(X86_FEATURE_LBRV),
d922056215617e Ravi Bangoria 2024-05-31 2995 "LBRV must be present for SEV-ES support");
d922056215617e Ravi Bangoria 2024-05-31 2996 goto out;
d922056215617e Ravi Bangoria 2024-05-31 2997 }
d922056215617e Ravi Bangoria 2024-05-31 2998
916391a2d1dc22 Tom Lendacky 2020-12-10 2999 /* Has the system been allocated ASIDs for SEV-ES? */
916391a2d1dc22 Tom Lendacky 2020-12-10 3000 if (min_sev_asid == 1)
916391a2d1dc22 Tom Lendacky 2020-12-10 3001 goto out;
916391a2d1dc22 Tom Lendacky 2020-12-10 3002
7aef27f0b2a8a5 Vipin Sharma 2021-03-29 3003 sev_es_asid_count = min_sev_asid - 1;
106ed2cad9f7bd Sean Christopherson 2023-06-06 3004 WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count));
916391a2d1dc22 Tom Lendacky 2020-12-10 3005 sev_es_supported = true;
1dfe571c12cf99 Brijesh Singh 2024-05-01 3006 sev_snp_supported = sev_snp_enabled && cc_platform_has(CC_ATTR_HOST_SEV_SNP);
916391a2d1dc22 Tom Lendacky 2020-12-10 3007
916391a2d1dc22 Tom Lendacky 2020-12-10 3008 out:
179a8427fcbffe Ashish Kalra 2025-05-12 3009 if (sev_enabled) {
179a8427fcbffe Ashish Kalra 2025-05-12 3010 init_args.probe = true;
179a8427fcbffe Ashish Kalra 2025-05-12 3011 if (sev_platform_init(&init_args))
179a8427fcbffe Ashish Kalra 2025-05-12 3012 sev_supported = sev_es_supported = sev_snp_supported = false;
179a8427fcbffe Ashish Kalra 2025-05-12 3013 else if (sev_snp_supported)
179a8427fcbffe Ashish Kalra 2025-05-12 3014 sev_snp_supported = is_sev_snp_initialized();
179a8427fcbffe Ashish Kalra 2025-05-12 3015 }
179a8427fcbffe Ashish Kalra 2025-05-12 3016
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3017 if (boot_cpu_has(X86_FEATURE_SEV))
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3018 pr_info("SEV %s (ASIDs %u - %u)\n",
0aa6b90ef9d75b Ashish Kalra 2024-01-31 3019 sev_supported ? min_sev_asid <= max_sev_asid ? "enabled" :
0aa6b90ef9d75b Ashish Kalra 2024-01-31 3020 "unusable" :
0aa6b90ef9d75b Ashish Kalra 2024-01-31 3021 "disabled",
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3022 min_sev_asid, max_sev_asid);
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3023 if (boot_cpu_has(X86_FEATURE_SEV_ES))
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3024 pr_info("SEV-ES %s (ASIDs %u - %u)\n",
800173cf7560e0 Thorsten Blum 2024-12-27 3025 str_enabled_disabled(sev_es_supported),
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3026 min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
1dfe571c12cf99 Brijesh Singh 2024-05-01 3027 if (boot_cpu_has(X86_FEATURE_SEV_SNP))
1dfe571c12cf99 Brijesh Singh 2024-05-01 3028 pr_info("SEV-SNP %s (ASIDs %u - %u)\n",
800173cf7560e0 Thorsten Blum 2024-12-27 3029 str_enabled_disabled(sev_snp_supported),
1dfe571c12cf99 Brijesh Singh 2024-05-01 3030 min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
6d1bc9754b0407 Alexander Mikhalitsyn 2023-05-22 3031
8d364a0792dd95 Sean Christopherson 2021-04-21 3032 sev_enabled = sev_supported;
8d364a0792dd95 Sean Christopherson 2021-04-21 3033 sev_es_enabled = sev_es_supported;
1dfe571c12cf99 Brijesh Singh 2024-05-01 3034 sev_snp_enabled = sev_snp_supported;
1dfe571c12cf99 Brijesh Singh 2024-05-01 3035
d1f85fbe836e61 Alexey Kardashevskiy 2023-06-15 3036 if (!sev_es_enabled || !cpu_feature_enabled(X86_FEATURE_DEBUG_SWAP) ||
d1f85fbe836e61 Alexey Kardashevskiy 2023-06-15 3037 !cpu_feature_enabled(X86_FEATURE_NO_NESTED_DATA_BP))
d1f85fbe836e61 Alexey Kardashevskiy 2023-06-15 3038 sev_es_debug_swap_enabled = false;
ac5c48027bacb1 Paolo Bonzini 2024-04-04 3039
ac5c48027bacb1 Paolo Bonzini 2024-04-04 3040 sev_supported_vmsa_features = 0;
ac5c48027bacb1 Paolo Bonzini 2024-04-04 3041 if (sev_es_debug_swap_enabled)
ac5c48027bacb1 Paolo Bonzini 2024-04-04 3042 sev_supported_vmsa_features |= SVM_SEV_FEAT_DEBUG_SWAP;
eaf78265a4ab33 Joerg Roedel 2020-03-24 3043 }
eaf78265a4ab33 Joerg Roedel 2020-03-24 3044
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-07-24 9:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 17:36 [PATCH v4 0/4] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 1/4] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 2/4] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 3/4] treewide: Explicitly include the x86 CPUID headers Ahmed S. Darwish
2025-07-23 17:36 ` [PATCH v4 4/4] x86/cpu: <asm/processor.h>: Do not include the CPUID API header Ahmed S. Darwish
2025-07-24 9:11 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).