Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4326285pxj; Tue, 8 Jun 2021 11:34:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYzIHGgkBBJ6FcYlASB3C0UorQCLVlr48UJg0yS/BJMCMd2qQs8fcjGBELQNlZT6yt6nu+ X-Received: by 2002:aa7:d5c9:: with SMTP id d9mr219222eds.278.1623177249025; Tue, 08 Jun 2021 11:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623177249; cv=none; d=google.com; s=arc-20160816; b=w5HcM3eUlMG1ibicl2uZD/qJ62wMu9wEgfAjvd/oLtY6Wk0DQULNbNz0n4Y5tVy+5o x6Ibq/Gw0cfn93OZlow9VBxwBZ6R8aV5tZhfADnDacTBqVh1cicrWPQJbC65QBaMphc9 DQ5YBGSfsZ74RPBZdCHCrFQP5bRe+3PHCi8l5mCldnOVxLYaih6vNca80xpBQcO4xy1Y qI6KpP6bphROkNd/2nSJ/1UJ3rfjehYuyg5LmdtDKO1ThMT7iuvGKHV9w1twbMoQ0hpW 06gh3wng+FkBoGYIGC2yeZxh8Gn1Yof4971ZNCpBWsfLw5ozSKtdCPFZnGOzGvvs10nS 7OOw== 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=XROYBc7EoUxJtz7qhGpFR3oWN0enfp0lK91y7n/2oYg=; b=YDw7/pFgVfTbeVk8pATLnpyg7WTW5RWjQ2epuOPlo0xMqRikG6Mvu2im+nK1qxQ0+w hKW+Q/q0T367fj4SYCMExp4991VjA3OZnxG+adXDM6fD3k01OU3N6cPk/XE/3TJYchKN K+X1Acsr2FW/iZ/CoNxsxp/ZtC0gLGUCavQ1G1fb0WmfMLZ20icUEn9UkpPwaCBbM25L BWNIN7LjU2rqAKZ9rxMd3UK8qiJRYXmZg5IyZrbYf+yz+WHCajbvDjVx0TvMDG+SSAqq RFeWaBtI1ImE2sA4HQDIrVLFEWO1SmDIOwfZzhrvZGhYoT+4ZYeA9pLyJyHEIG5CKvRG wmeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fR5L8Qo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si346751ejb.707.2021.06.08.11.33.45; Tue, 08 Jun 2021 11:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fR5L8Qo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234487AbhFHSc5 (ORCPT + 99 others); Tue, 8 Jun 2021 14:32:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:57386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234332AbhFHScH (ORCPT ); Tue, 8 Jun 2021 14:32:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7E1C7613C3; Tue, 8 Jun 2021 18:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177013; bh=B/Gs+pCslajavBfIyGu+Uc4kJDxnpnewLxxNa9+NQ8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0fR5L8Qosk3JBUscKN3Hwh59jyzdOPPH5RrQ8v98PJEzwo1K2FZzT4T7CpW6fTJQE PQXr7K93t6vBqETQ07LrIjyL73YIbcDEtOFZTXCEzcGqMaxhIgjfdrMFt9nvTHMHv4 sEEQXIFAWgaurXThkd2PcV4S0PkfnIbf9u/yFnNA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sudip Mukherjee Subject: [PATCH 4.9 27/29] KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode Date: Tue, 8 Jun 2021 20:27:21 +0200 Message-Id: <20210608175928.700196575@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175927.821075974@linuxfoundation.org> References: <20210608175927.821075974@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit 0884335a2e653b8a045083aa1d57ce74269ac81d upstream. Drop bits 63:32 on loads/stores to/from DRs and CRs when the vCPU is not in 64-bit mode. The APM states bits 63:32 are dropped for both DRs and CRs: In 64-bit mode, the operand size is fixed at 64 bits without the need for a REX prefix. In non-64-bit mode, the operand size is fixed at 32 bits and the upper 32 bits of the destination are forced to 0. Fixes: 7ff76d58a9dc ("KVM: SVM: enhance MOV CR intercept handler") Fixes: cae3797a4639 ("KVM: SVM: enhance mov DR intercept handler") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20210422022128.3464144-4-seanjc@google.com> Signed-off-by: Paolo Bonzini [sudip: manual backport to old file] Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3412,7 +3412,7 @@ static int cr_interception(struct vcpu_s err = 0; if (cr >= 16) { /* mov to cr */ cr -= 16; - val = kvm_register_read(&svm->vcpu, reg); + val = kvm_register_readl(&svm->vcpu, reg); switch (cr) { case 0: if (!check_selective_cr0_intercepted(svm, val)) @@ -3457,7 +3457,7 @@ static int cr_interception(struct vcpu_s kvm_queue_exception(&svm->vcpu, UD_VECTOR); return 1; } - kvm_register_write(&svm->vcpu, reg, val); + kvm_register_writel(&svm->vcpu, reg, val); } kvm_complete_insn_gp(&svm->vcpu, err); @@ -3489,13 +3489,13 @@ static int dr_interception(struct vcpu_s if (dr >= 16) { /* mov to DRn */ if (!kvm_require_dr(&svm->vcpu, dr - 16)) return 1; - val = kvm_register_read(&svm->vcpu, reg); + val = kvm_register_readl(&svm->vcpu, reg); kvm_set_dr(&svm->vcpu, dr - 16, val); } else { if (!kvm_require_dr(&svm->vcpu, dr)) return 1; kvm_get_dr(&svm->vcpu, dr, &val); - kvm_register_write(&svm->vcpu, reg, val); + kvm_register_writel(&svm->vcpu, reg, val); } skip_emulated_instruction(&svm->vcpu);