From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 C2EEBC54FC9 for ; Tue, 21 Apr 2020 12:59:25 +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 A22992076B for ; Tue, 21 Apr 2020 12:59:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A22992076B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.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.89) (envelope-from ) id 1jQsUc-0003ri-Q7; Tue, 21 Apr 2020 12:59:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQsUb-0003rd-Q5 for xen-devel@lists.xenproject.org; Tue, 21 Apr 2020 12:59:13 +0000 X-Inumbo-ID: e5e73a18-83cf-11ea-b4f4-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e5e73a18-83cf-11ea-b4f4-bc764e2007e4; Tue, 21 Apr 2020 12:59:13 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6DA30ABE7; Tue, 21 Apr 2020 12:59:11 +0000 (UTC) Subject: Re: [PATCH v10 1/3] x86/tlb: introduce a flush HVM ASIDs flag To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <20200416135909.16155-1-roger.pau@citrix.com> <20200416135909.16155-2-roger.pau@citrix.com> <80288e76-aff6-61d5-71aa-ae7c8e9d9a65@suse.com> <20200421104335.GU28601@Air-de-Roger> From: Jan Beulich Message-ID: <21abc8e6-5665-9d6f-395f-6e4eb8bf2e58@suse.com> Date: Tue, 21 Apr 2020 14:59:10 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200421104335.GU28601@Air-de-Roger> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Tim Deegan , George Dunlap , Wei Liu , Andrew Cooper Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 21.04.2020 12:43, Roger Pau Monné wrote: > On Tue, Apr 21, 2020 at 12:21:12PM +0200, Jan Beulich wrote: >> On 16.04.2020 15:59, Roger Pau Monne wrote: >>> Introduce a specific flag to request a HVM guest linear TLB flush, >>> which is an ASID/VPID tickle that forces a guest linear to guest >>> physical TLB flush for all HVM guests. >>> >>> This was previously unconditionally done in each pre_flush call, but >>> that's not required: HVM guests not using shadow don't require linear >>> TLB flushes as Xen doesn't modify the guest page tables in that case >>> (ie: when using HAP). >> >> I'm afraid I'm being confused by this: Even in shadow mode Xen >> doesn't modify guest page tables, does it? > > I'm also confused now. It's my understand that when running in shadow > mode guest page tables are not actually used, and the guest uses Xen's > crafted shadow tables instead, which are based on the original guest > page tables suitably adjusted by Xen in order to do the p2m > translation in the HVM case, or the needed PTE adjustments in the PV > case. > > So guest page tables are not modified, but are also not used as they > are never loaded into cr3. This matches my understanding. >>> @@ -254,3 +257,14 @@ unsigned int flush_area_local(const void *va, unsigned int flags) >>> >>> return flags; >>> } >>> + >>> +void guest_flush_tlb_mask(const struct domain *d, const cpumask_t *mask) >>> +{ >>> + unsigned int flags = (is_pv_domain(d) || paging_mode_shadow(d) ? FLUSH_TLB >>> + : 0) | >>> + (is_hvm_domain(d) && cpu_has_svm ? FLUSH_HVM_ASID_CORE >>> + : 0); >> >> Why the is_pv_domain() part of the condition? Afaict for PV >> domains you can get here only if they have shadow mode enabled. > > Right now yes, the only way to get here for PV domains is when using > shadow, but if this helper gets used in other non-shadow PV paths then > Xen's needs to do a TLB flush. Why would a non-shdow PV path find a need to call this function? Jan