From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 190234C8FEA for ; Thu, 11 Jun 2026 18:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781203063; cv=none; b=aAthkQRYv7E37lE0/foWyDh/0fPNJAZPxJCP1qZyMai7QGCIoT/LFRIdsN7wM8deV4iuYkQ5rW5TSr5P6Wk60QMSrQsKi3z9XboOWmrJ40bj2T3bAi4BRj57JxngKpBYOfm16mrfeSZbdPQluXQE+vpANxeESLt0/fu59DQ0fO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781203063; c=relaxed/simple; bh=CmzP/CS3tc+LESAeJ3gJm5wp17ARmBipCSf49/h0QZ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YaJITpVYox+0KFDFvX8ibSv4Y8MrfGLeygkyDYdo1pe/6E+ChSqVEfg6hHinW0+2ohTn2218Niz15x3jaAzRzol3cTsRwOOa/vGxMqHTV6GjspZoN4Q0B3GKnRdYpM/MoAznlA1wcltXIVA1AvTt6axaSqJjh0zaFR9IjKCmD90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=gznymQjZ; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gznymQjZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XF3zYkFm51zwJS7lS0wBaFE0MXAhO2W1M4IvIXKlC+c=; b=gznymQjZgUPYZ+y9BDmN0u6zzm qJtvnYsruuU6TqOuifaXYi9YJYGCEjT4eKbkQhqruwST8tiyCWM4b4PrPkT2gAyFdhzu1QXXphqvM BbgtwhXz4c6ucugcG9NrFrB0ubW+BiN1twPtMj5ky5jpHCmsSKmt1MLJ5GMJ3ItVtjjQFP/wUrgeg 9t7+ji3QSvm/EVD7SnOPOQhj0xrmaZxVbMTmJCYw8o09JGLAhmJTVT5bSfwMvZBDFoMHzx0IRztwN XTF2b68q+8i8fyG2gaxxFfIw0PaNmmsa7ViXaLTyrz//f96EJzvVb7JlE1XH3GG9i4D8Gyhj9EAkJ dn0DgH9g==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.2 #2 (Red Hat Linux)) id 1wXkHZ-00000005Yrt-0QYh; Thu, 11 Jun 2026 18:37:37 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 576EB300312; Thu, 11 Jun 2026 20:37:36 +0200 (CEST) Date: Thu, 11 Jun 2026 20:37:36 +0200 From: Peter Zijlstra To: Borislav Petkov Cc: Ronan Pigott , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: UMIP and clearcpuid= Message-ID: <20260611183736.GI187714@noisy.programming.kicks-ass.net> References: <20260610200054.GDainCdpF585khK77w@fat_crate.local> <3868008f140c843f4443b79d800dba5456df174a@rjp.ie> <20260610235501.GGain5VbwcvpUwCxiw@fat_crate.local> <20260611075311.GH48970@noisy.programming.kicks-ass.net> <20260611160946.GAairdygGg2bMCjibT@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260611160946.GAairdygGg2bMCjibT@fat_crate.local> On Thu, Jun 11, 2026 at 09:09:46AM -0700, Borislav Petkov wrote: > > It is really annoying having to disable UMIP though, its bugged me, just > > not enough to ever actually do anything about it. > > Well, what else could we do? Whitelist processes, make it more fine-grained or > so...? Perhaps just one print per task might be a good start? Something like so? I don't think anything hits this hard enough to matter performance wise; but the wine stuff can hit them often enough that the dmesg spam is annoying, and there's really nothing much you can do about it. This is somewhat similar to the split lock stuff, yeah, they're bad, but nobody is going to be fixing those games. And UMIP really is useful; these are gnarly instructions you really don't want, so as along as it all runs it should be fine. I suppose I should go re-enable it on my own machine and actually spend some time on it if/when I find another game that flat out doesn't work with the emulation. --- diff --git a/arch/x86/kernel/umip.c b/arch/x86/kernel/umip.c index 3ce99cbcf187..83517d5b8eae 100644 --- a/arch/x86/kernel/umip.c +++ b/arch/x86/kernel/umip.c @@ -90,49 +90,6 @@ static const char * const umip_insns[5] = { [UMIP_INST_STR] = "STR", }; -#define umip_pr_err(regs, fmt, ...) \ - umip_printk(regs, KERN_ERR, fmt, ##__VA_ARGS__) -#define umip_pr_debug(regs, fmt, ...) \ - umip_printk(regs, KERN_DEBUG, fmt, ##__VA_ARGS__) - -/** - * umip_printk() - Print a rate-limited message - * @regs: Register set with the context in which the warning is printed - * @log_level: Kernel log level to print the message - * @fmt: The text string to print - * - * Print the text contained in @fmt. The print rate is limited to bursts of 5 - * messages every two minutes. The purpose of this customized version of - * printk() is to print messages when user space processes use any of the - * UMIP-protected instructions. Thus, the printed text is prepended with the - * task name and process ID number of the current task as well as the - * instruction and stack pointers in @regs as seen when entering kernel mode. - * - * Returns: - * - * None. - */ -static __printf(3, 4) -void umip_printk(const struct pt_regs *regs, const char *log_level, - const char *fmt, ...) -{ - /* Bursts of 5 messages every two minutes */ - static DEFINE_RATELIMIT_STATE(ratelimit, 2 * 60 * HZ, 5); - struct task_struct *tsk = current; - struct va_format vaf; - va_list args; - - if (!__ratelimit(&ratelimit)) - return; - - va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - printk("%s" pr_fmt("%s[%d] ip:%lx sp:%lx: %pV"), log_level, tsk->comm, - task_pid_nr(tsk), regs->ip, regs->sp, &vaf); - va_end(args); -} - /** * identify_insn() - Identify a UMIP-protected instruction * @insn: Instruction structure with opcode and ModRM byte. @@ -322,8 +279,9 @@ static void force_sig_info_umip_fault(void __user *addr, struct pt_regs *regs) if (!(show_unhandled_signals && unhandled_signal(tsk, SIGSEGV))) return; - umip_pr_err(regs, "segfault in emulation. error%x\n", - X86_PF_USER | X86_PF_WRITE); + pr_err("%s[%d] ip:%lx sp:%lx: segfault in emulation. error%x\n", + tsk->comm, task_pid_nr(tsk), regs->ip, regs->sp, + X86_PF_USER | X86_PF_WRITE); } /** @@ -375,10 +333,13 @@ bool fixup_umip_exception(struct pt_regs *regs) if (umip_inst < 0) return false; - umip_pr_debug(regs, "%s instruction cannot be used by applications.\n", - umip_insns[umip_inst]); - - umip_pr_debug(regs, "For now, expensive software emulation returns the result.\n"); + if (!current->reported_umip_emu) { + pr_debug("%s[%d] ip:%lx sp:%lx: %s instruction cannot be used by application; " + "will be emulated.\n", + current->comm, task_pid_nr(current), regs->ip, regs->sp, + umip_insns[umip_inst]); + current->reported_umip_emu = 1; + } if (emulate_umip_insn(&insn, umip_inst, dummy_data, &dummy_data_size, user_64bit_mode(regs))) diff --git a/include/linux/sched.h b/include/linux/sched.h index c88fc10e9c38..f6ef5b519ad6 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1044,6 +1044,9 @@ struct task_struct { #ifdef CONFIG_X86_BUS_LOCK_DETECT unsigned reported_split_lock:1; #endif +#ifdef CONFIG_X86_UMIP + unsigned reported_umip_emu:1; +#endif #ifdef CONFIG_TASK_DELAY_ACCT /* delay due to memory thrashing */ unsigned in_thrashing:1;