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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 71D21C433E0 for ; Thu, 23 Jul 2020 20:22:14 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 40CDA20792 for ; Thu, 23 Jul 2020 20:22:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3w6pydta"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="S6pO3lE+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40CDA20792 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 076EC1252040F; Thu, 23 Jul 2020 13:22:14 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a0a:51c0:0:12e:550::1; helo=galois.linutronix.de; envelope-from=tglx@linutronix.de; receiver= Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BA5D81251E233 for ; Thu, 23 Jul 2020 13:22:07 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595535725; 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=xUfejVCnGJSFUxx4AbkzbVJFCZGcWbz/N8REfPWxQoU=; b=3w6pydta60AUDlW71ctlUmfCuxjZwrDBjdn+FnMylpeeRNx3lZdxfaaRT4irOoFTC9CUuh PXbbNu0NFQnT2ebz/rTRFFus4A56eVJaHT1Nku6xPVzKWr5/EfpxjeqXE2M8OHYK60mpNZ G/1vehBDzGDMsOv9JDLd9t0ZwgJq18uO4GXkwYlXX/XavlQ/d8MeiixW8yeG71ll4tXpXy OSNidJ+vtacBscsslNQRCmpPO3hM5Ayd5CFQN/LEVQ+5TWmlgprge1xI1euwEayu59G88G Yr4RymiC2f4ktP3jTZXWmeO9OG2t4cANxrJrr3YILRR0osb7reG9Ymiqqc1/bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595535725; 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=xUfejVCnGJSFUxx4AbkzbVJFCZGcWbz/N8REfPWxQoU=; b=S6pO3lE+IfHj3HhkeQ26FcQansBJxu9GNSfmIP0x4haRe07iB3E2Ls0tYUMfsjoVnW9XRq EEpNr2bboZIhELDQ== To: Andy Lutomirski , Fenghua Yu 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> Date: Thu, 23 Jul 2020 22:22:04 +0200 Message-ID: <87imeevv6b.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Message-ID-Hash: FBS5RK23BJJJBLGSQIVEX3RI4EW7UZNO X-Message-ID-Hash: FBS5RK23BJJJBLGSQIVEX3RI4EW7UZNO X-MailFrom: tglx@linutronix.de X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Dave Hansen , Andy Lutomirski , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Dave Hansen , X86 ML , Andrew Morton , "open list:DOCUMENTATION" , LKML , linux-nvdimm , Linux FS Devel , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 QW5keSBMdXRvbWlyc2tpIDxsdXRvQGFtYWNhcGl0YWwubmV0PiB3cml0ZXM6DQoNCj4gU3VwcG9z ZSBzb21lIGtlcm5lbCBjb2RlIChhIHN5c2NhbGwgb3Iga2VybmVsIHRocmVhZCkgY2hhbmdlcyBQ S1JTDQo+IHRoZW4gdGFrZXMgYSBwYWdlIGZhdWx0LiBUaGUgcGFnZSBmYXVsdCBoYW5kbGVyIG5l ZWRzIGEgZnJlc2gNCj4gUEtSUy4gVGhlbiB0aGUgcGFnZSBmYXVsdCBoYW5kbGVyIChzYXkgYSBW TUHigJlzIC5mYXVsdCBoYW5kbGVyKSBjaGFuZ2VzDQo+IFBLUlMuICBUaGUgd2UgZ2V0IGFuIGlu dGVycnVwdC4gVGhlIGludGVycnVwdCAqYWxzbyogbmVlZHMgYSBmcmVzaA0KPiBQS1JTIGFuZCB0 aGUgcGFnZSBmYXVsdCB2YWx1ZSBuZWVkcyB0byBiZSBzYXZlZCBzb21ld2hlcmUuDQo+DQo+IFNv IHdlIGhhdmUgbW9yZSB0aGFuIG9uZSBzYXZlZCB2YWx1ZSBwZXIgdGhyZWFkLCBhbmQgdGhyZWFk X3N0cnVjdA0KPiBpc27igJl0IGdvaW5nIHRvIHNvbHZlIHRoaXMgcHJvYmxlbS4NCg0KQSBzdGFj ayBvZiA3IGVudHJpZXMgYW5kIGFuIGluZGV4IG5lZWRzIDMyYnl0ZXMgdG90YWwgd2hpY2ggaXMg YQ0KcmVhc29uYWJsZSBhbW91bnQgYW5kIHNvbHZlcyB0aGUgcHJvYmxlbSBpbmNsdWRpbmcgc2No ZWR1bGluZyBmcm9tICNQRg0KbmljZWx5LiBNYWtlIGl0IDE1IGFuZCBpdCdzIHN0aWxsIG9ubHkg NjQgYnl0ZXMuDQoNCj4gQnV0IGlkdGVudHJ5X3N0YXRlIGlzIGFsc28gbm90IGdyZWF0IGZvciBh IGNvdXBsZSByZWFzb25zLiAgTm90IGFsbA0KPiBlbnRyaWVzIGhhdmUgaWR0ZW50cnlfc3RhdGUs IGFuZCB0aGUgdW53aW5kZXIgY2Fu4oCZdCBmaW5kIGl0IGZvcg0KPiBkZWJ1Z2dpbmcuIEZvciB0 aGF0IG1hdHRlciwgdGhlIHBhZ2UgZmF1bHQgbG9naWMgcHJvYmFibHkgd2FudHMgdG8NCj4ga25v dyB0aGUgcHJldmlvdXMgUEtSUywgc28gaXQgc2hvdWxkIGVpdGhlciBiZSBzdGFzaGVkIHNvbWV3 aGVyZQ0KPiBmaW5kYWJsZSBvciBpdCBzaG91bGQgYmUgZXhwbGljaXRseSBwYXNzZWQgYXJvdW5k Lg0KPg0KPiBNeSBzdWdnZXN0aW9uIGlzIHRvIGVubGFyZ2UgcHRfcmVncy4gIFRoZSBzYXZlIGFu ZCByZXN0b3JlIGxvZ2ljIGNhbg0KPiBwcm9iYWJseSBiZSBpbiBDLCBidXQgcHRfcmVncyBpcyB0 aGUgbG9naWNhbCBwbGFjZSB0byBwdXQgYSByZWdpc3Rlcg0KPiB0aGF0IGlzIHNhdmVkIGFuZCBy ZXN0b3JlZCBhY3Jvc3MgYWxsIGVudHJpZXMuDQoNCktpbmRhLCBidXQgdGhhdCBzdGlsbCBzdWNr cyBiZWNhdXNlIHNjaGVkdWxlIGZyb20gI1BGIHdpbGwgZ2V0IGl0IHdyb25nDQp1bmxlc3MgeW91 IGRvIGV4dHJhIG5hc3RpZXMuDQoNCj4gV2hvZXZlciBkb2VzIHRoaXMgd29yayB3aWxsIGhhdmUg dGhlIGRlbGlnaHRmdWwgam9iIG9mIGZpZ3VyaW5nIG91dA0KPiB3aGV0aGVyIEJQRiB0aGlua3Mg dGhhdCB0aGUgbGF5b3V0IG9mIHB0X3JlZ3MgaXMgQUJJIGFuZCwgaWYgc28sDQo+IGZpeGluZyB0 aGUgcmVzdWx0aW5nIG1lc3MuDQo+DQo+IFRoZSBmYWN0IHRoZSBuZXcgZmllbGRzIHdpbGwgZ28g YXQgdGhlIGJlZ2lubmluZyBvZiBwdF9yZWdzIHdpbGwgbWFrZQ0KPiB0aGlzIGFuIGVudGVydGFp bmluZyBwcm9zcGVjdC4NCg0KR29vZCBsdWNrIHdpdGggYWxsIG9mIHRoYXQuDQoNClRoYW5rcywN Cg0KICAgICAgICB0Z2x4Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fCkxpbnV4LW52ZGltbSBtYWlsaW5nIGxpc3QgLS0gbGludXgtbnZkaW1tQGxpc3RzLjAx Lm9yZwpUbyB1bnN1YnNjcmliZSBzZW5kIGFuIGVtYWlsIHRvIGxpbnV4LW52ZGltbS1sZWF2ZUBs aXN0cy4wMS5vcmcK 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 07291C433EB for ; Thu, 23 Jul 2020 20:22:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD1CF20792 for ; Thu, 23 Jul 2020 20:22:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3w6pydta"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="S6pO3lE+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727979AbgGWUWI (ORCPT ); Thu, 23 Jul 2020 16:22:08 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:32790 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgGWUWH (ORCPT ); Thu, 23 Jul 2020 16:22:07 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595535725; 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=xUfejVCnGJSFUxx4AbkzbVJFCZGcWbz/N8REfPWxQoU=; b=3w6pydta60AUDlW71ctlUmfCuxjZwrDBjdn+FnMylpeeRNx3lZdxfaaRT4irOoFTC9CUuh PXbbNu0NFQnT2ebz/rTRFFus4A56eVJaHT1Nku6xPVzKWr5/EfpxjeqXE2M8OHYK60mpNZ G/1vehBDzGDMsOv9JDLd9t0ZwgJq18uO4GXkwYlXX/XavlQ/d8MeiixW8yeG71ll4tXpXy OSNidJ+vtacBscsslNQRCmpPO3hM5Ayd5CFQN/LEVQ+5TWmlgprge1xI1euwEayu59G88G Yr4RymiC2f4ktP3jTZXWmeO9OG2t4cANxrJrr3YILRR0osb7reG9Ymiqqc1/bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595535725; 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=xUfejVCnGJSFUxx4AbkzbVJFCZGcWbz/N8REfPWxQoU=; b=S6pO3lE+IfHj3HhkeQ26FcQansBJxu9GNSfmIP0x4haRe07iB3E2Ls0tYUMfsjoVnW9XRq EEpNr2bboZIhELDQ== To: Andy Lutomirski , Fenghua Yu Cc: 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> Date: Thu, 23 Jul 2020 22:22:04 +0200 Message-ID: <87imeevv6b.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: > Suppose some kernel code (a syscall or kernel thread) changes PKRS > then takes a page fault. The page fault handler needs a fresh > PKRS. Then the page fault handler (say a VMA=E2=80=99s .fault handler) ch= anges > PKRS. The we get an interrupt. The interrupt *also* needs a fresh > PKRS and the page fault value needs to be saved somewhere. > > So we have more than one saved value per thread, and thread_struct > isn=E2=80=99t going to solve this problem. A stack of 7 entries and an index needs 32bytes total which is a reasonable amount and solves the problem including scheduling from #PF nicely. Make it 15 and it's still only 64 bytes. > But idtentry_state is also not great for a couple reasons. Not all > entries have idtentry_state, and the unwinder can=E2=80=99t find it for > debugging. For that matter, the page fault logic probably wants to > know the previous PKRS, so it should either be stashed somewhere > findable or it should be explicitly passed around. > > 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. > 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. Thanks, tglx 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 34CC2C433EC for ; Thu, 23 Jul 2020 20:22:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E301A207BB for ; Thu, 23 Jul 2020 20:22:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3w6pydta"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="S6pO3lE+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E301A207BB 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 479166B000E; Thu, 23 Jul 2020 16:22:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 428426B0010; Thu, 23 Jul 2020 16:22:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33F0E8D0002; Thu, 23 Jul 2020 16:22:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 1EC236B000E for ; Thu, 23 Jul 2020 16:22:09 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AF4A9180AD83A for ; Thu, 23 Jul 2020 20:22:08 +0000 (UTC) X-FDA: 77070462336.15.rub58_2b11dbd26f41 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 7C01918001C0A for ; Thu, 23 Jul 2020 20:22:08 +0000 (UTC) X-HE-Tag: rub58_2b11dbd26f41 X-Filterd-Recvd-Size: 4411 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Jul 2020 20:22:07 +0000 (UTC) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595535725; 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=xUfejVCnGJSFUxx4AbkzbVJFCZGcWbz/N8REfPWxQoU=; b=3w6pydta60AUDlW71ctlUmfCuxjZwrDBjdn+FnMylpeeRNx3lZdxfaaRT4irOoFTC9CUuh PXbbNu0NFQnT2ebz/rTRFFus4A56eVJaHT1Nku6xPVzKWr5/EfpxjeqXE2M8OHYK60mpNZ G/1vehBDzGDMsOv9JDLd9t0ZwgJq18uO4GXkwYlXX/XavlQ/d8MeiixW8yeG71ll4tXpXy OSNidJ+vtacBscsslNQRCmpPO3hM5Ayd5CFQN/LEVQ+5TWmlgprge1xI1euwEayu59G88G Yr4RymiC2f4ktP3jTZXWmeO9OG2t4cANxrJrr3YILRR0osb7reG9Ymiqqc1/bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595535725; 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=xUfejVCnGJSFUxx4AbkzbVJFCZGcWbz/N8REfPWxQoU=; b=S6pO3lE+IfHj3HhkeQ26FcQansBJxu9GNSfmIP0x4haRe07iB3E2Ls0tYUMfsjoVnW9XRq EEpNr2bboZIhELDQ== To: Andy Lutomirski , Fenghua Yu Cc: 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> Date: Thu, 23 Jul 2020 22:22:04 +0200 Message-ID: <87imeevv6b.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: 7C01918001C0A 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: > Suppose some kernel code (a syscall or kernel thread) changes PKRS > then takes a page fault. The page fault handler needs a fresh > PKRS. Then the page fault handler (say a VMA=E2=80=99s .fault handler) ch= anges > PKRS. The we get an interrupt. The interrupt *also* needs a fresh > PKRS and the page fault value needs to be saved somewhere. > > So we have more than one saved value per thread, and thread_struct > isn=E2=80=99t going to solve this problem. A stack of 7 entries and an index needs 32bytes total which is a reasonable amount and solves the problem including scheduling from #PF nicely. Make it 15 and it's still only 64 bytes. > But idtentry_state is also not great for a couple reasons. Not all > entries have idtentry_state, and the unwinder can=E2=80=99t find it for > debugging. For that matter, the page fault logic probably wants to > know the previous PKRS, so it should either be stashed somewhere > findable or it should be explicitly passed around. > > 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. > 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. Thanks, tglx