Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3860669pxj; Mon, 21 Jun 2021 08:10:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEqlR7PrZn5s7nrlKqgfjhOPSmIk+JOpaXJBdS3a3mGADIkUDxycb1gnGZmmk3GRcubCl6 X-Received: by 2002:a92:7303:: with SMTP id o3mr18602238ilc.203.1624288214108; Mon, 21 Jun 2021 08:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624288214; cv=none; d=google.com; s=arc-20160816; b=fx7lggS9G6dM3/BREB9tnRYQ77/Ph4p9/3vtZ4KwyOmgKhzgUv91Sou8KJhUTaVGld frCNU2PeXztOd/bl+kYM03quNY5ByQBFcnF+Ze0tK+ltaP7/eEEVpSRx15Q0kyjTFrhp rgRaNPsTqcMO9mn2zXauHjzhIXRoZYgT7VQmO64FCzuZ5kU2P31GNEC6OdTOiyikd9S7 ydYWSZglPCwMUV+VdwU0j6X4pglG3v9CLBz7KgmGA6M+N6uaQnYwc01i2yDcw+83mKQU p/gfD4ndGtL/xlG56kZxTfZGeg/2ZdthlxKKSl8PfH5tARj8DB0mOuWFGDDGVuROdw4K NpIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oeYSpEhZE6AmPfNM4+w2zYj9of/Mlvcohb59Uj+RS6k=; b=wT6RUUSgSNVKLVcM45zbHo7etj3OSIq9jHVTHExJJe93vGb41pJ0BuySv5klymAvue RJOu3nRqoKtC6bxqcWEkMaFCkh1yCeSINsza+hovo5yaYTrV9p7IRrVBN5LdEL948WGT KcsEhUgBV9tTFhyo+bpsiIEGLRoNOoBXXmYqBNaPc8d/i9YFoaZpUV4iFut09pmedNA3 /1HRRQkk3jxmKUzRp+GM145ChH4dVRYtIES0oYsoAHTlOWwnpSoXs6eA52MKZWd4AwF4 lwgeM6u+KLKnNmui7+KfblBDZCIqSrf3A7bLRE4Eu1JQMQypUghyI7ueOuy0tA/Q6qN9 4RXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=udr+eniE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si18842034jat.53.2021.06.21.08.09.58; Mon, 21 Jun 2021 08:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=udr+eniE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhFUPKi (ORCPT + 99 others); Mon, 21 Jun 2021 11:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbhFUPKi (ORCPT ); Mon, 21 Jun 2021 11:10:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A9FC061574 for ; Mon, 21 Jun 2021 08:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oeYSpEhZE6AmPfNM4+w2zYj9of/Mlvcohb59Uj+RS6k=; b=udr+eniEeQRB22JbVElibG//cJ jzbNGAnVUOEydkIjCnfG6UGKxmHS1FCLO+SG6Nqk/MRjZAsp6OTxGdLZ0/NTJ8gylehMPZumiy9bD okUbzqXaVAsuZNXwekXBiY87c4qmHinOcPEd+G/XQkA+MBGWZDGr+VMRCYEeLnk+hmFFKkCWOtFLd DFKCIUEYgJ0Nkp7dxCAbfsfR6ELNt2yzZ70YVG9a2ujinF/R4xcpGw9pjRQ4cmmWVrids6gdUebz9 xASPeX1lOUQIHo6XN+wdWzZhl4epihE+TQdpMy+eDRuOTU+c/0ZfodNchXxRooJgsDcGssghKkuKR 5eFIdWXQ==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvLW8-00DDQH-Lf; Mon, 21 Jun 2021 15:07:21 +0000 Date: Mon, 21 Jun 2021 16:07:16 +0100 From: Christoph Hellwig To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang , Christoph Hellwig , Zong Li , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/2] riscv: Map the kernel with correct permissions the first time Message-ID: References: <20210617131734.1923932-1-alex@ghiti.fr> <20210617131734.1923932-3-alex@ghiti.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210617131734.1923932-3-alex@ghiti.fr> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 17, 2021 at 03:17:34PM +0200, Alexandre Ghiti wrote: > > void free_initmem(void) > { > if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) > + set_kernel_memory(lm_alias(__init_begin), lm_alias(__init_end), > + IS_ENABLED(CONFIG_64BIT) ? set_memory_rw : set_memory_rw_nx); Breaking the second line up woul help a lot with readability: set_kernel_memory(lm_alias(__init_begin), lm_alias(__init_end), IS_ENABLED(CONFIG_64BIT) ? set_memory_rw : set_memory_rw_nx); > +#ifdef CONFIG_STRICT_KERNEL_RWX > +static __init pgprot_t pgprot_from_va(uintptr_t va) > +{ > + if (is_va_kernel_text(va)) > + return PAGE_KERNEL_READ_EXEC; > + > + /* > + * In 64b kernel, the kernel mapping is outside the linear mapping so we Spelling out 64-bit would be nice. > + * must protect its linear mapping alias from being executed and written. And please never spill comments over 80 characters, as that makes them completely unreadable. Besides a few more overly long lines this looks great.