From patchwork Thu Aug 20 15:08:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFE0514F6 for ; Thu, 20 Aug 2020 15:11:15 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C0B2204EA for ; Thu, 20 Aug 2020 15:11:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="eevHJFND" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C0B2204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC2-0003m1-6S; Thu, 20 Aug 2020 15:09:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC1-0003lg-1U for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:29 +0000 X-Inumbo-ID: 8a0b62eb-465a-4dcc-ab2c-2de7cd38152b Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8a0b62eb-465a-4dcc-ab2c-2de7cd38152b; Thu, 20 Aug 2020 15:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936166; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zT5MN7nvkqMoYuX6+gGl+F2zxCCkKoFt0fQb/G0S9wE=; b=eevHJFNDR6U+Sd/3KsBE8t22tpMtfVtlPrX0zK+FSFqQ5incDLt62qw3 n1vczbTtUBcf1C+CazPUH22iqYQz9x1rKI4xH8utmRFQoBRysXZUROEbZ /s1Ox1fi35z03RrjHDsCKhTAAHgyne7PCb0MF77A4ru5i94Imm0PH0GZK Y=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ts6GtElitM50VW9zQe5AqEG/mVPPu6nCutMkL+Ib3WxHgO7NIjQHtGsNhoY/RiBgNqvKz7ak3W wh0Hm/QPTSDAIA8HF071o1YYq181CHERzbFPe+Uqrh8jGO8zSmaEAJexR9SyVcxjtRdJufM4GG uha1thSb6aPSZrED0Hgt0lz3O0c+at/lY932hH3lCy0EluvyX6vFdhb61ubEZQ7nU/4k7JsMKe zYIpU+gTkWIWBJ3JLhzPzZNisHb4LhP8T0nx8/oySh5R0IjoViJU5NHtchHVDuOMSHgpVA+wcV mEU= X-SBRS: 2.7 X-MesageID: 24942327 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="24942327" From: Roger Pau Monne To: CC: Roger Pau Monne , Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 1/8] x86/vmx: handle writes to MISC_ENABLE MSR Date: Thu, 20 Aug 2020 17:08:28 +0200 Message-ID: <20200820150835.27440-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Such handling consist in checking that no bits have been changed from the read value, if that's the case silently drop the write, otherwise inject a fault. At least Windows guests will expect to write to the MISC_ENABLE MSR with the same value that's been read from it. Signed-off-by: Roger Pau Monné Acked-by: Andrew Cooper --- xen/arch/x86/hvm/vmx/vmx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index a0d58ffbe2..4717e50d4a 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3163,7 +3163,7 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) switch ( msr ) { - uint64_t rsvd; + uint64_t rsvd, tmp; case MSR_IA32_SYSENTER_CS: __vmwrite(GUEST_SYSENTER_CS, msr_content); @@ -3301,6 +3301,13 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) /* None of these MSRs are writeable. */ goto gp_fault; + case MSR_IA32_MISC_ENABLE: + /* Silently drop writes that don't change the reported value. */ + if ( vmx_msr_read_intercept(msr, &tmp) != X86EMUL_OKAY || + tmp != msr_content ) + goto gp_fault; + break; + case MSR_P6_PERFCTR(0)...MSR_P6_PERFCTR(7): case MSR_P6_EVNTSEL(0)...MSR_P6_EVNTSEL(7): case MSR_CORE_PERF_FIXED_CTR0...MSR_CORE_PERF_FIXED_CTR2: From patchwork Thu Aug 20 15:08:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3447A14F6 for ; Thu, 20 Aug 2020 15:10:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F2762184D for ; Thu, 20 Aug 2020 15:10:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="aMBlpmRv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F2762184D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC7-0003nR-NW; Thu, 20 Aug 2020 15:09:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC6-0003lg-1l for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:34 +0000 X-Inumbo-ID: 7f8d7d2f-2fda-4dec-8a3c-ab1294a9fe79 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7f8d7d2f-2fda-4dec-8a3c-ab1294a9fe79; Thu, 20 Aug 2020 15:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936167; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CEi0dM/7BZiEN912X8rVzEnoKxkc3ToKQEfV0GTNGho=; b=aMBlpmRv85G02PL4RXDyai5dYX7NguRFnLQhErA86immVbCBCAsv5kfQ 46g19ERApFEyHi0qxvb6nixTB7X6eIGyMFtuTJoaDZ7FoWGs/LME/60SJ DV/5hoZP7jLAz+/i93D9lc78TJkTNXhugt9cxFI0yEe7B3TIUo0lBw7aU 8=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 7UgPcAb17xC0Lh0mDPXV7r92EowuEbFQLsTV3gXXjj1ZeNXBlXWn43BEA6BgFssCksfw+6bQuL AfC4J6lenGn4osDgd71aRv6aQSxXTM4DnqrxJ95RUARWYN7ZQlsIBCX5N+SxecofVJ6pX4WS6/ m/xZWJAmH1ptFGwnvTJ+nzzH+s2tQNI0aE8cO+MO8l1A5WK7EW3TpmPKwuC45gAKSkn1yXlqbW 2kRASZMu5CYnfyPqbwooWymsAs7JXleklDcVSpwifoeXs+aW5leyn51zIdIR2CnuntoI4UaCZU H0w= X-SBRS: 2.7 X-MesageID: 25887029 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="25887029" From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 2/8] x86/svm: silently drop writes to SYSCFG and related MSRs Date: Thu, 20 Aug 2020 17:08:29 +0200 Message-ID: <20200820150835.27440-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The SYSCFG, TOP_MEM1 and TOP_MEM2 MSRs are currently exposed to guests and writes are silently discarded. Make this explicit in the SVM code now, and just return default constant values when attempting to read any of the MSRs, while continuing to silently drop writes. Signed-off-by: Roger Pau Monné --- Changes sincxe v1: - Return MtrrFixDramEn in MSR_K8_SYSCFG. --- xen/arch/x86/hvm/svm/svm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index ca3bbfcbb3..2d0823e7e1 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1917,6 +1917,21 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) goto gpf; break; + case MSR_K8_TOP_MEM1: + case MSR_K8_TOP_MEM2: + *msr_content = 0; + break; + + case MSR_K8_SYSCFG: + /* + * Return MtrrFixDramEn: albeit the current emulated MTRR + * implementation doesn't support the Extended Type-Field Format having + * such bit set is common on AMD hardware and is harmless as long as + * MtrrFixDramModEn isn't set. + */ + *msr_content = K8_MTRRFIXRANGE_DRAM_ENABLE; + break; + case MSR_K8_VM_CR: *msr_content = 0; break; @@ -2094,6 +2109,12 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content) goto gpf; break; + case MSR_K8_TOP_MEM1: + case MSR_K8_TOP_MEM2: + case MSR_K8_SYSCFG: + /* Drop writes. */ + break; + case MSR_K8_VM_CR: /* ignore write. handle all bits as read-only. */ break; From patchwork Thu Aug 20 15:08:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726527 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99473109B for ; Thu, 20 Aug 2020 15:11:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74729204EA for ; Thu, 20 Aug 2020 15:11:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="GGpUV/+M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74729204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCC-0003pW-8d; Thu, 20 Aug 2020 15:09:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCB-0003lg-23 for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:39 +0000 X-Inumbo-ID: bdbb1378-0677-4ef4-9ea5-1be20f41f552 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bdbb1378-0677-4ef4-9ea5-1be20f41f552; Thu, 20 Aug 2020 15:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936168; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aABF1ZpA+s0LDLyA9ZO3Bf9vZtEhgE3zcRaVk4S89kM=; b=GGpUV/+MU4w4kho2GMZCv1/n2a33UM50i6Nw9eFE/tEJ0kAFte2FBfzD tR8wQV/+1JPYY7qxHAlxZIK/U0s40vDSTHX45AH+99vXWjqk/cf0VzmGX h1YyWr5UiUHt5sYVW5+/kLF7KYW+0G2yU8GsttVVPBEFp/mKXOKwjvDy9 Q=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: BvLK3rBMe9cKIDcUU4crCtKc6f1ltuf7T3147XznKoJdhLfB1IeGzpju4UStKoq2DCKpU1UwpG CixPOXn2xjtbx3cCcyxBkH7koGhz38IZL1qTSIqTHPFzJgfpHn5Hggqej9i3r70F1Myqyv8Zac z903v/UwrrvEtBf28GIMkK9yBtaiC4xvonXQwJjNuZZYVaQE3sivGJHKukkpA0mJCXEslRD8Vm 0WLb+jkes1562Di+lcyUbQzltfz/Rj4ZA+GVyTWQrdiAktoXdj6+hwSfbu0aTeXP3W3lriN7i3 NvM= X-SBRS: 2.7 X-MesageID: 25266660 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="25266660" From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 3/8] x86/msr: explicitly handle AMD DE_CFG Date: Thu, 20 Aug 2020 17:08:30 +0200 Message-ID: <20200820150835.27440-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Report the hardware value of DE_CFG on AMD hardware and silently drop writes. Reported-by: Andrew Cooper Signed-off-by: Roger Pau Monné --- Changes since v1: - New in this version. --- xen/arch/x86/msr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index ca4307e19f..a890cb9976 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -274,6 +274,14 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) *val = msrs->tsc_aux; break; + case MSR_AMD64_DE_CFG: + if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) || + !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | + X86_VENDOR_HYGON)) || + rdmsr_safe(MSR_AMD64_DE_CFG, *val) ) + goto gp_fault; + break; + case MSR_AMD64_DR0_ADDRESS_MASK: case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: if ( !cp->extd.dbext ) @@ -499,6 +507,12 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) wrmsr_tsc_aux(val); break; + case MSR_AMD64_DE_CFG: + if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) || + !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) ) + goto gp_fault; + break; + case MSR_AMD64_DR0_ADDRESS_MASK: case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: if ( !cp->extd.dbext || val != (uint32_t)val ) From patchwork Thu Aug 20 15:08:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726547 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80BD7739 for ; Thu, 20 Aug 2020 15:11:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D9DD2086A for ; Thu, 20 Aug 2020 15:11:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="aaGWxMgl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D9DD2086A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC6-0003mx-Fd; Thu, 20 Aug 2020 15:09:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC4-0003mF-Rd for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:32 +0000 X-Inumbo-ID: 7c115b8d-a4dc-4e13-9dc2-4876a2493a15 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7c115b8d-a4dc-4e13-9dc2-4876a2493a15; Thu, 20 Aug 2020 15:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FKYzxNpQWEfSFaEX9BxBNLb9An6Dr63PFxa7t7708g8=; b=aaGWxMglVZp5IZ50G9rFfP1m+V7jfrK4LF51rlb34qhYtVT2hYBHah8m cYk1C70eerCig/7NC7CQE6Rp/1KOt4CODOR17SSPMbyQLVA8dd+mDaClJ lHaPajEostc38ea2P0SuHeWuLmbHDO8lf39yaJ32Xkqs5lCYS61x2uFba 0=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: dQMauhDpzkj4942q+G/yxU5ylH/07HIC2/D1T50wq4BWY2N4APmoUvV4TfJqZOw7I/b1K4mrb2 yQOUT42IIFjb4HJ13MIA2POWLhFrVYb2Pw4zE8s+F46wVV2xCOacv/xGxbw/WzbdFnU6BA2GP2 XkUAM1jIel3GLazaJ1zjuD9AkgZ24UUfeJa0WLBYZGEivOAtbNyKZ+i/RS/FX/6qshTdaMDB/o 8ueEgReD9G95wvxB5EfmLOQuebG17WpVv5PfFmUQbUmtXZphVTXW+QN6C4vmjSPbYi4alPrrw3 zCk= X-SBRS: 2.7 X-MesageID: 25292195 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="25292195" From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 4/8] x86/svm: drop writes to BU_CFG on revF chips Date: Thu, 20 Aug 2020 17:08:31 +0200 Message-ID: <20200820150835.27440-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We already have special casing to handle reads of this MSR for revF chips, so do as the comment in svm_msr_read_intercept says and drop writes. This is in preparation for changing the default MSR write behavior, which will instead return #GP on not explicitly handled writes. Signed-off-by: Roger Pau Monné --- Changes since v1: - New in this version. --- xen/arch/x86/hvm/svm/svm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 2d0823e7e1..7586b77268 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2125,6 +2125,12 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content) nsvm->ns_msr_hsavepa = msr_content; break; + case MSR_F10_BU_CFG: + /* See comment in svm_msr_read_intercept. */ + if ( boot_cpu_data.x86 != 0xf ) + goto gpf; + break; + case MSR_AMD64_TSC_RATIO: if ( msr_content & TSC_RATIO_RSVD_BITS ) goto gpf; From patchwork Thu Aug 20 15:08:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2C26739 for ; Thu, 20 Aug 2020 15:11:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF65D204EA for ; Thu, 20 Aug 2020 15:11:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="G/IM78Wz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF65D204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCH-0003sm-IL; Thu, 20 Aug 2020 15:09:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCG-0003lg-2P for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:44 +0000 X-Inumbo-ID: 33fd808e-749d-48f2-b6d2-da44e8b11909 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 33fd808e-749d-48f2-b6d2-da44e8b11909; Thu, 20 Aug 2020 15:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DgPYrIn2ueyNZtkxRfEph5bavhTq242QMrgpf1Jrbio=; b=G/IM78WzGbom0pfPBqc1d5+KI6JIRyl8PKTJQydrWfvvXgBvYBmBqrIe XwMLoTPNsoXsjS8h+xSJbXXIrBd6l6pLdJ0f5KaOQn6rbTKz2N09+EJGN Pyf9UhdOvrHsQrToCH1h9J6oGC0aQdmWZ+eCY8JE0OKOv4k5TAJP0kvOV Y=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: z+vuYppG4zblNgHYnqXoqB9apxIWoO1kbkdRKj1Verxge6DD/1PqsHw2Tc+S3IlLv4FK1CfGBE t1R7zSuTjMI3xvQSZx0LiIjW74Qu2tgAkTwhH9a75mk8+8BvXdvSzbHKflZh14/Vgmsp6jJP76 XC75oxk1vWsdTtYYCjuEX480Dh/4B33IH3Av/drft/Xpj2ACiExWMOxK+SRg+VB8bC7tY3gxqO Wx5MEYs+830o08UgL9rVFPUPzp4Tg/wizob8nDurDyPSq6AWg7wQcqaOWpH4iRMSYh2Du11bLl xew= X-SBRS: 2.7 X-MesageID: 25266665 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="25266665" From: Roger Pau Monne To: CC: Roger Pau Monne , Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 5/8] x86/pv: allow reading FEATURE_CONTROL MSR Date: Thu, 20 Aug 2020 17:08:32 +0200 Message-ID: <20200820150835.27440-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Linux PV guests will attempt to read the FEATURE_CONTROL MSR, so move the handling done in VMX code into guest_rdmsr as it can be shared between PV and HVM guests that way. Signed-off-by: Roger Pau Monné --- Changes from v1: - Move the VMX implementation into guest_rdmsr. --- xen/arch/x86/hvm/vmx/vmx.c | 8 +------- xen/arch/x86/msr.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 4717e50d4a..f6657af923 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2980,13 +2980,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) case MSR_IA32_DEBUGCTLMSR: __vmread(GUEST_IA32_DEBUGCTL, msr_content); break; - case MSR_IA32_FEATURE_CONTROL: - *msr_content = IA32_FEATURE_CONTROL_LOCK; - if ( vmce_has_lmce(curr) ) - *msr_content |= IA32_FEATURE_CONTROL_LMCE_ON; - if ( nestedhvm_enabled(curr->domain) ) - *msr_content |= IA32_FEATURE_CONTROL_ENABLE_VMXON_OUTSIDE_SMX; - break; + case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_VMFUNC: if ( !nvmx_msr_read_intercept(msr, msr_content) ) goto gp_fault; diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index a890cb9976..bb0dd5ff0a 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -181,6 +182,18 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) /* Not offered to guests. */ goto gp_fault; + case MSR_IA32_FEATURE_CONTROL: + if ( !(cp->x86_vendor & X86_VENDOR_INTEL) ) + goto gp_fault; + + *val = IA32_FEATURE_CONTROL_LOCK; + if ( vmce_has_lmce(v) ) + *val |= IA32_FEATURE_CONTROL_LMCE_ON; + if ( nestedhvm_enabled(d) ) + *val |= IA32_FEATURE_CONTROL_ENABLE_VMXON_OUTSIDE_SMX; + break; + + case MSR_IA32_PLATFORM_ID: if ( !(cp->x86_vendor & X86_VENDOR_INTEL) || !(boot_cpu_data.x86_vendor & X86_VENDOR_INTEL) ) From patchwork Thu Aug 20 15:08:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8DCA739 for ; Thu, 20 Aug 2020 15:11:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6370204EA for ; Thu, 20 Aug 2020 15:11:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="XQSehyxa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6370204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCB-0003og-0I; Thu, 20 Aug 2020 15:09:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mC9-0003mF-Jt for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:37 +0000 X-Inumbo-ID: 9861e113-6348-42c5-aedc-dd61bc5ea933 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9861e113-6348-42c5-aedc-dd61bc5ea933; Thu, 20 Aug 2020 15:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c3IiBsgTt3Xwg5H0pnyEg9IS2JotOo9gr0GaNIGnl/s=; b=XQSehyxapMofASmR7aFlLc9SqBMdH0RSH1O3AvKDCiOfEnEJBhHvZVwQ dk50aaxYk9k0CputEwRR5x42IEMMabZ0o/m0jl9yD+E7VZ+h15vBcgEwn lyzAlZLxA71YAzAjoZLmjWox3V1U0RqKc+cApyQEuaKGu1FuskE2uoTQz M=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: NTJ8v9W522m9Pr3epacihjm4Zejpg4eSnU7Cz2KngiYiYDTt37BbXLhI4nIbTTGDRq0EKMEtBN HJpUVkfNxl2dVZSyTq8aqI/ewG7gylK8Db9OqFBBBB93EJwNNn1MOhozGYjjIzmsO5st5EMNjA zojxLFVLNeH67GSRAUKWA1S9igZFT6sR2UDyHyihhcmrcb+KY0Xal31uinrubkBDtUPuQltyCD VQ4o8YHHewiLxGNaA2HbogfYQaVspXm+6TvhZR+46neeC7Qtdl2sz9ILv10XjqVSu/baqBQ4w0 8M0= X-SBRS: 2.7 X-MesageID: 24942345 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="24942345" From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 6/8] x86/pv: disallow access to unknown MSRs Date: Thu, 20 Aug 2020 17:08:33 +0200 Message-ID: <20200820150835.27440-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Change the catch-all behavior for MSR not explicitly handled. Instead of allow full read-access to the MSR space and silently dropping writes return an exception when the MSR is not explicitly handled. Signed-off-by: Roger Pau Monné Acked-by: Andrew Cooper --- xen/arch/x86/pv/emul-priv-op.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index bcc1188f6a..d4735b4f06 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -972,9 +972,10 @@ static int read_msr(unsigned int reg, uint64_t *val, } /* fall through */ default: + gdprintk(XENLOG_WARNING, "RDMSR 0x%08x unimplemented\n", reg); + break; + normal: - /* Everyone can read the MSR space. */ - /* gdprintk(XENLOG_WARNING, "Domain attempted RDMSR %08x\n", reg); */ if ( rdmsr_safe(reg, *val) ) break; return X86EMUL_OKAY; @@ -1141,14 +1142,15 @@ static int write_msr(unsigned int reg, uint64_t val, } /* fall through */ default: - if ( rdmsr_safe(reg, temp) ) - break; + gdprintk(XENLOG_WARNING, + "WRMSR 0x%08x val 0x%016"PRIx64" unimplemented\n", + reg, val); + break; - if ( val != temp ) invalid: - gdprintk(XENLOG_WARNING, - "Domain attempted WRMSR %08x from 0x%016"PRIx64" to 0x%016"PRIx64"\n", - reg, temp, val); + gdprintk(XENLOG_WARNING, + "Domain attempted WRMSR %08x from 0x%016"PRIx64" to 0x%016"PRIx64"\n", + reg, temp, val); return X86EMUL_OKAY; } From patchwork Thu Aug 20 15:08:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726553 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE5B9739 for ; Thu, 20 Aug 2020 15:11:29 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BD322086A for ; Thu, 20 Aug 2020 15:11:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="iBOICu/t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BD322086A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCM-0003wK-WB; Thu, 20 Aug 2020 15:09:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCL-0003lg-2T for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:49 +0000 X-Inumbo-ID: 8f02a0cd-ee48-4d2d-a496-e4fc73382743 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8f02a0cd-ee48-4d2d-a496-e4fc73382743; Thu, 20 Aug 2020 15:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SVndl4pASR8SDk46ofH1FSd8rv6zJbPHsqBTIDOsayY=; b=iBOICu/t6Vg3RxvBQNJaoaZHoVPRep4qOjiB29I8KgLGOKkFDTzaqWN1 9i504spEfPFr8j8UYvcYoPRxBNk5LwM/rexY/JLc8cQHqqnDk0pwDGQNB y+0v+5TXWh1hNKAj+lcXZuX0RoX5RwnJqnSEs8QSrHwlzfj2mXBhqGSyI 4=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: WC8Phs4G2OE1+xbh74B68s9+1JUr4rg7TGkxrf2xHD0JuVOyA2KMSEag4c0DcoYXrXk9JJ/1W8 yF0iSKW1e86GPOISJ8MczKKj6TgZvcZrMNhm23m8Ww3da42Qc6ar4QjMgfA8fl7QX5IQPA7i5g V2ytyZfvbZytU1gey9V5A67W1sdt67XR634LQlV/6QF3onAvnNuKsVpim1YrEmxrXDe1MXMFuw p4iRATwkqy2RH/Qd74z8g/vYE5P748RqW5XYxrY3qjHx7CHZfmb8MGgaHbzCCX4mIU+hpZollq +yU= X-SBRS: 2.7 X-MesageID: 25108124 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="25108124" From: Roger Pau Monne To: CC: Andrew Cooper , Jan Beulich , Wei Liu , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= , Jun Nakajima , Kevin Tian Subject: [PATCH v2 7/8] x86/hvm: Disallow access to unknown MSRs Date: Thu, 20 Aug 2020 17:08:34 +0200 Message-ID: <20200820150835.27440-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Andrew Cooper Change the catch-all behavior for MSR not explicitly handled. Instead of allow full read-access to the MSR space and silently dropping writes return an exception when the MSR is not explicitly handled. Signed-off-by: Andrew Cooper [remove rdmsr_safe from default case in svm_msr_read_intercept] Signed-off-by: Roger Pau Monné --- Changes since v1: - Fold chunk to remove explicit write handling of VMX MSRs just to #GP. - Remove catch-all rdmsr_safe in svm_msr_read_intercept. --- xen/arch/x86/hvm/svm/svm.c | 11 ++++------- xen/arch/x86/hvm/vmx/vmx.c | 16 ++++------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 7586b77268..1e4458c184 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1952,9 +1952,6 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) break; default: - if ( rdmsr_safe(msr, *msr_content) == 0 ) - break; - if ( boot_cpu_data.x86 == 0xf && msr == MSR_F10_BU_CFG ) { /* Win2k8 x64 reads this MSR on revF chips, where it @@ -1967,6 +1964,7 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) break; } + gdprintk(XENLOG_WARNING, "RDMSR 0x%08x unimplemented\n", msr); goto gpf; } @@ -2154,10 +2152,9 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content) break; default: - /* Match up with the RDMSR side; ultimately this should go away. */ - if ( rdmsr_safe(msr, msr_content) == 0 ) - break; - + gdprintk(XENLOG_WARNING, + "WRMSR 0x%08x val 0x%016"PRIx64" unimplemented\n", + msr, msr_content); goto gpf; } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index f6657af923..9cc9d81c41 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3015,9 +3015,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) break; } - if ( rdmsr_safe(msr, *msr_content) == 0 ) - break; - + gdprintk(XENLOG_WARNING, "RDMSR 0x%08x unimplemented\n", msr); goto gp_fault; } @@ -3290,11 +3288,6 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) __vmwrite(GUEST_IA32_DEBUGCTL, msr_content); break; - case MSR_IA32_FEATURE_CONTROL: - case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC: - /* None of these MSRs are writeable. */ - goto gp_fault; - case MSR_IA32_MISC_ENABLE: /* Silently drop writes that don't change the reported value. */ if ( vmx_msr_read_intercept(msr, &tmp) != X86EMUL_OKAY || @@ -3320,10 +3313,9 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) is_last_branch_msr(msr) ) break; - /* Match up with the RDMSR side; ultimately this should go away. */ - if ( rdmsr_safe(msr, msr_content) == 0 ) - break; - + gdprintk(XENLOG_WARNING, + "WRMSR 0x%08x val 0x%016"PRIx64" unimplemented\n", + msr, msr_content); goto gp_fault; } From patchwork Thu Aug 20 15:08:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11726497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8158F739 for ; Thu, 20 Aug 2020 15:10:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5CACE208E4 for ; Thu, 20 Aug 2020 15:10:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="FLLQf6MN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CACE208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCR-0003zE-B7; Thu, 20 Aug 2020 15:09:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8mCQ-0003lg-2a for xen-devel@lists.xenproject.org; Thu, 20 Aug 2020 15:09:54 +0000 X-Inumbo-ID: 9b9d86af-17a7-4d72-a21f-c75d8547d178 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9b9d86af-17a7-4d72-a21f-c75d8547d178; Thu, 20 Aug 2020 15:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597936180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u63m2tXhuuAu/gd/zkG4g8sb+Z+3RgZGzbLxlSgXxBo=; b=FLLQf6MNAmDy3kbMwrc49GPRFtRK+OR72K5NZ5F/l1fXmfNDEpeRGPny 0euUCjH34cNgfmpDBoKqLo0L3T7JkrLVoOPm0KInOF01uRGJTF6x1c1AA bTdZEM9QZwxSPoGd0n6G6OeKdT9MihoF+KKJ4nj6TVuIY9caxPc1UFaOq E=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: UE5O4/bvrPO/wv6B7XMDrVbV0sbAZ/kXCKUsOfw6/1lDaYcLKz2Sdy4k5yZr/ZSMdlcWtOl4iV qKor7pxl+zI/EYgrSrH7XTRTJ9w8bgZJvitq8wWnyxZQ0w0GKupz0kBuGAhELMASFCmp9G9KhT EOTfkpPKrzb5aGcxj1A2fQhMYmcAZBpwKSNY4Pt30sNbjG2qqj902Uo4RLUN6vlRqwGKInbdZ1 dZIThQ07DymCgvxh1PB6J5xHBE2zoqZjPAl1T5bJur2LwF3T79vbIJM3Hjqc3qw0ktsh2mOgEM yBI= X-SBRS: 2.7 X-MesageID: 25108129 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,333,1592884800"; d="scan'208";a="25108129" From: Roger Pau Monne To: CC: Andrew Cooper , Jan Beulich , Wei Liu , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Subject: [PATCH v2 8/8] x86/msr: Drop compatibility #GP handling in guest_{rd, wr}msr() Date: Thu, 20 Aug 2020 17:08:35 +0200 Message-ID: <20200820150835.27440-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820150835.27440-1-roger.pau@citrix.com> References: <20200820150835.27440-1-roger.pau@citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Andrew Cooper Now that the main PV/HVM MSR handlers raise #GP for all unknown MSRs, there is no need to special case these MSRs any more. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné --- Changes since v1: - New in this version. --- xen/arch/x86/msr.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index bb0dd5ff0a..560719c2aa 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -159,29 +159,6 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) switch ( msr ) { - case MSR_AMD_PATCHLOADER: - case MSR_IA32_UCODE_WRITE: - case MSR_PRED_CMD: - case MSR_FLUSH_CMD: - /* Write-only */ - case MSR_TEST_CTRL: - case MSR_CORE_CAPABILITIES: - case MSR_TSX_FORCE_ABORT: - case MSR_TSX_CTRL: - case MSR_MCU_OPT_CTRL: - case MSR_RTIT_OUTPUT_BASE ... MSR_RTIT_ADDR_B(7): - case MSR_U_CET: - case MSR_S_CET: - case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE: - case MSR_AMD64_LWP_CFG: - case MSR_AMD64_LWP_CBADDR: - case MSR_PPIN_CTL: - case MSR_PPIN: - case MSR_AMD_PPIN_CTL: - case MSR_AMD_PPIN: - /* Not offered to guests. */ - goto gp_fault; - case MSR_IA32_FEATURE_CONTROL: if ( !(cp->x86_vendor & X86_VENDOR_INTEL) ) goto gp_fault; @@ -349,29 +326,6 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) { uint64_t rsvd; - case MSR_IA32_PLATFORM_ID: - case MSR_CORE_CAPABILITIES: - case MSR_INTEL_CORE_THREAD_COUNT: - case MSR_INTEL_PLATFORM_INFO: - case MSR_ARCH_CAPABILITIES: - /* Read-only */ - case MSR_TEST_CTRL: - case MSR_TSX_FORCE_ABORT: - case MSR_TSX_CTRL: - case MSR_MCU_OPT_CTRL: - case MSR_RTIT_OUTPUT_BASE ... MSR_RTIT_ADDR_B(7): - case MSR_U_CET: - case MSR_S_CET: - case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE: - case MSR_AMD64_LWP_CFG: - case MSR_AMD64_LWP_CBADDR: - case MSR_PPIN_CTL: - case MSR_PPIN: - case MSR_AMD_PPIN_CTL: - case MSR_AMD_PPIN: - /* Not offered to guests. */ - goto gp_fault; - case MSR_AMD_PATCHLEVEL: BUILD_BUG_ON(MSR_IA32_UCODE_REV != MSR_AMD_PATCHLEVEL); /*