Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp965556imp; Wed, 20 Feb 2019 12:24:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IbFyUJ40JuX7jJl1UJOwDKuWXA4xhm+1QBrkDC/1hPayemy7XhShWv9JH3kgnlBh3wCzDm8 X-Received: by 2002:a17:902:5a5:: with SMTP id f34mr38796921plf.161.1550694281286; Wed, 20 Feb 2019 12:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550694281; cv=none; d=google.com; s=arc-20160816; b=ydERt2NTxTjSWJycH7WIjCqlN9o3/UIb9+Pk7UDycVlaFRhJpsrjRcNCrc6BNWVeVd Yos70cx1c67wbrLhnWUVGcUkQ/RRaILCbkZl8x4dSes1algs/cVf1bizVELojqXjeTn3 0QN+pJR6d31C8rO02WRnLg9kECMoZ+gSO0owX4J8IuZNztzO/T3CipBAYjdPzYt5g0Q+ Qo9s3iGXWucEDa7oIHT8iviMF2wW616X6+tAH2IQml0nQmPTV3sDc3+RkbNp5oYP//Is BehKJgaAwiK0CLxFC+6LDVxCAVah0nsAmZob6BX3MnYU4US3U+5azLLdKQFrMMrRY64L QCnA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ndvkg+/D0hf5OrbzmK4FZM7exvpdfllBJBc6SNXVjDs=; b=S1DKX1jL/rEgqXdb2oHqZ5oPLURxW0e6dyDjOZKiLWPJ13/VLjKQtcXgi5EhjdJyTG epHNsYJczZ8uVD4N0jaWUK2OFsLHaSbNrVUAKA+dkPutiWFCXrE1hDyKNLP6utVIbuHo zhDFpZiJsO/xWehiLpwu9oW4VO0zPrPYTr5JYH0cwM6nT7CKgWFbb5PBJ8GETEZu6KW8 6JkmY0S49d6mODChCqNp/VyDYpnnztimTO5a73Aj7rplKBZvbcrWWqI4ylTAu5nwZqe6 5vhDvd4tcbcW6REkZmCvm0gJMkZidqnTNyZy427vylSIWH505o8NF91iw+NtOTHQw/ut sOzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=JlODJvHf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 191si14267535pga.6.2019.02.20.12.24.25; Wed, 20 Feb 2019 12:24:41 -0800 (PST) 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=@oracle.com header.s=corp-2018-07-02 header.b=JlODJvHf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726203AbfBTURV (ORCPT + 99 others); Wed, 20 Feb 2019 15:17:21 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:34840 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbfBTURV (ORCPT ); Wed, 20 Feb 2019 15:17:21 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1KK9bEb088246; Wed, 20 Feb 2019 20:16:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=Ndvkg+/D0hf5OrbzmK4FZM7exvpdfllBJBc6SNXVjDs=; b=JlODJvHfDFO9wDU6O8Ik5ea3sjo8fA4wa2mCxi9Mtn/xMBfEjH619kIAAlqxOV1Pc1sc BYtrkjN8hMfhqJNcrclZevU6gg++bQ/a+BkFmKTdcvG6tFZ/RH6SMbvtZCd1wnwtCMW+ VUsbcxGSFRVZVY+USdj1rGh/AB7M5hS9so5stCJHMvmPoo2FzxuYiESZqcKD2bSA0hXq TysLp0BmdElEjX28+jnOPq1sH0hqX7ON2pfaKhfzdHFglMoAmvhb0Jgmt70Jac5N2ayK 0Yx4MXArOtTvfX5BfwUN8t70UfVEjnKoiPZwghXYXqj1XJzsIXt7fJTU8IPIAItqrgpl Vw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2qpb5rktkw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:16:58 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1KKGvIO002290 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Feb 2019 20:16:57 GMT Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1KKGuos009112; Wed, 20 Feb 2019 20:16:56 GMT Received: from paddy.lan (/94.61.137.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Feb 2019 12:16:55 -0800 From: Joao Martins To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ankur Arora , Boris Ostrovsky , Joao Martins , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH RFC 01/39] KVM: x86: fix Xen hypercall page msr handling Date: Wed, 20 Feb 2019 20:15:31 +0000 Message-Id: <20190220201609.28290-2-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190220201609.28290-1-joao.m.martins@oracle.com> References: <20190220201609.28290-1-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9173 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=973 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902200138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xen usually places its MSR at 0x4000000 or 0x4000200 depending on whether it is running in viridian mode or not. Note that this is not ABI guaranteed, so it is possible for Xen to advertise the MSR some place else. Given the way xen_hvm_config() is handled, if the former address is selected, this will conflict with HyperV's MSR (HV_X64_MSR_GUEST_OS_ID) which uses the same address. Given that the MSR location is arbitrary, move the xen_hvm_config() handling to the top of kvm_set_msr_common() before falling through. Signed-off-by: Joao Martins --- arch/x86/kvm/x86.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 65e4559eef2f..47360a4b0d42 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2429,6 +2429,9 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) u32 msr = msr_info->index; u64 data = msr_info->data; + if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr)) + return xen_hvm_config(vcpu, data); + switch (msr) { case MSR_AMD64_NB_CFG: case MSR_IA32_UCODE_WRITE: @@ -2644,8 +2647,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) vcpu->arch.msr_misc_features_enables = data; break; default: - if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr)) - return xen_hvm_config(vcpu, data); if (kvm_pmu_is_valid_msr(vcpu, msr)) return kvm_pmu_set_msr(vcpu, msr_info); if (!ignore_msrs) { -- 2.11.0