summarylogtreecommitdiffstats
path: root/4.12-npfeiler-PUD_OFFSET.patch
blob: c2b2bd5e15e108e9c6cc43ee912d88fe995f95b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
diff --git archive_files/common/lib/modules/fglrx/build_mod/firegl_public.c archive_files/common/lib/modules/fglrx/build_mod/firegl_public.c
index b2c9e7c..2e9a112 100755
--- archive_files/common/lib/modules/fglrx/build_mod/firegl_public.c
+++ archive_files/common/lib/modules/fglrx/build_mod/firegl_public.c
@@ -208,6 +208,10 @@
 #include <linux/sched/signal.h>
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+#include <asm/set_memory.h>
+#endif
+
 #include "firegl_public.h"
 #include "kcl_osconfig.h"
 #include "kcl_io.h"
@@ -2752,6 +2756,9 @@ int ATI_API_CALL KCL_MEM_VerifyWriteAccess(void* addr, kcl_size_t size)
 unsigned long ATI_API_CALL KCL_GetInitKerPte(unsigned long address)
 {
     pgd_t *pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    p4d_t *p4d_p;
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
     pud_t *pud_p;
 #endif
@@ -2766,7 +2773,13 @@ unsigned long ATI_API_CALL KCL_GetInitKerPte(unsigned long address)
 #endif
     PGD_PRESENT(pgd_p);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    P4D_OFFSET(p4d_p, pgd_p, address);
+    P4D_PRESENT(p4d_p);
+    PUD_OFFSET(pud_p, p4d_p, address);
+#else
     PUD_OFFSET(pud_p, pgd_p, address);
+#endif
     PUD_PRESENT(pud_p);
     PMD_OFFSET(pmd_p, pud_p, address);
 #else
@@ -2823,6 +2836,9 @@ unsigned long ATI_API_CALL KCL_GetPageTableByVirtAddr(
         unsigned long * page_addr)
 {
     pgd_t* pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    p4d_t *p4d_p;
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
     pud_t* pud_p;
 #endif
@@ -2835,7 +2851,13 @@ unsigned long ATI_API_CALL KCL_GetPageTableByVirtAddr(
     KCL_DEBUG2(FN_FIREGL_KCL,"pgd_p=0x%08lx\n", (unsigned long)pgd_p);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    P4D_OFFSET(p4d_p, pgd_p, virtual_addr);
+    P4D_PRESENT(p4d_p);
+    PUD_OFFSET(pud_p, p4d_p, virtual_addr);
+#else
     PUD_OFFSET(pud_p, pgd_p, virtual_addr);
+#endif
     PUD_PRESENT(pud_p);
     KCL_DEBUG2(FN_FIREGL_KCL,"pud_p=0x%08lx\n", (unsigned long)pud_p);
     PMD_OFFSET(pmd_p, pud_p, virtual_addr);
@@ -2892,6 +2914,9 @@ unsigned int ATI_API_CALL KCL_GetPageSizeByVirtAddr(
         unsigned int  * page_size)
 {
     pgd_t* pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    p4d_t *p4d_p;
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
     pud_t* pud_p;
 #endif
@@ -2904,7 +2929,13 @@ unsigned int ATI_API_CALL KCL_GetPageSizeByVirtAddr(
     KCL_DEBUG2(FN_FIREGL_KCL,"pgd_p=0x%08lx\n", (unsigned long)pgd_p);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    P4D_OFFSET(p4d_p, pgd_p, virtual_addr);
+    P4D_PRESENT(p4d_p);
+    PUD_OFFSET(pud_p, p4d_p, virtual_addr);
+#else
     PUD_OFFSET(pud_p, pgd_p, virtual_addr);
+#endif
     PUD_PRESENT(pud_p);
     KCL_DEBUG2(FN_FIREGL_KCL,"pud_p=0x%08lx\n", (unsigned long)pud_p);
     PMD_OFFSET(pmd_p, pud_p, virtual_addr);
@@ -3083,6 +3114,9 @@ int ATI_API_CALL KCL_TestAndClearPageDirtyFlag(unsigned long virtual_addr, unsig
 {
     int ret = -1; // init with page not present
     pgd_t* pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    p4d_t *p4d_p;
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
     pud_t* pud_p;
 #endif
@@ -3135,7 +3169,16 @@ int ATI_API_CALL KCL_TestAndClearPageDirtyFlag(unsigned long virtual_addr, unsig
          KCL_DEBUG1(FN_FIREGL_KCL,"pgd_p=0x%08lx\n", (unsigned long)pgd_p);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
-         PUD_OFFSET(pud_p, pgd_p, page_addr);
+        #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+        P4D_OFFSET(p4d_p, pgd_p, page_addr);
+        if (!p4d_present(*p4d_p)) {
+            KCL_DEBUG1(FN_FIREGL_KCL,"ERROR: !p4d_present\n");
+            continue;
+        }
+        PUD_OFFSET(pud_p, p4d_p, page_addr);
+        #else
+        PUD_OFFSET(pud_p, pgd_p, page_addr);
+        #endif
          if (!pud_present(*pud_p))
          {
              KCL_DEBUG1(FN_FIREGL_KCL,"ERROR: !pud_present\n");
@@ -4077,6 +4120,9 @@ char* ATI_API_CALL KCL_MEM_VM_GetRegionPhysAddrStr(struct vm_area_struct* vma,
                             kcl_dma_addr_t* phys_address)
 {
     pgd_t* pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    p4d_t *p4d_p;
+#endif
     pmd_t* pmd_p;
     pte_t  pte;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
@@ -4090,7 +4136,17 @@ char* ATI_API_CALL KCL_MEM_VM_GetRegionPhysAddrStr(struct vm_area_struct* vma,
         return buf;
     }
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+    #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+    p4d_p = p4d_offset(pgd_p, virtual_addr);
+    if (!p4d_present(*p4d_p))
+    {
+        *buf = 0;
+        return buf;
+    }
+    pud_p = pud_offset(p4d_p, virtual_addr);
+    #else
     pud_p = pud_offset(pgd_p, virtual_addr);
+    #endif
     if (!pud_present(*pud_p))
     {
         *buf = 0;
diff --git archive_files/common/lib/modules/fglrx/build_mod/firegl_public.h archive_files/common/lib/modules/fglrx/build_mod/firegl_public.h
index 14e25f9..aca2940 100755
--- archive_files/common/lib/modules/fglrx/build_mod/firegl_public.h
+++ archive_files/common/lib/modules/fglrx/build_mod/firegl_public.h
@@ -91,6 +91,23 @@ do { \
     } \
 } while(0)
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+#define P4D_OFFSET(p4d_p, pgd_p, pte_linear)  \
+do { \
+    p4d_p = p4d_offset(pgd_p, pte_linear); \
+} while(0)
+
+#define P4D_PRESENT(p4d_p) \
+do { \
+    if (!p4d_present(*(p4d_p))) \
+    { \
+        return PAGING_FAULT_SIGBUS_INT;   /* Something bad happened; generate SIGBUS */ \
+        /* alternatively we could generate a NOPAGE_OOM "out of memory" */ \
+    } \
+} while(0)
+
+#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
 #define PUD_PRESENT(pud_p) \
 do { \