From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBC4C433F5 for ; Fri, 12 Nov 2021 05:20:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B42160F26 for ; Fri, 12 Nov 2021 05:20:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8B42160F26 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vYWb1YzJYzwrutih5+9keaJahiTA+KoNbMt4HmiQzXA=; b=djCGUYRbSlugSW +anPsEMv9o0g/t2OOUxYAnFtc6lwMAFWCarwkMDpJOigrsgUJrm6DWcTA/B4lsU5UvCMaGlYAz36m Mjd6CKqnGqCJJHcsIlaNdwNIgdt3IS2vocTEDFfntYhw1bhRMvEodo8VycjLwKWTPxlZ8prFn7NEW /mlIyq88bJapNWZT+SjlyLCPYQxmS5GG9dVZDCuo/fLXFM4dzT/BywZ8NSFlabpFMxZrdUotZCxb9 4sxUdNIM9jI8HPEzxfZJjXIfy8jnco4TMTId+/MGH45XJbNvCA3gOw9Upi4xZ3H4kqv/lIi/Cb03v ARRuni7BnaXs6sjqfjhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlOxg-009PpS-Qm; Fri, 12 Nov 2021 05:18:52 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlOxd-009Pp7-AA for linux-arm-kernel@lists.infradead.org; Fri, 12 Nov 2021 05:18:50 +0000 Received: by mail-pf1-x434.google.com with SMTP id m14so7527820pfc.9 for ; Thu, 11 Nov 2021 21:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=izlioX+noapZuLSQ+c4qfbdEvlV780BtjTo0HhtwFvo=; b=mpFveqPv9F/jaBknaAD271vAu3OYuzH00BeOe/8wZ6fdFwH8hdsUQi2AFjxVtjVQrC ts9te9snBCp3UW8AkCLfjg72MyYRXyOfZyTjYYp5q5zE0lbCNTdPG1NQT58le4CC0tgQ TdaiTSzT852d5kVhB2Q8d7vb+Im2FTmOCT2ctNIGrhEgqIUEVt7SY5zg7NfW0DYkoUWT GZaC1Js/GgzHlT9EIuexErImZYtHBn8rmYpdd2QjU/E13yYPlUv8vr+wR/8mVoRtcw6d crSR2zrM+gzw6EGFvz0hBJdeon5PjVetzMl1RFzuNAPrjPwQxwSt8rkG00RKzhC12ItP 1g/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=izlioX+noapZuLSQ+c4qfbdEvlV780BtjTo0HhtwFvo=; b=eU/7piWgLNbqTYFJ4+09PTAl/vvCWC7aqtbw+MXG0aU1whO4bR0A5pQSvDD/hDiXK5 ruix1UrTP6SuQkpql5rAr+SrVCfUj1j+FdK6bQuQJyRoAWAQmvlv3yFlyXlVo4rbJGg8 7b05r+4ZcIQcNUcCyy6o9FAFB3IVEWjaW/cVmUxukwDuEqHNf58d78dnJHjvhzuo5obD +v5k9L9pLQY/TxhDZWQfTv0kSCSCduhoC+YtK7y73nEXP+6q+0op94U2GmSAIriDY/Ix lb4eD/+MpvBKp+7HLQYZet7jcbsEyRIOkpjZorXllGEatTVyQ2pJew2+8PDxrjf8KkZR YsiA== X-Gm-Message-State: AOAM532Q3U0TACooJ29SIfVAjDTEFNXxQKFAIblBm6J7Q1ORIWDcyWsT eLnKfSiT5iVrq9xnNdDrEQ== X-Google-Smtp-Source: ABdhPJy87R8BPE8gyE90ddvFqSURSD5aZsU2sxFxPjppEbLRj4bvMWV+9ZCmq0OlR6UrtnFcZqPZuw== X-Received: by 2002:a63:7e48:: with SMTP id o8mr8464380pgn.157.1636694328561; Thu, 11 Nov 2021 21:18:48 -0800 (PST) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b22sm3644157pge.2.2021.11.11.21.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 21:18:48 -0800 (PST) Date: Fri, 12 Nov 2021 13:18:42 +0800 From: Pingfan Liu To: Catalin Marinas Cc: Ard Biesheuvel , Linux ARM , Will Deacon , Pasha Tatashin , James Morse , Matthias Brugger Subject: Re: [PATCH] arm64: mm: assign PXN permission in trans_pgd Message-ID: References: <20211111060316.12438-1-kernelfans@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211111_211849_387192_464BF090 X-CRM114-Status: GOOD ( 25.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Nov 11, 2021 at 06:18:17PM +0000, Catalin Marinas wrote: > On Thu, Nov 11, 2021 at 05:13:02PM +0100, Ard Biesheuvel wrote: > > On Thu, 11 Nov 2021 at 17:09, Catalin Marinas wrote: > > > On Thu, Nov 11, 2021 at 02:03:16PM +0800, Pingfan Liu wrote: > > > > diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c > > > > index d7da8ca40d2e..7b43d179e94d 100644 > > > > --- a/arch/arm64/mm/trans_pgd.c > > > > +++ b/arch/arm64/mm/trans_pgd.c > > > > @@ -67,7 +67,7 @@ static int copy_pte(struct trans_pgd_info *info, pmd_t *dst_pmdp, > > > > dst_ptep = trans_alloc(info); > > > > if (!dst_ptep) > > > > return -ENOMEM; > > > > - pmd_populate_kernel(NULL, dst_pmdp, dst_ptep); > > > > + pmd_populate_kernel(&init_mm, dst_pmdp, dst_ptep); > > > > dst_ptep = pte_offset_kernel(dst_pmdp, start); > > > > > > Commit 5de59884ac0e ("arm64: trans_pgd: pass NULL instead of init_mm to > > > *_populate functions") actually replaced &init_mm with NULL. Commit > > > 59511cfd08f3 ("arm64: mm: use XN table mapping attributes for > > > user/kernel mappings") introduced the VM_BUG_ON. I will include this history in V2. > > > > > > So we either revert Pasha's trans_pgd commit (as per your patch) or we > > > fix Ard's commit to make it aware of a NULL mm and either skip the table > > > UXN altogether or treat it as init_mm. > > > > > > > That code in pmd_populate_kernel() does not actually *use* the mm > > argument at all, it just BUGs if its value != init_mm. So we can just > > relax the BUG() to disregard mm == NULL. This seems to be more reasonable solution than my V1. > > We also have pud_populate() that ends up setting PUD_TABLE_PXN when mm > is NULL. Fortunately we don't execute anything from those mappings, they > are just a copy of the linear map. > Also included to V2. Thank both of you for kindly review. Regards, Pingfan > BTW, in line with PAGE_KERNEL, pud_populate() could set both UXN and PXN > for init_mm mappings. > > -- > Catalin > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel