public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block
@ 2026-03-09 12:38 Ritesh Harjani (IBM)
  2026-03-09 12:38 ` [PATCH v2 2/2] powerpc/64s: Add support for huge pfnmaps Ritesh Harjani (IBM)
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-03-09 12:38 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Madhavan Srinivasan, Christophe Leroy, linux-mm, kvm,
	Alex Williamson, Peter Xu, Ritesh Harjani (IBM)

Architectures like PowerPC uses runtime defined values for
PMD_ORDER/PUD_ORDER. This is because it can use either RADIX or HASH MMU
at runtime using kernel cmdline. So the pXd_index_size is not known at
compile time. Without this fix, when we add huge pfn support on powerpc
in the next patch, vfio_pci_core driver compilation can fail with the
following errors.

  CC [M]  drivers/vfio/vfio_main.o
  CC [M]  drivers/vfio/group.o
  CC [M]  drivers/vfio/container.o
  CC [M]  drivers/vfio/virqfd.o
  CC [M]  drivers/vfio/vfio_iommu_spapr_tce.o
  CC [M]  drivers/vfio/pci/vfio_pci_core.o
  CC [M]  drivers/vfio/pci/vfio_pci_intrs.o
  CC [M]  drivers/vfio/pci/vfio_pci_rdwr.o
  CC [M]  drivers/vfio/pci/vfio_pci_config.o
  CC [M]  drivers/vfio/pci/vfio_pci.o
  AR      kernel/built-in.a
../drivers/vfio/pci/vfio_pci_core.c: In function ‘vfio_pci_vmf_insert_pfn’:
../drivers/vfio/pci/vfio_pci_core.c:1678:9: error: case label does not reduce to an integer constant
 1678 |         case PMD_ORDER:
      |         ^~~~
../drivers/vfio/pci/vfio_pci_core.c:1682:9: error: case label does not reduce to an integer constant
 1682 |         case PUD_ORDER:
      |         ^~~~
make[6]: *** [../scripts/Makefile.build:289: drivers/vfio/pci/vfio_pci_core.o] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:546: drivers/vfio/pci] Error 2
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [../scripts/Makefile.build:546: drivers/vfio] Error 2
make[3]: *** [../scripts/Makefile.build:546: drivers] Error 2

Fixes: f9e54c3a2f5b7 ("vfio/pci: implement huge_fault support")
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
v1 -> v2:
1. addressed review comments from Christophe [1]
[1]: https://lore.kernel.org/linuxppc-dev/0b8fce7a61561640634317a5e287cdb4794715fd.1772170860.git.ritesh.list@gmail.com/

 drivers/vfio/pci/vfio_pci_core.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index d43745fe4c84..0967307235b8 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -1670,21 +1670,16 @@ vm_fault_t vfio_pci_vmf_insert_pfn(struct vfio_pci_core_device *vdev,
 	if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
 		return VM_FAULT_SIGBUS;

-	switch (order) {
-	case 0:
+	if (!order)
 		return vmf_insert_pfn(vmf->vma, vmf->address, pfn);
-#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
-	case PMD_ORDER:
+
+	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP) && order == PMD_ORDER)
 		return vmf_insert_pfn_pmd(vmf, pfn, false);
-#endif
-#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
-	case PUD_ORDER:
+
+	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PUD_PFNMAP) && order == PUD_ORDER)
 		return vmf_insert_pfn_pud(vmf, pfn, false);
-		break;
-#endif
-	default:
-		return VM_FAULT_FALLBACK;
-	}
+
+	return VM_FAULT_FALLBACK;
 }
 EXPORT_SYMBOL_GPL(vfio_pci_vmf_insert_pfn);

--
2.39.5



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

* [PATCH v2 2/2] powerpc/64s: Add support for huge pfnmaps
  2026-03-09 12:38 [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Ritesh Harjani (IBM)
@ 2026-03-09 12:38 ` Ritesh Harjani (IBM)
  2026-03-09 14:24 ` [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Christophe Leroy (CS GROUP)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-03-09 12:38 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Madhavan Srinivasan, Christophe Leroy, linux-mm, kvm,
	Alex Williamson, Peter Xu, Ritesh Harjani (IBM)

This uses _RPAGE_SW2 bit for the PMD and PUDs similar to PTEs.
This also adds support for {pte,pmd,pud}_pgprot helpers needed for
follow_pfnmap APIs.

This allows us to extend the PFN mappings, e.g. PCI MMIO bars where
it can grow as large as 8GB or even bigger, to map at PMD / PUD level.
VFIO PCI core driver already supports fault handling at PMD / PUD level
for more efficient BAR mappings.

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
v1 -> v2:
1. Added CONFIG_PPC64 #ifdef blocks around p{u|m}d_pgprot()
2. Retained the RB from Christophe.

 arch/powerpc/Kconfig                         |  1 +
 arch/powerpc/include/asm/book3s/64/pgtable.h | 23 ++++++++++++++++++++
 arch/powerpc/include/asm/pgtable.h           | 14 ++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ad7a2fe63a2a..cf9283757e5d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -172,6 +172,7 @@ config PPC
 	select ARCH_STACKWALK
 	select ARCH_SUPPORTS_ATOMIC_RMW
 	select ARCH_SUPPORTS_DEBUG_PAGEALLOC	if PPC_BOOK3S || PPC_8xx
+	select ARCH_SUPPORTS_HUGE_PFNMAP	if PPC_BOOK3S_64 && TRANSPARENT_HUGEPAGE
 	select ARCH_SUPPORTS_PAGE_TABLE_CHECK	if !HUGETLB_PAGE
 	select ARCH_SUPPORTS_SCHED_MC		if SMP
 	select ARCH_SUPPORTS_SCHED_SMT		if PPC64 && SMP
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 1a91762b455d..639cbf34f752 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1289,6 +1289,29 @@ static inline pud_t pud_mkhuge(pud_t pud)
 	return pud;
 }

+#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
+static inline bool pmd_special(pmd_t pmd)
+{
+	return pte_special(pmd_pte(pmd));
+}
+
+static inline pmd_t pmd_mkspecial(pmd_t pmd)
+{
+	return pte_pmd(pte_mkspecial(pmd_pte(pmd)));
+}
+#endif
+
+#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
+static inline bool pud_special(pud_t pud)
+{
+	return pte_special(pud_pte(pud));
+}
+
+static inline pud_t pud_mkspecial(pud_t pud)
+{
+	return pte_pud(pte_mkspecial(pud_pte(pud)));
+}
+#endif

 #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
 extern int pmdp_set_access_flags(struct vm_area_struct *vma,
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index dcd3a88caaf6..97ccfa6e3dde 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -63,6 +63,20 @@ static inline pgprot_t pte_pgprot(pte_t pte)
 	return __pgprot(pte_flags);
 }

+#ifdef CONFIG_PPC64
+#define pmd_pgprot pmd_pgprot
+static inline pgprot_t pmd_pgprot(pmd_t pmd)
+{
+	return pte_pgprot(pmd_pte(pmd));
+}
+
+#define pud_pgprot pud_pgprot
+static inline pgprot_t pud_pgprot(pud_t pud)
+{
+	return pte_pgprot(pud_pte(pud));
+}
+#endif /* CONFIG_PPC64 */
+
 static inline pgprot_t pgprot_nx(pgprot_t prot)
 {
 	return pte_pgprot(pte_exprotect(__pte(pgprot_val(prot))));
--
2.39.5



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

* Re: [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block
  2026-03-09 12:38 [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Ritesh Harjani (IBM)
  2026-03-09 12:38 ` [PATCH v2 2/2] powerpc/64s: Add support for huge pfnmaps Ritesh Harjani (IBM)
