Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp451646imm; Fri, 11 May 2018 00:33:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrFuHjxTHoPvdGXR8G7CRnbVaW798KWRoEzwmzn3OQtw5+rvHF3osXc7jQmfMmGYnxbxqcf X-Received: by 2002:a62:2417:: with SMTP id r23-v6mr4407300pfj.108.1526024035979; Fri, 11 May 2018 00:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526024035; cv=none; d=google.com; s=arc-20160816; b=YbO0GQR0uEoErhRdug+gpeUCXBF+lg5UjqHyPQhDlHVqI3UgNtosKYmHqH8ojf6JFJ Y0i4kVAunK846GynStDZD7Le68zHp5ZuHI6+Hb5xEDM44R/Chk4KpiqWO7B1PE/jEulQ 55xxYsoagY2xrr/GfJGLkM/1TVeTCgLWPbpMnzU3gRNDmBOZXzk4leL/9Eh4SXUM0LVr pRK37XjJbras6SoC+0JbGO7d+SNgoQXtvKoRjt3O2JMqRS5ArzWmA6Iwc+v1IzCrug3S HbHE+oGjpx/tLsBi7Swo4BdMJPB2Y6gvVNHj6UPDDUoSNVniCkWrDGgd8BF8bniEuh9e J8Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=yd9yfrXJHMTTSqFaM090ZawrVkYzTNdqfPcY3s7ARkY=; b=nzwWe34BgeGf1brGg1tI7K0ldtRG5g+2ck/r9YLecFlO3SkM/oYGvq4Oi9jCSwE7dM kKkUht81fWLBkWo2MD/8KybxhfaYjC3P8ch3uTiGPwxKJTRQI46/JCT5rlL4ytrWq/nl esD5BUjboKCxot/pSRf1vYu6TJtiXBrNzSuqFahza1uHZVyc90+sOAJ/Rux8vitL59mo MWPmkCviQ6BANFiHzv3JlKTokGR9oz4AaaBFK3L8B0eAs5YfsMB6hA4xDW7K2Q1MmAwf pcwaPbrXWAXHWC4fh9SpAdtpJ+W6Yb6Fg6+I1CQi22J/jKiApnHURGXGIEOHuHIKQWnN PhtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21-v6si2586358plp.199.2018.05.11.00.33.41; Fri, 11 May 2018 00:33:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752572AbeEKHda (ORCPT + 99 others); Fri, 11 May 2018 03:33:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:54314 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752174AbeEKHd3 (ORCPT ); Fri, 11 May 2018 03:33:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4A96EAC71; Fri, 11 May 2018 07:33:28 +0000 (UTC) Subject: Re: [Xen-devel] [PATCH v2 1/3] xen/pvh: enable and set default MTRR type To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Andrew Cooper Cc: xen-devel@lists.xenproject.org, Boris Ostrovsky , linux-kernel@vger.kernel.org References: <20180509102129.14832-1-roger.pau@citrix.com> <20180509102129.14832-2-roger.pau@citrix.com> <20180509113016.tavac64ba5fu3tob@MacBook-Pro-de-Roger.local> <20180509151139.nytwuepervqjkcat@MacBook-Pro-de-Roger.local> From: Juergen Gross Message-ID: Date: Fri, 11 May 2018 09:33:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180509151139.nytwuepervqjkcat@MacBook-Pro-de-Roger.local> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/18 17:11, Roger Pau Monné wrote: > On Wed, May 09, 2018 at 12:30:16PM +0100, Roger Pau Monné wrote: >> On Wed, May 09, 2018 at 11:56:40AM +0100, Andrew Cooper wrote: >>> On 09/05/18 11:21, Roger Pau Monne wrote: >>> I'm not sure that setting the default MTRR type is going to be a >>> clever idea in hindsight when we come to doing PCI Passthrough support. >> >> Setting the default type to WB is also set by hvmloader, it's just >> that hvmloader also sets some of the fixed and variable ranges to UC >> in order to cover the iomem areas. >> >> The expectations when doing pci-passthrough is that the guest will >> always use paging and PAT in order to set the appropriate cache >> attributes, or else the guest itself will have to program the UC MTRR >> ranges, I admit that's not very nice however. >> >> What about enabling the default MTRR type and setting it to WB in the >> toolstack for PVH? IMO doing it Xen itself would be wrong. > > I have the following patch to set the default MTRR type, but I think > if we go down this road then we will also have to set UC MTRRs for > MMIO areas, which again seems fine to me. I like this route much better. Juergen > > ---8<--- > diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c > index e33a28847d..3cb1a1720f 100644 > --- a/tools/libxc/xc_dom_x86.c > +++ b/tools/libxc/xc_dom_x86.c > @@ -938,6 +938,8 @@ static int vcpu_hvm(struct xc_dom_image *dom) > HVM_SAVE_TYPE(HEADER) header; > struct hvm_save_descriptor cpu_d; > HVM_SAVE_TYPE(CPU) cpu; > + struct hvm_save_descriptor mtrr_d; > + HVM_SAVE_TYPE(MTRR) mtrr; > struct hvm_save_descriptor end_d; > HVM_SAVE_TYPE(END) end; > } bsp_ctx; > @@ -1014,6 +1016,15 @@ static int vcpu_hvm(struct xc_dom_image *dom) > if ( dom->start_info_seg.pfn ) > bsp_ctx.cpu.rbx = dom->start_info_seg.pfn << PAGE_SHIFT; > > + /* Set the MTRR. */ > + bsp_ctx.mtrr_d.typecode = HVM_SAVE_CODE(MTRR); > + bsp_ctx.mtrr_d.instance = 0; > + bsp_ctx.mtrr_d.length = HVM_SAVE_LENGTH(MTRR); > + /* XXX: maybe this should be a firmware option instead? */ > + if ( !dom->device_model ) > + /* Enable MTRR (bit 11) and set the default type to WB (6). */ > + bsp_ctx.mtrr.msr_mtrr_def_type = (1u << 11) | 6; > + > /* Set the end descriptor. */ > bsp_ctx.end_d.typecode = HVM_SAVE_CODE(END); > bsp_ctx.end_d.instance = 0; > >