public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* OvmfPkg: VM crashed trying to write to RO memory from CommonInterruptEntry
@ 2016-11-22 12:57 Evgeny Yakovlev
  2016-11-22 13:41 ` Laszlo Ersek
  0 siblings, 1 reply; 9+ messages in thread
From: Evgeny Yakovlev @ 2016-11-22 12:57 UTC (permalink / raw)
  To: edk2-devel; +Cc: eyakovlev, lersek, den, rkagan

We are running windows UEFI-based VMs on QEMU/KVM with OvmfPkg.

Very rarely we are experiencing a crash when VM tries to write to RO memory
very early during UEFI boot process.

Crash happens when VM tries to execute this code in interrupt handler:
https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm#L244-L246


fxsave [rdi], where RDI = 0xffe60

Which is bad - it points to ISA BIOS F-segment area.

This memory was mapped by qemu for read only access, which is reflected in
KVM EPT:
00000000000e0000-00000000000fffff (prio 1, R-): isa-bios

This is a very early IRQ0 interrupt, presumably during early initialization
phase (Sec or Pei).

Looks like CommonInterruptHandler does not switch to a separate stack and
works on interrupted context's stack, which was fairly close to 1MB
boundary when IRQ0 fired (RSP around 1002c0). When CommonInterruptEntry
reached highlighted code it subtracted 512 bytes from current RSP which
dropped to 0xffe60, below 1MB and into QEMU RO region.

We were figuring out how to best fix this. Possible solutions are to switch
to a separate stack in CommonInterruptEntry, relocate early OvmfPkg stack
to somewhere farther away from 1MB, to run with interrupts disabled until
we reach a later phase or maybe something else.

Any comments would be very appreciated!


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-12-07  9:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-22 12:57 OvmfPkg: VM crashed trying to write to RO memory from CommonInterruptEntry Evgeny Yakovlev
2016-11-22 13:41 ` Laszlo Ersek
2016-11-22 13:58   ` Evgeny Yakovlev
2016-11-22 16:58     ` Laszlo Ersek
2016-11-23  8:37       ` Evgeny Yakovlev
2016-11-23 16:54         ` Laszlo Ersek
2016-12-07  9:11           ` Evgeny Yakovlev
2016-11-23 14:31       ` Evgeny Yakovlev
2016-11-23 16:38         ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox