Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9136896ybl; Fri, 17 Jan 2020 06:58:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzPg02eRgGmrjixOTBnKL+aEzc8EA6oqfVRUVbSLGtTQyiAdJLjxUJlc76Gws7h32Cey1yn X-Received: by 2002:aca:d15:: with SMTP id 21mr3693465oin.127.1579273082685; Fri, 17 Jan 2020 06:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579273082; cv=none; d=google.com; s=arc-20160816; b=IGibN4Ry7tpHoWAefvFISYYMVM/g5jOJnLZOjUY+lxhYdCPTjKvkH5cdjd8o6ynASV RmxWK9vTQH9BOpdpxErbhby5FpVBDca1+X+VBgrhie6xwYqBlTTl14EFjUy5NkDimt91 CafSYH323TIIFAE/jTc2I/HZpfWK8xpMQi7ktHWl+iymPaRAFp76KrEn7A/ju2RmMzhv EAWEOXFQ9pRAZVNpzy18eh8F5VXfi8rdJ7mx7lM9ZEh7lzz7eyEMOQXFji5ceRiL94JU +ZUmniP0KgYgIZUhCrHPESLPsd1au6Nw2OEsmcB8eN+pgMgb4EDE1k+QixlA+vD0JC2y 5qGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=RDYxmTVi6oTBCZ/d+490GqYHOHA9lPToi4gO08lPyRM=; b=lRwIvxbsziQZ4ei0UmcYw4+Rh//LN2eW5qe201S81u+hAS2N+TcRs0rUYxEcgLovNU eOgHgc5eN4eOAPhW/NI9+1lrFgK7hB4WsDV1mq5TQBWsWJvICXS/Q3o4JQUMmnSn/J8G Klb9S5djyQO/HW3OmJw+5bY/gLLpOIuQ2YeIxhMcU4M918/dupFNRrojsfNPg7herIXT /ITsqYyClN+2jpARqS5lLR2wzovfLwj9Q6JkYL3bBin3QHUFmnhnbcTo3oXCZjmRI4vf RyY/JOcse6OjwwOaiumZZIsMC8NFsh3TvN3+DwLgwLWzkffQfEIMnRNLKWnSGebKDK1v tPqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=AgWPVT2X; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n85si13765670oig.191.2020.01.17.06.57.49; Fri, 17 Jan 2020 06:58:02 -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=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=AgWPVT2X; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728909AbgAQO4h (ORCPT + 99 others); Fri, 17 Jan 2020 09:56:37 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57950 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbgAQO4h (ORCPT ); Fri, 17 Jan 2020 09:56:37 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00HEr9gs170370; Fri, 17 Jan 2020 14:56:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=RDYxmTVi6oTBCZ/d+490GqYHOHA9lPToi4gO08lPyRM=; b=AgWPVT2XCVmAXkqITfU70s/3cCF8Sp0GY33C70RcH0SMhQwG7itGReWnDR5elNp9POcd C515OTVt5ANzeQJ6+iytxN56YsmbdjQQhGRXoDQ/XqeGVxJpKt9jur7muPeJeYK4gcXe 2x3RegrwIWpwmSktWpe5av0hWsLqsNs+35dJ4SZLF7aAyVI2O+KIFess/Y0GuRwC73iC +tARVqkzGDGCH2jTjZbSwmkE3UqFTj9Mci7Wld5D9x1+RbwZKBFvoyra6XWYWMs/3vs+ vHJrZweJDTdVe5yQWPTDkRXyNdgQ/wW9/LqmUx3CjqZRXpNjvt86zG3BPhIjIp4WEH9J JA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2xf73u91uj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 14:56:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00HEsBST166391; Fri, 17 Jan 2020 14:56:19 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2xk24f4w2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 14:56:19 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 00HEuH6G006884; Fri, 17 Jan 2020 14:56:17 GMT Received: from bostrovs-us.us.oracle.com (/10.152.32.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 17 Jan 2020 06:56:17 -0800 Subject: Re: [PATCH v2 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 , Juergen Gross , Stefano Stabellini , George Dunlap , Ross Lagerwall , Andrew Morton References: <20200117125834.14552-1-sergey.dyasli@citrix.com> <20200117125834.14552-3-sergey.dyasli@citrix.com> From: Boris Ostrovsky Message-ID: <28aba070-fa53-5677-c2d2-97d06514dda8@oracle.com> Date: Fri, 17 Jan 2020 09:56:12 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20200117125834.14552-3-sergey.dyasli@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9502 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=991 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001170117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9502 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001170117 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/17/20 7:58 AM, Sergey Dyasli wrote: > --- 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(); > + kasan_map_early_shadow(pv_top_pgt); > + } > + I'd suggest replacing this with xen_kasan_early_init() and doing everything, including PV check, there. This way non-Xen code won't need to be aware of Xen-specific details such as guest types. > 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); > + And drop "_pv" here (and below) for the same reason. -boris > load_cr3(early_top_pgt); > __flush_tlb_all(); > > @@ -433,6 +443,8 @@ void __init kasan_init(void) > load_cr3(init_top_pgt); > __flush_tlb_all(); > > + xen_pv_kasan_unpin_pgd(early_top_pgt); > + >