From patchwork Mon Sep 16 04:14:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 11146337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9ABBF1747 for ; Mon, 16 Sep 2019 04:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78CF3214C6 for ; Mon, 16 Sep 2019 04:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726330AbfIPEPV (ORCPT ); Mon, 16 Sep 2019 00:15:21 -0400 Received: from mga06.intel.com ([134.134.136.31]:16475 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbfIPEPV (ORCPT ); Mon, 16 Sep 2019 00:15:21 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Sep 2019 21:15:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,489,1559545200"; d="scan'208";a="387076082" Received: from diernhof-mobl3.ger.corp.intel.com (HELO localhost) ([10.249.39.128]) by fmsmga006.fm.intel.com with ESMTP; 15 Sep 2019 21:15:19 -0700 From: Jarkko Sakkinen To: linux-sgx@vger.kernel.org Cc: Jarkko Sakkinen , Sean Christopherson , Shay Katz-zamir , Serge Ayoun Subject: [PATCH v2 11/17] x86/sgx: Call sgx_encl_destroy() when the EWB flow fails Date: Mon, 16 Sep 2019 07:14:11 +0300 Message-Id: <20190916041417.12533-12-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190916041417.12533-1-jarkko.sakkinen@linux.intel.com> References: <20190916041417.12533-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Sender: linux-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org There is not much we can do if the EWB flow fails. It can fail if the binding of the backing storage fails or if the enclave is running inside a VM and the host is suspended. Cc: Sean Christopherson Cc: Shay Katz-zamir Cc: Serge Ayoun Signed-off-by: Jarkko Sakkinen --- arch/x86/kernel/cpu/sgx/reclaim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/reclaim.c b/arch/x86/kernel/cpu/sgx/reclaim.c index 4ae6122c18e5..c2a85db68307 100644 --- a/arch/x86/kernel/cpu/sgx/reclaim.c +++ b/arch/x86/kernel/cpu/sgx/reclaim.c @@ -345,7 +345,7 @@ static void sgx_encl_ewb(struct sgx_epc_page *epc_page, if (encls_failed(ret) || encls_returned_code(ret)) ENCLS_WARN(ret, "EWB"); - sgx_free_va_slot(va_page, va_offset); + sgx_encl_destroy(encl); } else { encl_page->desc |= va_offset; encl_page->va_page = va_page;