@ 2026-03-09 14:24 ` Christophe Leroy (CS GROUP)
  2026-03-09 21:46 ` Alex Williamson
  2026-03-10  6:27 ` Venkat
  3 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-03-09 14:24 UTC (permalink / raw)
  To: Ritesh Harjani (IBM), linuxppc-dev
  Cc: Madhavan Srinivasan, linux-mm, kvm, Alex Williamson, Peter Xu



Le 09/03/2026 à 13:38, Ritesh Harjani (IBM) a écrit :
> Architectures like PowerPC uses runtime defined values for
> PMD_ORDER/PUD_ORDER. This is because it can use either RADIX or HASH MMU
> at runtime using kernel cmdline. So the pXd_index_size is not known at
> compile time. Without this fix, when we add huge pfn support on powerpc
> in the next patch, vfio_pci_core driver compilation can fail with the
> following errors.
> 
>    CC [M]  drivers/vfio/vfio_main.o
>    CC [M]  drivers/vfio/group.o
>    CC [M]  drivers/vfio/container.o
>    CC [M]  drivers/vfio/virqfd.o
>    CC [M]  drivers/vfio/vfio_iommu_spapr_tce.o
>    CC [M]  drivers/vfio/pci/vfio_pci_core.o
>    CC [M]  drivers/vfio/pci/vfio_pci_intrs.o
>    CC [M]  drivers/vfio/pci/vfio_pci_rdwr.o
>    CC [M]  drivers/vfio/pci/vfio_pci_config.o
>    CC [M]  drivers/vfio/pci/vfio_pci.o
>    AR      kernel/built-in.a
> ../drivers/vfio/pci/vfio_pci_core.c: In function ‘vfio_pci_vmf_insert_pfn’:
> ../drivers/vfio/pci/vfio_pci_core.c:1678:9: error: case label does not reduce to an integer constant
>   1678 |         case PMD_ORDER:
>        |         ^~~~
> ../drivers/vfio/pci/vfio_pci_core.c:1682:9: error: case label does not reduce to an integer constant
>   1682 |         case PUD_ORDER:
>        |         ^~~~
> make[6]: *** [../scripts/Makefile.build:289: drivers/vfio/pci/vfio_pci_core.o] Error 1
> make[6]: *** Waiting for unfinished jobs....
> make[5]: *** [../scripts/Makefile.build:546: drivers/vfio/pci] Error 2
> make[5]: *** Waiting for unfinished jobs....
> make[4]: *** [../scripts/Makefile.build:546: drivers/vfio] Error 2
> make[3]: *** [../scripts/Makefile.build:546: drivers] Error 2
> 
> Fixes: f9e54c3a2f5b7 ("vfio/pci: implement huge_fault support")
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
> v1 -> v2:
> 1. addressed review comments from Christophe [1]
> [1]: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flinuxppc-dev%2F0b8fce7a61561640634317a5e287cdb4794715fd.1772170860.git.ritesh.list%40gmail.com%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C2525bc52e4e645e2fb0208de7dd8d236%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639086567353080039%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=DZuZX3hss7yYqBwYz61VgEY6J%2F7OuLViaTMYP43VoBY%3D&reserved=0
> 
>   drivers/vfio/pci/vfio_pci_core.c | 19 +++++++------------
>   1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index d43745fe4c84..0967307235b8 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -1670,21 +1670,16 @@ vm_fault_t vfio_pci_vmf_insert_pfn(struct vfio_pci_core_device *vdev,
>   	if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
>   		return VM_FAULT_SIGBUS;
> 
> -	switch (order) {
> -	case 0:
> +	if (!order)
>   		return vmf_insert_pfn(vmf->vma, vmf->address, pfn);
> -#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
> -	case PMD_ORDER:
> +
> +	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP) && order == PMD_ORDER)
>   		return vmf_insert_pfn_pmd(vmf, pfn, false);
> -#endif
> -#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
> -	case PUD_ORDER:
> +
> +	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PUD_PFNMAP) && order == PUD_ORDER)
>   		return vmf_insert_pfn_pud(vmf, pfn, false);
> -		break;
> -#endif
> -	default:
> -		return VM_FAULT_FALLBACK;
> -	}
> +
> +	return VM_FAULT_FALLBACK;
>   }
>   EXPORT_SYMBOL_GPL(vfio_pci_vmf_insert_pfn);
> 
> --
> 2.39.5
> 



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

* Re: [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block
  2026-03-09 12:38 [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Ritesh Harjani (IBM)
  2026-03-09 12:38 ` [PATCH v2 2/2] powerpc/64s: Add support for huge pfnmaps Ritesh Harjani (IBM)
  2026-03-09 14:24 ` [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Christophe Leroy (CS GROUP)
@ 2026-03-09 21:46 ` Alex Williamson
  2026-03-11  2:20   ` Ritesh Harjani
  2026-03-10  6:27 ` Venkat
  3 siblings, 1 reply; 6+ messages in thread
