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;