Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3509654rwi; Wed, 12 Oct 2022 03:09:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Yl6kwprqUieB61BERiT2CrC7OSxo8mDexxQDF2Vr6qnJd/BHV6ykdC6RzAp4THijldNOd X-Received: by 2002:aa7:db07:0:b0:458:f6e5:ab71 with SMTP id t7-20020aa7db07000000b00458f6e5ab71mr27471864eds.330.1665569348096; Wed, 12 Oct 2022 03:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665569348; cv=none; d=google.com; s=arc-20160816; b=F1mbvBYrDNDHqfPn0XCTSloo/ND+CBOYydagVC7U6NjRe5j+0RTXGaCFV3ScKQLFHk CsB4neakg5h6ocxMYik4q/QzB2iFF5eVbw9cntezfSlq9pHTfacCI3SBQueKTUeP7Gk4 h5VwDrctln1feRcqLPOq0LWemb7nqvucvTmhGX15IgnObONPQf0by9mgj7/SfyDB8Dgi r0IWFmkfeLAroY1/t0uMLzUot3Fjbh0uITQ+0vSVPG0OV3VCSuaETVQENx1uUw/ZGRup qgOCvkJ5I3gbxuSy4vc7mjsepPPL942SDS/Xm2JEpwhWG+7L9gCwcgcsIhTqD5ZT0Qa9 uN5g== 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 :message-id:date:subject:cc:to:from; bh=6aOOkJKDoxxQIh9vBh5iC4k+6NTzyL0d4MxeNpHi0Gs=; b=yMtr49UzTlyNvnFSwdmHBS/h4176rlHXrR+It7+B7Ts3w1ZOWw+ATdYOCa3dbwRRR7 64e1gNByreprrX3NTtqMaj4F6GYvVlIzugqnz6VHUcRwBQHAB5+TNfEADCuQAiVaw311 h7X47W7MHCKQP8znxZQA7zj3WB9FNj347m1Ajn+u5y0NEkXCJE/NOkKnTAp8FSnzOEG3 Bkc0TahfmaXICtoSjqspg+QiKSkpUAnpNE91QC/zm5mhOvTLi2TyuqFXH/XPjhBgIqwk ELRR22DwFeUPuLndWZHA3yDnK8GASU+SPil0XknKKHF1E0n0m5kQ/FsBH1XCzcxLVc1v +l5Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020aa7cf1a000000b00458d2bdcb30si14040518edy.96.2022.10.12.03.08.42; Wed, 12 Oct 2022 03:09:08 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbiJLJLV (ORCPT + 99 others); Wed, 12 Oct 2022 05:11:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiJLJLU (ORCPT ); Wed, 12 Oct 2022 05:11:20 -0400 Received: from out0-137.mail.aliyun.com (out0-137.mail.aliyun.com [140.205.0.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE86140F0; Wed, 12 Oct 2022 02:11:17 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047201;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---.Pa6ue-p_1665565873; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.Pa6ue-p_1665565873) by smtp.aliyun-inc.com; Wed, 12 Oct 2022 17:11:13 +0800 From: "Hou Wenlong" To: kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] KVM: x86: Mark transfer type as X86_TRANSFER_RET when loading CS in iret emulation Date: Wed, 12 Oct 2022 17:11:13 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY 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 When loading code segment descriptor in iret instruction emulation, the checks are same as far return instruction emulation, so transfer type should be X86_TRANSFER_RET in __load_segment_descriptor(). Although, only iret in real mode is implemented now, and no checks are actually needed for real mode, it would still be better to mark transfer type as X86_TRANSFER_RET. No functional change intended. Signed-off-by: Hou Wenlong --- arch/x86/kvm/emulate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 3b27622d4642..5052eb480068 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2100,6 +2100,7 @@ static int emulate_iret_real(struct x86_emulate_ctxt *ctxt) X86_EFLAGS_FIXED; unsigned long vm86_mask = X86_EFLAGS_VM | X86_EFLAGS_VIF | X86_EFLAGS_VIP; + u8 cpl = ctxt->ops->cpl(ctxt); /* TODO: Add stack limit check */ @@ -2121,7 +2122,8 @@ static int emulate_iret_real(struct x86_emulate_ctxt *ctxt) if (rc != X86EMUL_CONTINUE) return rc; - rc = load_segment_descriptor(ctxt, (u16)cs, VCPU_SREG_CS); + rc = __load_segment_descriptor(ctxt, (u16)cs, VCPU_SREG_CS, cpl, + X86_TRANSFER_RET, NULL); if (rc != X86EMUL_CONTINUE) return rc; -- 2.31.1