Re: [kvm-unit-tests PATCH 01/14] x86/cstart: Don't use MSR_GS_BASE in 32-bit boot code

Paolo Bonzini
2021-04-23T06:57:36Z

On 22/04/21 19:57, Sean Christopherson wrote:
> On Thu, Apr 22, 2021, Paolo Bonzini wrote:
>> On 22/04/21 05:04, Sean Christopherson wrote:
>>> Load the per-cpu GS.base for 32-bit build by building a temporary GDT
>>> and loading a "real" segment. Using MSR_GS_BASE is wrong and broken,
>>> it's a 64-bit only MSR and does not exist on 32-bit CPUs. The current
>>> code works only because 32-bit KVM VMX incorrectly disables interception
>>> of MSR_GS_BASE, and no one runs KVM on an actual 32-bit physical CPU,
>>> i.e. the MSR exists in hardware and so everything "works".
>>>
>>> 32-bit KVM SVM is not buggy and correctly injects #GP on the WRMSR, i.e.
>>> the tests have never worked on 32-bit SVM.
>>
>> Hmm, this breaks task switch. But setting up separate descriptors is
>> not hard:
>
> Much better.
>
> Using %ebx crushes the mbi_bootinfo pointer. The easiest fix is to use %edx or
> %ecx.
>
>> + mov (%ebx), %ebx
>
> No need to load the address into a reg, just drop the "$" above and encode
> "mov [imm32], <reg>".

Yep, I had already fixed more or less the same things (plus the task
gate TSS setup, which must not hardcode GS to 0x10; no idea how it
worked before) before seeing your mail. I sent the result to the
mailing list.

Paolo