From: Alex Williamson @ 2026-03-09 21:46 UTC (permalink / raw)
  To: Ritesh Harjani (IBM)
  Cc: linuxppc-dev, Madhavan Srinivasan, Christophe Leroy, linux-mm,
	kvm, Peter Xu, alex


Subject prefix should be "vfio/pci:".

On Mon,  9 Mar 2026 18:08:37 +0530
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com> wrote:

> Architectures like PowerPC uses runtime defined values for

s/uses/use/

> PMD_ORDER/PUD_ORDER. This is because it can use either RADIX or HASH MMU
> at runtime using kernel cmdline. So the pXd_index_size is not known at
> compile time. Without this fix, when we add huge pfn support on powerpc
> in the next patch, vfio_pci_core driver compilation can fail with the
> following errors.
> 
>   CC [M]  drivers/vfio/vfio_main.o
>   CC [M]  drivers/vfio/group.o
>   CC [M]  drivers/vfio/container.o
>   CC [M]  drivers/vfio/virqfd.o
>   CC [M]  drivers/vfio/vfio_iommu_spapr_tce.o
>   CC [M]  drivers/vfio/pci/vfio_pci_core.o
>   CC [M]  drivers/vfio/pci/vfio_pci_intrs.o
>   CC [M]  drivers/vfio/pci/vfio_pci_rdwr.o
>   CC [M]  drivers/vfio/pci/vfio_pci_config.o
>   CC [M]  drivers/vfio/pci/vfio_pci.o
>   AR      kernel/built-in.a
> ../drivers/vfio/pci/vfio_pci_core.c: In function ‘vfio_pci_vmf_insert_pfn’:
> ../drivers/vfio/pci/vfio_pci_core.c:1678:9: error: case label does not reduce to an integer constant
>  1678 |         case PMD_ORDER:
>       |         ^~~~
> ../drivers/vfio/pci/vfio_pci_core.c:1682:9: error: case label does not reduce to an integer constant
>  1682 |         case PUD_ORDER:
>       |         ^~~~
> make[6]: *** [../scripts/Makefile.build:289: drivers/vfio/pci/vfio_pci_core.o] Error 1
> make[6]: *** Waiting for unfinished jobs....
> make[5]: *** [../scripts/Makefile.build:546: drivers/vfio/pci] Error 2
> make[5]: *** Waiting for unfinished jobs....
> make[4]: *** [../scripts/Makefile.build:546: drivers/vfio] Error 2
> make[3]: *** [../scripts/Makefile.build:546: drivers] Error 2
> 
> Fixes: f9e54c3a2f5b7 ("vfio/pci: implement huge_fault support")
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---
> v1 -> v2:
> 1. addressed review comments from Christophe [1]
> [1]: https://lore.kernel.org/linuxppc-dev/0b8fce7a61561640634317a5e287cdb4794715fd.1772170860.git.ritesh.list@gmail.com/
> 
>  drivers/vfio/pci/vfio_pci_core.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index d43745fe4c84..0967307235b8 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -1670,21 +1670,16 @@ vm_fault_t vfio_pci_vmf_insert_pfn(struct vfio_pci_core_device *vdev,
>  	if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
>  		return VM_FAULT_SIGBUS;
> 
> -	switch (order) {
> -	case 0:
> +	if (!order)
>  		return vmf_insert_pfn(vmf->vma, vmf->address, pfn);
> -#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
> -	case PMD_ORDER:
> +
> +	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP) && order == PMD_ORDER)
>  		return vmf_insert_pfn_pmd(vmf, pfn, false);
> -#endif
> -#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
> -	case PUD_ORDER:
> +
> +	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PUD_PFNMAP) && order == PUD_ORDER)
>  		return vmf_insert_pfn_pud(vmf, pfn, false);
> -		break;
> -#endif
> -	default:
> -		return VM_FAULT_FALLBACK;
> -	}
> +
> +	return VM_FAULT_FALLBACK;
>  }
>  EXPORT_SYMBOL_GPL(vfio_pci_vmf_insert_pfn);

