From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH 02/10] x86/cet: Introduce WRUSS instruction Date: Mon, 11 Jun 2018 10:17:04 +0200 Message-ID: <20180611081704.GI12180@hirez.programming.kicks-ass.net> References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-3-yu-cheng.yu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Andy Lutomirski Cc: Yu-cheng Yu , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H. J. Lu" , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com List-Id: linux-arch.vger.kernel.org On Thu, Jun 07, 2018 at 09:40:02AM -0700, Andy Lutomirski wrote: > On Thu, Jun 7, 2018 at 7:41 AM Yu-cheng Yu wrote: > Peterz, isn't there some fancy better way we're supposed to handle the > error return these days? > > + asm volatile("1:.byte 0x66, 0x0f, 0x38, 0xf5, 0x37\n" > > + "xor %[err],%[err]\n" > > + "2:\n" > > + ".section .fixup,\"ax\"\n" > > + "3: mov $-1,%[err]; jmp 2b\n" > > + ".previous\n" > > + _ASM_EXTABLE(1b, 3b) > > + : [err] "=a" (err) > > + : [val] "S" (val), [addr] "D" (addr) > > + : "memory"); So the alternative is something like: __visible bool ex_handler_wuss(const struct exception_table_entry *fixup, struct pt_regs *regs, int trapnr) { regs->ip = ex_fixup_addr(fixup); regs->ax = -1L; return true; } int err = 0; asm volatile("1: INSN_WUSS\n" "2:\n" _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wuss) : "=a" (err) : "S" (val), "D" (addr)); But I'm not at all sure that's actually better. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from merlin.infradead.org ([205.233.59.134]:56734 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754146AbeFKIRk (ORCPT ); Mon, 11 Jun 2018 04:17:40 -0400 Date: Mon, 11 Jun 2018 10:17:04 +0200 From: Peter Zijlstra Subject: Re: [PATCH 02/10] x86/cet: Introduce WRUSS instruction Message-ID: <20180611081704.GI12180@hirez.programming.kicks-ass.net> References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-3-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andy Lutomirski Cc: Yu-cheng Yu , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H. J. Lu" , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com Message-ID: <20180611081704.u4nFLqWv_MbjlOhcQVhiwQtJTvTAzHgX07LQWZ3tJQ0@z> On Thu, Jun 07, 2018 at 09:40:02AM -0700, Andy Lutomirski wrote: > On Thu, Jun 7, 2018 at 7:41 AM Yu-cheng Yu wrote: > Peterz, isn't there some fancy better way we're supposed to handle the > error return these days? > > + asm volatile("1:.byte 0x66, 0x0f, 0x38, 0xf5, 0x37\n" > > + "xor %[err],%[err]\n" > > + "2:\n" > > + ".section .fixup,\"ax\"\n" > > + "3: mov $-1,%[err]; jmp 2b\n" > > + ".previous\n" > > + _ASM_EXTABLE(1b, 3b) > > + : [err] "=a" (err) > > + : [val] "S" (val), [addr] "D" (addr) > > + : "memory"); So the alternative is something like: __visible bool ex_handler_wuss(const struct exception_table_entry *fixup, struct pt_regs *regs, int trapnr) { regs->ip = ex_fixup_addr(fixup); regs->ax = -1L; return true; } int err = 0; asm volatile("1: INSN_WUSS\n" "2:\n" _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wuss) : "=a" (err) : "S" (val), "D" (addr)); But I'm not at all sure that's actually better.