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 69185C54FD0 for ; Tue, 21 Apr 2020 10:21:35 +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 3ADB52075E for ; Tue, 21 Apr 2020 10:21:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3ADB52075E 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 1jQq1l-0006mH-9w; Tue, 21 Apr 2020 10:21:17 +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.89) (envelope-from ) id 1jQq1j-0006mC-UR for xen-devel@lists.xenproject.org; Tue, 21 Apr 2020 10:21:15 +0000 X-Inumbo-ID: d463a788-83b9-11ea-9123-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d463a788-83b9-11ea-9123-12813bfff9fa; Tue, 21 Apr 2020 10:21:14 +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 36466ABAD; Tue, 21 Apr 2020 10:21:12 +0000 (UTC) Subject: Re: [PATCH v10 1/3] x86/tlb: introduce a flush HVM ASIDs flag To: Roger Pau Monne References: <20200416135909.16155-1-roger.pau@citrix.com> <20200416135909.16155-2-roger.pau@citrix.com> From: Jan Beulich Message-ID: <80288e76-aff6-61d5-71aa-ae7c8e9d9a65@suse.com> Date: Tue, 21 Apr 2020 12:21:12 +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: <20200416135909.16155-2-roger.pau@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 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? > @@ -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. > --- a/xen/arch/x86/mm/shadow/private.h > +++ b/xen/arch/x86/mm/shadow/private.h > @@ -818,6 +818,12 @@ static inline int sh_check_page_has_no_refs(struct page_info *page) > bool shadow_flush_tlb(bool (*flush_vcpu)(void *ctxt, struct vcpu *v), > void *ctxt); > > +static inline void sh_flush_local(const struct domain *d) > +{ > + flush_local(FLUSH_TLB | > + (is_hvm_domain(d) && cpu_has_svm ? FLUSH_HVM_ASID_CORE : 0)); > +} I think the right side of | wants folding with its counterpart in guest_flush_tlb_mask(). Doing so would avoid guest_flush_tlb_mask() getting updated but this one forgotten. Perhaps split out guest_flush_tlb_flags() from guest_flush_tlb_mask()? I also think this function should move into multi.c as long as it's needed only there. Jan