Otherwise LGTM.  This appears to be no change for current use cases, so
I assume this will go in through ppc trees.

Reviewed-by: Alex Williamson <alex@shazbot.org>


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

* Re: [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block
  2026-03-09 12:38 [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Ritesh Harjani (IBM)
                   ` (2 preceding siblings ...)
  2026-03-09 21:46 ` Alex Williamson
@ 2026-03-10  6:27 ` Venkat
  3 siblings, 0 replies; 6+ messages in thread
From: Venkat @ 2026-03-10  6:27 UTC (permalink / raw)
  To: Ritesh Harjani (IBM)
  Cc: linuxppc-dev, Madhavan Srinivasan, Christophe Leroy, linux-mm,
	kvm, Alex Williamson, Peter Xu



> On 9 Mar 2026, at 6:08 PM, Ritesh Harjani (IBM) <ritesh.list@gmail.com> wrote:
> 
> Architectures like PowerPC uses runtime defined values for
> PMD_ORDER/PUD_ORDER. This is because it can use either RADIX or HASH MMU
> at runtime using kernel cmdline. So the pXd_index_size is not known at
> compile time. Without this fix, when we add huge pfn support on powerpc
> in the next patch, vfio_pci_core driver compilation can fail with the
> following errors.
> 
>  CC [M]  drivers/vfio/vfio_main.o
>  CC [M]  drivers/vfio/group.o
>  CC [M]  drivers/vfio/container.o
>  CC [M]  drivers/vfio/virqfd.o
>  CC [M]  drivers/vfio/vfio_iommu_spapr_tce.o
>  CC [M]  drivers/vfio/pci/vfio_pci_core.o
>  CC [M]  drivers/vfio/pci/vfio_pci_intrs.o
>  CC [M]  drivers/vfio/pci/vfio_pci_rdwr.o
>  CC [M]  drivers/vfio/pci/vfio_pci_config.o
>  CC [M]  drivers/vfio/pci/vfio_pci.o
>  AR      kernel/built-in.a
> ../drivers/vfio/pci/vfio_pci_core.c: In function ‘vfio_pci_vmf_insert_pfn’:
> ../drivers/vfio/pci/vfio_pci_core.c:1678:9: error: case label does not reduce to an integer constant
> 1678 |         case PMD_ORDER:
>      |         ^~~~
> ../drivers/vfio/pci/vfio_pci_core.c:1682:9: error: case label does not reduce to an integer constant
> 1682 |         case PUD_ORDER:
>      |         ^~~~
> make[6]: *** [../scripts/Makefile.build:289: drivers/vfio/pci/vfio_pci_core.o] Error 1
> make[6]: *** Waiting for unfinished jobs....
> make[5]: *** [../scripts/Makefile.build:546: drivers/vfio/pci] Error 2
> make[5]: *** Waiting for unfinished jobs....
> make[4]: *** [../scripts/Makefile.build:546: drivers/vfio] Error 2
> make[3]: *** [../scripts/Makefile.build:546: drivers] Error 2
> 
> Fixes: f9e54c3a2f5b7 ("vfio/pci: implement huge_fault support")
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---

Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>

Tested this patch, and with this, build is successful and reported issue is fixed.


WithOut this patch:

drivers/vfio/pci/vfio_pci_core.c: In function ‘vfio_pci_vmf_insert_pfn’:
drivers/vfio/pci/vfio_pci_core.c:1677:9: error: case label does not reduce to an integer constant
 1677 |         case PMD_ORDER:
      |         ^~~~
drivers/vfio/pci/vfio_pci_core.c:1681:9: error: case label does not reduce to an integer constant
 1681 |         case PUD_ORDER:
      |         ^~~~

Regards,
Venkat.
> v1 -> v2:
> 1. addressed review comments from Christophe [1]
> [1]: https://lore.kernel.org/linuxppc-dev/0b8fce7a61561640634317a5e287cdb4794715fd.1772170860.git.ritesh.list@gmail.com/
> 
> drivers/vfio/pci/vfio_pci_core.c | 19 +++++++------------
> 1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index d43745fe4c84..0967307235b8 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -1670,21 +1670,16 @@ vm_fault_t vfio_pci_vmf_insert_pfn(struct vfio_pci_core_device *vdev,
> if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
> return VM_FAULT_SIGBUS;
> 
> - switch (order) {
> - case 0:
> + if (!order)
> return vmf_insert_pfn(vmf->vma, vmf->address, pfn);
> -#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
> - case PMD_ORDER:
> +
> + if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP) && order == PMD_ORDER)
> return vmf_insert_pfn_pmd(vmf, pfn, false);
> -#endif
> -#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
> - case PUD_ORDER:
> +
> + if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PUD_PFNMAP) && order == PUD_ORDER)
> return vmf_insert_pfn_pud(vmf, pfn, false);
> - break;
> -#endif
> - default:
> - return VM_FAULT_FALLBACK;
> - }
> +
> + return VM_FAULT_FALLBACK;
> }
> EXPORT_SYMBOL_GPL(vfio_pci_vmf_insert_pfn);
> 
> --
> 2.39.5
> 
> 



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

* Re: [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block
  2026-03-09 21:46 ` Alex Williamson
@ 2026-03-11  2:20   ` Ritesh Harjani
  0 siblings, 0 replies; 6+ messages in thread
From: Ritesh Harjani @ 2026-03-11  2:20 UTC (permalink / raw)
  To: Alex Williamson
  Cc: linuxppc-dev, Madhavan Srinivasan, Christophe Leroy, linux-mm,
	kvm, Peter Xu, alex

Alex Williamson <alex@shazbot.org> writes:

> Subject prefix should be "vfio/pci:".
>
> On Mon,  9 Mar 2026 18:08:37 +0530
> "Ritesh Harjani (IBM)" <ritesh.list@gmail.com> wrote:
>
>> Architectures like PowerPC uses runtime defined values for
>
> s/uses/use/
>

@maddy can we wrap this in while applying?
Otherwise - please let me know and I can re-send another version.

>> PMD_ORDER/PUD_ORDER. This is because it can use either RADIX or HASH MMU
>> at runtime using kernel cmdline. So the pXd_index_size is not known at
>> compile time. Without this fix, when we add huge pfn support on powerpc
>> in the next patch, vfio_pci_core driver compilation can fail with the
>> following errors.
>> 
>>   CC [M]  drivers/vfio/vfio_main.o
>>   CC [M]  drivers/vfio/group.o
>>   CC [M]  drivers/vfio/container.o
>>   CC [M]  drivers/vfio/virqfd.o
>>   CC [M]  drivers/vfio/vfio_iommu_spapr_tce.o
>>   CC [M]  drivers/vfio/pci/vfio_pci_core.o
>>   CC [M]  drivers/vfio/pci/vfio_pci_intrs.o
>>   CC [M]  drivers/vfio/pci/vfio_pci_rdwr.o
>>   CC [M]  drivers/vfio/pci/vfio_pci_config.o
>>   CC [M]  drivers/vfio/pci/vfio_pci.o
>>   AR      kernel/built-in.a
>> ../drivers/vfio/pci/vfio_pci_core.c: In function ‘vfio_pci_vmf_insert_pfn’:
>> ../drivers/vfio/pci/vfio_pci_core.c:1678:9: error: case label does not reduce to an integer constant
>>  1678 |         case PMD_ORDER:
>>       |         ^~~~
>> ../drivers/vfio/pci/vfio_pci_core.c:1682:9: error: case label does not reduce to an integer constant
>>  1682 |         case PUD_ORDER:
>>       |         ^~~~
>> make[6]: *** [../scripts/Makefile.build:289: drivers/vfio/pci/vfio_pci_core.o] Error 1
>> make[6]: *** Waiting for unfinished jobs....
>> make[5]: *** [../scripts/Makefile.build:546: drivers/vfio/pci] Error 2
>> make[5]: *** Waiting for unfinished jobs....
>> make[4]: *** [../scripts/Makefile.build:546: drivers/vfio] Error 2
>> make[3]: *** [../scripts/Makefile.build:546: drivers] Error 2
>> 
>> Fixes: f9e54c3a2f5b7 ("vfio/pci: implement huge_fault support")
>> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> ---
>> v1 -> v2:
>> 1. addressed review comments from Christophe [1]
>> [1]: https://lore.kernel.org/linuxppc-dev/0b8fce7a61561640634317a5e287cdb4794715fd.1772170860.git.ritesh.list@gmail.com/
>> 
>>  drivers/vfio/pci/vfio_pci_core.c | 19 +++++++------------
>>  1 file changed, 7 insertions(+), 12 deletions(-)
>> 
>> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
>> index d43745fe4c84..0967307235b8 100644
>> --- a/drivers/vfio/pci/vfio_pci_core.c
>> +++ b/drivers/vfio/pci/vfio_pci_core.c
>> @@ -1670,21 +1670,16 @@ vm_fault_t vfio_pci_vmf_insert_pfn(struct vfio_pci_core_device *vdev,
>>  	if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
>>  		return VM_FAULT_SIGBUS;
>> 
>> -	switch (order) {
>> -	case 0:
>> +	if (!order)
>>  		return vmf_insert_pfn(vmf->vma, vmf->address, pfn);
>> -#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
>> -	case PMD_ORDER:
>> +
>> +	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP) && order == PMD_ORDER)
>>  		return vmf_insert_pfn_pmd(vmf, pfn, false);
>> -#endif
>> -#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
>> -	case PUD_ORDER:
>> +
>> +	if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PUD_PFNMAP) && order == PUD_ORDER)
>>  		return vmf_insert_pfn_pud(vmf, pfn, false);
>> -		break;
>> -#endif
>> -	default:
>> -		return VM_FAULT_FALLBACK;
>> -	}
>> +
>> +	return VM_FAULT_FALLBACK;
>>  }
>>  EXPORT_SYMBOL_GPL(vfio_pci_vmf_insert_pfn);
>
> Otherwise LGTM.  This appears to be no change for current use cases, so
> I assume this will go in through ppc trees.
>

I think that will make sense to take these 2 patches via the same tree,
so that we don't see any build issues on powerpc when the next patch
enables huge pfnmap support.

> Reviewed-by: Alex Williamson <alex@shazbot.org>

Thanks!


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

end of thread, other threads:[~2026-03-11  2:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 12:38 [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Ritesh Harjani (IBM)
2026-03-09 12:38 ` [PATCH v2 2/2] powerpc/64s: Add support for huge pfnmaps Ritesh Harjani (IBM)
2026-03-09 14:24 ` [PATCH v2 1/2] drivers/vfio_pci_core: Change PXD_ORDER check from switch case to if/else block Christophe Leroy (CS GROUP)
2026-03-09 21:46 ` Alex Williamson
2026-03-11  2:20   ` Ritesh Harjani
2026-03-10  6:27 ` Venkat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox