On Wed, May 10, 2017 at 07:28:44PM +0000, Xu, Anthony wrote:
From: Kevin O'Connor [mailto:email@example.com] On Tue, May 09, 2017 at 08:39:07PM +0000, Xu, Anthony wrote:
I dig into seebios code, and found ahci_process_op is called with A20 off,
The call trace is, process_op_16->process_op_both->call32->call32_smm->process_op_32- ahci_process_op
call32_smm calls call32_prep, but because the method is C16_SMM, A20 is
not enabled in call32_prep.
ahci_process_op is called with A20 off.
As I understand it, entering System Managament Mode (SMM) should automatically enable A20, so it should not be necessary for call32_smm to enable it. Are you sure the issue is related to A20 instead of some other issue with SMM?
I'm pretty sure the issue is related to A20, I'm not familiar with Seabios code, I'm not sure why call32 needs to call32_smm. If my understanding is correct, VCPU is not in SMM mode at the time.
As background, seabios must support disk read/write requests when the x86 processor is in 16bit mode. There's some info on the modes seabios supports at: https://www.seabios.org/Memory_Model
Unfortunately, some disk controllers can only be controlled when the processor is in 32bit mode - ahci is an example of this. So, to service these calls, seabios must switch from 16bit mode to 32bit mode, perform the disk operation, and then return to 16bit mode.
SeaBIOS has a couple of different methods to accomplish this mode switching - it can directly switch modes (C16_BIG switch) or it can use a helper in SMM mode to perform the switch (C16_SMM). The preferred method is C16_SMM as C16_BIG isn't available in VM86 mode and it also clobbers the 16bit segment registers.
If you don't want to use C16_SMM, you can turn off CONFIG_CALL32_SMM via "make menuconfig".
It's still not clear to me why C16_SMM doesn't work though - as I think it should have saved and restored the A20 flag.