Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6347704ybl; Wed, 15 Jan 2020 03:11:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwcDLu+Z5NZ2F1Skcqu2RD2g7FXNFxQMaZeCxy4ITIOt8ooC+jp4lUMneJefO8ilIm/yrB0 X-Received: by 2002:a9d:518b:: with SMTP id y11mr2196881otg.349.1579086677481; Wed, 15 Jan 2020 03:11:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579086677; cv=none; d=google.com; s=arc-20160816; b=P9LPM5dFOJwxslt64P/QhIp0fy7gtw8FBjUcvJ4lLa3pkTTaW19VB3h5RhDNku8BjR 35aoA1jTUzz0AHII4FmOqt479ITLCtCDpvFNLsoXq6oozOQowW5kC3SVirAiNEYHHvm7 6S86BE3eH6B6Is3nZEDGzkSZ6DHzd1Fr2NavYxwvhLCx37p8k3nXm4ZpRgAjzNINetex 7AXlov42E8x6hjjitKkYPbQJJDjVhxuXqvJeKjbBAz57Wm4Lqp/bTSamI6Vf0WouUiLa +LtH/fc36IV2XR+kNk0epo3MjUitNFvjysQZbAlIJV1sOYiA//Gw8iRFPIdi26g3qJ7E TJyQ== 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=8Nar2xDuEvZwmTGfCQ+vV9tKxi5k2aRSad6YbGSEUVI=; b=HVlmbhVW0mMMav9xdXp7v5e2utvqWBnROw/VQMCOrotLpFxI8zQ4B3z248e3mL9USx wiE14DAwTzDiuspRjDl4xrdORp9OuGSZagNRxOzv4a8NPR3nw2XayDg7XmPC0iYxUpRg 6xXp1ZEGihPLMllTCCqH1dU+LIdWsm5M6BLopBaDUm3vCTfmvF8Z3RhBqMaaAvB8AtyC iexWt5XF7K2d3HFkswTD6/C8m3VxNgIukodTrQYD6yXA2CfWwqpEZFY7YwSZG6cV35FO cb6tLqnPN0eKkaoLiFggFu+QvWCtqVovDNT7uaAh8eQ9jMolkQRboZhUXmIaqB3wjsqE HOMw== 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 d22si10945086oti.316.2020.01.15.03.11.02; Wed, 15 Jan 2020 03:11:17 -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 S1729758AbgAOLJy (ORCPT + 99 others); Wed, 15 Jan 2020 06:09:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:55544 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbgAOLJy (ORCPT ); Wed, 15 Jan 2020 06:09:54 -0500 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 BAB13AC81; Wed, 15 Jan 2020 11:09:51 +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> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <6f643816-a7dc-f3bb-d521-b6ac104918d6@suse.com> Date: Wed, 15 Jan 2020 12:09:50 +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: <96c2414e-91fb-5a28-44bc-e30d2daabec5@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Juergen