Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4781947pxb; Tue, 25 Jan 2022 19:30:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIR29t587P0MRI2zBZ+gy3jbjY0KK/xQsM4Ca9VBRoyVrSX4onLUoVwxD/1NFLUqLedxam X-Received: by 2002:a17:906:dc8e:: with SMTP id cs14mr2992402ejc.185.1643167840133; Tue, 25 Jan 2022 19:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643167840; cv=none; d=google.com; s=arc-20160816; b=C+zpLpBTGLfWR2f6kmuy6F0ktIuD7DSVmahnA8hrKQS3vVigjgQ1IbNu9Z1Hmxpbh7 VFxUWY1OgahONY6/mQh7mFkSEAgEF9mrKSxMnCDae8cPBLYGSwCBrznJSorK7soUut8S IS0TOaUnW0qQRA3caR3kLQ+22DTMn9nHS8Kte0wpCXpmLIZBX1Pd08FpfauHp/YW0gUf sc9aC5xEhUVQ53bcHIDs3i5H19o1HPuqB2vwb90YdLFFmV/1AAajItU4Kjt4Kcq2jd12 Q5qDeeB2UMJxW2Ckfw3yObw/9I1PkZSVD5iHOBYzrUybp6Yz4jS4t1TtKXlYVstcypJZ mD7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=B1vSxQroadkO+ztU1VlFIy5TicbPCsxD/MHqjY7BUfE=; b=RM2+UBDOZBy8inPbemWsMr3UAYcaxr/yy2d+qU7GlqdjEFO1n9KchqaIR2teOD8AFL mDt25LTsOpOz7E/4H+9gRR2ARzt9W+D5AbAtFpT/t5qzq216gWaZ8SEuIBJiK5x1zypp GtSdS7853mQH4jqKafGxamRDiB05fU09JGHSjTLZ7fKUx0Jq+lK1KxhW/aQKtvLENTTP qo2YnN9jlMjigI+wChD/z4uuqSk6HAoE93juD9Y6s+/e49MJvQ1MRf8l5BC6xSltHCRP Tdc7U3qmIo+T67LcFN5S5ymm/mjYKxizSnYVUh9oGmbecXqxblv9le7FTrYRqm0WQCRX 2mug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EyMMRXFt; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 7si10892920edx.542.2022.01.25.19.30.16; Tue, 25 Jan 2022 19:30:40 -0800 (PST) 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=@intel.com header.s=Intel header.b=EyMMRXFt; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbiAYSZR (ORCPT + 99 others); Tue, 25 Jan 2022 13:25:17 -0500 Received: from mga03.intel.com ([134.134.136.65]:4719 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiAYSYL (ORCPT ); Tue, 25 Jan 2022 13:24:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643135050; x=1674671050; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UJIqw8gcL194wHLtJoARGquGC2qqeBOMWHN3mV2Gobg=; b=EyMMRXFt5NOcoBwlH8/Xj1wheqWzCIBlOy27ftXRanL2+l+2GqTs0/Ix YUkEozVsVFuOFr3JWKuuSIg3m1MahS/V/zvf0cp90tiyoUOGdNBOarW/6 sXBoW3mlTHGg71DCaNHSs3Z7WrIKZ7vlqYjGyROAhUnK16DyWMai0RLB8 9suKfH76ItUTKni3zOxvQnW4e2rYGvIlszallSwnpJZeRxb41V0m9KeUm 9k8+ndr8lZNZf5q6Tiwn/Q0jRfEbYwzGFpcsEIrTcCFSsU1YvG/bAOKpM 0x8UoFH+iCRqFuMyxATYtEnmHa66Aq+1LX48JQR+7xAgzm8ZEzhOtzDmn g==; X-IronPort-AV: E=McAfee;i="6200,9189,10238"; a="246319033" X-IronPort-AV: E=Sophos;i="5.88,315,1635231600"; d="scan'208";a="246319033" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 10:22:48 -0800 X-IronPort-AV: E=Sophos;i="5.88,315,1635231600"; d="scan'208";a="563134939" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 10:22:48 -0800 From: Reinette Chatre To: dave.hansen@linux.intel.com, jarkko@kernel.org, tglx@linutronix.de, bp@alien8.de, luto@kernel.org, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org Cc: vijay.dhanraj@intel.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH V2] x86/sgx: Silence softlockup detection when releasing large enclaves Date: Tue, 25 Jan 2022 10:22:43 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vijay reported that the "unclobbered_vdso_oversubscribed" selftest triggers the softlockup detector. Actual SGX systems have 128GB of enclave memory or more. The "unclobbered_vdso_oversubscribed" selftest creates one enclave which consumes all of the enclave memory on the system. Tearing down such a large enclave takes around a minute, most of it in the loop where the EREMOVE instruction is applied to each individual 4k enclave page. Spending one minute in a loop triggers the softlockup detector. Add a cond_resched() to give other tasks a chance to run and placate the softlockup detector. Cc: stable@vger.kernel.org Fixes: 1728ab54b4be ("x86/sgx: Add a page reclaimer") Reported-by: Vijay Dhanraj Acked-by: Dave Hansen Signed-off-by: Reinette Chatre --- Softlockup message: watchdog: BUG: soft lockup - CPU#7 stuck for 22s! [test_sgx:11502] Kernel panic - not syncing: softlockup: hung tasks sgx_encl_release+0x86/0x1c0 sgx_release+0x11c/0x130 __fput+0xb0/0x280 ____fput+0xe/0x10 task_work_run+0x6c/0xc0 exit_to_user_mode_prepare+0x1eb/0x1f0 syscall_exit_to_user_mode+0x1d/0x50 do_syscall_64+0x46/0xb0 entry_SYSCALL_64_after_hwframe+0x44/0xae Changes since V1: - V1: https://lore.kernel.org/lkml/1aa037705e5aa209d8b7a075873c6b4190327436.1642530802.git.reinette.chatre@intel.com/ - Add comment provided by Jarkko. arch/x86/kernel/cpu/sgx/encl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c index 001808e3901c..48afe96ae0f0 100644 --- a/arch/x86/kernel/cpu/sgx/encl.c +++ b/arch/x86/kernel/cpu/sgx/encl.c @@ -410,6 +410,8 @@ void sgx_encl_release(struct kref *ref) } kfree(entry); + /* Invoke scheduler to prevent soft lockups. */ + cond_resched(); } xa_destroy(&encl->page_array); -- 2.25.1