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=-8.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 98560C433E0 for ; Fri, 31 Jul 2020 11:24:45 +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 6A9B9208E4 for ; Fri, 31 Jul 2020 11:24:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NJJWFgbV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A9B9208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 1k1T9N-0004aj-MC; Fri, 31 Jul 2020 11:24:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1T9M-0004ac-BH for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 11:24:32 +0000 X-Inumbo-ID: 6723048c-d320-11ea-8e24-bc764e2007e4 Received: from mail-wr1-x430.google.com (unknown [2a00:1450:4864:20::430]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6723048c-d320-11ea-8e24-bc764e2007e4; Fri, 31 Jul 2020 11:24:31 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id f1so27113626wro.2 for ; Fri, 31 Jul 2020 04:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:content-language :thread-index; bh=GTbWCKy6JNu5/qi4072qGPDLgB/3dhBRBvdUoHZqR+o=; b=NJJWFgbVvJwFX/R661qppiZ5bBCV5SqVIcsPYNWhf0ZhKxCJ6BOFz0qzpwE8bkYdny Qe92qZqoMqDrZxvtXmTDGxB1e7Xc+dCVOVZ42ns1nxp3G0LAiA2hDMyQIgv6ViNCBGnx Ns2uYOV15c3V+BDYnBOZ99S6hRMRdg3J1Ka9w6BiurNq1XKc67PDS2o48HjQ3YPkclKX kf8uFURZg681gWkF3uUHtkxHbnQmch1I+06x2htvj4Be5rsTELmzPh04gNaONi0PWQ52 Htwc3rvZOB5bggEHQERTx3tczkrxwoqiTx6vDqBT2EpmG1wHahlsuHjQGbzC1nIXHzC9 bhvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :content-language:thread-index; bh=GTbWCKy6JNu5/qi4072qGPDLgB/3dhBRBvdUoHZqR+o=; b=kDQlI+K6DymOuAJNspVtcRzvdj+XH7P0yDSQynCyACPz8MIxfIUPOCmUjzH5lolKbm YjVAaHvuOl4fzinzN6RmR7W+VPId8rhgwWtFF1JVh4BUQgZG3cQkefU3gXibpEbUOIkO 6hQSu7oxsr7XHWjXaccbsM7pT04QypiB7wkzPEVrmo0XM47y4KrgoJmBE4Whe6NZw9oi hezypl4hEaKhPoEORTS6qGWgf/YbIWZgRCp3oWflZvpOVKL5PDF0N+PIUP4Gz5h1yixX 9YWt6kWhsuT0p1KkhfRM/L0TaFAoGuEUzArKHZikl5E4vWBWmhiqN1zaMO+CdIgRYOCS 5iWg== X-Gm-Message-State: AOAM533BqYiVq14v/Ofbs6wX8o76pP8OwLh7BTUgLeXRWf0EYcvcfUN8 TYjYiYTyQfLLRd58U1WZ2No= X-Google-Smtp-Source: ABdhPJwQ4xrLakLXFsIFwQvrfm4gr44Yi6VlcPFlFRaPYwMhk1TP/wHA2+8NgHUnU+rYROHVPRaAEw== X-Received: by 2002:a5d:4d87:: with SMTP id b7mr3375732wru.170.1596194670802; Fri, 31 Jul 2020 04:24:30 -0700 (PDT) Received: from CBGR90WXYV0 ([2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec]) by smtp.gmail.com with ESMTPSA id x11sm12757822wrl.28.2020.07.31.04.24.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Jul 2020 04:24:30 -0700 (PDT) From: Paul Durrant X-Google-Original-From: "Paul Durrant" To: "'Andrew Cooper'" , References: <20200731104644.20906-1-paul@xen.org> In-Reply-To: Subject: RE: [PATCH] x86/hvm: set 'ipat' in EPT for special pages Date: Fri, 31 Jul 2020 12:19:17 +0100 Message-ID: <003b01d6672c$6e8ffb40$4baff1c0$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AQLI7tFygWYJCZY9nQSqDpuxgiPp+AIVoClxpyvNmOA= 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: , Reply-To: paul@xen.org 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" > -----Original Message----- > From: Andrew Cooper > Sent: 31 July 2020 12:21 > To: Paul Durrant ; xen-devel@lists.xenproject.org > Cc: Paul Durrant ; Jan Beulich = ; Wei Liu ; Roger > Pau Monn=C3=A9 > Subject: Re: [PATCH] x86/hvm: set 'ipat' in EPT for special pages >=20 > 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. >=20 > = https://github.com/xenserver/xen.pg/blob/XS-8.2.x/master/xen-override-cac= hing-cp-26562.patch >=20 > (Yay for internal ticket references escaping into the wild.) >=20 :-) >=20 > 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. >=20 > The only correct way to fix this is to not (mis)use BAR space for RAM > mappings. >=20 Oh yes, t his is only a mitigation. I believe Roger is working on a mechanism for = guests to query for non-populated RAM space, which would be suitable for = use by PV drivers. Paul > ~Andrew