Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6583238ybi; Wed, 31 Jul 2019 17:28:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDay2vS3HC5eBlpdgHkXD+Y4SoLDMMcOj1LpMoXSHPbGGCnQujZKd0SC0apkABFPuqEZ+S X-Received: by 2002:a62:e315:: with SMTP id g21mr51586735pfh.225.1564619311035; Wed, 31 Jul 2019 17:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564619311; cv=none; d=google.com; s=arc-20160816; b=sBaUkm6cky8DpFYvKjxCgWKNMCl2JdkPmcQUgW1cTWP5s+TYsAmU/mVNMGV58Ptwrb 2o24Nw59FDUEUIeOngaPrKS1fBvwVk12nxYbr5NvC/ZOECC7PYxCJCDwU7cZ08cocQlj SI6KGlgV3zriB2b32B4rlxm8OqbgfmXbLi1VrR9Dp50l14CZLOXHpFgnbYffZPO3Sm49 bUBTWdZy28TVE1HHlOoIAPq/A9wDy35jM/a53HYbxeQTxLlQS4WDvC4t8mQ8MrT63ztC YpW+nNUPz4XlWY9FpWEf11bsT4D2L6FcTPL8807d6ehZO42ks6epIfwJS4xJ9K4Y01iS e0lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vPg+CJA8NdegBEcW3LNpwboEDARgzjvNwZmoM/5WOMw=; b=Gdq7b72ikSkHDihJ3GxP7hDkaZ70ddgaeJ4wMK8nXBdnZzkAbwNeUmGVUDkpW2NKPG RQXoHtDCX/z184Ru99TqjcNszsSE36PLrPttG10hUpuXl7qT6Bmxc9zbEoM+huKPuIAC /ReIBqMlze41gbRD9nyOvxRxWKWvooMZPPl8D1X1e7xpL3rxTBhtrjrY2KryV8LbKG6o o3hLkfROmdFv0b1c14HtcGaI56II2hwuy2XTfmwd35MRWpkA3qTvpFniOfSxiLzCkoI7 wkbzfQGjtq316KxSOQk5tjyPBxW6YdA0oFm5ZBPh3iIloA/fQyKJJuGhGBMKd1TErTrl /9tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j27si23750842pgj.571.2019.07.31.17.28.15; Wed, 31 Jul 2019 17:28:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729488AbfGaX4j (ORCPT + 99 others); Wed, 31 Jul 2019 19:56:39 -0400 Received: from mga01.intel.com ([192.55.52.88]:41458 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbfGaX4j (ORCPT ); Wed, 31 Jul 2019 19:56:39 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2019 16:56:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,332,1559545200"; d="scan'208";a="196581614" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by fmsmga004.fm.intel.com with ESMTP; 31 Jul 2019 16:56:38 -0700 Date: Wed, 31 Jul 2019 16:56:37 -0700 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Vitaly Kuznetsov , kvm list , LKML , Radim =?utf-8?B?S3LEjW3DocWZ?= , Joerg Roedel Subject: Re: [PATCH RFC 3/5] x86: KVM: svm: clear interrupt shadow on all paths in skip_emulated_instruction() Message-ID: <20190731235637.GB2845@linux.intel.com> References: <20190620110240.25799-1-vkuznets@redhat.com> <20190620110240.25799-4-vkuznets@redhat.com> <87ftmm71p3.fsf@vitty.brq.redhat.com> <36a9f411-f90c-3ffa-9ee3-6ebee13a763f@redhat.com> <20190731233731.GA2845@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 04:45:21PM -0700, Jim Mattson wrote: > On Wed, Jul 31, 2019 at 4:37 PM Sean Christopherson > wrote: > > > At a glance, the full emulator models behavior correctly, e.g. see > > toggle_interruptibility() and setters of ctxt->interruptibility. > > > > I'm pretty sure that leaves the EPT misconfig MMIO and APIC access EOI > > fast paths as the only (VMX) path that would incorrectly handle a > > MOV/POP SS. Reading the guest's instruction stream to detect MOV/POP SS > > would defeat the whole "fast path" thing, not to mention both paths aren't > > exactly architecturally compliant in the first place. > > The proposed patch clears the interrupt shadow in the VMCB on all > paths through svm's skip_emulated_instruction. If this happens at the > tail end of emulation, it doesn't matter if the full emulator does the > right thing. Unless I'm missing something, skip_emulated_instruction() isn't called in the emulation case, x86_emulate_instruction() updates %rip directly, e.g.: if (writeback) { unsigned long rflags = kvm_x86_ops->get_rflags(vcpu); toggle_interruptibility(vcpu, ctxt->interruptibility); vcpu->arch.emulate_regs_need_sync_to_vcpu = false; kvm_rip_write(vcpu, ctxt->eip); if (r == EMULATE_DONE && ctxt->tf) kvm_vcpu_do_singlestep(vcpu, &r); if (!ctxt->have_exception || exception_type(ctxt->exception.vector) == EXCPT_TRAP) __kvm_set_rflags(vcpu, ctxt->eflags); /* * For STI, interrupts are shadowed; so KVM_REQ_EVENT will * do nothing, and it will be requested again as soon as * the shadow expires. But we still need to check here, * because POPF has no interrupt shadow. */ if (unlikely((ctxt->eflags & ~rflags) & X86_EFLAGS_IF)) kvm_make_request(KVM_REQ_EVENT, vcpu); }