Message ID | 20221025124223.227577-11-mlevitsk@redhat.com |
---|---|
State | Accepted |
Commit | 5015bb89b58225f97df6ac44383e7e8c8662c8c9 |
Headers | show
Return-Path: <linux-kselftest-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBF19C04A95 for <linux-kselftest@archiver.kernel.org>; Tue, 25 Oct 2022 12:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232196AbiJYMo2 (ORCPT <rfc822;linux-kselftest@archiver.kernel.org>); Tue, 25 Oct 2022 08:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232334AbiJYMnu (ORCPT <rfc822;linux-kselftest@vger.kernel.org>); Tue, 25 Oct 2022 08:43:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A0E71905CC for <linux-kselftest@vger.kernel.org>; Tue, 25 Oct 2022 05:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666701791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hjv4lWsvg+hFAXBQVxvDxYwhYVqBj8cP/nEGapoZ4V4=; b=YLP9G5uFIYQ7saO9QSGrWsJ/oWhrJK9VgQDZOLhhXEnZaqpCXDxgrlzxQf+ZMsjAGixDjV UVD+c9l92J5iSxLatrZVqcYsFKZ86T+yUcQe0aEDDyyJwlnYpk9RRkSxyX83hMKa69RrHQ 5scmuRQQ7Nk+Cm6bw+CIYZ5DomVV+RI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-417-nfn2UCqLM1K6Lyga9TBEwg-1; Tue, 25 Oct 2022 08:43:05 -0400 X-MC-Unique: nfn2UCqLM1K6Lyga9TBEwg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F1AC101AA47; Tue, 25 Oct 2022 12:43:04 +0000 (UTC) Received: from amdlaptop.tlv.redhat.com (dhcp-4-238.tlv.redhat.com [10.35.4.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1505A20290A2; Tue, 25 Oct 2022 12:43:00 +0000 (UTC) From: Maxim Levitsky <mlevitsk@redhat.com> To: kvm@vger.kernel.org Cc: Paolo Bonzini <pbonzini@redhat.com>, Yang Zhong <yang.zhong@intel.com>, linux-kselftest@vger.kernel.org, Kees Cook <keescook@chromium.org>, Borislav Petkov <bp@alien8.de>, Guang Zeng <guang.zeng@intel.com>, Wanpeng Li <wanpengli@tencent.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, Maxim Levitsky <mlevitsk@redhat.com>, Joerg Roedel <joro@8bytes.org>, linux-kernel@vger.kernel.org, Wei Wang <wei.w.wang@intel.com>, Jim Mattson <jmattson@google.com>, Dave Hansen <dave.hansen@linux.intel.com>, Sean Christopherson <seanjc@google.com>, Vitaly Kuznetsov <vkuznets@redhat.com>, x86@kernel.org, Shuah Khan <shuah@kernel.org> Subject: [PATCH v4 10/23] KVM: x86: emulator: em_sysexit should update ctxt->mode Date: Tue, 25 Oct 2022 15:42:10 +0300 Message-Id: <20221025124223.227577-11-mlevitsk@redhat.com> In-Reply-To: <20221025124223.227577-1-mlevitsk@redhat.com> References: <20221025124223.227577-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: <linux-kselftest.vger.kernel.org> X-Mailing-List: linux-kselftest@vger.kernel.org |
Series |
SMM emulation and interrupt shadow fixes
|
expand
|
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 671f7e5871ff70..e23c984d6aae09 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2525,6 +2525,7 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt) ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); ctxt->_eip = rdx; + ctxt->mode = usermode; *reg_write(ctxt, VCPU_REGS_RSP) = rcx; return X86EMUL_CONTINUE;
SYSEXIT is one of the instructions that can change the processor mode, thus ctxt->mode should be updated after it. Note that this is likely a benign bug, because the only problematic mode change is from 32 bit to 64 bit which can lead to truncation of RIP, and it is not possible to do with sysexit, since sysexit running in 32 bit mode will be limited to 32 bit version. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> --- arch/x86/kvm/emulate.c | 1 + 1 file changed, 1 insertion(+)