Skip to content

Commit 11a86e0

Browse files
niklas88gregkh
authored andcommitted
s390: enable HAVE_IOREMAP_PROT
[ Upstream commit d460bb6 ] In commit b02002c ("s390/pci: Implement ioremap_wc/prot() with MIO") we implemented both ioremap_wc() and ioremap_prot() however until now we had not set HAVE_IOREMAP_PROT in Kconfig, do so now. This also requires implementing pte_pgprot() as this is used in the generic_access_phys() code enabled by CONFIG_HAVE_IOREMAP_PROT. As with ioremap_wc() we need to take the MMIO Write Back bit index into account. Moreover since the pgprot value returned from pte_pgprot() is to be used for mappings into kernel address space we must make sure that it uses appropriate kernel page table protection bits. In particular a pgprot value originally coming from userspace could have the _PAGE_PROTECT bit set to enable fault based dirty bit accounting which would then make the mapping inaccessible when used in kernel address space. Fixes: b02002c ("s390/pci: Implement ioremap_wc/prot() with MIO") Reviewed-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5cef836 commit 11a86e0

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎arch/s390/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ config S390
164164
select HAVE_FUTEX_CMPXCHG if FUTEX
165165
select HAVE_GCC_PLUGINS
166166
select HAVE_GENERIC_VDSO
167+
select HAVE_IOREMAP_PROT if PCI
167168
select HAVE_IRQ_EXIT_ON_IRQ_STACK
168169
select HAVE_KERNEL_BZIP2
169170
select HAVE_KERNEL_GZIP

‎arch/s390/include/asm/pgtable.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,25 @@ static inline int pte_unused(pte_t pte)
863863
return pte_val(pte) & _PAGE_UNUSED;
864864
}
865865

866+
/*
867+
* Extract the pgprot value from the given pte while at the same time making it
868+
* usable for kernel address space mappings where fault driven dirty and
869+
* young/old accounting is not supported, i.e _PAGE_PROTECT and _PAGE_INVALID
870+
* must not be set.
871+
*/
872+
static inline pgprot_t pte_pgprot(pte_t pte)
873+
{
874+
unsigned long pte_flags = pte_val(pte) & _PAGE_CHG_MASK;
875+
876+
if (pte_write(pte))
877+
pte_flags |= pgprot_val(PAGE_KERNEL);
878+
else
879+
pte_flags |= pgprot_val(PAGE_KERNEL_RO);
880+
pte_flags |= pte_val(pte) & mio_wb_bit_mask;
881+
882+
return __pgprot(pte_flags);
883+
}
884+
866885
/*
867886
* pgd/pmd/pte modification functions
868887
*/

0 commit comments

Comments
 (0)