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=-5.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 7C3CBC433DF for ; Tue, 30 Jun 2020 12:48:42 +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 4D2642082F for ; Tue, 30 Jun 2020 12:48:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="33apq4Hh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D2642082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1jqFgU-0001IS-AL; Tue, 30 Jun 2020 12:48:22 +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.92) (envelope-from ) id 1jqFgT-0001IN-3S for xen-devel@lists.xenproject.org; Tue, 30 Jun 2020 12:48:21 +0000 X-Inumbo-ID: fa225742-bacf-11ea-8615-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fa225742-bacf-11ea-8615-12813bfff9fa; Tue, 30 Jun 2020 12:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=z7jc5NzfTkp8y5Cz8EXxkRyo5Q5w5XhhJH6y+Igibds=; b=33apq4HhaQC2e4pLznWqAg3tP/ 1P0V6U+FC/fTBGn7I/RBkoxe5tcYa2oFwsAmz6X7+4tRapC/7L+kJFqXDgZt+cUclYd+jUap4aWrN paDcuhqPDpZG9criQcUBEqQzqny4AziomBprLg91Tl6xFijmh9i1/jJz6ieMoeU2NfPY=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jqFgN-00007W-V4; Tue, 30 Jun 2020 12:48:15 +0000 Received: from [54.239.6.187] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jqFgN-0005z1-Mk; Tue, 30 Jun 2020 12:48:15 +0000 Subject: Re: [PATCH for-4.14 v4] x86/tlb: fix assisted flush usage To: Roger Pau Monne , xen-devel@lists.xenproject.org References: <20200626155723.91558-1-roger.pau@citrix.com> From: Julien Grall Message-ID: Date: Tue, 30 Jun 2020 13:48:13 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200626155723.91558-1-roger.pau@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit 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: Stefano Stabellini , Wei Liu , paul@xen.org, Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Hi Roger, On 26/06/2020 16:57, Roger Pau Monne wrote: > Commit e9aca9470ed86 introduced a regression when avoiding sending > IPIs for certain flush operations. Xen page fault handler > (spurious_page_fault) relies on blocking interrupts in order to > prevent handling TLB flush IPIs and thus preventing other CPUs from > removing page tables pages. Switching to assisted flushing avoided such > IPIs, and thus can result in pages belonging to the page tables being > removed (and possibly re-used) while __page_fault_type is being > executed. > > Force some of the TLB flushes to use IPIs, thus avoiding the assisted > TLB flush. Those selected flushes are the page type change (when > switching from a page table type to a different one, ie: a page that > has been removed as a page table) and page allocation. This sadly has > a negative performance impact on the pvshim, as less assisted flushes > can be used. Note the flush in grant-table code is also switched to > use an IPI even when not strictly needed. This is done so that a > common arch_flush_tlb_mask can be introduced and always used in common > code. > > Introduce a new flag (FLUSH_FORCE_IPI) and helper to force a TLB flush > using an IPI (flush_tlb_mask_sync, x86 only). Note that the flag is > only meaningfully defined when the hypervisor supports PV or shadow > paging mode, as otherwise hardware assisted paging domains are in > charge of their page tables and won't share page tables with Xen, thus > not influencing the result of page walks performed by the spurious > fault handler. > > Just passing this new flag when calling flush_area_mask prevents the > usage of the assisted flush without any other side effects. > > Note the flag is not defined on Arm. > > Fixes: e9aca9470ed86 ('x86/tlb: use Xen L0 assisted TLB flush when available') > Reported-by: Andrew Cooper > Signed-off-by: Roger Pau Monné Acked-by: Julien Grall Cheers, -- Julien Grall