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 1036CC4332F for ; Thu, 11 Nov 2021 18:19:48 +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 D71B26135E for ; Thu, 11 Nov 2021 18:19:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D71B26135E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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=s0d8Pa0nuRpoVa+MZYV5cM8QIztZva0Xi0ay4h7quoA=; b=TpTAn+VjnpgkHU F7YE+C3tia0W5psd2QbAMKqQ2N6lhs6qTx+ZNUXYg+6kbmw0P+BQL8x4hBcmJBCe6ZyPc8hIqFKOM RhjQtwF+tjbfbSwEn7ntPIbJ+m7OfrYoIGecpTKY7p3t6a+FblMcptL6UW4iRgBWnjSljnQb9Mi3f i0N5FFKvcG2Nimx9Jdul/iHgctTEFAdsVobkztTpLufnXZrBcFePy3r2V85scMjlx0T3upt3yix9u NRSFTsbvDNenhgLFNvHhSFIlJAGkON+9sgv5Fc+I9l43YQLvjdymzwt1Xb0l0GQkldgJTp9Tkr/wk /TL72KT7ycXsWyJo9y3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlEeY-008Y9N-4p; Thu, 11 Nov 2021 18:18:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlEeV-008Y94-00 for linux-arm-kernel@lists.infradead.org; Thu, 11 Nov 2021 18:18:24 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FEAB61284; Thu, 11 Nov 2021 18:18:21 +0000 (UTC) Date: Thu, 11 Nov 2021 18:18:17 +0000 From: Catalin Marinas To: Ard Biesheuvel Cc: Pingfan Liu , 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_101823_075424_EB23C18F X-CRM114-Status: GOOD ( 17.56 ) 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 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. > > > > 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. 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. 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