Patch "s390: enable HAVE_IOREMAP_PROT" has been added to the 5.13-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    s390: enable HAVE_IOREMAP_PROT

to the 5.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     s390-enable-have_ioremap_prot.patch
and it can be found in the queue-5.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3a666411ed34b4014ecf3b9c681b787a14c134b2
Author: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
Date:   Fri Feb 19 12:00:52 2021 +0100

    s390: enable HAVE_IOREMAP_PROT
    
    [ Upstream commit d460bb6c6417588dd8b0907d34f69b237918812a ]
    
    In commit b02002cc4c0f ("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: b02002cc4c0f ("s390/pci: Implement ioremap_wc/prot() with MIO")
    Reviewed-by: Gerald Schaefer <gerald.schaefer@xxxxxxxxxxxxx>
    Signed-off-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
    Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index b4c7c34069f8..d6582f57e0a1 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -164,6 +164,7 @@ config S390
 	select HAVE_FUTEX_CMPXCHG if FUTEX
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO
+	select HAVE_IOREMAP_PROT if PCI
 	select HAVE_IRQ_EXIT_ON_IRQ_STACK
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index b38f7b781564..adea53f69bfd 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -863,6 +863,25 @@ static inline int pte_unused(pte_t pte)
 	return pte_val(pte) & _PAGE_UNUSED;
 }
 
+/*
+ * Extract the pgprot value from the given pte while at the same time making it
+ * usable for kernel address space mappings where fault driven dirty and
+ * young/old accounting is not supported, i.e _PAGE_PROTECT and _PAGE_INVALID
+ * must not be set.
+ */
+static inline pgprot_t pte_pgprot(pte_t pte)
+{
+	unsigned long pte_flags = pte_val(pte) & _PAGE_CHG_MASK;
+
+	if (pte_write(pte))
+		pte_flags |= pgprot_val(PAGE_KERNEL);
+	else
+		pte_flags |= pgprot_val(PAGE_KERNEL_RO);
+	pte_flags |= pte_val(pte) & mio_wb_bit_mask;
+
+	return __pgprot(pte_flags);
+}
+
 /*
  * pgd/pmd/pte modification functions
  */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux