Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1628imu; Thu, 6 Dec 2018 14:52:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xw01FhZUnuuhnPtC4U6U4WMSqew10x+FWP2g5UGSvgVJ/BAk+nZ2g9jw1Uzlm0cQeL4Amz X-Received: by 2002:a17:902:2c03:: with SMTP id m3mr31201246plb.125.1544136765265; Thu, 06 Dec 2018 14:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544136765; cv=none; d=google.com; s=arc-20160816; b=DfSiXHrcvE+VUDXyMROkxzpfTsXZlWuU4MkRRfVbhxKh4cvw3VPBsNgGDQ2K7b2KGd 6+bEqFFWZjaMjZrgbV805y/+xa2CjwKt6qxDG0mjO3ThlBG+5/Z412QotoZgvUrtGdVx xH/vt0VNkUweHavptFNQKO9D2ZqThSUY+2IZQOlUCLiC7GiMSyTtV4CnS1xAZSQnuiNj LT3/kJuuqlvPmJiw7Px3yQfAy0MxNSZpVAPat4KY3Qj4qwDBOh2iZF+2D72fnahQRaYR lO3xLKKnTJvJU4zC6Slw2Mpxk/CbcecKdnEmAIR/7cJaNaY+0Y6P/3NC/98lZgWx8sQt XLcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FckNcChf/RG82Cz3pruvCv8cgNyx5qr9tX7G3pLN82I=; b=zILFfUtEUaPbwC3xiSbwfWVI/XmW+nbArTA0DhDfCIuCSrX1z08N+fOFqJN/D23/vU TjbCYkj+fMwMPlxjW6duJBURkszE4SKzVB2Y30Ah3Bifj0yzkxkEDWEcvt9iBVUFNeD/ t7Ca6ikcjsHHO1Xh7pZC2pPcD9+E5v4pvJZ0IIJhGB2MJhfp9xhyBVhIbvjg/7q+zFOc Rjw+qllwGMWwNKUsoPhd11YVp4OOqjZWnnshpchWyPXmvZxCDaMTTVTnBQHwz0/fNRqF URimEb+tWmUEVxjTQVO4wdPD/3I9UceWj6gi0rjhQLnmVZZO9tUQkhSUgvUrreGsORIK c2bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qtwMkMiq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12si1362623pfg.155.2018.12.06.14.52.18; Thu, 06 Dec 2018 14:52:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qtwMkMiq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726170AbeLFWuP (ORCPT + 99 others); Thu, 6 Dec 2018 17:50:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:51558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbeLFWuP (ORCPT ); Thu, 6 Dec 2018 17:50:15 -0500 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 739A22146F for ; Thu, 6 Dec 2018 22:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544136614; bh=AQDugY4nh3/WNirV89dHDsIWcEG+qqLLrGxAqtmhGg0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qtwMkMiqGmD4sn/YpTuY7waRurt2pt8Y7YT0fT5i70HPb2mlGoVS0hZbylQIZRlrH UtWxgouacE2betUG0w+2vhHt1SdyIPa2WkZy6Epdf1jrVFmPKcxdnf2XsR+LNWjKPg i5yEfbD3ipR3fo8YfzyNtTNEQoNE8k/BG1oQjWW4= Received: by mail-wr1-f46.google.com with SMTP id x10so2051517wrs.8 for ; Thu, 06 Dec 2018 14:50:14 -0800 (PST) X-Gm-Message-State: AA+aEWYklLIkEPFeige9dLvG8tG6fG1Pb9Yr54IZSYlmcZzgJuuGI/Bl bP2iNtXwFr4hwnMNOvTXTjPYfyE/sTihnmuVOZLYLg== X-Received: by 2002:adf:ea81:: with SMTP id s1mr26135004wrm.309.1544136612955; Thu, 06 Dec 2018 14:50:12 -0800 (PST) MIME-Version: 1.0 References: <20181206221922.31012-1-sean.j.christopherson@intel.com> <20181206221922.31012-5-sean.j.christopherson@intel.com> In-Reply-To: <20181206221922.31012-5-sean.j.christopherson@intel.com> From: Andy Lutomirski Date: Thu, 6 Dec 2018 14:50:01 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 4/4] x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitions To: "Christopherson, Sean J" Cc: Andrew Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Dave Hansen , Peter Zijlstra , "H. Peter Anvin" , LKML , Jarkko Sakkinen , Josh Triplett Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 6, 2018 at 2:19 PM Sean Christopherson wrote: > + > + /* > + * Invoke the caller's exit handler if one was provided. The return > + * value tells us whether to re-enter the enclave (EENTER or ERESUME) > + * or to return (EEXIT). > + */ > + if (exit_handler) { > + leaf = exit_handler(exit_info, tcs, priv); > + if (leaf == SGX_EENTER || leaf == SGX_ERESUME) > + goto enter_enclave; > + if (leaf == SGX_EEXIT) > + return 0; > + return -EINVAL; > + } else if (leaf != SGX_EEXIT) { > + return -EFAULT; > + } This still seems overcomplicated to me. How about letting the requested leaf (EENTER or ERESUME) be a parameter to the function and then just returning here? As it stands, you're requiring any ERESUME that gets issued (other than the implicit ones) to be issued in the same call stack, which is very awkward if you're doing something like forwarding the fault to a different task over a socket and then waiting in epoll_wait() or similar before resuming the enclave. --Andy