Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3404511rwa; Tue, 23 Aug 2022 04:20:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR5WGQzH5qKGVLbuWjVGdfu8TzGGObGLUFBISiTzerGWvNMMcwcDW//WYlAdLHX7W5VjzYJq X-Received: by 2002:a05:6a00:4147:b0:52d:fe84:2614 with SMTP id bv7-20020a056a00414700b0052dfe842614mr25437022pfb.10.1661253619851; Tue, 23 Aug 2022 04:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253619; cv=none; d=google.com; s=arc-20160816; b=bdqVHAoDVlZYwI187b95sHxCWU56zwCB2EwyuM6hCMPZY2cxfGRuw9d8sTU9dft74s mztugolGDMGdpuXju7GNWh2dLDDcl/904yxQ5Tqu0t9QUgXPlFz2O8J0P+/3q+m52QVn /SvwY0vuer/G95xk5Icp8V3JuBiIgxmvSKNSOk5dDXP1NZJlYdjDQGdAL4RY5KXVH/bH fp36juOKv224+MKWfAy7GbTBSa3WCt3DXqiEBwN4mjH+NY2nx4ZiBE38o6T4KiAk0mll RNoEKIsYnTTdCZ8Z9Xp9gYhIvhpGvogdUSoMLufzN3KVO5XPI87jL9CDBIss9gAIbl1F 5E2A== 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=AsArTgkJ16w0IZ1LbAxxNdKL1GSWWXA8rhwAz+XiQZ0=; b=eeiPLDd7iIZE0D8HHX6OKaM4DfdcNhk/tDc0C7fp8AKQd3ijiSR2zeFrJQ35LuIcQc 5cBPFP5wpbcE3YFp9NIgrI6F8HWU6vIRwxlsGGlPqQ39M22t520LPvqGKHCIbhodx0Ej F8KktSmWY3XyADCfArLNZrAz3vFARQmyIwZ3f52EnlQxtQGmW9ws9DBJ86F/KmOu5hk5 C0xI0ylpysn+KVImTjjW4i7tD0JyVlllGIFLTWIcfufUH+0DVwsGyZbgGga0xtYByV1u 6C2KQltASDKe+iOfu6d9O7QUGDMho2PdKaRvi3H++gNXngbOJ8TbJbeUzEWOp6gpzixm 81qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=coJ2cnWm; 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 w9-20020a63af09000000b00429f94269c4si389445pge.573.2022.08.23.04.20.08; Tue, 23 Aug 2022 04:20:19 -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=coJ2cnWm; 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 S1350195AbiHWJ3x (ORCPT + 99 others); Tue, 23 Aug 2022 05:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348812AbiHWJ1e (ORCPT ); Tue, 23 Aug 2022 05:27:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 017BF915F7; Tue, 23 Aug 2022 01:37:19 -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 A558BB81C4F; Tue, 23 Aug 2022 08:36:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6C44C433C1; Tue, 23 Aug 2022 08:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243782; bh=B3zwTcB/xhXEugosPjzJlf0j/Duf78YLQt3ExNWz/Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=coJ2cnWm016p45/vdQMGvPwK7rkcS/KcBB7njdKEC81/R6fzWlZqZia6ujE0Awh2m KB4ICjG3alO+S/56NdDVD2P5mb1phD/pcWOAxZvXTl9B6lu38UTY5umONGi3NX7jhh 7wDgU0TYwyHCPcYlnccKUS+zv6C5LoPUirDuUeQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Maxim Levitsky Subject: [PATCH 4.14 020/229] KVM: x86: Set error code to segment selector on LLDT/LTR non-canonical #GP Date: Tue, 23 Aug 2022 10:23:01 +0200 Message-Id: <20220823080054.161410421@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 @@ -1758,8 +1758,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) {