patch-2.4.21 linux-2.4.21/include/asm-s390x/page.h

Next file: linux-2.4.21/include/asm-s390x/pci.h
Previous file: linux-2.4.21/include/asm-s390x/io.h
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/include/asm-s390x/page.h linux-2.4.21/include/asm-s390x/page.h
@@ -9,6 +9,7 @@
 #ifndef _S390_PAGE_H
 #define _S390_PAGE_H
 
+#include <asm/errno.h>
 #include <asm/setup.h>
 
 /* PAGE_SHIFT determines the page size */
@@ -16,6 +17,9 @@
 #define PAGE_SIZE       (1UL << PAGE_SHIFT)
 #define PAGE_MASK       (~(PAGE_SIZE-1))
 
+#define STORAGE_ACC_KEY		6
+#define STORAGE_ACC_KEY_MASK	(STORAGE_ACC_KEY<<4)
+
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
@@ -126,6 +130,59 @@
 #define virt_to_page(kaddr)	(mem_map + (__pa(kaddr) >> PAGE_SHIFT))
 #define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
 
+/* the pfix table of all mem addresses */
+extern void* *pfix_table;
+#define pfix_get_page_addr(ptr) (pfix_table[(unsigned long)ptr>>PAGE_SHIFT])
+#define pfix_get_addr(ptr) (pfix_get_page_addr(ptr)+ \
+			    ((unsigned long)ptr&PAGE_MASK))
+
+/*
+ * These two functions allow to lock and unlock pages in VM. They need
+ * the absolute address of the page to be locked or unlocked. This will
+ * only work if the diag98 option in the user directory is enabled for
+ * the guest.
+ */
+
+/* if result is 0, addr will become the host absolute address */
+extern __inline__ int pfix_lock_page(void *addr)
+{
+        int ret = -ENOMEM;
+
+        if (!MACHINE_HAS_PFIX)
+                return -ENOSYS;
+
+        __asm__ __volatile__(
+                "   lg    0,%1\n"  /* parameter in gpr 0 */
+                "   lghi  2,0\n"   /* function code is 0 */
+                "   diag  2,0,0x98\n" /* result in gpr 1 */
+                "   jnz   0f\n"
+                "   lghi  %0,0\n"
+                "0: lg    %1,1\n"  /* gpr1 contains host absol. addr */
+                : "+d" (ret), "+d" ((unsigned long)addr) : 
+                : "0", "1", "2", "cc" );
+        return ret;
+}
+
+extern __inline__ int pfix_unlock_page(unsigned long addr)
+{
+        int ret = -EINVAL;
+
+        if (!MACHINE_HAS_PFIX)
+                return -ENOSYS;
+
+        __asm__ __volatile__(
+                "   lgr   0,%1\n"  /* parameter in gpr 0 */
+                "   lghi  2,4\n"   /* function code is 4 */
+                "   diag  2,0,0x98\n" /* result in gpr 1 */
+                "   jnz   0f\n"
+                "   lghi  %0,0\n"
+                "0:\n"
+                : "+d" (ret)
+                : "a" (addr)
+                : "0", "1", "2", "cc" );
+        return ret;
+}
+
 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)