microsoft / graphics-driver-samples

This repository contains graphics driver samples used to demonstrate how to write graphics driver for the windows platform.
Other
378 stars 132 forks source link

KeInvalidateAllCaches() alternative for ARM64 #60

Open tester962 opened 5 years ago

tester962 commented 5 years ago

The driver can't be compiled on ARM64 because of the missing KeInvalidateAllCaches(). Can someone provide an alternative using KeInvalidateRangeAllCaches() ?

File: RosKmdRapAdapter.cpp, line 445

BelleNottelling commented 5 years ago

According to this: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddk/nf-ntddk-keinvalidateallcaches, KeInvalidateAllCaches() is availbe universally on all platforms

thchi12 commented 5 years ago

But VS refuses to build that when set to ARM64 and complains about KeInvalidateAllCaches.

BelleNottelling commented 5 years ago

Yeah, I know. I'm not sure why it does that. It happens even if you include ntddk.h

thchi12 commented 5 years ago

It seems this thing cannot be used in WoA ARM64. I opened ntoskrnl.exe using IDA and searched for it but found nothing. While the x64 one does have this.

pmsjt commented 1 year ago

Arm arch itself does not provide a way to clean and/or invalidate the entire d-cache. This means that d-cache clean operations always need a start address and length. That is the reason a parameter-less KeInvalidateAllCaches cannot be implemented reliably.

_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
NTKERNELAPI
VOID
FASTCALL
KeInvalidateRangeAllCaches (
    _In_ PVOID BaseAddress,
    _In_ ULONG Length
    );

Is the replacement and it is available on all architectures. For some reason, I can't find it in the documentation. Will try to investigate why.

pmsjt commented 1 year ago

Doc is live :)

https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/nf-ntddk-keinvalidaterangeallcaches