Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7556537ybl; Thu, 16 Jan 2020 01:29:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxQuZc1KF15e8ty2MIldnfFL++olywd4rxD1rG98UlovL+r/dN5ZXBz269w+tA9lfLIYxwG X-Received: by 2002:a05:6830:1487:: with SMTP id s7mr1155442otq.269.1579166995564; Thu, 16 Jan 2020 01:29:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579166995; cv=none; d=google.com; s=arc-20160816; b=tshblDQkAgr5vyB4YPogs1AZGXa9qy328Wac5KLn74cULxt/Y9CX5yOKDQwArpnLst hrBnkBqnPciFhInv76nNNlrcvQk7ajW+vRILbpWlq+SdhxppEjU3W+cKpXB8xdkQJA4E e+uBEfBBIeHM3HyPidWkJbV+WP1cJnx8xFDpTfe9jVrowNqr8QgtwyfKDOhNFeZ9AHb6 xVSZaU8ohDDMOlCSj64P7IXfL8cEBBnDc4ubcR9UwFf15MYt+fFg9FDzHs6cLIQbFmpV EcXV/sN3YVVFK98IQRdJm7Unz5UkB1jD0F3225KqwN70qF2LFqVVuo9Sbgqr8I710EJd Yq9A== 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; bh=sK+xxYhIGWS8mM1bV0s2HiVqedY3pD3W9xWs5yqSwu8=; b=IjhcAEeXAjL/R4Fyln5AIYXuMouDA3m9EEUIomhuVmfP2kjFzD6YqTVdo6U76ZcE3Z ro+XQzG+NPk8dQnKJfbnwYMpqvgNJH8SUueN2a0nnQnrvrLO8KzJjiqBY9OsIikcjPfp VqTH7505VRE0tVVsTOZaY3FgPtfNKGHAMFyAyT0Riij/FYL5zNW+iIIXIr2AKKCfP+Mb sua2bgsOu/7OibVjHEy8pgjtAXApAkQ2R756gpu19rhXqR78jsqhYW7Ne+s9mJz/GYhA e4A16inUhpUL3/8HxN5HvNGnLOAnTgulcAnovSvaPI6GV+2M3xQZid7fMvL+D1KzKdfT 9niQ== 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 o7si13004821otk.185.2020.01.16.01.29.43; Thu, 16 Jan 2020 01:29:55 -0800 (PST) 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 S1730333AbgAPHzC (ORCPT + 99 others); Thu, 16 Jan 2020 02:55:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:43758 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbgAPHzC (ORCPT ); Thu, 16 Jan 2020 02:55:02 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4D021AC2C; Thu, 16 Jan 2020 07:55:00 +0000 (UTC) Subject: Re: [PATCH v1 1/4] kasan: introduce set_pmd_early_shadow() To: Sergey Dyasli Cc: xen-devel@lists.xen.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Boris Ostrovsky , Stefano Stabellini , George Dunlap , Ross Lagerwall , Andrew Morton References: <20200108152100.7630-1-sergey.dyasli@citrix.com> <20200108152100.7630-2-sergey.dyasli@citrix.com> <96c2414e-91fb-5a28-44bc-e30d2daabec5@citrix.com> <6f643816-a7dc-f3bb-d521-b6ac104918d6@suse.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: Date: Thu, 16 Jan 2020 08:54:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.01.20 17:32, Sergey Dyasli wrote: > On 15/01/2020 11:09, Jürgen Groß wrote: >> On 15.01.20 11:54, Sergey Dyasli wrote: >>> Hi Juergen, >>> >>> On 08/01/2020 15:20, Sergey Dyasli wrote: >>>> It is incorrect to call pmd_populate_kernel() multiple times for the >>>> same page table. Xen notices it during kasan_populate_early_shadow(): >>>> >>>> (XEN) mm.c:3222:d155v0 mfn 3704b already pinned >>>> >>>> This happens for kasan_early_shadow_pte when USE_SPLIT_PTE_PTLOCKS is >>>> enabled. Fix this by introducing set_pmd_early_shadow() which calls >>>> pmd_populate_kernel() only once and uses set_pmd() afterwards. >>>> >>>> Signed-off-by: Sergey Dyasli >>> >>> Looks like the plan to use set_pmd() directly has failed: it's an >>> arch-specific function and can't be used in arch-independent code >>> (as kbuild test robot has proven). >>> >>> Do you see any way out of this other than disabling SPLIT_PTE_PTLOCKS >>> for PV KASAN? >> >> Change set_pmd_early_shadow() like the following: >> >> #ifdef CONFIG_XEN_PV >> static inline void set_pmd_early_shadow(pmd_t *pmd, pte_t *early_shadow) >> { >> static bool pmd_populated = false; >> >> if (likely(pmd_populated)) { >> set_pmd(pmd, __pmd(__pa(early_shadow) | _PAGE_TABLE)); >> } else { >> pmd_populate_kernel(&init_mm, pmd, early_shadow); >> pmd_populated = true; >> } >> } >> #else >> static inline void set_pmd_early_shadow(pmd_t *pmd, pte_t *early_shadow) >> { >> pmd_populate_kernel(&init_mm, pmd, early_shadow); >> } >> #endif >> >> ... and move it to include/xen/xen-ops.h and call it with >> lm_alias(kasan_early_shadow_pte) as the second parameter. > > Your suggestion to use ifdef is really good, especially now when I > figured out that CONFIG_XEN_PV implies X86. But I don't like the idea > of kasan code calling a non-empty function from xen-ops.h when > CONFIG_XEN_PV is not defined. I'd prefer to keep set_pmd_early_shadow() > in mm/kasan/init.c with the suggested ifdef. Fine with me. Juergen