Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4325561pxj; Tue, 8 Jun 2021 11:33:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqpiGoWEMhTqj5hTNhLgbG+fyNFBfZW01SvpEOIodWsdjAjO5AQb5zyUWA+kfA41I4QMBb X-Received: by 2002:a17:907:206a:: with SMTP id qp10mr24636317ejb.309.1623177181797; Tue, 08 Jun 2021 11:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623177181; cv=none; d=google.com; s=arc-20160816; b=Ps0sG8YkDZD3WN65lUA1/P8ZexNCcDiuvWkN9dt/uhWxDlYCfUpG9r1acjfjuxoO5h 07sUfYlh0LwTIPo3W4Ti5nqtcGFIq5Mm9UmyvQaastSVwt5jjCaJeZ6LEe1HLdWesV7g d4AwCrwNM04XQ0uqDceg2yNxR2WAiry8WtuVrN4K1bXGV3IHyP+jQA2FqhbCYCSFw3KL 0llMMAV2YOS0HOaJjAzliLrPBNVHoqVPaz9YT8iaDtIbQ2CGPiKSEcng2Z06LY3Iyxew CEKFxodxuEH6qgXkuzuvZTsFhLh0+qBwOkEoTz2UfmRT3QwBOFjhUwCVHGuDEqCGNfya KDnw== 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=JmxRAw5D0gYow2nOdoqpC5XKlrR8Pcvul+E28H0OEUg=; b=LRoijvMnM7MX2ytgdlKP8ckOTN4Jco7l1ak/lJ4sck2DCPRKrr9fVpxUVrbJYzNmFR vqBT+LmPE1Nyl3MrKQj012+rXRld2mM7lMm6y/R8/DGb6VbYVkMIxY10NVpSdo1GQ67Z KIhJ4wEjIdmXSYt78HkhM246gYjAFVTPV7S4xQJ3B57unA8Dq0beXStPEb3qFxOW1UjQ Q/tN9z5U+SFn67a7nN647ZSWoHHuGo7jqQPf4zx2fJQDRz2ABYdEr4C2hSSwPYDQmbdp lfTn5mB3H3S6db0iKhOgNRC5Lf9qoSYDOsKcbPjPERGTP282Khn87n4s+hc4czN5jXAB 9Y/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vT866J9f; 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 d21si372069ejm.343.2021.06.08.11.32.38; Tue, 08 Jun 2021 11:33:01 -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=vT866J9f; 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 S234291AbhFHSb4 (ORCPT + 99 others); Tue, 8 Jun 2021 14:31:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:56134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234131AbhFHSb0 (ORCPT ); Tue, 8 Jun 2021 14:31:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C4BD61352; Tue, 8 Jun 2021 18:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623176960; bh=Dqzs51n09CBzyeBLLoDNn/q8ALuPLbQcOST6ertR6kQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vT866J9fe9VqdtkBtyJGwliPQYKPUWbsf1FEUco/AsICDyr37wFT59UDrPOc+ihhc eE0tgo5DVrRtOYUspPOluC5uoStHIg4E1tdYN8uogPWeAPF/YirCD+Va+lSBPgZJuo 3tQS1dOvAKPFaOH9peEnfXuk8SjvrJl3E/jiXYco= 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.4 21/23] KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode Date: Tue, 8 Jun 2021 20:27:13 +0200 Message-Id: <20210608175927.219476997@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175926.524658689@linuxfoundation.org> References: <20210608175926.524658689@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 @@ -2927,7 +2927,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)) @@ -2972,7 +2972,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); @@ -3004,13 +3004,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);