Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3139940yba; Mon, 22 Apr 2019 21:06:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrK+powugTgWu5dbI+ciJ//b/t2TMbkP4cGClqTTfTIECPtkCvr8zU6I4Q+T3tidaJRpOm X-Received: by 2002:aa7:8384:: with SMTP id u4mr24033962pfm.214.1555992360384; Mon, 22 Apr 2019 21:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555992360; cv=none; d=google.com; s=arc-20160816; b=QUFEslVibtu/Mi3+/VcXBrM4mWoJUI+x7HqFceHa84Ks1RDy1zsDsv1uWuFF3Ioc4j /rrzPcijFhcLXFkU17RpvUifoXinEwMzhA+PBBLJNuPndWyBj23IUlkd4iUk6wZrW7YQ 4ARKh7xwEr/tBcZ86CbAhNZCtoCTmImhOxRaQ7iC0sXl1NYMsmkxwSPz2hL/pZtSnupL zOkyshlT66iWtFYHK2DgeVGailNH8yj9UTI9Uo9Ocfqh5itgJ7kLpz2qx4YSDVKFUJgS 4KNfoBMncDyDQ/SKXsbVzQ3Z6u7u0L5rpLTc8oa5CEFU1jTlz2tuQIe8M8EoESgJvIre wRoQ== 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=uxXD+QhDQL61f8VoNmjQs3eif5Y6EI2MjGwzzp7bP7w=; b=hRG3ziUp31R6HAghkRFl6V1pryzZKK6ZgWM5S6dOojTS9qg56iUwn0kiAkDOP9Vhei kojtK6HqZ6GNqCfkR5UPVQxxEHERC75V8tqzeHo3FwOuJmPifa3C15bxm8nb6iGV3ICk yS1OrQ8SMjbSDhuXaSc7hsfy3PR2rUtk+2/Z8sGchYIZfXMNkNnatFc6NI4IxnpJf3Ac bAh6a2TsxvBz2n3ygFXKQ/zxBin1towaEk/uCUhclPvZAYACMERdwfyuaElwTL7EadBd TeeRDZQtdOSDg7IzBKAUTJ+ZeuiPVd8TdSHIvUn4OCs5mw/DZGGz7ejUkekecd+9LS+z z9+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aSGVN8lr; 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 a2si13442725pgw.545.2019.04.22.21.05.45; Mon, 22 Apr 2019 21:06:00 -0700 (PDT) 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=aSGVN8lr; 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 S1728912AbfDWB3V (ORCPT + 99 others); Mon, 22 Apr 2019 21:29:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:39034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbfDWB3U (ORCPT ); Mon, 22 Apr 2019 21:29:20 -0400 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 92ACB20896 for ; Tue, 23 Apr 2019 01:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555982959; bh=rvvCXm3NyxcvTskwYMP3xXvK0tJlFtzpbaQipvChvCs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aSGVN8lrFJFVCqZG3Cwa8HwPqUbQeuTXHU5a14kpoVmKF5RRMNMelHOdg8DKEJybF 4f2w/V5O5AWtuBAPtse2H2uZdvNN8vOXSOmISQYTG4crIgXytNi0nTqJkysz2ZPYkr 79l+x6/5ZLvDL8M5tIMW5x5vnaM9Q3cuOOGE1rho= Received: by mail-wm1-f48.google.com with SMTP id h18so16530896wml.1 for ; Mon, 22 Apr 2019 18:29:19 -0700 (PDT) X-Gm-Message-State: APjAAAWQHBItyKn0skezdQEpu5id0HNynRXaXaKj+dITibGnLsBILvwR 61DMitFqd0qmyA65aTpXWOiSCSnMH1q53kDzLCILig== X-Received: by 2002:a1c:eb18:: with SMTP id j24mr230176wmh.32.1555982958011; Mon, 22 Apr 2019 18:29:18 -0700 (PDT) MIME-Version: 1.0 References: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> In-Reply-To: From: Andy Lutomirski Date: Mon, 22 Apr 2019 18:29:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v1 3/3] selftests/x86: Augment SGX selftest to test new __vdso_sgx_enter_enclave() and its callback interface To: Cedric Xing Cc: LKML , X86 ML , linux-sgx@vger.kernel.org, Andrew Morton , Dave , Sean J , nhorman@redhat.com, npmccallum@redhat.com, Serge , Shay , Haitao , Andy Shevchenko , Thomas Gleixner , Kai , Borislav Petkov , Josh Triplett , Andrew Lutomirski , Kai , David Rientjes , Jarkko Sakkinen 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 Mon, Apr 22, 2019 at 5:37 PM Cedric Xing wrote: > > Given the changes to __vdso_sgx_enter_enclave(), the selftest is augmented to > test the newly added callback interface. This addtional test marks the whole > enclave range as PROT_READ, and calls mprotect() upon #PFs to add necessary PTE > permissions per PFEC (#PF Error Code) until the enclave finishes. Nifty. What's not tested here is running this code with EFLAGS.TF set and making sure that it unwinds correctly. Also, Jarkko, unless I missed something, the vDSO extable code likely has a bug. If you run the instruction right before ENCLU with EFLAGS.TF set, then do_debug() will eat the SIGTRAP and skip to the exception handler. Similarly, if you put an instruction breakpoint on ENCLU, it'll get skipped. Or is the code actually correct and am I just remembering wrong? --Andy