Page MenuHomeFreeBSD

bhyve: when accessing non-backed gpa, emulate hw
ClosedPublic

Authored by kib on May 2 2025, 3:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 13, 6:44 AM
Unknown Object (File)
Thu, Jun 5, 2:31 PM
Unknown Object (File)
Thu, May 29, 3:11 AM
Unknown Object (File)
Sat, May 24, 4:52 PM
Unknown Object (File)
Sat, May 24, 2:08 AM
Unknown Object (File)
Fri, May 23, 12:41 PM
Unknown Object (File)
Fri, May 23, 10:12 AM
Unknown Object (File)
Wed, May 21, 7:28 PM

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.May 2 2025, 3:23 PM
markj added a subscriber: markj.
markj added inline comments.
usr.sbin/bhyve/mem.c
195

Maybe make this a global variable?

198
This revision is now accepted and ready to land.May 3 2025, 10:01 PM
kib marked 2 inline comments as done.

Make fb_entry static. Reword the message.

This revision now requires review to proceed.May 4 2025, 8:51 AM

Drop now unused string.h

One issue with this is that the code is MI, but the implemented behaviour is x86-specific -- I'm not sure what happens on arm64 when a non-existent GPA is accessed, maybe an serror is raised. Maybe @andrew could comment.

usr.sbin/bhyve/mem.c
198

I reworded as you suggested. But note that the address always exists, it is the backing memory that could not.

Restore original behavior on !x86.

Eliminate arch ifdefs, move code into mem_x86.c, mem_md.c.

Another stray change, sorry.

One issue with this is that the code is MI, but the implemented behaviour is x86-specific -- I'm not sure what happens on arm64 when a non-existent GPA is accessed, maybe an serror is raised. Maybe @andrew could comment.

On arm64 I would expect we implement it as a synchronous external abort. We should have all the information needed & it lets the guest recover, or at least report the precise location of the fault.

On armv8, generate simple-minded SError.

usr.sbin/bhyve/aarch64/mem_aarch64.c
48 ↗(On Diff #155174)

I don't think this is correct as it looks like this should only be raised for an SError exception. The kernel can currently only raise synchronous exceptions. I think the logic should be:

spsr = get(VM_REG_GUEST_CPSR);
if ((spsr & PSR_M_MASK) == PSR_M_EL0t)
    esr = EXCP_DATA_ABORT_L << ESR_ELx_EC_SHIFT;
else
    esr = EXCP_DATA_ABORT << ESR_ELx_EC_SHIFT;
esr |= ESR_ELx_IL | ISS_DATA_DFSC_EXT;

Add needed headers for mem_aarch64.c

Implement andrew' suggestion.

I'm ok with the arm64 parts

This revision is now accepted and ready to land.May 9 2025, 2:29 PM