🐛 Order the region's stores before a register store on arm64
A doorbell names what the guest wrote to the region before it. Each writer publishes with a release store and a full fence. On x86-64 that keeps every store in order, the register's included. On arm64 those barriers (DMB ISH) order the stores for the guest's CPUs alone, the inner-shareable domain. The device is no CPU of the guest's. Both of the kext's register writes, the display's and the accelerator's, now take a DMB OSHST before the store on arm64, as Linux's writel does before a doorbell. The doorbell a process rings reaches the device through the accelerator's writeRegister, so it is covered too. The function is empty on x86-64.
This commit is contained in:
1 parent
73cd560ec1
commit
2dfdbe1df5
3 files changed
+16
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include "RgfxBootConsole.hpp"
|
||||
#include "RgfxFeatures.hpp"
|
||||
#include "RgfxPipeColor.hpp"
|
||||
#include "RgfxRegionMapping.hpp"
|
||||
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <IOKit/IOPlatformExpert.h>
|
||||
@@ -169,6 +170,7 @@ UInt32 ReimsGraphics::readRegister(UInt32 offset) const
|
||||
|
||||
void ReimsGraphics::writeRegister(UInt32 offset, UInt32 value)
|
||||
{
|
||||
rgfxRegisterWriteBarrier();
|
||||
*reinterpret_cast<volatile UInt32 *>(registers + offset) = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "RgfxFeatures.hpp"
|
||||
#include "RgfxIOSurfaceKPI.hpp"
|
||||
#include "RgfxPciClass.hpp"
|
||||
#include "RgfxRegionMapping.hpp"
|
||||
#include "RgfxSurfaceRows.hpp"
|
||||
#include "RgfxTrace.hpp"
|
||||
#include "RgfxVideoCodecs.hpp"
|
||||
@@ -295,6 +296,7 @@ UInt32 RgfxAccelerator::readRegister(UInt32 offset) const
|
||||
|
||||
void RgfxAccelerator::writeRegister(UInt32 offset, UInt32 value)
|
||||
{
|
||||
rgfxRegisterWriteBarrier();
|
||||
*reinterpret_cast<volatile UInt32 *>(registers + offset) = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +38,16 @@ constexpr bool kRgfxRegionWriteCombines = true;
|
||||
constexpr uint64_t kRgfxKextFeatureRegionWriteCombined =
|
||||
kRgfxRegionWriteCombines ? kRgfxKextFeatureWriteCombined : 0;
|
||||
|
||||
// Before a store to the device's registers (a doorbell, a status): orders every store before it,
|
||||
// the region's among them, before the register's store for the device. On arm64 the region's
|
||||
// release stores and fences order them for the guest's CPUs alone (inner shareable), and the
|
||||
// device is no CPU of the guest's, so the register's store takes a DMB OSHST first, as Linux's
|
||||
// writel does. x86-64 keeps every store in order, and takes nothing.
|
||||
inline void rgfxRegisterWriteBarrier()
|
||||
{
|
||||
#if RGFX_GUEST_ARM64
|
||||
__builtin_arm_dmb(2); // DMB OSHST
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // RGFX_REGION_MAPPING_HPP_
|
||||
Reference in new issue
Block a user