Skip to content

MS v5 style HMA access function wrong, requested size *must* be free to succeed #196

@ecm-pushbx

Description

@ecm-pushbx

As I discussed in a dosemu2 issue: dosemu2/dosemu2#1816 (comment)

if (r.AH == 0x4a)

I don't understand the if (tsize < size) in my last reference. Shouldn't it check for the requested size being larger and fail the allocation then?

Also another comment by me: dosemu2/dosemu2#1816 (comment)

MS-DOS v5 returns an error (DI = -1) if you try to allocate more than there is available space. So it's valid to never query the size, just init BX with the size you want and try to allocate it. It seems both fdpp and FreeDOS get that wrong, certainly FreeDOS allocates the available size and returns a BX < the requested size.

During my tests I also found that FreeDOS seems to keep track of a byte-granular size and offset, whereas MS-DOS v7 deals in paragraphs. MS-DOS v5 also seems to round everything to paragraphs.

Currently the kernel will allocate HMA space unconditionally in 2F.4A02, shrinking the allocation to whatever space is available if the input in BX is too large. Original MS-DOS (v5 and v7 both) will error out and set DI to FFFFh instead if the requested size cannot be satisfied.

The problem of not aligning allocation offsets + sizes on paragraph boundaries is less critical but may also cause incompatibilities with programs expecting aligned addresses.

I will likely prepared a PR to fix this soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompatibilityissue may effect compatibility

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions