Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp30187ybt; Mon, 6 Jul 2020 03:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV6o+Baol+AohoZFzkU3o+7nxGedb+2PVcYvxaFQMoLrddVARz2SjFFaFTfypjEB+0+0TZ X-Received: by 2002:a50:9e2e:: with SMTP id z43mr56192393ede.385.1594030645405; Mon, 06 Jul 2020 03:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594030645; cv=none; d=google.com; s=arc-20160816; b=d6Vv9JF652+mP3w52VAdb953n8m8y3Qhkee4dymU00gz5RdsBu9GDE/6Srru4WRPtB FWsQXHNzvvUcDr91GlK6Jqsekn5Coc3BIB5u9ZVOfAiQWQxguVeIDu6hkFyQ1DEe39Oh qxDw/GmrnUHmbKsPiIzMWvGh/0evbTHarTihh/tGyXTQv3Zdk+Esp62yDMQDf0dGWczf 1m1y+qw0jGrJghEbKjZbDydVqsHkmvMZRshHZwDP9QhwxggFwPFC078HbnTLkTFtkhlM uXOlO5M5hrRhR9+yf8qWRKDRbOeUrGQ9M4PLW67zNroiYzHj5NI7P3OgGGuLsJCw0oBt sarA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr :dkim-signature; bh=y00OdWof8B7hX3dUalznp6ro8iF6vV1F6rc05AqrTuo=; b=nm9n7K8hywzljYB+3It4dRJbI6bEi7kT2XlzE6MYWpzAX/NyIfTb5fHlEzIU3i7a9M k4K35yXRyvnQgFXlTYSclR1jMMhtLCsF8qLrAsN0d5eaRKYC802Q83nnKXOo4PYQS9U8 qEn3coypPXYREO95cNsCu4rh04K16MUxOIej2zS9fVtYRiIIbNFOlr2NvK+82b4oHRG/ rms7rXdZQ8JZBAU00Grilu1EsTSloQ1yvef3KAWf7ZNMDAsz7c+6eUyPH3zhAQTjRXns UFsF0Yy2zAkehjO2BLSCVrwIVYp5VNrI5k2PriTxqOceLFKVackUlo9sxVY5eifVIVQW g01A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=FVZleZOI; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si12933202eju.41.2020.07.06.03.17.02; Mon, 06 Jul 2020 03:17:25 -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=@amazon.de header.s=amazon201209 header.b=FVZleZOI; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728827AbgGFKQu (ORCPT + 99 others); Mon, 6 Jul 2020 06:16:50 -0400 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:14888 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728283AbgGFKQt (ORCPT ); Mon, 6 Jul 2020 06:16:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1594030609; x=1625566609; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=y00OdWof8B7hX3dUalznp6ro8iF6vV1F6rc05AqrTuo=; b=FVZleZOIqP4m68NM+Hy+GuOBL8/TgVokmGKBl7P7yDQ7Mlp6pZ9l19jF gj767n9GpYqRNbqnBhM81gtsocXj9pfNLiRR3UdfFp884a2GOqKPQW9S5 PRhERtMLMYs179LnxCXQ7HmzLAZl7XvaXDA0lsuDqs/WY/1KtnRE1TuIB w=; IronPort-SDR: 1kq6ENwe75TG9tIJtksKVDAXdmE/a6qJF4ZtUjVWQ1Cc+NGiwCJji5z2yR4HeYrSZ+J0zJSphh IG1N1Qj8jLHw== X-IronPort-AV: E=Sophos;i="5.75,318,1589241600"; d="scan'208";a="40182548" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 06 Jul 2020 10:16:48 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (Postfix) with ESMTPS id 1CB19A0719; Mon, 6 Jul 2020 10:16:46 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 6 Jul 2020 10:16:45 +0000 Received: from 38f9d3867b82.ant.amazon.com (10.43.160.156) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 6 Jul 2020 10:16:40 +0000 Subject: Re: [PATCH v4 10/18] nitro_enclaves: Add logic for enclave image load info To: Andra Paraschiv , CC: Anthony Liguori , Benjamin Herrenschmidt , Colm MacCarthaigh , "Bjoern Doebel" , David Woodhouse , "Frank van der Linden" , Greg KH , Martin Pohlack , Matt Wilson , "Paolo Bonzini" , Balbir Singh , "Stefano Garzarella" , Stefan Hajnoczi , Stewart Smith , Uwe Dannowski , , References: <20200622200329.52996-1-andraprs@amazon.com> <20200622200329.52996-11-andraprs@amazon.com> From: Alexander Graf Message-ID: <817700cd-1db2-558b-ae62-fdb279bca6ed@amazon.de> Date: Mon, 6 Jul 2020 12:16:31 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200622200329.52996-11-andraprs@amazon.com> Content-Language: en-US X-Originating-IP: [10.43.160.156] X-ClientProxiedBy: EX13D31UWC002.ant.amazon.com (10.43.162.220) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="windows-1252"; format="flowed" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22.06.20 22:03, Andra Paraschiv wrote: > Before setting the memory regions for the enclave, the enclave image > needs to be placed in memory. After the memory regions are set, this > memory cannot be used anymore by the VM, being carved out. > = > Add ioctl command logic to get the offset in enclave memory where to > place the enclave image. Then the user space tooling copies the enclave > image in the memory using the given memory offset. > = > Signed-off-by: Andra Paraschiv > --- > Changelog > = > v3 -> v4 > = > * Use dev_err instead of custom NE log pattern. > * Set enclave image load offset based on flags. > * Update the naming for the ioctl command from metadata to info. > = > v2 -> v3 > = > * No changes. > = > v1 -> v2 > = > * New in v2. > --- > drivers/virt/nitro_enclaves/ne_misc_dev.c | 25 +++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > = > diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nit= ro_enclaves/ne_misc_dev.c > index d6777008f685..cfdefa52ed2a 100644 > --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c > +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c > @@ -536,6 +536,31 @@ static long ne_enclave_ioctl(struct file *file, unsi= gned int cmd, > return rc; > } > = > + case NE_GET_IMAGE_LOAD_INFO: { > + struct ne_image_load_info image_load_info =3D {}; > + > + if (copy_from_user(&image_load_info, (void *)arg, > + sizeof(image_load_info))) { > + dev_err_ratelimited(ne_misc_dev.this_device, > + "Error in copy from user\n"); The -EFAULT tells you all you need. Just remove this print. > + > + return -EFAULT; > + } > + > + if (image_load_info.flags =3D=3D NE_EIF_IMAGE) > + image_load_info.memory_offset =3D NE_EIF_LOAD_OFFSET; > + > + if (copy_to_user((void *)arg, &image_load_info, > + sizeof(image_load_info))) { > + dev_err_ratelimited(ne_misc_dev.this_device, > + "Error in copy to user\n"); Same here. Alex > + > + return -EFAULT; > + } > + > + return 0; > + } > + > default: > return -ENOTTY; > } > = Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879