Skip to content

Commit aecc63a

Browse files
committed
Merge branch 'sparc32-srmmu-improve-type-safety-of-__nocache_fix'
Mike Rapoport says: ==================== sparc32: srmmu: improve type safety of __nocache_fix() As discussed at [1] the __nocache_fix() macro in sparc's SRMMU can be made type safe and so the compiler will yell anout misuse of pXd pointers for which the __nocache_fix() is primarily used. The first patch is an fix of such misuse that I've discovered after adding type cast to __nocache_fix(), but to avoid breaking bisection I've made it the first commit. v2: rebased on v5.8-rc2+ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 7780918 + c0d5b0c commit aecc63a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

arch/sparc/include/asm/pgtsrmmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ extern unsigned long last_valid_pfn;
113113
extern void *srmmu_nocache_pool;
114114
#define __nocache_pa(VADDR) (((unsigned long)VADDR) - SRMMU_NOCACHE_VADDR + __pa((unsigned long)srmmu_nocache_pool))
115115
#define __nocache_va(PADDR) (__va((unsigned long)PADDR) - (unsigned long)srmmu_nocache_pool + SRMMU_NOCACHE_VADDR)
116-
#define __nocache_fix(VADDR) __va(__nocache_pa(VADDR))
116+
#define __nocache_fix(VADDR) ((__typeof__(VADDR))__va(__nocache_pa(VADDR)))
117117

118118
/* Accessing the MMU control register. */
119119
unsigned int srmmu_get_mmureg(void);

arch/sparc/mm/srmmu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ static void __init srmmu_early_allocate_ptable_skeleton(unsigned long start,
689689
pgdp = pgd_offset_k(start);
690690
p4dp = p4d_offset(pgdp, start);
691691
pudp = pud_offset(p4dp, start);
692-
if (pud_none(*(pud_t *)__nocache_fix(pudp))) {
692+
if (pud_none(*__nocache_fix(pudp))) {
693693
pmdp = __srmmu_get_nocache(
694694
SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE);
695695
if (pmdp == NULL)
@@ -698,7 +698,7 @@ static void __init srmmu_early_allocate_ptable_skeleton(unsigned long start,
698698
pud_set(__nocache_fix(pudp), pmdp);
699699
}
700700
pmdp = pmd_offset(__nocache_fix(pudp), start);
701-
if (srmmu_pmd_none(*(pmd_t *)__nocache_fix(pmdp))) {
701+
if (srmmu_pmd_none(*__nocache_fix(pmdp))) {
702702
ptep = __srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
703703
if (ptep == NULL)
704704
early_pgtable_allocfail("pte");
@@ -810,33 +810,33 @@ static void __init srmmu_inherit_prom_mappings(unsigned long start,
810810
p4dp = p4d_offset(pgdp, start);
811811
pudp = pud_offset(p4dp, start);
812812
if (what == 2) {
813-
*(pgd_t *)__nocache_fix(pgdp) = __pgd(probed);
813+
*__nocache_fix(pgdp) = __pgd(probed);
814814
start += PGDIR_SIZE;
815815
continue;
816816
}
817-
if (pud_none(*(pud_t *)__nocache_fix(pudp))) {
817+
if (pud_none(*__nocache_fix(pudp))) {
818818
pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE,
819819
SRMMU_PMD_TABLE_SIZE);
820820
if (pmdp == NULL)
821821
early_pgtable_allocfail("pmd");
822822
memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE);
823823
pud_set(__nocache_fix(pudp), pmdp);
824824
}
825-
pmdp = pmd_offset(__nocache_fix(pgdp), start);
825+
pmdp = pmd_offset(__nocache_fix(pudp), start);
826826
if (what == 1) {
827827
*(pmd_t *)__nocache_fix(pmdp) = __pmd(probed);
828828
start += PMD_SIZE;
829829
continue;
830830
}
831-
if (srmmu_pmd_none(*(pmd_t *)__nocache_fix(pmdp))) {
831+
if (srmmu_pmd_none(*__nocache_fix(pmdp))) {
832832
ptep = __srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
833833
if (ptep == NULL)
834834
early_pgtable_allocfail("pte");
835835
memset(__nocache_fix(ptep), 0, PTE_SIZE);
836836
pmd_set(__nocache_fix(pmdp), ptep);
837837
}
838838
ptep = pte_offset_kernel(__nocache_fix(pmdp), start);
839-
*(pte_t *)__nocache_fix(ptep) = __pte(probed);
839+
*__nocache_fix(ptep) = __pte(probed);
840840
start += PAGE_SIZE;
841841
}
842842
}
@@ -850,7 +850,7 @@ static void __init do_large_mapping(unsigned long vaddr, unsigned long phys_base
850850
unsigned long big_pte;
851851

852852
big_pte = KERNEL_PTE(phys_base >> 4);
853-
*(pgd_t *)__nocache_fix(pgdp) = __pgd(big_pte);
853+
*__nocache_fix(pgdp) = __pgd(big_pte);
854854
}
855855

856856
/* Map sp_bank entry SP_ENTRY, starting at virtual address VBASE. */
@@ -940,7 +940,7 @@ void __init srmmu_paging_init(void)
940940
srmmu_ctx_table_phys = (ctxd_t *)__nocache_pa(srmmu_context_table);
941941

942942
for (i = 0; i < num_contexts; i++)
943-
srmmu_ctxd_set((ctxd_t *)__nocache_fix(&srmmu_context_table[i]), srmmu_swapper_pg_dir);
943+
srmmu_ctxd_set(__nocache_fix(&srmmu_context_table[i]), srmmu_swapper_pg_dir);
944944

945945
flush_cache_all();
946946
srmmu_set_ctable_ptr((unsigned long)srmmu_ctx_table_phys);

0 commit comments

Comments
 (0)