Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2166201rwn; Fri, 9 Sep 2022 09:23:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qMCtsjHlmtGcNZ2Ybv03mo8kTjFMRVvX0nKPScIfqE5kRyf05GHMONPMvl/dUO1Pd5Qek X-Received: by 2002:a17:906:fd8b:b0:770:7d4c:3486 with SMTP id xa11-20020a170906fd8b00b007707d4c3486mr10164599ejb.518.1662740595234; Fri, 09 Sep 2022 09:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662740595; cv=none; d=google.com; s=arc-20160816; b=0pTz4hNw4SwItdIJRn2nAFLcCtw0Vnn3m59srpwIyYLLAXvq88yg4YQpydTpy+vqch /iZlMFc0xqGtIDxrfooD0FzlgPxQh+kaqpyzrDCKPcwoSi4KP4dxFfxCE0eUqxE8vTdv QP0pzJKIxbJ/2QiOwuFPtm9Zx7/fIvUGFNlVbSkT9F56lHkEvq2YXRyGsPfW6XH7SbpB qvj8Hm75le5BSg4GjQv8o9GYCZOBydtC2BkrtAD+NcB8t1PNFtVKScpHC8OEjyMdgof/ /xcm6onsMHQq5LDXMIW+Yz1/kx09viArz141QcNq5VTkuNfZtD/KdQdvklchUT52uaaM GXFw== 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:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=q8puwUi/3Qg2xUa9DdkAjRyjCefCro43pK6avKxOsik=; b=G2Rsz/sSgk7SfgLAGgTK6F8oAiPm+R4LL/95HlZMh0IvqRZxpfaBxI/JPWrC378DAj m67AKU8TDYSRkFTWqO0GSEJTFf5EKg1w5jvutQ/cYlelALSQGp7zoQ7Kd/12FRxx2lo+ JMMUVx8/Aq9Eba11QmGzMVjBVMlLsTVszbecVIddoEeO2iA8GTXExoag+jfef3MNE3tG Gsx3APaE9irRg777S/I4e7JI+YVRvHqDOAxMJdd1HnccMyXLiK8wNkd2lkOHu0nn1QBs D+1JYQ0qOxiLeiru8HCAx1rAy9rawfeK3tczSF+/ZztmPNKKKFHJLWq+CcIjfAzKVJno eAmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Tlgj+ITW; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tk5-20020a170907c28500b0077048fcd963si679108ejc.815.2022.09.09.09.22.50; Fri, 09 Sep 2022 09:23:15 -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=@linutronix.de header.s=2020 header.b=Tlgj+ITW; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231817AbiIIPds (ORCPT + 99 others); Fri, 9 Sep 2022 11:33:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbiIIPdD (ORCPT ); Fri, 9 Sep 2022 11:33:03 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 078A42DAA8; Fri, 9 Sep 2022 08:32:45 -0700 (PDT) Date: Fri, 09 Sep 2022 15:31:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662737478; 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: in-reply-to:in-reply-to:references:references; bh=q8puwUi/3Qg2xUa9DdkAjRyjCefCro43pK6avKxOsik=; b=Tlgj+ITW4P6GBeHjLyqDzTGGrUxITX97hVHzZGnGPUc211H52Cz0Fl3wMBliduJhClLC9Z KC/Np7o5XPgH5qrqCxH3jNDOsoa6eeLOZxIzpwPRRCOwd4IFC/3dBkLKI4jzChVSe47lt9 OvJ/J5ffufUbdzw2Sj3MyghFLd5RxG89iBT20qAfVe+fqp1zWjK5bCAWJiOg0bd5EPY0nk isOdvYPquauLWIxylIMSFRgQ2flzYRtKUroOWszwYUlrRdX38DgJ55iUC7uaZ4r16nAbQo o5DH7/7xyLv/XQDHcKQozGaVivaKNi6q/8n3NJyDNOvaCGu9MZ8RnlsgFd2Yyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662737478; 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: in-reply-to:in-reply-to:references:references; bh=q8puwUi/3Qg2xUa9DdkAjRyjCefCro43pK6avKxOsik=; b=8BQN1iTwvaKPP0IUHBX1GVmJrowPIIA0nrGRbKbaVbFqVONHyqrlwtJczy5gouRBAkQ6G7 KjyPI8MiitjkZdBg== 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: Handle VA page allocation failure for EAUG on PF. Cc: Haitao Huang , Jarkko Sakkinen , Dave Hansen , Reinette Chatre , Vijay Dhanraj , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220906000221.34286-3-jarkko@kernel.org> References: <20220906000221.34286-3-jarkko@kernel.org> MIME-Version: 1.0 Message-ID: <166273747726.401.7413581964147438392.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 81fa6fd13b5c43601fba8486f2385dbd7c1935e2 Gitweb: https://git.kernel.org/tip/81fa6fd13b5c43601fba8486f2385dbd7c1935e2 Author: Haitao Huang AuthorDate: Tue, 06 Sep 2022 03:02:21 +03:00 Committer: Dave Hansen CommitterDate: Thu, 08 Sep 2022 13:28:31 -07:00 x86/sgx: Handle VA page allocation failure for EAUG on PF. VM_FAULT_NOPAGE is expected behaviour for -EBUSY failure path, when augmenting a page, as this means that the reclaimer thread has been triggered, and the intention is just to round-trip in ring-3, and retry with a new page fault. Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave") Signed-off-by: Haitao Huang Signed-off-by: Jarkko Sakkinen Signed-off-by: Dave Hansen Reviewed-by: Reinette Chatre Tested-by: Vijay Dhanraj Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20220906000221.34286-3-jarkko@kernel.org --- arch/x86/kernel/cpu/sgx/encl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c index 24c1bb8..8bdeae2 100644 --- a/arch/x86/kernel/cpu/sgx/encl.c +++ b/arch/x86/kernel/cpu/sgx/encl.c @@ -344,8 +344,11 @@ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma, } va_page = sgx_encl_grow(encl, false); - if (IS_ERR(va_page)) + if (IS_ERR(va_page)) { + if (PTR_ERR(va_page) == -EBUSY) + vmret = VM_FAULT_NOPAGE; goto err_out_epc; + } if (va_page) list_add(&va_page->list, &encl->va_pages);