From patchwork Wed Sep 9 14:50:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11765569 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 B05C492C for ; Wed, 9 Sep 2020 14:52:08 +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 6FC782068D for ; Wed, 9 Sep 2020 14:52:08 +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="C0FCXauI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FC782068D 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 1kG1RK-0005Hr-RA; Wed, 09 Sep 2020 14:51:14 +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 1kG1RJ-0005Hm-GN for xen-devel@lists.xenproject.org; Wed, 09 Sep 2020 14:51:13 +0000 X-Inumbo-ID: 7710f681-5e2d-4cca-98e9-926dbf73d292 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7710f681-5e2d-4cca-98e9-926dbf73d292; Wed, 09 Sep 2020 14:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1599663073; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=T5drBJQw5icXhtwlyFbVjxtHTcuWeoT6NAXl1HUX1FM=; b=C0FCXauIXCiVO13WrR39lPZanq3F7X24+4RSLQG5+i4mj6dkGyLfR+Cl ruTXY1fcq9sI5G60f2RSkQQ8gxdh+Ri1qBo94Ag7/EHLqnYLVhBSiCZFi 6N21ihnF5M/eeG6TUINXEOrSKOuCbHZQTMD5YTVsHK06w1975Uvbccd2Y 4=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: LTqpRkA/fmXTWoX/s09qmWnDYjSN/hiJEoAb7In96piO8SuLIchw3PTl3tOWrbo420QF/M+OHb jt8rFy+nliq90cj9O8/ufLMeDibj4xA94fNB29vOq2gekwvn46KTDi02zjqLlpW+OzfDU9Wcb+ CXol+Tl/lhk4O19knWJd0B9kEIcPhX3nsQzs1UoQ9nf2AmY9KZ8oWWZA+feqHMShXtQ5XDDeLa qrIj3Lzq7IWrGx5qOpmHLMnm1IH07T/x69NX+lEaoNrvbAHGE5oKFuaqaxr2TewqlCU/qk0ogD QM8= X-SBRS: 2.7 X-MesageID: 26282907 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,409,1592884800"; d="scan'208";a="26282907" From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu , Paul Durrant Subject: [PATCH] x86/hvm: don't treat MMIO pages as special ones regarding cache attributes Date: Wed, 9 Sep 2020 16:50:58 +0200 Message-ID: <20200909145058.72066-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 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" MMIO regions below the maximum address on the memory map can have a backing page struct that's shared with dom_io (see x86 arch_init_memory and it's usage of share_xen_page_with_guest), and thus also fulfill the is_special_page check because the page has the Xen heap bit set. This is incorrect for MMIO regions when is_special_page is used by epte_get_entry_emt, as it will force direct MMIO regions mapped into the guest p2m to have the cache attributes set to write-back. Add an extra check in epte_get_entry_emt in order to detect pages shared with dom_io (ie: MMIO regions) and don't force them to write-back cache type on that case. Fixes: 81fd0d3ca4b2cd ('x86/hvm: simplify 'mmio_direct' check in epte_get_entry_emt()') Signed-off-by: Roger Pau Monné Reviewed-by: Paul Durrant --- Cc: Paul Durrant --- xen/arch/x86/hvm/mtrr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c index fb051d59c3..33b1dd9052 100644 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -829,7 +829,9 @@ int epte_get_entry_emt(struct domain *d, unsigned long gfn, mfn_t mfn, for ( i = 0; i < (1ul << order); i++ ) { - if ( is_special_page(mfn_to_page(mfn_add(mfn, i))) ) + const struct page_info *page = mfn_to_page(mfn_add(mfn, i)); + + if ( is_special_page(page) && page_get_owner(page) != dom_io ) { if ( order ) return -1;