All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Andy Lutomirski <luto@amacapital.net>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	David Laight <David.Laight@aculab.com>
Subject: Re: [PATCH v2 3/6] kvm: x86: Emulate split-lock access as a write
Date: Thu, 12 Mar 2020 19:42:53 +0800	[thread overview]
Message-ID: <18333d32-9ec4-4aee-8c58-b2f44bb8e83d@intel.com> (raw)
In-Reply-To: <20200227001117.GX9940@linux.intel.com>

On 2/27/2020 8:11 AM, Sean Christopherson wrote:
> On Tue, Feb 11, 2020 at 02:34:18PM +0100, Paolo Bonzini wrote:
>> On 11/02/20 14:22, Thomas Gleixner wrote:
>>> Paolo Bonzini <pbonzini@redhat.com> writes:
>>>> On 03/02/20 16:16, Xiaoyao Li wrote:
>>>>> A sane guest should never tigger emulation on a split-lock access, but
>>>>> it cannot prevent malicous guest from doing this. So just emulating the
>>>>> access as a write if it's a split-lock access to avoid malicous guest
>>>>> polluting the kernel log.
>>>>
>>>> Saying that anything doing a split lock access is malicious makes little
>>>> sense.
>>>
>>> Correct, but we also have to accept, that split lock access can be used
>>> in a malicious way, aka. DoS.
>>
>> Indeed, a more accurate emulation such as temporarily disabling
>> split-lock detection in the emulator would allow the guest to use split
>> lock access as a vehicle for DoS, but that's not what the commit message
>> says.  If it were only about polluting the kernel log, there's
>> printk_ratelimited for that.  (In fact, if we went for incorrect
>> emulation as in this patch, a rate-limited pr_warn would be a good idea).
>>
>> It is much more convincing to say that since this is pretty much a
>> theoretical case, we can assume that it is only done with the purpose of
>> DoS-ing the host or something like that, and therefore we kill the guest.
> 
> The problem with "kill the guest", and the reason I'd prefer to emulate the
> split-lock as a write, is that killing the guest in this case is annoyingly
> difficult.
> 
> Returning X86EMUL_UNHANDLEABLE / EMULATION_FAILED gets KVM to
> handle_emulation_failure(), but handle_emulation_failure() will only "kill"
> the guest if emulation failed in L1 CPL==0.  For all other modes, it will
> inject a #UD and resume the guest.  KVM also injects a #UD for L1 CPL==0,
> but that's the least annoying thing.
> 
> Adding a new emulation type isn't an option because this code can be
> triggered through normal emulation.  A new return type could be added for
> split-lock, but that's code I'd really not add, both from an Intel
> perspective and a KVM maintenance perspective.  And, we'd still have the
> conundrum of what to do if/when split-lock #AC is exposed to L1, e.g. in
> that case, KVM should inject an #AC into L1, not kill the guest.  Again,
> totally doable, but ugly and IMO an unnecessary maintenance burden.
> 
> I completely agree that poorly emulating the instruction from the (likely)
> malicious guest is a hack, but it's a simple and easy to maintain hack.

Paolo,

What's your opinion about above?

>>>> Split lock detection is essentially a debugging feature, there's a
>>>> reason why the MSR is called "TEST_CTL".  So you don't want to make the
>>>
>>> The fact that it ended up in MSR_TEST_CTL does not say anything. That's
>>> where they it ended up to be as it was hastily cobbled together for
>>> whatever reason.
>>
>> Or perhaps it was there all the time in test silicon or something like
>> that...  That would be a very plausible reason for all the quirks behind it.
>>
>> Paolo
>>


  reply	other threads:[~2020-03-12 11:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-03 15:16 [PATCH v2 0/6] kvm/split_lock: Add feature split lock detection support in kvm Xiaoyao Li
2020-02-03 15:16 ` [PATCH v2 1/6] x86/split_lock: Add and export get_split_lock_detect_state() Xiaoyao Li
2020-02-03 21:45   ` Sean Christopherson
2020-02-03 15:16 ` [PATCH v2 2/6] x86/split_lock: Add and export split_lock_detect_set() Xiaoyao Li
2020-02-03 15:16 ` [PATCH v2 3/6] kvm: x86: Emulate split-lock access as a write Xiaoyao Li
2020-02-03 20:54   ` Sean Christopherson
2020-02-04  2:55     ` Xiaoyao Li
2020-02-11 12:20   ` Paolo Bonzini
2020-02-11 13:22     ` Thomas Gleixner
2020-02-11 13:34       ` Paolo Bonzini
2020-02-11 14:02         ` Xiaoyao Li
2020-02-11 14:34           ` David Laight
2020-02-27  0:11         ` Sean Christopherson
2020-03-12 11:42           ` Xiaoyao Li [this message]
2020-03-12 15:00             ` Paolo Bonzini
2020-02-03 15:16 ` [PATCH v2 4/6] kvm: vmx: Extend VMX's #AC handding for split lock in guest Xiaoyao Li
2020-02-03 21:14   ` Sean Christopherson
2020-02-04  6:46     ` Xiaoyao Li
2020-02-10 21:30       ` Sean Christopherson
2020-02-03 15:16 ` [PATCH v2 5/6] kvm: x86: Emulate MSR IA32_CORE_CAPABILITIES Xiaoyao Li
2020-02-03 21:43   ` Sean Christopherson
2020-02-04  9:19     ` Xiaoyao Li
2020-02-04  9:37       ` Peter Zijlstra
2020-02-11  3:52         ` Andy Lutomirski
2020-02-11 12:38           ` Peter Zijlstra
2020-02-03 15:16 ` [PATCH v2 6/6] x86: vmx: virtualize split lock detection Xiaoyao Li
2020-02-03 15:58   ` Xiaoyao Li
2020-02-03 18:52   ` Andy Lutomirski
2020-02-03 21:42   ` Sean Christopherson
2020-02-04  2:52     ` Xiaoyao Li
2020-02-04  5:35       ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18333d32-9ec4-4aee-8c58-b2f44bb8e83d@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=David.Laight@aculab.com \
    --cc=bp@alien8.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.