Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2925049rwb; Mon, 15 Aug 2022 14:10:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4EWHG2kqM0LS/LWvKCgvRaQlYbJlVx0RRbwXmu5pu4jz/cnNNib7ZdYfiN0CPoRnnRza0N X-Received: by 2002:a17:90b:4b05:b0:1f5:b530:af6b with SMTP id lx5-20020a17090b4b0500b001f5b530af6bmr30322559pjb.150.1660597802320; Mon, 15 Aug 2022 14:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597802; cv=none; d=google.com; s=arc-20160816; b=ExiqxH7LaT3G6IlWLPo0eHWRn9rbZloq9kAFWLhaz2v0iQAuQQvxCd0xlNe2j9VOl+ Psoo5evsxEf6EE1NcX2cjUxJbI3rTDYGMYfBHfdFWyeuI+rkXmmDdf95C56Dfb/Qa5tP aeqZ5QCmy4lRgraXCm/ZQwvqQFylmafqkOEbVsVvl4DBdvKNF+EjUw2X5H3xTTtTX4sR M1/x1QRzR+d0GBqRWoGI/dQ9p/5h6Bh84myywCVnUIEJeBXogTrxrZWTR5a25Vu4w55K hkVKRFQtV6SJQ/RrXZE0XogH7WhM+k7N/YuJsfFe1iG8ouW7njHghsaxtYRd5kNxy4F4 BQcQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LrrOkGHclIqmSMq05EcG/78lZOoL2C6yTt7Ygc1gHCI=; b=M3+xjJh/DOdRa+kmhVE2N5y/6pcqichtjGJr2ygBWI3jiEgnBOOMoDsFFyMzuQDFed FYnulgKWwvMhbC1CYTJmsqdfL5gYuDi4Vy+zjnGFF6Tdc5KV7HvOf8L7NHTrpGPmhr3U AjHCL69MfhACLMGybV8Di6BPWHJ/nYNrRG4tT18FJfu3TPTwk0zzrVPHJcKW0Nr+L/gI CYZjOeCp38741O1mxq8sZuDPikGPXQ2g18NMeOF9B222HK+nsW4DBixlybkBwGMYUNSv cnBjvlexY12yWBxIKCG/AAXts3WbIMlGOxyXQNMrqcNUBlA6LoUArt2XyZc+FFZSS2bK lrKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lt+a6b3Z; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a170903244d00b0016efa52d3ffsi12301754pls.241.2022.08.15.14.09.51; Mon, 15 Aug 2022 14:10:02 -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=@linuxfoundation.org header.s=korg header.b=Lt+a6b3Z; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345990AbiHOUJv (ORCPT + 99 others); Mon, 15 Aug 2022 16:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345858AbiHOUJD (ORCPT ); Mon, 15 Aug 2022 16:09:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 486AC48CB3; Mon, 15 Aug 2022 11:55:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F9BC6123D; Mon, 15 Aug 2022 18:55:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59BDBC433D6; Mon, 15 Aug 2022 18:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589750; bh=97zjYBB23BfRBu0CCZkuOZde815VbzM7pC1v+wXwUcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lt+a6b3Z+vwqaw3z2UduD6NZH4NcIrmEACAy8uUvzckYcuuuVo+6g3CY9j/e36I5T aTVEksEdlGiss1xJyg8GUOd333XjET/zSnB19Y7Oj//9SLyE8hirZ1y9yFKKA43r59 uKqlSOS1y5N6NX53Z8q2SrU9YvBbJqgCytbO9/0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Maxim Levitsky Subject: [PATCH 5.18 0037/1095] KVM: x86: Set error code to segment selector on LLDT/LTR non-canonical #GP Date: Mon, 15 Aug 2022 19:50:36 +0200 Message-Id: <20220815180430.925274525@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Sean Christopherson commit 2626206963ace9e8bf92b6eea5ff78dd674c555c upstream. When injecting a #GP on LLDT/LTR due to a non-canonical LDT/TSS base, set the error code to the selector. Intel SDM's says nothing about the #GP, but AMD's APM explicitly states that both LLDT and LTR set the error code to the selector, not zero. Note, a non-canonical memory operand on LLDT/LTR does generate a #GP(0), but the KVM code in question is specific to the base from the descriptor. Fixes: e37a75a13cda ("KVM: x86: Emulator ignores LDTR/TR extended base on LLDT/LTR") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Reviewed-by: Maxim Levitsky Link: https://lore.kernel.org/r/20220711232750.1092012-3-seanjc@google.com Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/emulate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1724,8 +1724,8 @@ static int __load_segment_descriptor(str if (ret != X86EMUL_CONTINUE) return ret; if (emul_is_noncanonical_address(get_desc_base(&seg_desc) | - ((u64)base3 << 32), ctxt)) - return emulate_gp(ctxt, 0); + ((u64)base3 << 32), ctxt)) + return emulate_gp(ctxt, err_code); } if (seg == VCPU_SREG_TR) {