[vbox-dev] Replacing VbglPhysHeapAlloc with kmalloc for linux vboxguest module ?

Michael Thayer michael.thayer at oracle.com
Thu Jul 6 09:54:58 UTC 2017

Hello Hans,

06.07.2017 11:44, Knut St. Osmundsen wrote:
> Hi Hans.
> On 2017-07-06 11:13 AM, Hans de Goede wrote:
>> Hi,
>> VbglPhysHeapAlloc seems to be yet another mem-allocator
>> which chunks up memory returned by RTMemContAlloc, which
>> returns physical contiguous memory below 4GB.
> Need for keeping the code cross platform, not all supported guest have
> nice and efficient memory management functions.
>> I don't see any reason why we cannot use kmalloc directly
>> for that with a GFP_DMA32 flag.
>> One other thing which RTMemContAlloc seems to do is mark
>> the pages executable. Does memory used by VbglGRAlloc /
>> VbglGRPerform need to be marked executable ?
> Hysterical raisins.  The RTMemContAlloc API is really ancient, the x86
> world was 32-bit only and the NX bit existed only in AMD64 preliminary
> docs.  It is(/was?) also used for various trampoline code (logging, ++)
> and world switchers (VMM/VMMSwitcher/*), which needed to be executable,
> thus all memory it returns is executable. 
> That the phys heap in VBoxGuest is working with memory marked executable
> is just a side effect of that API requirement.  I'm not aware of any
> reason why these allocations would need to be executable.  We should
> probably address this ourselves too.

Just to confirm (I asked Knut), there is no reason you should not use
kmalloc in your version.

Michael Thayer | VirtualBox engineer
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | D-71384 Weinstadt

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: Riesstraße 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister
der Handelskammer Midden-Nederland, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Jan Schultheiss, Val Maher

More information about the vbox-dev mailing list