Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp39236imu; Fri, 14 Dec 2018 14:01:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wri8uK5Odj0zDgUbBC1y7vC61VeZhmEnPR5+hd2k58SUXquwB7kE4XiqrljKbqNIvJyxDO X-Received: by 2002:a65:5387:: with SMTP id x7mr4226156pgq.412.1544824909303; Fri, 14 Dec 2018 14:01:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544824909; cv=none; d=google.com; s=arc-20160816; b=FQxmBJvDNoPC8JVbd/rBociRIPnPNS31lrwbJ5iZpPi4IbfMZii892Ur3sY3FEyhzb GfAqWUYLqX2FKgdWH29GpDlM8B61eGG/CelxuUiXLPatNZrqiM7d5KtAEwdLL+2APPht 6m1nmRm/QYZv137LMdX/4B2I/xkVaZJNUA8c6DK/Dfp/Z3mvB4AOtypeeFiyHwXD2KXW LJDnmq2uP0SyeW3ed3GPCFb5Ymcm6TjQPrkxwAXrcz1YX0JbTpEXcAzvgYhXaHl1kjPI sUHojD0xJBfp8AQtxfcFNu+8ZMLkiXS/+mE9IhXgtpmzTz6/oSEY6TFjuOzhDzROATP+ OOYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=s5HvuwmPspxxfDVZh6KxZlLztSEM7fRKbdSuD35ea8E=; b=Th2D7oKs4bYZ3Py6ZAWKuUEzHLghCFU5Wh5qcWfS1o12cKPRmOV5KLI1Glqp2/CVHG Tvazd0uMiHrjF22FXUUtPAO1crbF5xT7mtFh4le3gS7LRuKSlPt9TMlhkuhx51c1TzRh F4owlkV5T/tfCY6ajtfCB1nfzRDLSERkbb2NwC9vKg7USo/77dWKgebflkqPBUxqMRh/ d3PV3ERQI0Rv8OyQfryqGdtsG0Xsk9mP4Gs4yvpCkGxq/op80uyHLXCHUiUYehYMx60w /nEbBFHbdx4VYnPKSfr8rlDtQ4jhRFGcwSW9GGRt8t7HoETLgLCyqQV9Hl6xevJ2nMFo uq4A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o27si5052554pgl.53.2018.12.14.14.01.34; Fri, 14 Dec 2018 14:01:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731247AbeLNV5d (ORCPT + 99 others); Fri, 14 Dec 2018 16:57:33 -0500 Received: from mga01.intel.com ([192.55.52.88]:13309 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731020AbeLNV5d (ORCPT ); Fri, 14 Dec 2018 16:57:33 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2018 13:57:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,354,1539673200"; d="scan'208";a="118650661" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by FMSMGA003.fm.intel.com with ESMTP; 14 Dec 2018 13:57:31 -0800 From: Sean Christopherson To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Dave Hansen , Peter Zijlstra , Jarkko Sakkinen Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, Andy Lutomirski , Josh Triplett , Haitao Huang , Jethro Beekman , "Dr . Greg Wettstein" Subject: [RFC PATCH v5 0/5] x86: Add vDSO exception fixup for SGX Date: Fri, 14 Dec 2018 13:57:24 -0800 Message-Id: <20181214215729.4221-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __vdso_sgx_enter_enclave() gets another rewrite, this time to strip it down to the bare minimum and explicitly break compliance with the x86-64 ABI. Feedback from v4 revealed that __vdso_sgx_enter_enclave() would need to save (a lot) more than just the non-volatile GPRs to be compliant with the x86-64 ABI, at which point breaking from the ABI completely became much more palatable. The non-standard ABI also solves the question of "which GPRs should be marshalled to/from the enclave" by getting out of the way entirely and letting userspace have free reign (except for RSP, which has a big ol' DO NOT TOUCH sign on it). [1] https://lkml.kernel.org/r/cda13cff-1a56-a40f-7d69-f0f1ab752f8e@fortanix.com v1: https://lkml.kernel.org/r/20181205232012.28920-1-sean.j.christopherson@intel.com v2: https://lkml.kernel.org/r/20181206221922.31012-1-sean.j.christopherson@intel.com v3: https://lkml.kernel.org/r/20181210232141.5425-1-sean.j.christopherson@intel.com v4: https://lkml.kernel.org/r/20181213213135.12913-1-sean.j.christopherson@intel.com v5: - Strip down __vdso_sgx_enter_enclave() so it only touches RSP and GPRs that are already collateral damage of ENCLU[EENTER/ERESUME]. - Add a 16-byte reserved field to 'struct sgx_enclave_exception' so the struct can grow in a backwards compatible fashion. - Add a blurb at the end of the changelog for patch 1/5 explaining why the vDSO fixup macros look different than the equivalent kernel macros. Sean Christopherson (5): x86/vdso: Add support for exception fixup in vDSO functions x86/fault: Add helper function to sanitize error code x86/fault: Attempt to fixup unhandled #PF on ENCLU before signaling x86/traps: Attempt to fixup exceptions in vDSO before signaling x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitions arch/x86/entry/vdso/Makefile | 6 +- arch/x86/entry/vdso/extable.c | 37 +++++++++ arch/x86/entry/vdso/extable.h | 29 +++++++ arch/x86/entry/vdso/vdso-layout.lds.S | 9 ++- arch/x86/entry/vdso/vdso.lds.S | 1 + arch/x86/entry/vdso/vdso2c.h | 58 ++++++++++++-- arch/x86/entry/vdso/vsgx_enter_enclave.S | 97 ++++++++++++++++++++++++ arch/x86/include/asm/vdso.h | 5 ++ arch/x86/include/uapi/asm/sgx.h | 18 +++++ arch/x86/kernel/traps.c | 14 ++++ arch/x86/mm/fault.c | 33 +++++--- 11 files changed, 284 insertions(+), 23 deletions(-) create mode 100644 arch/x86/entry/vdso/extable.c create mode 100644 arch/x86/entry/vdso/extable.h create mode 100644 arch/x86/entry/vdso/vsgx_enter_enclave.S -- 2.19.2