From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43375C433F5 for ; Mon, 6 Sep 2021 21:07:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2791D604E9 for ; Mon, 6 Sep 2021 21:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233331AbhIFVIv (ORCPT ); Mon, 6 Sep 2021 17:08:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45005 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbhIFVIs (ORCPT ); Mon, 6 Sep 2021 17:08:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630962463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3DI3KYd3Cj467udFY79GhjR176LpQbVCepUvXZINXOg=; b=fzeRz6fCLHrSPxd0TBz6i/onVdBxjzLVIDLwrAIZG07aa303POTovtkU3ckXg/7CHQQ2YM VwnCVosO4GWBp6VDFZtCJ/bwhUVtAN5rifo2jLPo2hCStdO4ePfpuNK2OKpYHZH34z86uI jY3AsHBNfZsmlvozXlswZdWJ9iQBfVQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-545-6nX3R8uCMCKfx3f4Yaty5w-1; Mon, 06 Sep 2021 17:07:42 -0400 X-MC-Unique: 6nX3R8uCMCKfx3f4Yaty5w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5924D8145E6; Mon, 6 Sep 2021 21:07:40 +0000 (UTC) Received: from starship (unknown [10.35.206.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E212369A; Mon, 6 Sep 2021 21:07:36 +0000 (UTC) Message-ID: Subject: Re: [PATCH 1/2] KVM: VMX: avoid running vmx_handle_exit_irqoff in case of emulation From: Maxim Levitsky To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, Thomas Gleixner , Wanpeng Li , Joerg Roedel , "H. Peter Anvin" , Jim Mattson , Ingo Molnar , Vitaly Kuznetsov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Borislav Petkov , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Date: Tue, 07 Sep 2021 00:07:35 +0300 In-Reply-To: References: <20210826095750.1650467-1-mlevitsk@redhat.com> <20210826095750.1650467-2-mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-09-06 at 12:09 +0200, Paolo Bonzini wrote: > On 26/08/21 18:01, Sean Christopherson wrote: > > > + if (vmx->emulation_required) > > > + return; > > Rather than play whack-a-mole with flows consuming stale state, I'd much prefer > > to synthesize a VM-Exit(INVALID_GUEST_STATE). Alternatively, just skip ->run() > > entirely by adding hooks in vcpu_enter_guest(), but that's a much larger change > > and probably not worth the risk at this juncture. > > I'm going with Maxim's patch for now (and for stable kernels especially) > but I like the > > > + if (unlikely(static_call(kvm_x86_emulation_required)(vcpu))) > + return static_call(kvm_x86_emulate_invalid_guest_state)(vcpu); > + > > idea. I'll put a Fixes for 95b5a48c4f2b ("KVM: VMX: Handle NMIs, #MCs and > async #PFs in common irqs-disabled fn", Linux 5.3). > > Paolo > Note that I posted V2 of this patch series ([PATCH v2 0/6] KVM: few more SMM fixes) There I addressed the review feedback from this patch series, and for this particular case, I synthesized invalid VM exit as was suggested. Best regards, Maxim Levitsky