Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp165997ybt; Mon, 6 Jul 2020 06:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNCtsdRDkEz3egGyF/Gdd/32md/EeTIbApu4//aii0FK/0rdQth0Msvckz0/vor3JaCL/P X-Received: by 2002:a17:906:e91:: with SMTP id p17mr36751126ejf.252.1594042669072; Mon, 06 Jul 2020 06:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594042669; cv=none; d=google.com; s=arc-20160816; b=qNeDcWcd6+NEGMl84HfpTdY5/Xk9GwkkLdSDPEgWdHs+L6puPrWpFhSPkAPrjpwwdl E7zCFSbmqRKmOhNUbeC+Hs2htybk8AbhPSlmKin5wZ6hWiZXSE7gqaIIglCwjV3ot2/H GcuhnbnVj6Orz2AfnkCQpQtKbsfit6J4XAIyNCUtAQx4HsCqNk7yqsiq2Wjj0k1e/D1I tRIxRRpeXw/yzWqrOjb6AThiOyk1/a5q4c+j/kWN898gf+U/ThVnDot3x7FZzveZ9k5P lycsLFVSR1JmH/H3ExmgWMa8qrTUH7PyiI6fq6k+OE7u3clpq4UIyWb5yd30EuZFP8VR 4TFw== 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=2i10p3zHZtcsjkGHAB08tLjw+aVWWu3Y8lozHTN4nT4=; b=xp1vw+qmj5p3hALCgQBeosTeuPdnK9uJwt8iOYg3L5YSYIiFJyzxCEb53zupVcPl1W vO+oLLKs91AAaMInkQnIkgePxTnrVV47D+6lDyvxfg4ye4Ptywx1CG30mbWZnJBanqx7 w9+MF+a2gnew2silihIgePonEbexl9VdsbR9jWltFK6fKf3vumvKesfN7gCSARd7x1JX pyMmRThret98zJ6kOPJYi/w8rARZP9fHDkwPMUbAZaqXpHNoB84aZBTO0j4wCC9WgXqq zmc01aYDTsU2Vd2Zh29w4/m98n7XGu3F89NgsET22XLP0aX80HiO77DhqWSo6N5eiFlH dvcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=fgGjNz47; 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.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si13538794edp.327.2020.07.06.06.37.26; Mon, 06 Jul 2020 06:37:49 -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.com header.s=amazon201209 header.b=fgGjNz47; 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.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729589AbgGFNgV (ORCPT + 99 others); Mon, 6 Jul 2020 09:36:21 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:47682 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729286AbgGFNgU (ORCPT ); Mon, 6 Jul 2020 09:36:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1594042580; x=1625578580; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=2i10p3zHZtcsjkGHAB08tLjw+aVWWu3Y8lozHTN4nT4=; b=fgGjNz476DaX64NiLwtNO4Bg6y6hbcF/PUW8H76UhiDE0Au2RWLrNNGd XtRT02LZ9aepgdlv7hTZlhYFtYPRjg5jkT1GKdySZ5/4tRh9az7MdM2UK /t8jnwqQdeQo5aZ/+P6qTLhmsF7QH4MceubEpbaxN7cG1C5T7fV81PYTV o=; IronPort-SDR: csDJiQyAkPskSeMUpPzF9fAUTAf4fh+mx6xOBL18dP1Zb4OYcfjJ1z+U4xy36E64H9kombM0A3 pZiFB/GlFtmg== X-IronPort-AV: E=Sophos;i="5.75,320,1589241600"; d="scan'208";a="41679877" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-87a10be6.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 06 Jul 2020 13:35:50 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2c-87a10be6.us-west-2.amazon.com (Postfix) with ESMTPS id 89A01A15CA; Mon, 6 Jul 2020 13:35:47 +0000 (UTC) Received: from EX13D16EUB001.ant.amazon.com (10.43.166.28) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 6 Jul 2020 13:35:46 +0000 Received: from 38f9d34ed3b1.ant.amazon.com (10.43.160.26) by EX13D16EUB001.ant.amazon.com (10.43.166.28) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 6 Jul 2020 13:35:37 +0000 Subject: Re: [PATCH v4 10/18] nitro_enclaves: Add logic for enclave image load info To: Alexander Graf , 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> <817700cd-1db2-558b-ae62-fdb279bca6ed@amazon.de> From: "Paraschiv, Andra-Irina" Message-ID: Date: Mon, 6 Jul 2020 16:35:27 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <817700cd-1db2-558b-ae62-fdb279bca6ed@amazon.de> Content-Language: en-US X-Originating-IP: [10.43.160.26] X-ClientProxiedBy: EX13D16UWB002.ant.amazon.com (10.43.161.234) To EX13D16EUB001.ant.amazon.com (10.43.166.28) 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 06/07/2020 13:16, Alexander Graf wrote: > > > 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. >> --- >> =A0 drivers/virt/nitro_enclaves/ne_misc_dev.c | 25 +++++++++++++++++++++= ++ >> =A0 1 file changed, 25 insertions(+) >> >> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c = >> b/drivers/virt/nitro_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, = >> unsigned int cmd, >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 return rc; >> =A0=A0=A0=A0=A0 } >> =A0 +=A0=A0=A0 case NE_GET_IMAGE_LOAD_INFO: { >> +=A0=A0=A0=A0=A0=A0=A0 struct ne_image_load_info image_load_info =3D {}; >> + >> +=A0=A0=A0=A0=A0=A0=A0 if (copy_from_user(&image_load_info, (void *)arg, >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sizeof(image_loa= d_info))) { >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 dev_err_ratelimited(ne_misc_dev.this_= device, >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "= Error in copy from user\n"); > > The -EFAULT tells you all you need. Just remove this print. Removed the log from here and the other occurrences in the patch series. Thanks, Andra > >> + >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return -EFAULT; >> +=A0=A0=A0=A0=A0=A0=A0 } >> + >> +=A0=A0=A0=A0=A0=A0=A0 if (image_load_info.flags =3D=3D NE_EIF_IMAGE) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 image_load_info.memory_offset =3D NE_= EIF_LOAD_OFFSET; >> + >> +=A0=A0=A0=A0=A0=A0=A0 if (copy_to_user((void *)arg, &image_load_info, >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sizeof(image_load_info= ))) { >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 dev_err_ratelimited(ne_misc_dev.this_= device, >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "= Error in copy to user\n"); > > Same here. > > > Alex > >> + >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return -EFAULT; >> +=A0=A0=A0=A0=A0=A0=A0 } >> + >> +=A0=A0=A0=A0=A0=A0=A0 return 0; >> +=A0=A0=A0 } >> + >> =A0=A0=A0=A0=A0 default: >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 return -ENOTTY; >> =A0=A0=A0=A0=A0 } >> Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar= Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in R= omania. Registration number J22/2621/2005.