virtio-win / kvm-guest-drivers-windows

Windows paravirtualized drivers for QEMU\KVM
https://www.linux-kvm.org/page/WindowsGuestDrivers
BSD 3-Clause "New" or "Revised" License
1.99k stars 382 forks source link

WPP_GLOBAL_Control clarification #466

Closed janisozaur closed 3 years ago

janisozaur commented 4 years ago

While looking at the code I noticed following snippet, extracted from preprocessed ParaNdis_Common.i file:

static __inline void
DumpMac(int dbg_level, const char* calling_function, const char* header_str, UCHAR* mac)
{
      __annotation( L"TMF:", L"a95c641b-f553-3765-860d-0d03cf3c0e75 netkvm.sys // SRC=" L"ParaNdis_Common.cpp" L" MJ= MN=", L"#typev " L"ParaNdis_Common_cpp601" L" 28 \"%0 %!FUNC![%10!s!] - %11!s!: %12!02x!-%13!02x!-%14!02x!-%15!02x!-%16!02x!-%17!02x!\" //   Flags=TRACE_DRIVER LEVEL=dbg_level" , L"{", L"calling_function, ItemString -- 10" , L"header_str, ItemString -- 11" , L"mac[0], ItemLong -- 12" , L"mac[1], ItemLong -- 13" , L"mac[2], ItemLong -- 14" , L"mac[3], ItemLong -- 15" , L"mac[4], ItemLong -- 16" , L"mac[5], ItemLong -- 17" , L"}"), (( (WPP_GLOBAL_Control != (WPP_PROJECT_CONTROL_BLOCK*)&WPP_GLOBAL_Control) && (dbg_level <= virtioDebugLevel) ? (void)0, WPP_SF_ssDDDDDD( ((WPP_GLOBAL_Control[((WPP_BIT_TRACE_DRIVER) >> 16)].Control).Logger), 28, WPP_a95c641bf5533765860d0d03cf3c0e75_Traceguids+0, calling_function, header_str, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]), 1 : 0 )) ;
#line 604 "C:\\Users\\User\\source\\repos\\kvm-guest-drivers-windows\\NetKVM\\Common\\ParaNdis_Common.cpp"

}

The bit that I'm interested in is WPP_GLOBAL_Control != (WPP_PROJECT_CONTROL_BLOCK*)&WPP_GLOBAL_Control condition. I would like to understand it a bit more, it's likely I'm missing something here, as it seems to me it should be the same as WPP_GLOBAL_Control != WPP_GLOBAL_Control.

janisozaur commented 4 years ago

Original code before expansion: https://github.com/virtio-win/kvm-guest-drivers-windows/blob/72f495033e6710d6459f9be6c706576caedda876/NetKVM/Common/ParaNdis_Common.cpp#L599-L604

ybendito commented 4 years ago

Is there something specific to netkvm or virtio-win? Or the same happens also with other drivers/not only drivers that use WPP?

janisozaur commented 4 years ago

I can't quite tell yet, I'm not really familiar with developing drivers on Windows and when filing I was not aware WPP is part provided by MS. That said I have not yet worked out where does the condition get injected from.