Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3004359ybt; Mon, 29 Jun 2020 12:39:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqsC/hB5tpeQT2eb82JAWA4R/BCGh6vZzulpCzTd+3dEWpJZdsyHDM9nFwzlpjHSYHtVbD X-Received: by 2002:a17:906:c083:: with SMTP id f3mr9723813ejz.530.1593459590576; Mon, 29 Jun 2020 12:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593459590; cv=none; d=google.com; s=arc-20160816; b=Aq0Qgt3BjpqymBv7yi1MjHU8Tul3j7O+8oyuzS/fcZ53aeJYTKq5RDtcKc684+nvwT 18oK93vsw4QNym5DIOD9Zskv5G2dOY61RFXTeZf4UHmflF4Q48eJn9EDIn4pizA1TFsY 478Eq5fkpAd5teJdaQCzDqYqjRogtjnSKU3mSy4SuszDGVEFb6GqvyTWm0fHsGdUVzJ6 qOMmt6xQuryGyD4ZVjTBfuJMlioTcl3klP/eqC1UqudZgCRouGZe8a0nB0nAelSPL/Zs y5XWHEuVqnVu4wlP3rXHAqMIffylTnXsoRWKNN/W0a7Z8jRLIjFK/1LmRkFnJ+cUUVpT Ayfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=j5hXS9nvnbM+fSpieFZ04v4XNRE7FJsxEX2ec96mQh0=; b=r5jeqjSR9k6I6TBp4R70UuDOvaAvWXRU49fI9ybSThw7znKlxBHN0fHJmk74z66qzt uVpJthn2NlK/KyrtHSHQGTbbgPK6rljgZ8e3HRAK0WqXVKg9MdJggcXsFo9rxNVX+w/x o/brJYF6SdaLoiaLKhHbr4DAQ++lK78J4wUjA/truGHEp7vFOLYMaYK7pdIuIQhEpa3T m07wJ/kYa8XGY8vd67V45OU1QVYixZAPaMQ3e29gg7RugG/pUYwkZHS/0a17cBlDgHZ8 CfEPDDbFr2FVsRsEPisfOCV/95nGQFuw3eVAX0c65Wf2AuyZ3h91pgbg7fr1UOv+eV/l 7fbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=OBaDehdl; 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=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si326468eju.177.2020.06.29.12.39.27; Mon, 29 Jun 2020 12:39:50 -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=@alien8.de header.s=dkim header.b=OBaDehdl; 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=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733016AbgF2TjO (ORCPT + 99 others); Mon, 29 Jun 2020 15:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387433AbgF2Thn (ORCPT ); Mon, 29 Jun 2020 15:37:43 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04EB2C03140B; Mon, 29 Jun 2020 10:10:29 -0700 (PDT) Received: from zn.tnic (p200300ec2f092800b9efbf1c1ef2eddc.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:2800:b9ef:bf1c:1ef2:eddc]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4212D1EC01A9; Mon, 29 Jun 2020 19:10:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1593450628; 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:in-reply-to:in-reply-to: references:references; bh=j5hXS9nvnbM+fSpieFZ04v4XNRE7FJsxEX2ec96mQh0=; b=OBaDehdlg74vqOdiIcPbAbw5Rje/RWi1O7zVjWKP0EDqPqWqYFbl5qQ3gfCD/qW3lbLuO2 BSt1CvSrup/U1RHK89+BJnA9/J3LyWGRS3fY2Iw8AKeIt20+OAQpr0TTdx1kF342/Nq4a1 8yMJ4JH+A0CL+GRaITz21ZvbCvHu17Y= Date: Mon, 29 Jun 2020 19:10:22 +0200 From: Borislav Petkov To: Jarkko Sakkinen Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Andy Lutomirski , Jethro Beekman , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v33 15/21] x86/vdso: Add support for exception fixup in vDSO functions Message-ID: <20200629171022.GC32176@zn.tnic> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-16-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200617220844.57423-16-jarkko.sakkinen@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2020 at 01:08:37AM +0300, Jarkko Sakkinen wrote: ... > intended benefit of massaging GCC's inlining algorithm is unlikely to > realized in the vDSO any time soon, if ever. That is a very good explanation and I would prefer if it would be in a sgx-specific README or so instead of it getting lost in git... > +bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, > + unsigned long error_code, unsigned long fault_addr) > +{ > + const struct vdso_image *image = current->mm->context.vdso_image; > + const struct vdso_exception_table_entry *extable; > + unsigned int nr_entries, i; > + unsigned long base; > + > + /* > + * Do not attempt to fixup #DB or #BP. It's impossible to identify > + * whether or not a #DB/#BP originated from within an SGX enclave and > + * SGX enclaves are currently the only use case for vDSO fixup. > + */ So this is all fine and dandy but nowhere do I see the code doing: if (am_I_an_sgx_enclave(tsk)) fixup_vdso_exception() because that vDSO exception fixup, albeit it looking kinda generic, is SGX-only for now. So it should be designed to run only for SGX enclaves for now. Also, is there any particular reason for fixup_vdso_exception() to be in arch/x86/entry/vdso/extable.c instead of in arch/x86/mm/extable.c? I mean, it gets called by traps.c so it looks like normal kernel code to me or am I missing some vdso magic? And built only when CONFIG_INTEL_SGX is enabled. And so on... ... > diff --git a/arch/x86/entry/vdso/extable.h b/arch/x86/entry/vdso/extable.h > new file mode 100644 > index 000000000000..aafdac396948 > --- /dev/null > +++ b/arch/x86/entry/vdso/extable.h > @@ -0,0 +1,29 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __VDSO_EXTABLE_H > +#define __VDSO_EXTABLE_H > + > +/* > + * Inject exception fixup for vDSO code. Unlike normal exception fixup, > + * vDSO uses a dedicated handler the addresses are relative to the overall > + * exception table, not each individual entry. > + */ > +#ifdef __ASSEMBLY__ > +#define _ASM_VDSO_EXTABLE_HANDLE(from, to) \ > + ASM_VDSO_EXTABLE_HANDLE from to > + > +.macro ASM_VDSO_EXTABLE_HANDLE from:req to:req > + .pushsection __ex_table, "a" > + .long (\from) - __ex_table > + .long (\to) - __ex_table > + .popsection > +.endm > +#else > +#define _ASM_VDSO_EXTABLE_HANDLE(from, to) \ > + ".pushsection __ex_table, \"a\"\n" \ > + ".long (" #from ") - __ex_table\n" \ > + ".long (" #to ") - __ex_table\n" \ > + ".popsection\n" > +#endif > + > +#endif /* __VDSO_EXTABLE_H */ > + .git/rebase-apply/patch:122: new blank line at EOF. + Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette