Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp155466imm; Thu, 30 Aug 2018 10:35:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY8S3HXfHugZdycDKPqPBaFYpuBCAyj3TvF2AWgZ5jbMcR3a+mFLkgtMg9vZeuPbDhRqt2C X-Received: by 2002:a63:d613:: with SMTP id q19-v6mr10700958pgg.327.1535650541423; Thu, 30 Aug 2018 10:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535650541; cv=none; d=google.com; s=arc-20160816; b=opkEaWGPMLHezcblZ2oMfVTSGqbaHfMJUD4S/iUV2yHs1jTIiYJYnKaP7YiDob7OVT 3owxuBuZh7MOjA5P2MU6sBYoI/vYgVa9SzNSt9EKeyjyqzqPEF25XjNf02czwG326RmW BMdvZEISsvxPpyIpKrlk6ZgKcooM5htUd9YffQIbIervYCnxWtfs94iaHO0Nznf6zmf1 Eu47Oh35qDnUiaCOokftx6TBuPn0jA5yvWWQtTJlhXCSahDFUHuANB0TU+IgV7eiY1Cx okj2PxNWbXklscjtnH7B9nACb2mTGle2pKb3tM+Cd8+gMnY5bXBZEbexXjER4yAsK9yF yYjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=nXuNXZU/DAwnIKUZhVX/FPkHbonY/5QkMWqYCYJHnZ0=; b=B7UIISaPWPagK5B4I2Hyh29tfM7t6YUX/hwlXTHCa3QCADQIL0LmrSebW1O1sSwu3I BI59f2BkuqjLWeTnyYWTZgRr83eHoLX6iy1AF9y+/WPU+fdBh1mBgmscgSYSknZuZ3nn NhqkmXitueCei31ZEgKbly62u/vxd0qsHaJUf37NrtKp90D3b0Rp0u9m4qlX5tiyDreS YuzDBBqFxYlCAGK5e7JTBtOr3vWo9aOGsGw/Xys+qTPfK+p4OachM7WGIvTkc3euRHsB 0H+vjOnLW22/fmqebZ2Vi+AU4dk7oLlQxV0asN7Dy9iOy0rOYP4JWKFheKG40ygSXn8B jX/Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m126-v6si8059824pfb.126.2018.08.30.10.35.27; Thu, 30 Aug 2018 10:35:41 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727568AbeH3VhU (ORCPT + 99 others); Thu, 30 Aug 2018 17:37:20 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:14372 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbeH3VhU (ORCPT ); Thu, 30 Aug 2018 17:37:20 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Thu, 30 Aug 2018 10:33:41 -0700 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 90A96B05D7; Thu, 30 Aug 2018 13:34:06 -0400 (EDT) From: Nadav Amit To: Thomas Gleixner CC: , Ingo Molnar , , Arnd Bergmann , , Dave Hansen , Nadav Amit , Andy Lutomirski , Masami Hiramatsu , Kees Cook , Dave Hansen Subject: [PATCH 1/6] x86/alternatives: clarify text_mutex use in text_poke Date: Thu, 30 Aug 2018 10:32:13 -0700 Message-ID: <20180830173218.238900-2-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830173218.238900-1-namit@vmware.com> References: <20180830173218.238900-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-002.vmware.com: namit@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org text_mutex is expected to be held before text_poke() is called, but we cannot add a lockdep assertion since kgdb does not take it, and instead *supposedly* ensures the lock is not taken and will not be acquired by any other core while text_poke() is running. The reason for the "supposedly" comment is that it is not entirely clear that this would be the case if gdb_do_roundup is zero. Add a comment to clarify this behavior. Cc: Andy Lutomirski Cc: Masami Hiramatsu Cc: Kees Cook Cc: Dave Hansen Suggested-by: Peter Zijlstra Signed-off-by: Nadav Amit --- arch/x86/kernel/alternative.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 014f214da581..d0c0d8b724e1 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -685,7 +685,10 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode, * in a way that permits an atomic write. It also makes sure we fit on a single * page. * - * Note: Must be called under text_mutex. + * Context: Must be called under text_mutex. kgdb is an exception: it does not + * hold the mutex, as it *supposedly* ensures that no other core is + * holding the mutex and ensures that none of them will acquire the + * mutex while the code runs. */ void *text_poke(void *addr, const void *opcode, size_t len) { -- 2.17.1