@@ -63,7 +63,7 @@ NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING pRe
63
63
64
64
/* Setup print buffer, since we print from SPL */
65
65
initDbgCircularBuffer ();
66
-
66
+
67
67
spl_start ();
68
68
69
69
kstat_osx_init (pRegistryPath );
@@ -147,6 +147,8 @@ void spl_update_version(HANDLE h, PUNICODE_STRING pRegistryPath)
147
147
}
148
148
}
149
149
150
+ extern boolean_t spl_minimal_physmem_p_logic (void );
151
+ extern uint64_t total_memory ;
150
152
int spl_check_assign_types (kstat_named_t * kold , PKEY_VALUE_FULL_INFORMATION regBuffer )
151
153
{
152
154
@@ -162,12 +164,27 @@ int spl_check_assign_types(kstat_named_t *kold, PKEY_VALUE_FULL_INFORMATION regB
162
164
return 0 ;
163
165
}
164
166
uint64_t newvalue = * (uint64_t * )((uint8_t * )regBuffer + regBuffer -> DataOffset );
165
- KdPrintEx ((DPFLTR_IHVDRIVER_ID , DPFLTR_ERROR_LEVEL , "%s: kstat '%s': 0x%llx -> 0x%llx\n" , __func__ ,
166
- kold -> name ,
167
- kold -> value .ui64 ,
168
- newvalue
169
- ));
170
- kold -> value .ui64 = newvalue ;
167
+ if (strcmp (kold -> name , "zfs_total_memory_limit" ) == 0 ) {
168
+ if (newvalue >= 2ULL * 1024ULL * 1024ULL * 1024ULL && newvalue < total_memory ) {
169
+ dprintf ("%s:%d: total_memory 0x%llx -> %llx\n" , __func__ , __LINE__ , total_memory , MIN (newvalue , total_memory ));
170
+ total_memory = MIN (newvalue , total_memory );
171
+ physmem = total_memory / PAGE_SIZE ;
172
+ spl_minimal_physmem_p_logic ();
173
+ KdPrintEx ((DPFLTR_IHVDRIVER_ID , DPFLTR_ERROR_LEVEL , "%s: kstat '%s': 0x%llx -> 0x%llx\n" , __func__ ,
174
+ kold -> name ,
175
+ kold -> value .ui64 ,
176
+ newvalue ));
177
+ kold -> value .ui64 = newvalue ;
178
+ } else {
179
+ dprintf ("%s:%d: Invalid value 0x%llx for %s, value should be >=0x%llx and <=0x%llx\n" , __func__ , __LINE__ , newvalue , kold -> name , (2ULL * 1024ULL * 1024ULL * 1024ULL ), total_memory );
180
+ }
181
+ } else {
182
+ KdPrintEx ((DPFLTR_IHVDRIVER_ID , DPFLTR_ERROR_LEVEL , "%s: kstat '%s': 0x%llx -> 0x%llx\n" , __func__ ,
183
+ kold -> name ,
184
+ kold -> value .ui64 ,
185
+ newvalue ));
186
+ kold -> value .ui64 = newvalue ;
187
+ }
171
188
return 1 ;
172
189
}
173
190
0 commit comments