Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp12981rwb; Thu, 22 Sep 2022 13:37:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7sh8O7pVcuGTjLIwNzaqi/FHQlPdJfdXdgSP1g9SuNYpGhSMmlwirTzQvhv8lnJsGFRAEr X-Received: by 2002:a65:6454:0:b0:434:a700:f0bf with SMTP id s20-20020a656454000000b00434a700f0bfmr4423230pgv.383.1663879053314; Thu, 22 Sep 2022 13:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663879053; cv=none; d=google.com; s=arc-20160816; b=HTcZT+jX718Q6fRGR9TWUFKU8V9/mhoUXF/UXFsG+bAmZ7WElpNVMLrR4y7NKT/uRa XU3GpBZjF6n+SJcd+vvXCkOYBzQBZ/CKYnFrI10zauLLsfmXUTvNkpZJFh//cmCaTVQN 0fhGUw59IfSmEV/BccvO3nEidrsW6xntpSrTMw4qQGwnQjsaD0gQg2s6GaF5nXY0l/f2 SkimwsSnU4U92qY8dFiTVqwONBs2rp2/ub/+M33kNl9Nb8cg3bMj9GmLnEYt54gs+mCm TkQWtW61Wn5VAak5qRYocK8Y6dyn2R+0mpySw5sKcsNsYt67G3c9wQ24D2F+3GlbTZZL n0Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=LqKxQwD0l5O908aJwulGuCrG/rPjtiSjbbyXhmh6sww=; b=YPD19fggjg5Rhhb/NBS987PZ6d/DpRWKqrXkqdDDdTUdM0ybaZpU0E3HFknqj+EmvZ BYVkaA19tOYMY+702Lg+Wf2wfo3lmxGPz9Ck2fb9wCdbyTLopu0sucvmUCLiSRjaQX/0 EBtgxkip8jGpeZpa+t82npVhlrk5NBVRcXcBYxfvRWVPaM29lB8asbLjB7io31Vm5hZR w6JaTvNRLGncwjVxmYKKBWAiyuYDiwJZqqvqmJUh7vzJjD2w1Hh5lJ3nXvUacARoNm7M mpWGNHkSrh9O3iRpWM9iEtymkNref2fOkuaDq3zvdGeZChgRDqp5wzHwzz+/qUTZS/lI g4kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OhzPvIpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a62e705000000b005352aeae657si6181828pfh.199.2022.09.22.13.37.01; Thu, 22 Sep 2022 13:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OhzPvIpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbiIVUEj (ORCPT + 99 others); Thu, 22 Sep 2022 16:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232950AbiIVUEK (ORCPT ); Thu, 22 Sep 2022 16:04:10 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 165B4B61; Thu, 22 Sep 2022 13:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663877049; x=1695413049; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=snMZXlvHgnKICyfiYSRp0+L0NsQopjCdJqHUvJECElM=; b=OhzPvIpT5wHKRKXAKyl96v8ABN6NTEQxwXxklkxeay6UEUXluO6k0SjB xGo28551Ni9gwkqZPnYqEjT1ibOKmBFc1Y12mzgkBcHjv5MvzLmmBEGeF 8IFZm18l91EMW38Xhz3hXwy4EcEIUpayRSjVaHc5Z+1EGiNUB0wa0WJPW 1jWVw7lD9Enc8RIuZRc7WhylGhXLMUzQgEI9rXTRvfCDlURDDXYD2G3ZF hdaMv/jbQOG3jlWe68w2yv9klpx8W79oq+cqgAuJUJuhQixBeXTHB4KBo +pf867bS3pJir3Xg/etJAzWNQZ/hA7hGh7nJoEsBvEjf9yCoBc949AOvy w==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="280141801" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="280141801" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 13:04:08 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="653129114" Received: from sknaidu-mobl1.amr.corp.intel.com (HELO [10.212.165.187]) ([10.212.165.187]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 13:04:07 -0700 Message-ID: Subject: Re: [RFC PATCH 03/20] x86/sgx: Track owning enclave in VA EPC pages From: Kristen Carlson Accardi To: Dave Hansen , linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: Sean Christopherson Date: Thu, 22 Sep 2022 13:04:06 -0700 In-Reply-To: <1adb03c8-1274-3898-0677-03015a1f5a5d@intel.com> References: <20220922171057.1236139-1-kristen@linux.intel.com> <20220922171057.1236139-4-kristen@linux.intel.com> <1adb03c8-1274-3898-0677-03015a1f5a5d@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2022-09-22 at 11:55 -0700, Dave Hansen wrote: > On 9/22/22 10:10, Kristen Carlson Accardi wrote: > > -struct sgx_epc_page *sgx_alloc_va_page(bool reclaim) > > +struct sgx_epc_page *sgx_alloc_va_page(struct sgx_encl *encl, bool > > reclaim) > > =C2=A0{ > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct sgx_epc_page *ep= c_page; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int ret; > > @@ -1218,6 +1219,8 @@ struct sgx_epc_page *sgx_alloc_va_page(bool > > reclaim) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0return ERR_PTR(-EFAULT); > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > =C2=A0 > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0epc_page->owner =3D encl; > > + > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return epc_page; > > =C2=A0} >=20 > BTW, is there a flag or any other way to tell to what kind of object > ->owner points? The owner will only be an sgx_encl type if it is a va page, so to tell what kind of object owner is, you look at the epc page flags - like this: if (epc_page->flags & SGX_EPC_PAGE_ENCLAVE) encl =3D ((struct sgx_encl_page *)epc_page->owner)->encl; else if (epc_page->flags & SGX_EPC_PAGE_VERSION_ARRAY) encl =3D epc_page->owner; ...