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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 9E11FC32750 for ; Tue, 13 Aug 2019 13:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 779F7206C2 for ; Tue, 13 Aug 2019 13:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729446AbfHMNyN (ORCPT ); Tue, 13 Aug 2019 09:54:13 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51311 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbfHMNxo (ORCPT ); Tue, 13 Aug 2019 09:53:44 -0400 Received: by mail-wm1-f66.google.com with SMTP id 207so1609393wma.1 for ; Tue, 13 Aug 2019 06:53:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N0JnsZY26PRvpYDGTc2Pe4GLRcJAxgHbDsa9zV94zQU=; b=RgDEWFD4XX6dCqoTyUQo0ZXbGPDkIp74CJJAoxnVpa77FQzr/+Q8r3GAzJ812ibayG /6l5U9mIvx4GE2LdUY9BILGkRKZRcxt++SKGzPs1EdEB4KjdShv+ZuOVJ9OZi3xbs/IU hU+yYHhuEBDP+MrEL8Dow7pIhrp6PMg/J5X5z5/nAJtiMmuWrs1WhyovxYmzb6Bii+S8 oS+edR3y3ZwJ3dA/nkybChg8EUGETt9hzwc6Q+1mlvw96Nx8fXq/5iZPMTZcjuu9O6MH y4XTOqFzxiv+9Tdmx90YSID646smV4iUqr5LkY3VjSSTjXxIZAzIBUL5Z5/85hv1z5Ke FL9g== X-Gm-Message-State: APjAAAWxl0KQJtkhIrg2aON7mJHN13WdQLldsZJDvjlC6CFJVz2YgffG qkZSo49tZ477rjBoVVtMPeE9TQ== X-Google-Smtp-Source: APXvYqx7LOYSOyFaXYCeHH4qMpq9142a94Tu9q092qneV6hhDoXpP+eyaFhRAGlLPcVNfQqsCLla0Q== X-Received: by 2002:a1c:c915:: with SMTP id f21mr3139239wmb.173.1565704422729; Tue, 13 Aug 2019 06:53:42 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id k1sm15205820wru.49.2019.08.13.06.53.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 06:53:42 -0700 (PDT) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Jim Mattson , Sean Christopherson Subject: [PATCH v4 3/7] x86: KVM: clear interrupt shadow on EMULTYPE_SKIP Date: Tue, 13 Aug 2019 15:53:31 +0200 Message-Id: <20190813135335.25197-4-vkuznets@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813135335.25197-1-vkuznets@redhat.com> References: <20190813135335.25197-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When doing x86_emulate_instruction(EMULTYPE_SKIP) interrupt shadow has to be cleared if and only if the skipping is successful. There are two immediate issues: - In SVM skip_emulated_instruction() we are not zapping interrupt shadow in case kvm_emulate_instruction(EMULTYPE_SKIP) is used to advance RIP (!nrpip_save). - In VMX handle_ept_misconfig() when running as a nested hypervisor we (static_cpu_has(X86_FEATURE_HYPERVISOR) case) forget to clear interrupt shadow. Note that we intentionally don't handle the case when the skipped instruction is supposed to prolong the interrupt shadow ("MOV/POP SS") as skip-emulation of those instructions should not happen under normal circumstances. Suggested-by: Sean Christopherson Reviewed-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e8f797fe9d9e..c2409d06c114 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6539,6 +6539,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, kvm_rip_write(vcpu, ctxt->_eip); if (ctxt->eflags & X86_EFLAGS_RF) kvm_set_rflags(vcpu, ctxt->eflags & ~X86_EFLAGS_RF); + kvm_x86_ops->set_interrupt_shadow(vcpu, 0); return EMULATE_DONE; } -- 2.20.1