From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C6A9C433E4 for ; Thu, 23 Jul 2020 22:14:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E383220768 for ; Thu, 23 Jul 2020 22:14:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="V5Z5Rq1n"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DpE/SglP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E383220768 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5D62D8D0002; Thu, 23 Jul 2020 18:14:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 585D78D0001; Thu, 23 Jul 2020 18:14:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49B7E8D0002; Thu, 23 Jul 2020 18:14:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 339598D0001 for ; Thu, 23 Jul 2020 18:14:33 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DC0898248047 for ; Thu, 23 Jul 2020 22:14:32 +0000 (UTC) X-FDA: 77070745584.23.grade83_07022d626f42 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id ADC8237043 for ; Thu, 23 Jul 2020 22:14:32 +0000 (UTC) X-HE-Tag: grade83_07022d626f42 X-Filterd-Recvd-Size: 4352 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Jul 2020 22:14:31 +0000 (UTC) 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 X-Rspamd-Queue-Id: ADC8237043 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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