From patchwork Fri Oct 20 08:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 155869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp899205vqb; Fri, 20 Oct 2023 01:10:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2+U1IL4oveBIqAROELMouFJ0q4j0KZ8HBNEFKopMJCCFXnh1184ULLBOBKjn7M2Y6qAFt X-Received: by 2002:a17:90a:d2c4:b0:27d:a14c:eba6 with SMTP id dj4-20020a17090ad2c400b0027da14ceba6mr1185462pjb.21.1697789425079; Fri, 20 Oct 2023 01:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697789425; cv=none; d=google.com; s=arc-20160816; b=ZRXeyyHzAVodKBFWGVtK8AmiX+ubBKaSIYepsDonEqqbeZ/EXfWZOhivjXEgmmcVva r/TV6N/NDgTO4BGlDlSnclK8Dvk7wvPdZRjOluTkmRD5GI3NSmGUGwv2mFxevaSFwIUR gPFSGKqVxPdM5VtnbVKpUTsT/T8Gjrdmw8zrQzJMLXsB4o8LgZs7Avkn6HmJU0ZVPe0X 8fsTwZn97V/GUcFyPy5xm2F/16PEzxWIyBpDfQ8N5LQoUhOGC3Ur4xx11HvR5MOtKD2+ J+XmJbxxoAk0d+uzMSm0cmBHpxlAhLEWbIn5wJQwC21KvYODi4yJvRoVNqRSHGt1/RFo IBow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=k9cEt6RCZsT0SZQPSsNYDc8lc1K/B93bfA94NveKhpA=; fh=qXDcp55ys/4nhBUvzQbdrbbNcKWQ65P1nFnXmveO4Ts=; b=OipKRM53ZEQnVd8BQ1DygX1cTyXzMvZTtfuMa3QWUJti4Xk+zFlMjXm0jzocpqQX1l e4O6nLvxLe5jUDhxiHWhgxGEAqFivAjdTv/emYmozWKc1HAqiZA4GC6+ejoVJz7Tkrof r6aWvyIYUTVDgGONYVj9V/kxZvm8v+Vadq9y2P0SQF+mKWGn8dVwQs1v9udbgiBSKZ6P x+k/ctKowfUAnzUDV8rh2Nsk3dLa/0B0ILQAZoziEB7ZoFuH7GmJdMvabey546wV8zPR QVhMSavIZx0SAe2a8x/GHNLhGf7VrkP3PUSfCwdpF3EJumEKd1zhO/qbpBGrCR29iK37 Op6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4JBehA5j; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id b1-20020a17090a9bc100b0027491203b43si3722642pjw.189.2023.10.20.01.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4JBehA5j; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 60B498276C3D; Fri, 20 Oct 2023 01:10:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235666AbjJTIKP (ORCPT + 25 others); Fri, 20 Oct 2023 04:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235655AbjJTIKO (ORCPT ); Fri, 20 Oct 2023 04:10:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A33D115; Fri, 20 Oct 2023 01:10:12 -0700 (PDT) Date: Fri, 20 Oct 2023 08:10:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697789411; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k9cEt6RCZsT0SZQPSsNYDc8lc1K/B93bfA94NveKhpA=; b=4JBehA5jx76Rw26JYeV/ASsBKFT7qpmbFqMSLszlJZPmTwyNBUFNV/tk8vxktzQAVqNBLZ AHgx6BL2u8XKicajRaUoiHooKp08us58oruMaNC/h17qm2qsp537mULqfruvBNCv5fWJXR gxbi8/kQ4djykoxAIbAd4D8/u/cxdn/8lRX3UsUWb7dSyW8/zepmpnmNooPQUE9FY4Adv0 Gpxoy+Og9ryXtgFrr755gH8JaQAXsGPmtI3NNdhhWqh/I8hmzoRWK6WHJD9CLRl60dqb5a OXYvy/+w9D9gs3pwOsFCVenAQY3Xv9bURb32jVzKb/hwpdJbm+4GlaEpibs+UA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697789411; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k9cEt6RCZsT0SZQPSsNYDc8lc1K/B93bfA94NveKhpA=; b=BOSjsx4/4hrH6pRn7i+EnDSW9EDoHsBU9K5pLd1iFlncWR2Pbxnesey4TJ6qysHf4N68ww 8hDvIOH7AsJMFBCw== From: "tip-bot2 for Haitao Huang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/sgx: Return VM_FAULT_SIGBUS instead of VM_FAULT_OOM for EPC exhaustion Cc: Haitao Huang , Ingo Molnar , stable@vger.kernel.org, #@tip-bot2.tec.linutronix.de, v6.0+@tip-bot2.tec.linutronix.de, x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169778941056.3135.14169781154210769341.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 01:10:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780261243902831908 X-GMAIL-MSGID: 1780261243902831908 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 6b7b71a70af6d75e0a9eddf4b01e4383a78b8a5e Gitweb: https://git.kernel.org/tip/6b7b71a70af6d75e0a9eddf4b01e4383a78b8a5e Author: Haitao Huang AuthorDate: Thu, 19 Oct 2023 19:53:53 -07:00 Committer: Ingo Molnar CommitterDate: Fri, 20 Oct 2023 10:05:48 +02:00 x86/sgx: Return VM_FAULT_SIGBUS instead of VM_FAULT_OOM for EPC exhaustion In the EAUG on page fault path, VM_FAULT_OOM is returned when the Enclave Page Cache (EPC) runs out. This may trigger unneeded OOM kill that will not free any EPCs. Return VM_FAULT_SIGBUS instead. Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave") Signed-off-by: Haitao Huang Signed-off-by: Ingo Molnar Cc: stable@vger.kernel.org # v6.0+ --- arch/x86/kernel/cpu/sgx/encl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c index 279148e..d13b7e4 100644 --- a/arch/x86/kernel/cpu/sgx/encl.c +++ b/arch/x86/kernel/cpu/sgx/encl.c @@ -322,7 +322,7 @@ struct sgx_encl_page *sgx_encl_load_page(struct sgx_encl *encl, * ENCLS[EAUG] instruction. * * Returns: Appropriate vm_fault_t: VM_FAULT_NOPAGE when PTE was installed - * successfully, VM_FAULT_SIGBUS or VM_FAULT_OOM as error otherwise. + * successfully, VM_FAULT_SIGBUS as error otherwise. */ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma, struct sgx_encl *encl, unsigned long addr) @@ -348,7 +348,7 @@ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma, secinfo_flags = SGX_SECINFO_R | SGX_SECINFO_W | SGX_SECINFO_X; encl_page = sgx_encl_page_alloc(encl, addr - encl->base, secinfo_flags); if (IS_ERR(encl_page)) - return VM_FAULT_OOM; + return VM_FAULT_SIGBUS; mutex_lock(&encl->lock);