Re: [PATCH 5/6] KVM: SVM: pass a proper reason in kvm_emulate_instruction()
From: David Edmondson
Date: Tue Apr 13 2021 - 06:54:43 EST
On Monday, 2021-04-12 at 16:04:02 GMT, Sean Christopherson wrote:
> +Aaron
>
> On Mon, Apr 12, 2021, David Edmondson wrote:
>> From: Joao Martins <joao.m.martins@xxxxxxxxxx>
>>
>> Declare various causes of emulation and use them as appropriate.
>>
>> Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
>> Signed-off-by: David Edmondson <david.edmondson@xxxxxxxxxx>
>> ---
>> arch/x86/include/asm/kvm_host.h | 6 ++++++
>> arch/x86/kvm/svm/avic.c | 3 ++-
>> arch/x86/kvm/svm/svm.c | 26 +++++++++++++++-----------
>> 3 files changed, 23 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index 79e9ca756742..e1284680cbdc 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -1535,6 +1535,12 @@ enum {
>> EMULREASON_IO_COMPLETE,
>> EMULREASON_UD,
>> EMULREASON_PF,
>> + EMULREASON_SVM_NOASSIST,
>> + EMULREASON_SVM_RSM,
>> + EMULREASON_SVM_RDPMC,
>> + EMULREASON_SVM_CR,
>> + EMULREASON_SVM_DR,
>> + EMULREASON_SVM_AVIC_UNACCEL,
>
> Passing these to userspace arguably makes them ABI, i.e. they need to go into
> uapi/kvm.h somewhere. That said, I don't like passing arbitrary values for what
> is effectively the VM-Exit reason. Why not simply pass the exit reason, assuming
> we do indeed want to dump this info to userspace?
That would suffice, yes.
> What is the intended end usage of this information? Actual emulation? Debug?
> Logging?
Debug (which implies logging, given that I want this to happen on
systems that are in service).
> Depending on what you're trying to do with the info, maybe there's a better
> option. E.g. Aaron is working on a series that includes passing pass the code
> stream (instruction bytes) to userspace on emulation failure, though I'm not
> sure if he's planning on providing the VM-Exit reason.
Having the instruction stream will be good.
Aaron: do you have anything to share now? In what time frame do you
think you might submit patches?
I'm happy to re-work this to make the exit reason available, if that's
the appropriate direction.
dme.
--
And you're standing here beside me, I love the passing of time.