Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6685409ybl; Wed, 15 Jan 2020 08:34:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyVd41u7FLyXBJG+wEy7OyC+zU5y4ti2b5iTpY6GjEKJ8P6szjUu9W+VW1eSQK8NbmeDJ4C X-Received: by 2002:a54:4e08:: with SMTP id a8mr498163oiy.77.1579106074949; Wed, 15 Jan 2020 08:34:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579106074; cv=none; d=google.com; s=arc-20160816; b=kt5Ei1FBEY9Psigtf5O9YAtLfm5AxL09Q617weWllcwQNbUVfqrE/MztrGjLaJoo96 WYztNw7IxIBsqqSj7089sCB722WXaTDjO7O0P/v5GgXoqL/Yaetztrn9/JagDrD+7qgH Qb+99ekcWC45E6FmsCa8j4UQxTHyt0uLHzxYsk8Z0gF/LWRdmlXPglG63uOJFnDvoBGM 5uWy73MK0ylwOpwCMpjIHMUgJ79JrBLhS2zJAd9VLLswoaHpbkmnUn5zXRiVZn5GVIlj dJpgtpCb8FjqpoE0tnuAmjU+3NhhE9gSNd1ZYRcpFo1U4POhWOwhptsk5hxiJ/KyGfH7 K76g== 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:autocrypt:from:references:cc:to:subject:ironport-sdr :dkim-signature; bh=+Usi5BtCfYy1gr5qC2coiTPoertN10ZV6b0TtBA+fQs=; b=ModTl3fcEeo9Gw5kOp02YD6pW4G5EgxQL/zc0jNUHlefJehAqINC6azcPM66kC1jpt +M/dN90w/xFUxN/A4Afd2oa6tJzTAIYBktBjGnea/EPy6UGrbv7fR7nqR0KgoO6leLBQ Va7p7wMjiz8HCUJxi1YYzOEBkb9mVmpxB5OQURnMdo34WnJBl8HvmachmIMUX2O857fX xroZ97GliYEd1kAXd439kjof0N2jElUS0HjDcPeqDkkGd5Y8ecx/NhX/nxu6qCD7gDr3 aWyExladgo3S9x8A/dK8XAhP1a2uRdwuLNA9dUFbkCrUB2YnMQWCcunnCersnE8wuS/i PqTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@citrix.com header.s=securemail header.b=Icoc4VTJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14si11340813oti.33.2020.01.15.08.34.21; Wed, 15 Jan 2020 08:34:34 -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; dkim=fail header.i=@citrix.com header.s=securemail header.b=Icoc4VTJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728946AbgAOQcN (ORCPT + 99 others); Wed, 15 Jan 2020 11:32:13 -0500 Received: from esa3.hc3370-68.iphmx.com ([216.71.145.155]:3868 "EHLO esa3.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728913AbgAOQcM (ORCPT ); Wed, 15 Jan 2020 11:32:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579105932; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=g3KiYQZWNEyU4MsRgwgpWouimLRqhaxPnA1sjIwEV6Y=; b=Icoc4VTJbbnvuktj/GsujHn33zmQo0zGozDskE21YmCHrcNKTdp+qw6v QQJOb976AAHOIJN5zSBP14jraLQYyO+n8BOPxLL140XWS5Aachis48hXZ 023HsQeEEMwyOwvurskcG7qORipCA7LpzUQJIQdSl0gU2SBhlnndK016h 0=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=sergey.dyasli@citrix.com; spf=Pass smtp.mailfrom=sergey.dyasli@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of sergey.dyasli@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of sergey.dyasli@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: bkdhVv7+jMwYgYDmPTe9LtkpH0O/koXWbzidtzU0jmq2k2W7y0z8sdgd8jQSbc5ha1bt3GZ1ci atAFUSXt6n+9zxzrQ84lgG49P9NYylmzqSNxWZ9aWXrXuRImAr5KZhdsdIf7QbnDqPqIx9tIJD CTJ/i6OKaxBEkX2arQZvhOK0lcZLiRfq3/YmZTezw8epzATAx2uWIm1r4K0BkOTLQHve+M61Y3 7h6z7waIS5kexpbL0CS5cKDTtVlsbAnvf762eq6rlbtL5uzpiCDczteptYnhXB3LagqVTHL/cm YCo= X-SBRS: 2.7 X-MesageID: 10950738 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,323,1574139600"; d="scan'208";a="10950738" Subject: Re: [PATCH v1 1/4] kasan: introduce set_pmd_early_shadow() To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= CC: , , , , Andrey Ryabinin , Alexander Potapenko , "Dmitry Vyukov" , Boris Ostrovsky , Stefano Stabellini , George Dunlap , Ross Lagerwall , Andrew Morton , "sergey.dyasli@citrix.com >> Sergey Dyasli" 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: Sergey Dyasli Autocrypt: addr=sergey.dyasli@citrix.com; keydata= xsFNBFtMVHEBEADc/hZcLexrB6vGTdGqEUsYZkFGQh6Z1OO7bCtM1go1RugSMeq9tkFHQSOc 9c7W9NVQqLgn8eefikIHxgic6tGgKoIQKcPuSsnqGao2YabsTSSoeatvmO5HkR0xGaUd+M6j iqv3cD7/WL602NhphT4ucKXCz93w0TeoJ3gleLuILxmzg1gDhKtMdkZv6TngWpKgIMRfoyHQ jsVzPbTTjJl/a9Cw99vuhFuEJfzbLA80hCwhoPM+ZQGFDcG4c25GQGQFFatpbQUhNirWW5b1 r2yVOziSJsvfTLnyzEizCvU+r/Ek2Kh0eAsRFr35m2X+X3CfxKrZcePxzAf273p4nc3YIK9h cwa4ZpDksun0E2l0pIxg/pPBXTNbH+OX1I+BfWDZWlPiPxgkiKdgYPS2qv53dJ+k9x6HkuCy i61Icj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SyAgPu1XSNa600gMJ QrSxgbe7bW72gCjeHcrIjfv+uh5cZ5/J/edpWXRuE4Tz82nxudBIHE2vnQEoJrXOh2kAJiYs G+IllDqFKDPrnS0R3DenBNG0Ir8h9W6heETnhQUc9NDFCSr81Mp0fROdBfYZnQzgSZMjN2eY pkNEWshJER4ZYY+7hAmqI51HnsKuM46QINh00jJHRMykW3TBMlwnUFxZ0gplAecjCFC7g2zj g1qNxLnxMS4wCsyEVhCkPyYnS8zuoa4ZUH37CezD01Ph4O1saln5+M4blHCEAUpZIkTGpUoi SEwtoxu6EEUYfbcjWgzJCs023hbRykZlFALoRNCwVz/FnPuVu291jn9kjvCTEeE6g2dCtOrO ukuXzk1tIeeoggsU7AJ0bzP7QOEhEckaBbP4k6ic26LJGWNMinllePyEMXzsgmMHVN//8wDT NWaanhP/JZ1v5Mfn8s1chIqC0sJIw73RvvuBkOa+jx0OwW3RFoQ= Message-ID: Date: Wed, 15 Jan 2020 16:32:07 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <6f643816-a7dc-f3bb-d521-b6ac104918d6@suse.com> Content-Type: text/plain; charset="utf-8" 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/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. -- Thanks, Sergey