Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp459315ima; Fri, 26 Oct 2018 00:48:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5cEhi+jVR0AL1VufYG2fz2Yn35oHE/scr3UsGUVpu4Q0PL0ZumVKsS3pmVjj/DC//daUMsd X-Received: by 2002:a62:3641:: with SMTP id d62-v6mr2592539pfa.97.1540540139615; Fri, 26 Oct 2018 00:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540540139; cv=none; d=google.com; s=arc-20160816; b=nM8nKqg4s41C7SU6sbE8JU30q+fUAYYyg/lYHJy4EEsHl+h0gBClBscwdmpz3PGFla 21BHen+o7D9/oQSspbNSNgIEqT9XagguboROaPcbJP9qmMu5FRRz1fsd1L1ot7xyrojw oju7CPq/JuzuZ4LSXdeljob5jFJG34BW3zlUQmXfeXjLGE5+fro/1wbwTzUszWbVesRv 5gGp4PdF7MUjrCq7JTOvWsuIvr+FiPVsYi8ShCjnEGNpL3HydoTK+NWYZ36acK9tPtz9 fBIo/+2+Ny3pZvI/B4ZyVkyzlnInOjDPm/cL0aMtYCFWIsyzlGe8BTrsDHLNDa+xt4Yl +4Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=qtnSdPKQ76vcK1ZpyTMGmbRXwoP++9uGEkRv486bOEo=; b=mhupJmAq5quSUFogscTQeXE6G/jXjjgNqHI/zK1Yg6KAqWXwoSA1PU9sQKkqh+LEPf RI6cBqogGJbtJ5ObcA5nhqunIaYJO4ZeaqgdxW+OV3L/1jYgNOjMsqaYAGpinTK/m3k+ MX+KQgSnYqp3l7I5uYMBed1L/MRQ4MbgBehRjg9pOWYmYVbgsaA9mu9azG5/TgVbPwRw re/IYqwL3WGlO0mWgzX7wG7S7aCb8IfXKPWso6QtzcVjwFBPJVz0Okkq074WJguIgH6I 4l0F5knzDBQE6YBK0hT7XcZRMyKhpJ1Tj0L0hm3cznqXp2zh4iBOTFY9xz0JRBR88YbC W39g== 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 m12-v6si10056805pll.105.2018.10.26.00.48.43; Fri, 26 Oct 2018 00:48:59 -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 S1726243AbeJZQYB (ORCPT + 99 others); Fri, 26 Oct 2018 12:24:01 -0400 Received: from verein.lst.de ([213.95.11.211]:34775 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbeJZQYB (ORCPT ); Fri, 26 Oct 2018 12:24:01 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 91A4B68C38; Fri, 26 Oct 2018 09:48:02 +0200 (CEST) Date: Fri, 26 Oct 2018 09:48:02 +0200 From: Christoph Helwig To: Joe Jin Cc: Boris Ostrovsky , Konrad Rzeszutek Wilk , "DONGLI.ZHANG" , konrad@kernel.org, Christoph Helwig , John Sobecki , "xen-devel@lists.xenproject.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] xen-swiotlb: exchange memory with Xen only when pages are contiguous Message-ID: <20181026074802.GA4768@lst.de> References: <20181024130246.GA22616@localhost.localdomain> <83900cf4-690c-9725-d022-d427fdeb4f7d@oracle.com> <581cb7ea-3112-791d-918d-9bb887e4744f@oracle.com> <24a62522-1629-5d0b-398e-6d2c1a0b97f7@oracle.com> <922914c9-22db-c5d1-33da-d07691ebd7d7@oracle.com> <45f5ffe8-3f48-4485-53f0-5a056be69b0c@oracle.com> <5b64850f-9142-0360-fe4e-9e7bc74d2368@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b64850f-9142-0360-fe4e-9e7bc74d2368@oracle.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 25, 2018 at 11:56:02AM -0700, Joe Jin wrote: > I just discussed this patch with Boris in private, his opinions(Boris, > please correct me if any misunderstood) are: > > 1. With/without the check, both are incorrect, he thought we need to > prevented unalloc'd free at here. > 2. On freeing, if upper layer already checked the memory was DMA-able, > the checking at here does not make sense, we can remove all checks. > 3. xen_create_contiguous_region() and xen_destroy_contiguous_region() > to come in pairs. > > For #1 and #3, I think we need something associate it, like a list, on > allocating, add addr to it, on freeing, check if in the list. Is there any way to figure out based on an address if the exchange operation happened? > For #2, I'm was not found anywhere validated the address on > dma_free_coherent() callpath, not just xen-swiotlb. At least for simple direct mappings there is no easy way to verify that without keeping a list, and for some of the ops that do vmap like operations we have basic santiy checks, but nothing that really catches a wrong free.