Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1852993ybl; Thu, 9 Jan 2020 02:47:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyaH2mpIuQaOw1DwjeC4tDOQVV4tsQBPcAk1sLF/f0p68fYaSdJHGFGhfIdOk/jlT+kIs5q X-Received: by 2002:a9d:3e43:: with SMTP id h3mr7720914otg.84.1578566843003; Thu, 09 Jan 2020 02:47:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578566842; cv=none; d=google.com; s=arc-20160816; b=tcoV6CXEoR80M+RXv/7Oz/we08QBJXOotqqA45CJ/qCxUBYm4uDlGsMK87m4Q4FSjP F6Wsu4UBdwcjZtX2dz/U2DSbSYsPsaSbLPzlp0ngj/qX2RY8m8BqMutzdfjBoXLQ+tEL +57tG/MG6nzEV+k0U1tB2hW0XxDrR9re+5sCgiO7hbTiboQ9sM1egDQ88NkoiFB391aK SomMxY/mmUr1SR3VzQhYnEe+5Sm98SbS452Pymt23XXiBJOwvb0ovyKWfdXYROKtuJ9Q Moxrw1QaVMpoiz8/96SldPO/43nh8u3XC+DX2vQZtScAk+6fc+lJ/rzTqbwIrz239/d6 qo4Q== 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=Xt1xB7cKg0q9fA/Lk3zDCRSrgriFWa4w8FNQhviT++Y=; b=GQrGpweJyo5RjcRoS0RR75WPana4Qv+ApYgboJ4cjVTBJMonuBmRm9eGQo8zFKk8wt 1Ca7ZREtcS+TYvMWws60xVdl+0yzmAsJ2RgnK/UKfoO7YNT1igidXNaB5S/r+WjFuaSk mgYlTCPw7xCBd2kD1u0Pxc8clrqJaPTvBq57pWmBnZD25FndSaszCWAD1QTM2z/mDnx0 rWA3GMogyH82bMsYvXOh1g0X4qeT4ZIcdm8/7vrz+cipM/OqmpJ25Q51ydssV+kcOs6Q 8L7uknUkVS6LOjxV77hPVjD7OmN+1bxxrD8jm+giM7myF9PLNsF1Qqzf0dHcXvvQNMaj wGeg== 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 t28si3839209otr.16.2020.01.09.02.47.09; Thu, 09 Jan 2020 02:47:22 -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 S1729442AbgAIJXt (ORCPT + 99 others); Thu, 9 Jan 2020 04:23:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:52402 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729269AbgAIJXs (ORCPT ); Thu, 9 Jan 2020 04:23:48 -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 1938ABC8D; Thu, 9 Jan 2020 09:22:51 +0000 (UTC) Subject: Re: [PATCH v1 2/4] x86/xen: add basic KASAN support for PV kernel To: Sergey Dyasli , xen-devel@lists.xen.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: 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-3-sergey.dyasli@citrix.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <0c968669-2b21-b772-dba8-f674057bd6e7@suse.com> Date: Thu, 9 Jan 2020 10:15:28 +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: <20200108152100.7630-3-sergey.dyasli@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 08.01.20 16:20, Sergey Dyasli wrote: > This enables to use Outline instrumentation for Xen PV kernels. > > KASAN_INLINE and KASAN_VMALLOC options currently lead to boot crashes > and hence disabled. > > Signed-off-by: Sergey Dyasli > --- > RFC --> v1: > - New functions with declarations in xen/xen-ops.h > - Fixed the issue with free_kernel_image_pages() with the help of > xen_pv_kasan_unpin_pgd() > --- > arch/x86/mm/kasan_init_64.c | 12 ++++++++++++ > arch/x86/xen/Makefile | 7 +++++++ > arch/x86/xen/enlighten_pv.c | 3 +++ > arch/x86/xen/mmu_pv.c | 39 +++++++++++++++++++++++++++++++++++++ > drivers/xen/Makefile | 2 ++ > include/xen/xen-ops.h | 4 ++++ > kernel/Makefile | 2 ++ > lib/Kconfig.kasan | 3 ++- > 8 files changed, 71 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c > index cf5bc37c90ac..902a6a152d33 100644 > --- a/arch/x86/mm/kasan_init_64.c > +++ b/arch/x86/mm/kasan_init_64.c > @@ -13,6 +13,9 @@ > #include > #include > > +#include > +#include > + > #include > #include > #include > @@ -332,6 +335,11 @@ void __init kasan_early_init(void) > for (i = 0; pgtable_l5_enabled() && i < PTRS_PER_P4D; i++) > kasan_early_shadow_p4d[i] = __p4d(p4d_val); > > + if (xen_pv_domain()) { > + pgd_t *pv_top_pgt = xen_pv_kasan_early_init(); You are breaking the build with CONFIG_XEN_PV undefined here. > + kasan_map_early_shadow(pv_top_pgt); > + } > + > kasan_map_early_shadow(early_top_pgt); > kasan_map_early_shadow(init_top_pgt); > } > @@ -369,6 +377,8 @@ void __init kasan_init(void) > __pgd(__pa(tmp_p4d_table) | _KERNPG_TABLE)); > } > > + xen_pv_kasan_pin_pgd(early_top_pgt); Same here (and below). For the pin/unpin variants I'd rather have an inline wrapper containing the "if (xen_pv_domain())" in xen-ops.h which can easily contain the needed #ifdef CONFIG_XEN_PV. Juergen