Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp406193imn; Wed, 3 Aug 2022 08:52:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IvUMfkMZlOgc+KzrQ3xkZDL1Ik/NkYRlYDAe6sWb4MfhFLutvdGZj00My5/lbmiOtxXaP X-Received: by 2002:a17:903:28c:b0:16d:cf30:3b71 with SMTP id j12-20020a170903028c00b0016dcf303b71mr26847346plr.165.1659541975915; Wed, 03 Aug 2022 08:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659541975; cv=none; d=google.com; s=arc-20160816; b=GCvyBFJ1wtuBBC6ZYQine/t8foF+iEozDp0Y9M4mo6gsJgkX3ilbIw7OmDVFoUVjFo 66YCdu65ZkeLPDxft78MRVHsg6iNyBW/i8QJ+m6e7zM1ArwwajOa3bBTBfF4fg07nZfM Dfq0h+64vZEq8SgMc7RPP8RT3r1tS8JFeZLpda0Vj1TGev3BbFjmp8DVxF0e0L58ZjUq x+A2K+LRJei7lN/kyuRrYo4oAAEy7MvBePQPuBCqCRalzRr0wYIdtxxKaDeI/JF2PqO2 MVxrwI74rsz1SiGc4Vz2Fxslec6jxK5LgVCkbADfEZMspoQkIWo6ReY7NhAS0L1H29dY ggpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WNhWOc+yr+2wT/jsCzj92Jb7fDCD7N/zAbD0yvwDZp4=; b=A+pijpEraZZJPBNoy1oH+71PdLEFEyst4byIMJdOqnPe8xOuxhGSduY+WOaoABYSNU EBY+E2GhD6Na+b4qe4RJN93soRYcFUvDGy/xv+u85ZAj3HHAjppfYRZTGAFRUogGH/fy ZiwMrxdHP/Eq7zmvBDxWcMRhYVv4kzIy5PbRPYTqpEYQbrdFwDK30nVc7DXQHtHCr6my k9fSnsfctwXSgnu1rMNDR3cxUvpyS9/cLuRZ++0EIKpfEaOT1Jv5bi684v5Cws8iPzfR 9wJvjcCQScN3Ra+p7f1QYs9ejRo6MC+qDScSPLxAFmBxjhvV2YEpFurpT2DNthv0fYC1 S2vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N+f+cRfe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a6541c6000000b0040d3e6f0ee2si17677451pgq.656.2022.08.03.08.52.41; Wed, 03 Aug 2022 08:52:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N+f+cRfe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238270AbiHCPuj (ORCPT + 99 others); Wed, 3 Aug 2022 11:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238218AbiHCPua (ORCPT ); Wed, 3 Aug 2022 11:50:30 -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 ESMTP id E33E12DC3 for ; Wed, 3 Aug 2022 08:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659541829; 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=WNhWOc+yr+2wT/jsCzj92Jb7fDCD7N/zAbD0yvwDZp4=; b=N+f+cRfejLnlQcfGi15oRAQPh+5pZ+RVCThe/Y8G7EuJqM7VL2Y9epPUkP0ddpUhI/sn8Z 93xpWDvoFETeTPRqnSHC20ENZ1oXK0GWAIXIBblN7+m50Jx9qIQmQ2Jl+SF0slQB9WrGeJ dznWc0w9s7RMo++nE+14AHdPJKsEkuQ= 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-515-5FKKviBjP1KIafHzq22m6Q-1; Wed, 03 Aug 2022 11:50:26 -0400 X-MC-Unique: 5FKKviBjP1KIafHzq22m6Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35EE8101A54E; Wed, 3 Aug 2022 15:50:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91AB01121314; Wed, 3 Aug 2022 15:50:21 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Borislav Petkov , Dave Hansen , linux-kernel@vger.kernel.org, Wanpeng Li , Maxim Levitsky , Ingo Molnar , Sean Christopherson , x86@kernel.org, Jim Mattson , Kees Cook , Thomas Gleixner , "H. Peter Anvin" , Joerg Roedel , Vitaly Kuznetsov , Paolo Bonzini Subject: [PATCH v3 02/13] KVM: x86: emulator: em_sysexit should update ctxt->mode Date: Wed, 3 Aug 2022 18:50:00 +0300 Message-Id: <20220803155011.43721-3-mlevitsk@redhat.com> In-Reply-To: <20220803155011.43721-1-mlevitsk@redhat.com> References: <20220803155011.43721-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is one of the instructions that can change the processor mode. 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 --- arch/x86/kvm/emulate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 047c583596bb86..7bdc495710bd0e 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2888,6 +2888,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; -- 2.26.3