Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1679524ybh; Thu, 23 Jul 2020 15:15:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1bhrkvj8MREfRpBBJwVqiPEjxy9GEMBWbwPnCpA2d8WRlWK9LjUs4NbWWpHXKGk0i+S9X X-Received: by 2002:a50:ec93:: with SMTP id e19mr6038897edr.254.1595542505553; Thu, 23 Jul 2020 15:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595542505; cv=none; d=google.com; s=arc-20160816; b=fCmPb4GvJIjYGsF/C0Mfc1aPyEa3a0V81JCNRZuQLXaESDpT99B6HQh4Vnp+xrJxKw VAQXjIXUzA2QCSbWRWqQ4c3/S6KVWTqgD7ckKdC8RYKa6UgAGJVxPP1/tdoo9fECI0xg 1LtfGC+7r8gLCFbUjKOT97Xp+4AtqbT7jUSFHsxSfMndYZT2hjqFnByfuRWzGEBo7F/h thOFek0dKEujhcXU8ycoWVuMRMKCO8UD01FuveH80YqyO9A7I3DNER84efM/RdbHaQJ2 XGZ1QNq+3YBPXdseqIfx4FRlnKpgS0owjk8f1qwsJin1n4hn98pWMBLtia0MFMYbNF0Y Reqg== 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 :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=JmyzjmH8/olb4mM6hh3RrBawdAZ1ohRuT2f6HKf6J84=; b=PTnHN+gojPOfcC/9XorB9iEsrcp72QmP0cwL3q6LbMZ7Ki3w85T/YpZ3Ep+TkAmD15 8e0cM+ll3FRqOVNipUTTDuxs0ZVPbIYAyHilLFtE1jktiQMcVl2wJgZfCKIU0R5m5oNf bH2u/zLEgJ7hKM9pJskd4Z0BmtiRUWXmLA70uE/jnDNTdX9/EpbGYK4GfS2wES0fhmih 3kACycxtUzzVlAcTESEkky5UVbOUyr84g85/shu9mm+clAxoNinv2E/Ps/akLAEO2mVy Oa1Nxi8W2MRjOVOePiOtE1Eso+OAucq74EFJ94y92khvMxC9+A16JHvPEXO5Ktn52AuG u43w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=V5Z5Rq1n; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="DpE/SglP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm6si2736603edb.169.2020.07.23.15.14.42; Thu, 23 Jul 2020 15:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=V5Z5Rq1n; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="DpE/SglP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbgGWWOb (ORCPT + 99 others); Thu, 23 Jul 2020 18:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbgGWWOb (ORCPT ); Thu, 23 Jul 2020 18:14:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC07C0619D3; Thu, 23 Jul 2020 15:14:31 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595542468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JmyzjmH8/olb4mM6hh3RrBawdAZ1ohRuT2f6HKf6J84=; b=V5Z5Rq1nk71rXzhuUOz5ybYySxFdqFcH8dpWSElBd5qV0W8MCoBko+38RNWOwqWv2ju5Ig bQIZTjLoRGXb0gRm8ytYEZ+t/kr7TRL00g3qwWdo76SMcfJ4GqUmx1vL6JGaDTvO7FZH+R ehWAUFsqGo/fbWIHtNHboBF7FH01EARrdMRiueauNFcaZcnEvopvmfNUwCfpZJv1T5dDwT im0DmUgWCCRiLQJaa9slhiO8uBTVN7eOzTJKLsyQvSGFvkDS9iSTv6B55CVKQYzX50pMS/ 92w4HmCS53+4wG2ZzwtaOhcrmTM/WnQ4LlDs75AQoLaiaAd4mZmRHbv65Gb2eA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595542468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JmyzjmH8/olb4mM6hh3RrBawdAZ1ohRuT2f6HKf6J84=; b=DpE/SglP+UbEOY+9bcINMPHA9y7J8tMcjgmZMJCa1/pPbw5ifZwHGpOKKPr+c+G54aYYVK 9inwqDxRJmQ+XGDQ== To: Andy Lutomirski Cc: Fenghua Yu , Dave Hansen , Andy Lutomirski , Weiny Ira , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Dave Hansen , X86 ML , Dan Williams , Vishal Verma , Andrew Morton , "open list\:DOCUMENTATION" , LKML , linux-nvdimm , Linux FS Devel , Linux-MM , "open list\:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH RFC V2 17/17] x86/entry: Preserve PKRS MSR across exceptions In-Reply-To: References: <20200723165204.GB77434@romley-ivt3.sc.intel.com> <87imeevv6b.fsf@nanos.tec.linutronix.de> Date: Fri, 24 Jul 2020 00:14:28 +0200 Message-ID: <874kpxx4jf.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andy Lutomirski writes: >> On Jul 23, 2020, at 1:22 PM, Thomas Gleixner wrote: >> =EF=BB=BFAndy Lutomirski writes: >>> My suggestion is to enlarge pt_regs. The save and restore logic can >>> probably be in C, but pt_regs is the logical place to put a register >>> that is saved and restored across all entries. >> >> Kinda, but that still sucks because schedule from #PF will get it wrong >> unless you do extra nasties. > > This seems like we=E2=80=99re reinventing the wheel. PKRS is not > fundamentally different from, say, RSP. If we want to save it across > exceptions, we save it on entry and context-switch-out and restore it > on exit and context-switch-in. It's fundamentally different from RSP because it has state (refcount) attached, which RSP clearly has not. If you get rid of the state then yes. >>> Whoever does this work will have the delightful job of figuring out >>> whether BPF thinks that the layout of pt_regs is ABI and, if so, >>> fixing the resulting mess. >>> >>> The fact the new fields will go at the beginning of pt_regs will make >>> this an entertaining prospect. >> >> Good luck with all of that. > > We can always cheat like this: > > struct real_pt_regs { > unsigned long pkrs; > struct pt_regs regs; > }; > > and pass a pointer to regs around. What BPF doesn't know about can't hur= t it. Yes, but that's the easy part of the problem :) Thanks, tglx