Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3053858imu; Sun, 11 Nov 2018 06:44:19 -0800 (PST) X-Google-Smtp-Source: AJdET5erP10cCf5h9brgtZ/JUWN9MR+48ZC8QN8qqL+IckenDHKSTjALe7yI8gbNLmijswsyjQxA X-Received: by 2002:a17:902:c7:: with SMTP id a65-v6mr16750074pla.296.1541947458956; Sun, 11 Nov 2018 06:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541947458; cv=none; d=google.com; s=arc-20160816; b=qT9tB8cK9/zWziIdzV4Aci0T2wKGVcbOcU3fMBhYLgPF7CP/sEkbAn8E18xlkn15zy 2KzgZ4TzCZC8e7GMhMMzShxnvjhNMQYj73NrrYqEpxP6/HWFOqpImDTSp2nwAzb9WW9z 93IAWAeqhHOyDl+Lkykl7vjiAkMsUf7YTNeAy2/HvyIprsnVJyXVv6n8Kj+nl9Wegazn lZvkg4YC4ZUs4j/+N/C3lott7pkfS9HX6/07untLH4Nsv1yNe2h3qGa/TbkoDCPzHT6L mnaatXnG2goDVtajgdRaay5dvnZdMHmcoQku9mtlIZb1tS7nDXZWxryTwHyMmH4EpkUD TVdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gj1P1RQgOjTgsugLOE7R7BUL5Ok02AgJYAV8aEcJDho=; b=A88tZQfDWQ+M2aN/1Q2ZVL0yeINzE8k63x7brf2a1idvmrjtMDzMhb+jqAxDGD0sdk ptIMjCb4Z/B3N0dbLN6aVqH6uA1jfCo5XvGqmQrQyj01vrQ7u/CHIklE47Fflkvi9YgG zSXQfF0+a2QNZHqX3um99A13+gc/fXPpsVIE57qqtymomp2i+VoXuzoC1nyaG1gmuwXS Elvf08CGzl2IJ5pF9DRbFFkhDW0BQW1HuoDHbPT7sbmvqBoUkqnoeGAur+osCGkzglJj cEQexRHHeSl1DvI7a0gIUdKzmp6u/NvcDv2lXfdOm1zcppqUSDpDAd38dgvmjx01SgRE icMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FqzUe5cu; 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 d19-v6si12843705pgg.227.2018.11.11.06.43.58; Sun, 11 Nov 2018 06:44:18 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FqzUe5cu; 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 S1728440AbeKLAcT (ORCPT + 99 others); Sun, 11 Nov 2018 19:32:19 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:33038 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbeKLAcT (ORCPT ); Sun, 11 Nov 2018 19:32:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gj1P1RQgOjTgsugLOE7R7BUL5Ok02AgJYAV8aEcJDho=; b=FqzUe5cuDuN+McQZasYLlldtQ ZXz2tGKzxU0G20iMQfYMUux+e2xeSpCfnyKrRvNsIkHGNToNb+Fbty7tV8M+JVkNXqlN70FRehEke BaXqfAPysBQCQ1jvZ/qQTym+6mmPPdf5J+IbfsArq/NfdN49lGWzAupu1mpACievYQWjEaBAPh80o FtOgTusv9lADFDIZcJfycJ2A0GQe7xCzLIKasqfSo3ibwhXDPUqgzsGSWkal5XnouzomxTVeGI5mx N88Gf9CRr2aENQX8bEBdmlstyVbh1/wA19QtjLA7iM097hviH/R2jlvHBZp4Pk9zB19ReZtzLFifl NxWd1qPPA==; Received: from [64.114.255.114] (helo=worktop) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLqxT-00058A-9y; Sun, 11 Nov 2018 14:43:27 +0000 Received: by worktop (Postfix, from userid 1000) id 18C826E07F4; Sun, 11 Nov 2018 15:43:27 +0100 (CET) Date: Sun, 11 Nov 2018 15:43:27 +0100 From: Peter Zijlstra To: Nadav Amit Cc: Ingo Molnar , linux-kernel@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Dave Hansen , Kees Cook , Dave Hansen Subject: Re: [PATCH v4 05/10] x86/alternative: initializing temporary mm for patching Message-ID: <20181111144327.GG12766@worktop.psav.com> References: <20181110231732.15060-1-namit@vmware.com> <20181110231732.15060-6-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181110231732.15060-6-namit@vmware.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I don't seem to have gotten patches 0-2,7 for some reason; I'll try and dig them out of the LKML folder. On Sat, Nov 10, 2018 at 03:17:27PM -0800, Nadav Amit wrote: > +void __init poking_init(void) > +{ > + spinlock_t *ptl; > + pte_t *ptep; > + > + poking_mm = copy_init_mm(); > + if (!poking_mm) { > + pr_err("x86/mm: error setting a separate poking address space"); > + return; > + } > + > + /* > + * Randomize the poking address, but make sure that the following page > + * will be mapped at the same PMD. We need 2 pages, so find space for 3, > + * and adjust the address if the PMD ends after the first one. > + */ > + poking_addr = TASK_UNMAPPED_BASE + > + (kaslr_get_random_long("Poking") & PAGE_MASK) % > + (TASK_SIZE - TASK_UNMAPPED_BASE - 3 * PAGE_SIZE); > + > + if (((poking_addr + PAGE_SIZE) & ~PMD_MASK) == 0) > + poking_addr += PAGE_SIZE; > + > + /* > + * We need to trigger the allocation of the page-tables that will be > + * needed for poking now. Later, poking may be performed in an atomic > + * section, which might cause allocation to fail. > + */ > + ptep = get_locked_pte(poking_mm, poking_addr, &ptl); > + if (!WARN_ON(!ptep)) > + pte_unmap_unlock(ptep, ptl); > +} The difference in how we deal with -ENOMEM here is weird. I think we have a _lot_ of code that simply hard assumes we don't fail memory alloc on init. I for instance would not mind to simply remove both branches and let the kernel crash and burn if we ever fail here.