Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1861859rwb; Fri, 19 Aug 2022 10:36:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WxsGwuvd3Hww+KQ1kCvufRlHOu0LtZ772nNlDRjHVActwMPUCVvf4eGbfbmcAOQ1dHWVX X-Received: by 2002:a65:4848:0:b0:3fc:52c3:6ca5 with SMTP id i8-20020a654848000000b003fc52c36ca5mr7037333pgs.264.1660930602075; Fri, 19 Aug 2022 10:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930602; cv=none; d=google.com; s=arc-20160816; b=zuho1+u3RKj0XGz3Fp89YjcRsYyrEbpkFczvrEhAFCU6IBeGiZP718E03qBXe4MUlF Sui5ljPnXT/doZdnB+h0BWFaY2HQu7ov/2tUlMNnVMpEKAj9AU2zHumDg6fqmBtEipXb cW7hu/Hd5lrDxNWVCOrOox+eUzOGi5AKHBrsdd3lew2UrHq0bquwIZQJwUXN7Zrm3CQo i7X53HPdiGxH7iztrqLUYwHUTyUGz2l/cpOvHmoVDiFumdTsChOg1sg8SuB41uei8ynr WoiIEUZIvnbQx9rZVC29SCOlBWMTz0rkYXOtfhtmWkLmoA3t8NORrTPIbQZSLgnT21OJ WyYg== 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=fmtfGieMG/mWKFCWoTunj/crIAbCr9OUpfrem3p23V4=; b=xNqa3XsqRARUP4Kb4RpOo74c2S2jhyPm0J3BnRFtPMslE1N+o+n+gs1uwd8XoTYCN3 jK3qiQRLBs8yZ36L5acgb7qSrsdybSDCHeDXxcUOxTZBc8KYJqF1BaA6+ElQuSKgikus vVEcewSfHv8zFJAU1z2s+xU8elXXWCsyHxvm/ZnjaEpPQBWY4TBkcjur6GDYdJtTEUwi npVNBuRrcHXfpWDJ5tBQhHhzcwOtYUJ+QkaH8sF0pHCe/2z1CNKoowrKLTUJgfuCh84R iPD25/MC0pVKgUeiLFeCZxl1Fdj5F66z8pWS7aw9Dec8dgrT0STivQZ2+GBPsFTO4x1E IkqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rnY6lqY4; 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 70-20020a621849000000b0052acc972ec6si3682119pfy.62.2022.08.19.10.36.30; Fri, 19 Aug 2022 10:36:42 -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=rnY6lqY4; 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 S1350344AbiHSPvg (ORCPT + 99 others); Fri, 19 Aug 2022 11:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350422AbiHSPub (ORCPT ); Fri, 19 Aug 2022 11:50:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A54105F38; Fri, 19 Aug 2022 08:48:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 13189B82813; Fri, 19 Aug 2022 15:48:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 577ABC433D7; Fri, 19 Aug 2022 15:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924085; bh=LLjEaiaU+rXJ5Hm1Jja3z9R4ceG3bb+NgXlEBIT10xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rnY6lqY4MPDXKwY+Qggefk/+L8ufHM5zh/OOHSjBKjzShhccSBNrXCj7g0vMwMnHH eNC/wqoOeWZpdEXHcAm+/mAL/lxWEHd0KxK3Wr/fZlyNpP0ZPSXkEUIn0A5YFh61HT tu1T2ILKwJF41RicJKTLCtuMA1EWwb9K/SRfzXHs= 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.10 020/545] KVM: x86: Set error code to segment selector on LLDT/LTR non-canonical #GP Date: Fri, 19 Aug 2022 17:36:30 +0200 Message-Id: <20220819153830.096003133@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 @@ -1809,8 +1809,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) {