linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers
@ 2025-07-22  6:54 Ahmed S. Darwish
  2025-07-22  6:54 ` [PATCH v3 1/6] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Ahmed S. Darwish @ 2025-07-22  6:54 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 the former has no need for the latter.

For this to work, modify all CPUID call sites which implicitly include
the CPUID <asm/cpuid/api.h> header to explicitly include it instead.

Note, 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 v3
~~~~~~~~~~~~

* 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 (6):
  x86/cpuid: Remove transitional <asm/cpuid.h> header
  ASoC: Intel: avs: Include CPUID header at file scope
  x86: Reorder headers alphabetically
  drivers: Reorder headers alphabetically
  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                   |  9 +--
 arch/x86/coco/tdx/tdx.c                       |  6 +-
 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                  | 15 ++--
 arch/x86/events/intel/core.c                  |  1 +
 arch/x86/events/intel/lbr.c                   |  1 +
 arch/x86/events/zhaoxin/core.c                | 12 ++--
 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                   | 71 ++++++++++---------
 arch/x86/kernel/cpu/amd.c                     | 26 +++----
 arch/x86/kernel/cpu/centaur.c                 |  1 +
 arch/x86/kernel/cpu/hygon.c                   |  1 +
 arch/x86/kernel/cpu/mce/core.c                | 63 ++++++++--------
 arch/x86/kernel/cpu/mce/inject.c              |  1 +
 arch/x86/kernel/cpu/microcode/amd.c           | 13 ++--
 arch/x86/kernel/cpu/microcode/core.c          | 23 +++---
 arch/x86/kernel/cpu/microcode/intel.c         | 12 ++--
 arch/x86/kernel/cpu/mshyperv.c                | 29 ++++----
 arch/x86/kernel/cpu/resctrl/core.c            |  6 +-
 arch/x86/kernel/cpu/resctrl/monitor.c         |  1 +
 arch/x86/kernel/cpu/scattered.c               |  3 +-
 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         |  3 +-
 arch/x86/kernel/cpu/topology_ext.c            |  1 +
 arch/x86/kernel/cpu/transmeta.c               |  3 +
 arch/x86/kernel/cpu/vmware.c                  | 14 ++--
 arch/x86/kernel/cpu/zhaoxin.c                 |  1 +
 arch/x86/kernel/cpuid.c                       |  1 +
 arch/x86/kernel/jailhouse.c                   | 10 +--
 arch/x86/kernel/kvm.c                         | 36 +++++-----
 arch/x86/kernel/paravirt.c                    | 29 ++++----
 arch/x86/kvm/mmu/mmu.c                        | 57 +++++++--------
 arch/x86/kvm/mmu/spte.c                       |  1 +
 arch/x86/kvm/reverse_cpuid.h                  |  2 +
 arch/x86/kvm/svm/sev.c                        | 26 +++----
 arch/x86/kvm/svm/svm.c                        | 51 ++++++-------
 arch/x86/kvm/vmx/pmu_intel.c                  |  7 +-
 arch/x86/kvm/vmx/sgx.c                        |  3 +-
 arch/x86/kvm/vmx/vmx.c                        | 19 ++---
 arch/x86/mm/pti.c                             | 22 +++---
 arch/x86/pci/xen.c                            | 23 +++---
 arch/x86/xen/enlighten_hvm.c                  | 13 ++--
 arch/x86/xen/pmu.c                            | 13 ++--
 arch/x86/xen/time.c                           | 23 +++---
 drivers/char/agp/efficeon-agp.c               | 11 +--
 drivers/cpufreq/longrun.c                     |  7 +-
 drivers/cpufreq/powernow-k7.c                 | 14 ++--
 drivers/cpufreq/powernow-k8.c                 | 17 ++---
 drivers/cpufreq/speedstep-lib.c               |  6 +-
 drivers/firmware/efi/libstub/x86-5lvl.c       |  1 +
 drivers/gpu/drm/gma500/mmu.c                  |  2 +
 drivers/hwmon/fam15h_power.c                  | 14 ++--
 drivers/hwmon/k10temp.c                       |  2 +
 drivers/hwmon/k8temp.c                        | 12 ++--
 .../net/ethernet/stmicro/stmmac/dwmac-intel.c |  5 +-
 drivers/ras/amd/fmpm.c                        |  3 +-
 drivers/thermal/intel/intel_hfi.c             |  1 +
 drivers/thermal/intel/x86_pkg_temp_thermal.c  | 15 ++--
 drivers/virt/acrn/hsm.c                       |  1 +
 drivers/xen/events/events_base.c              | 28 ++++----
 drivers/xen/grant-table.c                     | 15 ++--
 drivers/xen/xenbus/xenbus_xs.c                | 23 +++---
 sound/soc/intel/avs/tgl.c                     | 25 ++++---
 73 files changed, 496 insertions(+), 387 deletions(-)
 delete mode 100644 arch/x86/include/asm/cpuid.h

base-commit: 89be9a83ccf1f88522317ce02f854f30d6115c41
-- 
2.50.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-07-22 14:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22  6:54 [PATCH v3 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-22  6:54 ` [PATCH v3 1/6] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-07-22  6:54 ` [PATCH v3 2/6] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish
2025-07-22  6:54 ` [PATCH v3 3/6] x86: Reorder headers alphabetically Ahmed S. Darwish
2025-07-22 14:18   ` Sean Christopherson
2025-07-22  6:54 ` [PATCH v3 4/6] drivers: " Ahmed S. Darwish
2025-07-22  6:54 ` [PATCH v3 5/6] treewide: Explicitly include the x86 CPUID headers Ahmed S. Darwish
2025-07-22  6:54 ` [PATCH v3 6/6] x86/cpu: <asm/processor.h>: Do not include the CPUID API header Ahmed S. Darwish

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).