Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4340056pxj; Tue, 8 Jun 2021 11:55:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrQVfRBj/zmM3DfQttZ+UCcoTNbf+kOUOZ8QI1Dzw07w40ZJkpysNXudUew+W+ob/b/ghu X-Received: by 2002:a50:e702:: with SMTP id a2mr27650560edn.3.1623178521927; Tue, 08 Jun 2021 11:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623178521; cv=none; d=google.com; s=arc-20160816; b=i2az6Tv63G8fxTK+2LQn6QR5Z/K4vkqAmjS9tSirm25aHxnOiZraxSvU6DaULpU72Z DVfs7J+7uvsEL2OAvkfZHH1tI0BFhvttsg8pcX/SBguTfSk05p9wg6PxMUfjjQomIN3E 9xMCan6mlo6deVAek4250ODdI4FL37yg//Jr83DLR8IHSjSbGHQfSqdwg8fzsg3uv0v4 44JLlf62mCSEgdB1TG43noqaz2dFDB9MPXx6qWaHLbR6jCjBLVQviAgp2kJooJbTfoCN K7K9Q2RXmmUVcUBcRMQU7CpgpPJbT9fD0b7TPARWksKWDmSihhebN8tRxkV9gJfmA/RQ F0XA== 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=hhrBwTeCg6sVta4nP+nsaUdxIfKiS4IayZNM9cjkcvY=; b=zu1JfF7o9pE/kt3+KouTUzqUM/D09vLWBSlOh+SwPMxKg+tzi5XNsNd5nKPgFYE9H/ Dc4OXPHNWF0eIlc5IlykFzoOcEIZbT7GaKSetzjhkTJMsQ+kXJrUXQf6gbgbsHyOk9rM P2lZNVnmhuTC/Ure825/YJUCoCqhz6ogNpeXAPVGAGNaOFRmXfNg0La9c9HSjxbGgk0U MMM5P29Sza/zisGNcGGN4G4thdtR1Zl58aBugnzKMb2HHSEYY112yruY9ToMXayRwpDc sE58ngK9U0Q2LZJFqRzydVQsVnKo2SmlqwbyJKtoBGY3S77w9lBR9hRBcvAfO50g4RYk 1s2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xkRYPGhH; 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 v7si491883edj.328.2021.06.08.11.54.59; Tue, 08 Jun 2021 11:55:21 -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=xkRYPGhH; 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 S236578AbhFHSyi (ORCPT + 99 others); Tue, 8 Jun 2021 14:54:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:43938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234095AbhFHSsl (ORCPT ); Tue, 8 Jun 2021 14:48:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E37456141E; Tue, 8 Jun 2021 18:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177509; bh=8pibklfxU6kogs6fyLA6YZuem/5mpJ9QU9NK6kTb3aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xkRYPGhH0oTg+nzrFyGfdcimpJMCZg4uaeuHzfQlsVygm0083wW1dN+kNk/O7Ki7/ DQ1/LnoSIKEErMqjBBX8HLJefoZ/5W+lwA7qIlKfLRpkeycS58eKsC5m3zyi34cdhe Q68yzVM86fSQOW6yNMERLLuMOqkwTc1+oXsq+hsI= 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 5.4 70/78] KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode Date: Tue, 8 Jun 2021 20:27:39 +0200 Message-Id: <20210608175937.635579096@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175935.254388043@linuxfoundation.org> References: <20210608175935.254388043@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 @@ -4057,7 +4057,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)) @@ -4102,7 +4102,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); } return kvm_complete_insn_gp(&svm->vcpu, err); } @@ -4132,13 +4132,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); } return kvm_skip_emulated_instruction(&svm->vcpu);