Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4734626pxj; Wed, 9 Jun 2021 00:04:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUKAw3NVJ/Fx2IjnolKIzud66p0M/0QXfm9MM+oAHlM5JKj7OlnWzyAKE1u1j9r2mH+OTp X-Received: by 2002:a17:906:8988:: with SMTP id gg8mr25413340ejc.266.1623222253445; Wed, 09 Jun 2021 00:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623222253; cv=none; d=google.com; s=arc-20160816; b=TTMfXk4of7JVH3M+k7n4HFW2Qxvhmo+remQpcrXjo9HdDFmhOLVKKdCwqzlQATb+L3 J+Avku/k20yCCkx4+wfRh91owUQhrN/rfAsYH9HeA+XNQihWHWfAM0pd5gNtGa2R5wGi uiS5nYYjqfMVW6vPCM5KFXUqsC+QgXcKji2aUaotfX/xQ6XcT93etYbb+y7kt1picY0Q u130Gbdc1KofSZgwIQcrfPS9JveO1WrTEvEpo/9x/xIWrQQn7XeG3igLHL8+n72bxOiD CcWlS29TLe79BT4rNq5Z/qan0kCKtv5vZkk6/+fCZw3Z+iAlXrgrfLFJc2kICXxxJG9B AbJA== 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=W7XZ1CuCm5aYvWd9M8gb/kWzKTygLEL55J5dcl/0Fy0=; b=DZzQk0PqM0x1Bbml5E1yS9AVMcOdQvnP1A8Kby1Dr4NU4Q99ebHBh6Ea+UbxUSfzo7 rrB2krdHrpUvmRb+mUsn9GPu4JwCs74ukYXYsUddTx/SHX5l15X9wfrKU52rWTMFxA6Q dr/SkScV4aRR2R3HpgTrXNtyeEO892ouRee/2N7bDCralBL6hSut2IWo8zUMozJEcqaW vTBr0vhPAK2n4p9KsbxNQ5Ns7sButqHO7wCjC22qYkdXy2ZqBu/+xhw54mppADqsIqhx i8BB6oaK0K0iMxX7OhFntWX7kyp3mXCfKkzxu9mBHe2qioc+fzBHVKownCt08xK5jIW2 MoRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Y/FgJtsp"; 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 b18si1703913edv.227.2021.06.09.00.03.49; Wed, 09 Jun 2021 00:04:13 -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="Y/FgJtsp"; 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 S234956AbhFHSh2 (ORCPT + 99 others); Tue, 8 Jun 2021 14:37:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:57858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234851AbhFHSfW (ORCPT ); Tue, 8 Jun 2021 14:35:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D86F7613F4; Tue, 8 Jun 2021 18:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177136; bh=8NOjyvvQfL4HAU18FT1tzY1sJj2ikgSMgbfavif44Ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/FgJtspAC843d5nk+YRdORlTChBYkokDVgNShh2npZjU44w5QCaYn0YD9M4v2/59 /xz9Qzgfp6RKPCTBIWBUNfGzW7DFZ4OH0uyq+l5CwgB6oEu/a3Qr9Mh/pPVMCP/7b0 SZ8IRDRWUV/WmkxFXl12Il5nTG+Fc20Izt3xKgBo= 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.14 45/47] KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode Date: Tue, 8 Jun 2021 20:27:28 +0200 Message-Id: <20210608175931.971396980@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175930.477274100@linuxfoundation.org> References: <20210608175930.477274100@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 @@ -3532,7 +3532,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)) @@ -3577,7 +3577,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); } @@ -3607,13 +3607,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);