From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailapp01.imgtec.com ([195.59.15.196]:62674 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23993874AbdAYOjwSw9Sy (ORCPT ); Wed, 25 Jan 2017 15:39:52 +0100 Date: Wed, 25 Jan 2017 14:39:36 +0000 From: "Maciej W. Rozycki" Subject: Re: [PATCH v2 1/2] MIPS: ptrace: disallow setting watchpoints in kernel address space In-Reply-To: Message-ID: References: <1485163113-21780-1-git-send-email-marcin.nowakowski@imgtec.com> <20170124185452.GL29015@jhogan-linux.le.imgtec.org> <20170124220554.GM29015@jhogan-linux.le.imgtec.org> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Return-Path: Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: To: James Hogan Cc: Marcin Nowakowski , Ralf Baechle , linux-mips@linux-mips.org Message-ID: <20170125143936.34Kb6doWjoxXON8MgMWI6241EO2I27_1ZIGYa1C8Pfs@z> On Tue, 24 Jan 2017, Maciej W. Rozycki wrote: > However if we can prove that we won't need the IP[1:0] bits in scenarios > that involve a TLB refill, then we could just quickly do a short sequence, > say: > > lui $k0, 1 << 23 Umm, thinko here, this obviously has to be: li $k0, 1 << 23 or alternatively: lui $k0, 1 << (23 - 16) (GAS will emit a single LUI instruction in either case). > mtc0 $13, $k0 > eret > > Otherwise we'll have to do a full RMW sequence; fortunately a single INS > from $0 will do here again to clear CP0.Cause.WP and keep the remaining > bits. Maybe we could do just the same in the regular exception epilogue > to avoid the dependency on a hazard (and consequently an issue with QEMU). Of course a similar hazard is still there, so the same precautions apply. Also I think we do need to clear CP0.Cause.WP in all cases before ERET, including the various exception fast paths, such as in the TLBL/TLBS/TLBM handlers, which also means we don't have to fiddle with CP0.EntryHi.ASID in handler execution paths that run at EXL entirely to completion. Maciej