Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp805292imm; Thu, 6 Sep 2018 10:19:46 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaINDU6od+JCmb4hccQ4JQEyKAryBzkHiUSB+EhfRIy9kB+YKHrI3su0AmPvymsP3rtNECe X-Received: by 2002:a63:ff50:: with SMTP id s16-v6mr3889712pgk.241.1536254385943; Thu, 06 Sep 2018 10:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536254385; cv=none; d=google.com; s=arc-20160816; b=UtINFDunPOyPvy4rX3cHW5R6P33LhCgqH9cnHULYgqyJx59bbOlBm4RHusLCE74I0u v8SpU6zQqU/yWw43KWFIoTo1mkqVa4Y4oD7vsYxLeHMG81wptu8fxeNtyaC5WJXo0eSf WMulQIMYbZgubrsJCv/fGzkuleqrXq7geixR1lCh5OuFxj/uxlcKNWt49vLMZSXhLBLn y4njWXDHfS3uvd0xZsz+DWI0NdMBmH5Ug7ASXhSaj5jm9qaFGWFAxnPFwd/y5ihNsaXf Dm4RLoYeSs+Wjh5UjR1Jn7ER5m6zXv2JbdsTRBo0FWwHSzvadUGU//zfqCVdi04cI/FM cGEA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=92kLe+ZA7i8xLr9KM09UIIhtHm4W5k0v9LZceprp9Eo=; b=uBlnG2ENoGuMoQm+nBUQvRRBUnA9loZUeX870k8e6umTTCxdW+edFWANMZL1wE5/Gs PIDZIr0twfLGCsAnSU82l/Gncs/rs4v8YtzIemxt1nWTfVPqUY1qkq5nqNXHTnBSpdzq cLrjRRBrz3maK3z3YcwAfbXIxyBBUUWTvqQMsFXx+FiyoegOx0hdMyOxTsgvV7B1CguL l2gn+UQFWRbmEk0L0fiTjajOsO6pSBhFNCfBJq1SBcl6ddYcaqXOS2GYiHJR5DkFtYaj YdMJ0u1QHwVl5/cHuCcBae5hBmfTsM8t6CWzO5D7UcV+m73DsACIPNha+unxImq/lVTS UbuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MSGyRVoQ; 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 k18-v6si5802451pgm.102.2018.09.06.10.19.30; Thu, 06 Sep 2018 10:19:45 -0700 (PDT) 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=MSGyRVoQ; 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 S1728603AbeIFVy1 (ORCPT + 99 others); Thu, 6 Sep 2018 17:54:27 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49460 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728074AbeIFVy1 (ORCPT ); Thu, 6 Sep 2018 17:54:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=92kLe+ZA7i8xLr9KM09UIIhtHm4W5k0v9LZceprp9Eo=; b=MSGyRVoQPrXpUAPOGoWn0DRRvz wtV94A7p+Rh1qfEKvgegFAsHiOuo0nwprJjOmw1TkjfSvippYSAHq+/CvImZBhSzBO++QetqpO7rt Cd8+qKGKnSmN4ABB0ERnHxvqlnDzqYU/wUMHKEg5gg1m9xb+X0BwwnqXfXDfj6fYPGaZjoR2/W7y+ USglgCg2MwNtfhQfe3Xb73Rx/96ObE0QWaWpn2hN020ChyCCr9NvLJxicHcDYUjmCt0c8x6ESHds3 BZYmhwMGdANAAP4nQx8OWJGr9LFIQO0IyaFnwYDOlt98Z03I+EgudlmdOrZ/NaEve5xRTI4YZa3/t 3hbUqXdA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxxul-0001uD-PG; Thu, 06 Sep 2018 17:17:55 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 24A7D2018BF7D; Thu, 6 Sep 2018 19:17:54 +0200 (CEST) Date: Thu, 6 Sep 2018 19:17:54 +0200 From: Peter Zijlstra To: Nadav Amit Cc: Thomas Gleixner , LKML , Ingo Molnar , X86 ML , Arnd Bergmann , linux-arch , Dave Hansen , Jiri Kosina , Andy Lutomirski , Masami Hiramatsu , Kees Cook Subject: Re: [PATCH v2 0/6] x86/alternatives: text_poke() fixes Message-ID: <20180906171754.GJ24106@hirez.programming.kicks-ass.net> References: <20180902173224.30606-1-namit@vmware.com> <20180905185617.GC24082@hirez.programming.kicks-ass.net> <8D3CE999-6D3A-4984-934A-634BDD8AC25A@vmware.com> <6B256AB7-0158-47DF-B2D5-4C835579F3A3@vmware.com> <20180906081300.GF24082@hirez.programming.kicks-ass.net> <20180906101641.GG24142@hirez.programming.kicks-ass.net> <6703CD9F-2D84-4449-A423-A4DC24677673@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6703CD9F-2D84-4449-A423-A4DC24677673@vmware.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 06, 2018 at 05:01:25PM +0000, Nadav Amit wrote: > In addition, there might be a couple of issues with your fix: It boots on my box ;-) > 1. __set_pte_vaddr() is not used exclusive by set_fixmap(). This means > the warning might be wrong, but also means that these code patches (Xen’s > set_pte_mfn(), CPU-entry-area setup) needs to be checked. And as you said > before, someone might use this function for other purposes as well. CEA is fine, that actually needs it too. The one thing I missed out on earlier is the below chunk, that is no longer needed now that cea_set_pte() actually does the right thing. diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index b7b01d762d32..14ad97fa0749 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -293,12 +293,6 @@ static void ds_update_cea(void *cea, void *addr, size_t size, pgprot_t prot) preempt_disable(); for (; msz < size; msz += PAGE_SIZE, pa += PAGE_SIZE, cea += PAGE_SIZE) cea_set_pte(cea, pa, prot); - - /* - * This is a cross-CPU update of the cpu_entry_area, we must shoot down - * all TLB entries for it. - */ - flush_tlb_kernel_range(start, start + size); preempt_enable(); } @@ -310,8 +304,6 @@ static void ds_clear_cea(void *cea, size_t size) preempt_disable(); for (; msz < size; msz += PAGE_SIZE, cea += PAGE_SIZE) cea_set_pte(cea, 0, PAGE_NONE); - - flush_tlb_kernel_range(start, start + size); preempt_enable(); } > 2. Printing the virtual address can break KASLR. Local KASLR is a myth.. but sure, we can fix the print. > 3. The WARN() can introduce some overhead since checking if IRQs are > disabled takes considerably long time. Perhaps VM_WARN() or something is > better. I realize this code-path is not on the hot-path though... Yeah, if it triggers you have bigger problems. We can make it WARN_ONCE() I suppose. > 4. I guess flush_tlb_kernel_range() should also have something like > VM_WARN_ON(irqs_disabled()), just as an additional general sanity check. It has, it's hidden in kernel/smp.c:smp_call_function_many(). > Let me know if you want me to make these changes and include your patch in > the set. The set is no longer needed. text_poke() is fine and correct with this one patch.