Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8AFFC433E1 for ; Fri, 31 Jul 2020 11:21:38 +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 8B825208E4 for ; Fri, 31 Jul 2020 11:21:38 +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="XDsBhj0D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B825208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 1k1T6J-0004HE-Iu; Fri, 31 Jul 2020 11:21:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1T6I-0004H9-Ot for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 11:21:22 +0000 X-Inumbo-ID: f5d6ab58-d31f-11ea-8e24-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f5d6ab58-d31f-11ea-8e24-bc764e2007e4; Fri, 31 Jul 2020 11:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1596194481; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=+P1KIq/6Ywxtu4pyKU6IAI26bhhPg71MBoPm2a6aTl4=; b=XDsBhj0D5p64Qfq8zOAY+o0ThNqjLavS8XD0YpO5JfJ30/Ed8rxfZdFY OnZsNunxIhCHL+KQiP2/T7gZVKb0tL0lbrjgK2zE9sJggEVG7Kt4YqkhV J97RLrItIVg5cTSfS3A9n9Nw0SKhMKSH2816ZSa3N6X1O/Jj/d6mBUCw0 g=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: uphDXr02WgtTe1GvOXKeVMjNOgwYLd2gH0NC1Vc5TBbEzCsHctGsV4rui27Z52AJGMyC+pNrsq MDorvIzNOkt6vWz/pU11LWx+qXRG2M/2ypVSHxCckwRAXWgU96MGgZwZw3i5p4EN8Xcvdl5Odg 1cD+89pcZcjv18Gr9n1Srx279TCT6mM8mddPFbghyrsRrLtKGrj6dE6euuhSyWCszb7h+Rjtxm ttha+qKUtaJc8UeffoVnTxbqruQ1INNAKCK+QBs3OpgYOBHCKPEJ5zN65CgWgoCAOO0lxl5xym a4g= X-SBRS: 3.7 X-MesageID: 23633986 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,418,1589256000"; d="scan'208";a="23633986" Subject: Re: [PATCH] x86/hvm: set 'ipat' in EPT for special pages To: Paul Durrant , References: <20200731104644.20906-1-paul@xen.org> From: Andrew Cooper Message-ID: Date: Fri, 31 Jul 2020 12:21:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200731104644.20906-1-paul@xen.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) 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: , Cc: Paul Durrant , Wei Liu , Jan Beulich , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 31/07/2020 11:46, Paul Durrant wrote: > From: Paul Durrant > > All non-MMIO ranges (i.e those not mapping real device MMIO regions) that > map valid MFNs are normally marked MTRR_TYPE_WRBACK and 'ipat' is set. Hence > when PV drivers running in a guest populate the BAR space of the Xen Platform > PCI Device with pages such as the Shared Info page or Grant Table pages, > accesses to these pages will be cachable. > > However, should IOMMU mappings be enabled be enabled for the guest then these > accesses become uncachable. This has a substantial negative effect on I/O > throughput of PV devices. Arguably PV drivers should bot be using BAR space to > host the Shared Info and Grant Table pages but it is currently commonplace for > them to do this and so this problem needs mitigation. Hence this patch makes > sure the 'ipat' bit is set for any special page regardless of where in GFN > space it is mapped. > > NOTE: Clearly this mitigation only applies to Intel EPT. It is not obvious > that there is any similar mitigation possible for AMD NPT. Downstreams > such as Citrix XenServer have been carrying a patch similar to this for > several releases though. https://github.com/xenserver/xen.pg/blob/XS-8.2.x/master/xen-override-caching-cp-26562.patch (Yay for internal ticket references escaping into the wild.) However, it is very important to be aware that this is just papering over the problem, and it will cease to function as soon as we get MKTME support.  When we hit that point, iPAT cannot be used, as it will cause data corruption in guests. The only correct way to fix this is to not (mis)use BAR space for RAM mappings. ~Andrew