Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3823942ybt; Tue, 30 Jun 2020 11:55:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxbOJBmEPJ6iLVpDBjlDp71ntlwpnHdCUYpWNE6akTJr4tZcREqG7AikarvJtFL2pjilT8 X-Received: by 2002:a17:907:4420:: with SMTP id om24mr10152380ejb.10.1593542955380; Tue, 30 Jun 2020 11:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593542955; cv=none; d=google.com; s=arc-20160816; b=WwqYa4GOfW+RDsXVhI87m+EXUhoOhrRPGttd74L0Bjo+noE5MBL+2/R6Zc7pC0ZDF4 WfjGWZKXAnUJXQx/1+125I24UFuGJ5lbX6EVAQ8zmP1O/wt7oj91k+j50mNp2xE6yzKb QwePq46Cy3b0j3k8u3bByvKRKATvowk8vP3ZBh/+/jUQrCK3r9NDzF9RdtaYDOGl6sAE iY5GsC8hgKSUv38OVj8sDlVNTOR6Q0lc2gOS85UZJlN92sD7PbelUOD/5S7ddnXst0sC 4bkXJZIfZYjJiybIOWZPNYjjVYZZpbbpl6jXcC541tIEqwSWNYD6xzjy98zhsk0w7B7H ZXpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=JvJNYxyssKZymBHOtO5mwD1fFbPH0bfWxJbm9w3VMoQ=; b=uoiqT/77V/kLPbBR4+qR9KrJfJ2nBI5gdluuesM4tieNQyEw1kcfSQhjlIQeZfayn7 xwARv9C6UIbWtvXSP1Dw3INMeRm/Ar3J1hAf6KcDNiWqA0oQyC1aIk3DjXz1C5hcujY2 eP55OMgvQgqhVmzQuEfuI2FZAexv5IyQczQdsVQfxTUJsby3JtHwHSIoxaZlu/Jl2m4b SKPxcvAt/ocPuY4Izz5nQT4lzJlmV5C3coSS4PoqsDjrBhuToXSlOjnAnC4JU/aXizeC UWmZ0qKwWXn73CWNIIhmkbtTGwZKUsNCz2Z23cHY0GQmZ0oHRfF3ybIVj3m1RabNv2Gs 6Rkw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y97si2555746ede.234.2020.06.30.11.48.53; Tue, 30 Jun 2020 11:49:15 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390288AbgF3RX3 (ORCPT + 99 others); Tue, 30 Jun 2020 13:23:29 -0400 Received: from mga12.intel.com ([192.55.52.136]:62758 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390282AbgF3RX2 (ORCPT ); Tue, 30 Jun 2020 13:23:28 -0400 IronPort-SDR: RyxdjboNfOtYfgJ2tVyG41C5M8cXaIW7ZRoFcJqKR1uJUQjXNWiXPehUAQkZiNyYubfrYULwGF y6CbBMsR271A== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="125950840" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="125950840" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 10:23:05 -0700 IronPort-SDR: W+mmP8TYMf1/apOyssk6Ri4mYct5mOVaSAKhe3R5djAYh93yFp9VzXdXk3HMjAKgXjFgpD3mGz LZ+gZniJyIKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="481003583" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by fmsmga006.fm.intel.com with ESMTP; 30 Jun 2020 10:23:05 -0700 Date: Tue, 30 Jun 2020 10:23:05 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Borislav Petkov , Jarkko Sakkinen , X86 ML , linux-sgx@vger.kernel.org, LKML , Jethro Beekman , Andrew Morton , Andy Shevchenko , asapek@google.com, "Xing, Cedric" , chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, Dave Hansen , "Huang, Haitao" , Josh Triplett , "Huang, Kai" , "Svahn, Kai" , kmoy@google.com, Christian Ludloff , Andrew Lutomirski , Neil Horman , npmccallum@redhat.com, puiterwijk@redhat.com, David Rientjes , Thomas Gleixner , yaozhangx@google.com Subject: Re: [PATCH v33 15/21] x86/vdso: Add support for exception fixup in vDSO functions Message-ID: <20200630172305.GG7733@linux.intel.com> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-16-jarkko.sakkinen@linux.intel.com> <20200629171022.GC32176@zn.tnic> <20200630060055.GS12312@linux.intel.com> <20200630084128.GA1093@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 09:48:22AM -0700, Andy Lutomirski wrote: > On Tue, Jun 30, 2020 at 1:41 AM Borislav Petkov wrote: > > > > On Mon, Jun 29, 2020 at 11:00:55PM -0700, Sean Christopherson wrote: > > > E.g. the vDSO function should get the fixup even if userspace screws > > > up mmap() and invokes __vdso_sgx_enter_enclave() without being tagged > > > an SGX task. > > > > I sincerely hope you don't mean this seriously. > > > > Please add a member to task_struct which denotes that a task is an > > sgx task, test that member where needed and forget real quickly about > > running *any* *fixup* for unrelated tasks. > > I don't see the problem. If you call this magic vDSO function and get > a fault, it gets handled. What's the failure mode? > > > > > > No hard dependency, it's normal kernel code. My reasoning for dropping it > > > in .../vdso was largely to co-locate it with vdso/extable.h due to the > > > dependency on the format of 'struct vdso_exception_table_entry'. > > > > A struct which you defined instead of simply using struct > > exception_table_entry even if it has a handler member which would remain > > unused? > > Don't forget the cross-arch issue. We need that structure to have > constant layout so that the -m32 build from the vDSO has the same > layout as in the kernel. > > So my only actual objection to the patch is that there should probably > be a comment above the structure reminding people that it needs to > have the same layout on 32-bit, x32, and x86_64. So maybe the entries > should be s32 instead of int, although this doesn't really matter. I highly doubt my past self thought about the cross-arch issue. The main reason I created 'struct vdso_exception_table_entry' is that interpretation of the fields is different. For the kernel, the fields contain offsets that are relative to the address of the field itself, i.e. of the fixup itself. For vDSO, the offsets are relative to the base of the vDSO. Reusing exception_table_entry felt like it would be all kinds of confusing.