Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4579942ybi; Tue, 11 Jun 2019 08:56:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyju9kBujj80WT1Df8ess2aR9y/oVxGoIpIc+/6Bq6F9ZAL3uxpVT8Cc/yby9g3jRH+ol9w X-Received: by 2002:a62:ed09:: with SMTP id u9mr80734778pfh.23.1560268589402; Tue, 11 Jun 2019 08:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560268589; cv=none; d=google.com; s=arc-20160816; b=pmGSfxnuHF5MHslbkgA4bJ2VV2SxweeP+BoV/BKJynaRKxTb90QqSKbubygNwDDwIZ rvIkhog070GRn/tB9NgCH8qWv/UcG37MmDlTQZ8SJHvLEljDCVJh60yN4qOYosQN/VZG KoR9fg69MZdJUzg71dVWDN/pChg+hp4suhIK9EY9j+QI9QAddbxY7g+92bIP6m7+CP4y MRMS2gz69J4ukDm7LWJZqoXM4FSrA94JwgScGibxcwLZLH111ESAjy7L8ZC5Tm4c1KwO 7S3BelGaHFwXSJkylBt1xFwRzZZtrZli6OV+kBP1nJSFLtSlqfZIG34JJYOc6uGkD6Fi FuqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=GxlKGJCE2lO+OlIEw18F401aO8HWOL9+8KziqJn8SZU=; b=dYHyMZhSkmSrOTjdh41v+qvXTqJCXTZvPA99m80VPLX+IRvNZlwlb0fZWH5wAT2ofO v9qn8+4YzETyNHUj1+eY43YfHJtKpWJjsvzwEsu1u2j3fayHpW2+2GRgozbDW0v60qhN /GU2o8paTL8RnCs+Z5ZlkWkIn5YeQjJP+nfPJxeBetEGNTl0UvjjKYgH1t78mLk6G3m9 +4wdax6GwqARxXNPsK9e+ksz6LxtTWrf5IK3+eJYCUIDVHUj+vdFQUuM2yoXG05qnHfj hrlJn6XGISj0zeijoZC5vq14NyfxgpZVehFgUd8Q/9WdDOASIDdn3efh5HiiSNz+1el1 yykA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18si2037624pls.437.2019.06.11.08.56.14; Tue, 11 Jun 2019 08:56:29 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404528AbfFKPOO (ORCPT + 99 others); Tue, 11 Jun 2019 11:14:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:53514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391755AbfFKPOO (ORCPT ); Tue, 11 Jun 2019 11:14:14 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A79062080A; Tue, 11 Jun 2019 15:14:11 +0000 (UTC) Date: Tue, 11 Jun 2019 11:14:10 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Ard Biesheuvel , Andy Lutomirski , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Nadav Amit , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Subject: Re: [PATCH 08/15] x86/alternatives: Teach text_poke_bp() to emulate instructions Message-ID: <20190611111410.366f4ced@gandalf.local.home> In-Reply-To: <20190605131945.005681046@infradead.org> References: <20190605130753.327195108@infradead.org> <20190605131945.005681046@infradead.org> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 05 Jun 2019 15:08:01 +0200 Peter Zijlstra wrote: > -void text_poke_bp(void *addr, const void *opcode, size_t len, void *handler) > +void text_poke_bp(void *addr, const void *opcode, size_t len, const void *emulate) > { > unsigned char int3 = 0xcc; > > - bp_int3_handler = handler; > + bp_int3_opcode = emulate ?: opcode; > bp_int3_addr = (u8 *)addr + sizeof(int3); > bp_patching_in_progress = true; > > lockdep_assert_held(&text_mutex); > > /* > + * poke_int3_handler() relies on @opcode being a 5 byte instruction; > + * notably a JMP, CALL or NOP5_ATOMIC. > + */ > + BUG_ON(len != 5); If we have a bug on here, why bother with passing in len at all? Just force it to be 5. We could make it a WARN_ON() and return without doing anything. This also prevents us from ever changing two byte jmps. -- Steve > + > + /* > * Corresponding read barrier in int3 notifier for making sure the > - * in_progress and handler are correctly ordered wrt. patching. > + * in_progress and opcode are correctly ordered wrt. patching. > */ > smp_wmb(); > > -