Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2760759ybh; Mon, 5 Aug 2019 06:25:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjV3gQJpvK0p9PD4Hi0e+ioaeIq7EPAEeGG4z8wj2e+32w+UT+dfLxEt+KAPznNVOkY3GW X-Received: by 2002:a17:90b:8d8:: with SMTP id ds24mr17770744pjb.135.1565011544511; Mon, 05 Aug 2019 06:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011544; cv=none; d=google.com; s=arc-20160816; b=A2B9V4L6BEpEikRG9kRDd277z90R4TZVrAhXCQqL5ckeIyYkBdL8doN1xFExK3jAfB ETMngSUCuk2E0pn+XC5hR1vocrX97nYZnnc/iWFnLFm4TQkWbrIOD9/E1LdxdlyvB1Tq D4V0clpenTildGcIjBvzEY2A+4aDsTBy+aJyX4pSR58o/kpVMu8658HJMcya5XUgCeGt 8U3l4x5DfmcbIF24XJM6ySGFqrEiHo1kngqi4hoHfi5Z4u5gObkj+Aniiu91o3KU5rLf E7e0/7h5FVTvoNl4CsD2F6VAE2AUK1xLbjkk1UZFQeA3kaK1ehTavQqS1yG8a0r+CSjb U9iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PA22Gqn3+ixGx1lVOA4zb1OM7BI5uqQMbcJa0QgPZoE=; b=k+U23flDZD/lRrvGDwFuGe7ZcfWWam+4Mx27yKhb8rZBrjgNNwuj3Y5WQP8H5G2F+z cg/Im5iakWM4SDlQfZgMSm3cW92P1AmkmxkBNbu310GV1quWIfIXuHM516xNn0Xt2yvh atgLdBEywbvPunX1iCi7DgEGtH0AKlXMkL4Xe8mTyrqtAAGZnCCrNN1zlCad/lPETzVW S3OJiIQdfTNd+QvT+tFp5EKd2crmo0xCKX1HQ5NVGSEOEsWE7S/JC6am3tjO17GW958u b4N9GcbzF4+3cL1BX1pPMAIyrwQOSeTtqRatMBYhwDKHWZp8NYjYgO8gsU8Or10HpDL7 o8Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jWK0nsPP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si45778946pfi.34.2019.08.05.06.25.28; Mon, 05 Aug 2019 06:25:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jWK0nsPP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730815AbfHENXZ (ORCPT + 99 others); Mon, 5 Aug 2019 09:23:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:60028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730807AbfHENXY (ORCPT ); Mon, 5 Aug 2019 09:23:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 318392087B; Mon, 5 Aug 2019 13:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011403; bh=HHXGhJKti16845K2WGW8y8pgKz43cuRHFDvkze4Ljx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWK0nsPP1D3NCVEfU64N2LwCfvjiqRahTobDDAoE90AJ/xUUDG6J7WQfl1nFXGeRn IpEoddnYL0y/v0TkcYHHJ+fyX7efeBqYbkVhJc6187fvhP2tkQsIu6T8HvH9gk+zzM 3/9dls1TASCjiVq1IsH9o4E0CuDa3MrV2m4/uoAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Villard , Joao Martins , Liran Alon , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.2 044/131] KVM: nVMX: Ignore segment base for VMX memory operand when segment not FS or GS Date: Mon, 5 Aug 2019 15:02:11 +0200 Message-Id: <20190805124954.389758698@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124951.453337465@linuxfoundation.org> References: <20190805124951.453337465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6694e48012826351036fd10fc506ca880023e25f ] As reported by Maxime at https://bugzilla.kernel.org/show_bug.cgi?id=204175: In vmx/nested.c::get_vmx_mem_address(), when the guest runs in long mode, the base address of the memory operand is computed with a simple: *ret = s.base + off; This is incorrect, the base applies only to FS and GS, not to the others. Because of that, if the guest uses a VMX instruction based on DS and has a DS.base that is non-zero, KVM wrongfully adds the base to the resulting address. Reported-by: Maxime Villard Reviewed-by: Joao Martins Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/nested.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index ef6575ab60edc..b96723294b2f3 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4087,7 +4087,10 @@ int get_vmx_mem_address(struct kvm_vcpu *vcpu, unsigned long exit_qualification, * mode, e.g. a 32-bit address size can yield a 64-bit virtual * address when using FS/GS with a non-zero base. */ - *ret = s.base + off; + if (seg_reg == VCPU_SREG_FS || seg_reg == VCPU_SREG_GS) + *ret = s.base + off; + else + *ret = off; /* Long mode: #GP(0)/#SS(0) if the memory address is in a * non-canonical form. This is the only check on the memory -- 2.20.1